[Python-checkins]
python/dist/src/Mac/Demo/PICTbrowse ICONbrowse.py, 1.10,
1.11 PICTbrowse.py, 1.11, 1.12 PICTbrowse2.py, 1.12,
1.13 cicnbrowse.py, 1.9, 1.10 oldPICTbrowse.py, 1.7, 1.8
tim_one at users.sourceforge.net
tim_one at users.sourceforge.net
Sun Jul 18 07:58:37 CEST 2004
- Previous message: [Python-checkins] python/dist/src/Mac/Demo/applescript makedisk.py,
1.1, 1.2
- Next message: [Python-checkins] python/dist/src/Mac/Demo/applescript/Disk_Copy
Special_Events.py, 1.2, 1.3 Standard_Suite.py, 1.2,
1.3 Utility_Events.py, 1.1, 1.2 __init__.py, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Mac/Demo/PICTbrowse
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29056/Demo/PICTbrowse
Modified Files:
ICONbrowse.py PICTbrowse.py PICTbrowse2.py cicnbrowse.py
oldPICTbrowse.py
Log Message:
Whitespace normalization, via reindent.py.
Index: ICONbrowse.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Demo/PICTbrowse/ICONbrowse.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** ICONbrowse.py 12 Feb 2004 17:35:12 -0000 1.10
--- ICONbrowse.py 18 Jul 2004 05:58:03 -0000 1.11
***************
*** 28,163 ****
def main():
! macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc")
! ICONbrowse()
class ICONbrowse(FrameWork.Application):
! def __init__(self):
! # First init menus, etc.
! FrameWork.Application.__init__(self)
! # Next create our dialog
! self.main_dialog = MyDialog(self)
! # Now open the dialog
! contents = self.findICONresources()
! self.main_dialog.open(ID_MAIN, contents)
! # Finally, go into the event loop
! self.mainloop()
!
! def makeusermenus(self):
! self.filemenu = m = FrameWork.Menu(self.menubar, "File")
! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit)
!
! def quit(self, *args):
! self._quit()
!
! def showICON(self, resid):
! w = ICONwindow(self)
! w.open(resid)
! #EasyDialogs.Message('Show ICON %r' % (resid,))
!
! def findICONresources(self):
! num = Res.CountResources('ICON')
! rv = []
! for i in range(1, num+1):
! Res.SetResLoad(0)
! try:
! r = Res.GetIndResource('ICON', i)
! finally:
! Res.SetResLoad(1)
! id, type, name = r.GetResInfo()
! rv.append((id, name))
! return rv
!
class ICONwindow(FrameWork.Window):
! def open(self, (resid, resname)):
! if not resname:
! resname = '#%r' % (resid,)
! self.resid = resid
! self.picture = Icn.GetIcon(self.resid)
! l, t, r, b = 0, 0, 32, 32
! self.pictrect = (l, t, r, b)
! width = r-l
! height = b-t
! if width < MINWIDTH: width = MINWIDTH
! elif width > MAXWIDTH: width = MAXWIDTH
! if height < MINHEIGHT: height = MINHEIGHT
! elif height > MAXHEIGHT: height = MAXHEIGHT
! bounds = (LEFT, TOP, LEFT+width, TOP+height)
!
! self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
! self.do_postopen()
!
! def do_update(self, *args):
! currect = self.fitrect()
! Icn.PlotIcon(currect, self.picture)
!
! def fitrect(self):
! """Return self.pictrect scaled to fit in window"""
! graf = self.wid.GetWindowPort()
! screenrect = graf.GetPortBounds()
! picwidth = self.pictrect[2] - self.pictrect[0]
! picheight = self.pictrect[3] - self.pictrect[1]
! if picwidth > screenrect[2] - screenrect[0]:
! factor = float(picwidth) / float(screenrect[2]-screenrect[0])
! picwidth = picwidth / factor
! picheight = picheight / factor
! if picheight > screenrect[3] - screenrect[1]:
! factor = float(picheight) / float(screenrect[3]-screenrect[1])
! picwidth = picwidth / factor
! picheight = picheight / factor
! return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth),
! screenrect[1]+int(picheight))
!
class MyDialog(FrameWork.DialogWindow):
! "Main dialog window for ICONbrowse"
! def open(self, id, contents):
! self.id = id
! FrameWork.DialogWindow.open(self, ID_MAIN)
! self.dlg.SetDialogDefaultItem(MAIN_SHOW)
! self.contents = contents
! self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST)
! h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart,
! Controls.kControlListBoxListHandleTag)
! self.list = List.as_List(h)
! self.setlist()
! def setlist(self):
! self.list.LDelRow(0, 0)
! self.list.LSetDrawingMode(0)
! if self.contents:
! self.list.LAddRow(len(self.contents), 0)
! for i in range(len(self.contents)):
! v = repr(self.contents[i][0])
! if self.contents[i][1]:
! v = v + '"' + self.contents[i][1] + '"'
! self.list.LSetCell(v, (0, i))
! self.list.LSetDrawingMode(1)
! self.list.LUpdate(self.wid.GetWindowPort().visRgn)
!
! def getselection(self):
! items = []
! point = (0,0)
! while 1:
! ok, point = self.list.LGetSelect(1, point)
! if not ok:
! break
! items.append(point[1])
! point = point[0], point[1]+1
! values = []
! for i in items:
! values.append(self.contents[i])
! return values
!
! def do_show(self, *args):
! selection = self.getselection()
! for resid in selection:
! self.parent.showICON(resid)
!
! def do_close(self):
! self.close()
!
! def do_itemhit(self, item, event):
! if item == MAIN_SHOW:
! self.do_show()
main()
--- 28,163 ----
def main():
! macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc")
! ICONbrowse()
class ICONbrowse(FrameWork.Application):
! def __init__(self):
! # First init menus, etc.
! FrameWork.Application.__init__(self)
! # Next create our dialog
! self.main_dialog = MyDialog(self)
! # Now open the dialog
! contents = self.findICONresources()
! self.main_dialog.open(ID_MAIN, contents)
! # Finally, go into the event loop
! self.mainloop()
!
! def makeusermenus(self):
! self.filemenu = m = FrameWork.Menu(self.menubar, "File")
! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit)
!
! def quit(self, *args):
! self._quit()
!
! def showICON(self, resid):
! w = ICONwindow(self)
! w.open(resid)
! #EasyDialogs.Message('Show ICON %r' % (resid,))
!
! def findICONresources(self):
! num = Res.CountResources('ICON')
! rv = []
! for i in range(1, num+1):
! Res.SetResLoad(0)
! try:
! r = Res.GetIndResource('ICON', i)
! finally:
! Res.SetResLoad(1)
! id, type, name = r.GetResInfo()
! rv.append((id, name))
! return rv
!
class ICONwindow(FrameWork.Window):
! def open(self, (resid, resname)):
! if not resname:
! resname = '#%r' % (resid,)
! self.resid = resid
! self.picture = Icn.GetIcon(self.resid)
! l, t, r, b = 0, 0, 32, 32
! self.pictrect = (l, t, r, b)
! width = r-l
! height = b-t
! if width < MINWIDTH: width = MINWIDTH
! elif width > MAXWIDTH: width = MAXWIDTH
! if height < MINHEIGHT: height = MINHEIGHT
! elif height > MAXHEIGHT: height = MAXHEIGHT
! bounds = (LEFT, TOP, LEFT+width, TOP+height)
!
! self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
! self.do_postopen()
!
! def do_update(self, *args):
! currect = self.fitrect()
! Icn.PlotIcon(currect, self.picture)
!
! def fitrect(self):
! """Return self.pictrect scaled to fit in window"""
! graf = self.wid.GetWindowPort()
! screenrect = graf.GetPortBounds()
! picwidth = self.pictrect[2] - self.pictrect[0]
! picheight = self.pictrect[3] - self.pictrect[1]
! if picwidth > screenrect[2] - screenrect[0]:
! factor = float(picwidth) / float(screenrect[2]-screenrect[0])
! picwidth = picwidth / factor
! picheight = picheight / factor
! if picheight > screenrect[3] - screenrect[1]:
! factor = float(picheight) / float(screenrect[3]-screenrect[1])
! picwidth = picwidth / factor
! picheight = picheight / factor
! return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth),
! screenrect[1]+int(picheight))
!
class MyDialog(FrameWork.DialogWindow):
! "Main dialog window for ICONbrowse"
! def open(self, id, contents):
! self.id = id
! FrameWork.DialogWindow.open(self, ID_MAIN)
! self.dlg.SetDialogDefaultItem(MAIN_SHOW)
! self.contents = contents
! self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST)
! h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart,
! Controls.kControlListBoxListHandleTag)
! self.list = List.as_List(h)
! self.setlist()
! def setlist(self):
! self.list.LDelRow(0, 0)
! self.list.LSetDrawingMode(0)
! if self.contents:
! self.list.LAddRow(len(self.contents), 0)
! for i in range(len(self.contents)):
! v = repr(self.contents[i][0])
! if self.contents[i][1]:
! v = v + '"' + self.contents[i][1] + '"'
! self.list.LSetCell(v, (0, i))
! self.list.LSetDrawingMode(1)
! self.list.LUpdate(self.wid.GetWindowPort().visRgn)
!
! def getselection(self):
! items = []
! point = (0,0)
! while 1:
! ok, point = self.list.LGetSelect(1, point)
! if not ok:
! break
! items.append(point[1])
! point = point[0], point[1]+1
! values = []
! for i in items:
! values.append(self.contents[i])
! return values
!
! def do_show(self, *args):
! selection = self.getselection()
! for resid in selection:
! self.parent.showICON(resid)
!
! def do_close(self):
! self.close()
!
! def do_itemhit(self, item, event):
! if item == MAIN_SHOW:
! self.do_show()
main()
Index: PICTbrowse.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Demo/PICTbrowse/PICTbrowse.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** PICTbrowse.py 12 Feb 2004 17:35:12 -0000 1.11
--- PICTbrowse.py 18 Jul 2004 05:58:04 -0000 1.12
***************
*** 23,141 ****
def main():
! macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc")
! PICTbrowse()
class PICTbrowse(FrameWork.Application):
! def __init__(self):
! # First init menus, etc.
! FrameWork.Application.__init__(self)
! # Next create our dialog
! self.main_dialog = MyDialog(self)
! # Now open the dialog
! contents = self.findPICTresources()
! self.main_dialog.open(ID_MAIN, contents)
! # Finally, go into the event loop
! self.mainloop()
!
! def makeusermenus(self):
! self.filemenu = m = FrameWork.Menu(self.menubar, "File")
! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit)
!
! def quit(self, *args):
! self._quit()
!
! def showPICT(self, resid):
! w = PICTwindow(self)
! w.open(resid)
! #EasyDialogs.Message('Show PICT %r' % (resid,))
!
! def findPICTresources(self):
! num = Res.CountResources('PICT')
! rv = []
! for i in range(1, num+1):
! Res.SetResLoad(0)
! try:
! r = Res.GetIndResource('PICT', i)
! finally:
! Res.SetResLoad(1)
! id, type, name = r.GetResInfo()
! rv.append((id, name))
! return rv
!
class PICTwindow(FrameWork.Window):
! def open(self, (resid, resname)):
! if not resname:
! resname = '#%r' % (resid,)
! self.resid = resid
! picture = Qd.GetPicture(self.resid)
! # Get rect for picture
! print repr(picture.data[:16])
! sz, t, l, b, r = struct.unpack('hhhhh', picture.data[:10])
! print 'pict:', t, l, b, r
! width = r-l
! height = b-t
! if width < 64: width = 64
! elif width > 480: width = 480
! if height < 64: height = 64
! elif height > 320: height = 320
! bounds = (LEFT, TOP, LEFT+width, TOP+height)
! print 'bounds:', bounds
!
! self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
! self.wid.SetWindowPic(picture)
! self.do_postopen()
!
class MyDialog(FrameWork.DialogWindow):
! "Main dialog window for PICTbrowse"
! def open(self, id, contents):
! self.id = id
! FrameWork.DialogWindow.open(self, ID_MAIN)
! self.dlg.SetDialogDefaultItem(MAIN_SHOW)
! self.contents = contents
! self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST)
! h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart,
! Controls.kControlListBoxListHandleTag)
! self.list = List.as_List(h)
! self.setlist()
! def setlist(self):
! self.list.LDelRow(0, 0)
! self.list.LSetDrawingMode(0)
! if self.contents:
! self.list.LAddRow(len(self.contents), 0)
! for i in range(len(self.contents)):
! v = repr(self.contents[i][0])
! if self.contents[i][1]:
! v = v + '"' + self.contents[i][1] + '"'
! self.list.LSetCell(v, (0, i))
! self.list.LSetDrawingMode(1)
! self.list.LUpdate(self.wid.GetWindowPort().visRgn)
!
! def getselection(self):
! items = []
! point = (0,0)
! while 1:
! ok, point = self.list.LGetSelect(1, point)
! if not ok:
! break
! items.append(point[1])
! point = point[0], point[1]+1
! values = []
! for i in items:
! values.append(self.contents[i])
! return values
!
! def do_show(self, *args):
! selection = self.getselection()
! for resid in selection:
! self.parent.showPICT(resid)
!
! def do_close(self):
! self.close()
!
! def do_itemhit(self, item, event):
! if item == MAIN_SHOW:
! self.do_show()
main()
--- 23,141 ----
def main():
! macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc")
! PICTbrowse()
class PICTbrowse(FrameWork.Application):
! def __init__(self):
! # First init menus, etc.
! FrameWork.Application.__init__(self)
! # Next create our dialog
! self.main_dialog = MyDialog(self)
! # Now open the dialog
! contents = self.findPICTresources()
! self.main_dialog.open(ID_MAIN, contents)
! # Finally, go into the event loop
! self.mainloop()
!
! def makeusermenus(self):
! self.filemenu = m = FrameWork.Menu(self.menubar, "File")
! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit)
!
! def quit(self, *args):
! self._quit()
!
! def showPICT(self, resid):
! w = PICTwindow(self)
! w.open(resid)
! #EasyDialogs.Message('Show PICT %r' % (resid,))
!
! def findPICTresources(self):
! num = Res.CountResources('PICT')
! rv = []
! for i in range(1, num+1):
! Res.SetResLoad(0)
! try:
! r = Res.GetIndResource('PICT', i)
! finally:
! Res.SetResLoad(1)
! id, type, name = r.GetResInfo()
! rv.append((id, name))
! return rv
!
class PICTwindow(FrameWork.Window):
! def open(self, (resid, resname)):
! if not resname:
! resname = '#%r' % (resid,)
! self.resid = resid
! picture = Qd.GetPicture(self.resid)
! # Get rect for picture
! print repr(picture.data[:16])
! sz, t, l, b, r = struct.unpack('hhhhh', picture.data[:10])
! print 'pict:', t, l, b, r
! width = r-l
! height = b-t
! if width < 64: width = 64
! elif width > 480: width = 480
! if height < 64: height = 64
! elif height > 320: height = 320
! bounds = (LEFT, TOP, LEFT+width, TOP+height)
! print 'bounds:', bounds
!
! self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
! self.wid.SetWindowPic(picture)
! self.do_postopen()
!
class MyDialog(FrameWork.DialogWindow):
! "Main dialog window for PICTbrowse"
! def open(self, id, contents):
! self.id = id
! FrameWork.DialogWindow.open(self, ID_MAIN)
! self.dlg.SetDialogDefaultItem(MAIN_SHOW)
! self.contents = contents
! self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST)
! h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart,
! Controls.kControlListBoxListHandleTag)
! self.list = List.as_List(h)
! self.setlist()
! def setlist(self):
! self.list.LDelRow(0, 0)
! self.list.LSetDrawingMode(0)
! if self.contents:
! self.list.LAddRow(len(self.contents), 0)
! for i in range(len(self.contents)):
! v = repr(self.contents[i][0])
! if self.contents[i][1]:
! v = v + '"' + self.contents[i][1] + '"'
! self.list.LSetCell(v, (0, i))
! self.list.LSetDrawingMode(1)
! self.list.LUpdate(self.wid.GetWindowPort().visRgn)
!
! def getselection(self):
! items = []
! point = (0,0)
! while 1:
! ok, point = self.list.LGetSelect(1, point)
! if not ok:
! break
! items.append(point[1])
! point = point[0], point[1]+1
! values = []
! for i in items:
! values.append(self.contents[i])
! return values
!
! def do_show(self, *args):
! selection = self.getselection()
! for resid in selection:
! self.parent.showPICT(resid)
!
! def do_close(self):
! self.close()
!
! def do_itemhit(self, item, event):
! if item == MAIN_SHOW:
! self.do_show()
main()
Index: PICTbrowse2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Demo/PICTbrowse/PICTbrowse2.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** PICTbrowse2.py 12 Feb 2004 17:35:12 -0000 1.12
--- PICTbrowse2.py 18 Jul 2004 05:58:04 -0000 1.13
***************
*** 27,163 ****
def main():
! macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc")
! PICTbrowse()
class PICTbrowse(FrameWork.Application):
! def __init__(self):
! # First init menus, etc.
! FrameWork.Application.__init__(self)
! # Next create our dialog
! self.main_dialog = MyDialog(self)
! # Now open the dialog
! contents = self.findPICTresources()
! self.main_dialog.open(ID_MAIN, contents)
! # Finally, go into the event loop
! self.mainloop()
!
! def makeusermenus(self):
! self.filemenu = m = FrameWork.Menu(self.menubar, "File")
! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit)
!
! def quit(self, *args):
! self._quit()
!
! def showPICT(self, resid):
! w = PICTwindow(self)
! w.open(resid)
! #EasyDialogs.Message('Show PICT %r' % (resid,))
!
! def findPICTresources(self):
! num = Res.CountResources('PICT')
! rv = []
! for i in range(1, num+1):
! Res.SetResLoad(0)
! try:
! r = Res.GetIndResource('PICT', i)
! finally:
! Res.SetResLoad(1)
! id, type, name = r.GetResInfo()
! rv.append((id, name))
! return rv
!
class PICTwindow(FrameWork.Window):
! def open(self, (resid, resname)):
! if not resname:
! resname = '#%r' % (resid,)
! self.resid = resid
! self.picture = Qd.GetPicture(self.resid)
! # Get rect for picture
! sz, t, l, b, r = struct.unpack('hhhhh', self.picture.data[:10])
! self.pictrect = (l, t, r, b)
! width = r-l
! height = b-t
! if width < MINWIDTH: width = MINWIDTH
! elif width > MAXWIDTH: width = MAXWIDTH
! if height < MINHEIGHT: height = MINHEIGHT
! elif height > MAXHEIGHT: height = MAXHEIGHT
! bounds = (LEFT, TOP, LEFT+width, TOP+height)
!
! self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
! self.do_postopen()
!
! def do_update(self, *args):
! currect = self.fitrect()
! Qd.DrawPicture(self.picture, currect)
!
! def fitrect(self):
! """Return self.pictrect scaled to fit in window"""
! graf = self.dlg.GetWindowPort()
! screenrect = graf.GetPortBounds()
! picwidth = self.pictrect[2] - self.pictrect[0]
! picheight = self.pictrect[3] - self.pictrect[1]
! if picwidth > screenrect[2] - screenrect[0]:
! factor = float(picwidth) / float(screenrect[2]-screenrect[0])
! picwidth = picwidth / factor
! picheight = picheight / factor
! if picheight > screenrect[3] - screenrect[1]:
! factor = float(picheight) / float(screenrect[3]-screenrect[1])
! picwidth = picwidth / factor
! picheight = picheight / factor
! return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth),
! screenrect[1]+int(picheight))
!
class MyDialog(FrameWork.DialogWindow):
! "Main dialog window for PICTbrowse"
! def open(self, id, contents):
! self.id = id
! FrameWork.DialogWindow.open(self, ID_MAIN)
! self.dlg.SetDialogDefaultItem(MAIN_SHOW)
! self.contents = contents
! self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST)
! h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart,
! Controls.kControlListBoxListHandleTag)
! self.list = List.as_List(h)
! self.setlist()
! def setlist(self):
! self.list.LDelRow(0, 0)
! self.list.LSetDrawingMode(0)
! if self.contents:
! self.list.LAddRow(len(self.contents), 0)
! for i in range(len(self.contents)):
! v = repr(self.contents[i][0])
! if self.contents[i][1]:
! v = v + '"' + self.contents[i][1] + '"'
! self.list.LSetCell(v, (0, i))
! self.list.LSetDrawingMode(1)
! self.list.LUpdate(self.wid.GetWindowPort().visRgn)
!
! def getselection(self):
! items = []
! point = (0,0)
! while 1:
! ok, point = self.list.LGetSelect(1, point)
! if not ok:
! break
! items.append(point[1])
! point = point[0], point[1]+1
! values = []
! for i in items:
! values.append(self.contents[i])
! return values
!
! def do_show(self, *args):
! selection = self.getselection()
! for resid in selection:
! self.parent.showPICT(resid)
!
! def do_close(self):
! self.close()
!
! def do_itemhit(self, item, event):
! if item == MAIN_SHOW:
! self.do_show()
main()
--- 27,163 ----
def main():
! macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc")
! PICTbrowse()
class PICTbrowse(FrameWork.Application):
! def __init__(self):
! # First init menus, etc.
! FrameWork.Application.__init__(self)
! # Next create our dialog
! self.main_dialog = MyDialog(self)
! # Now open the dialog
! contents = self.findPICTresources()
! self.main_dialog.open(ID_MAIN, contents)
! # Finally, go into the event loop
! self.mainloop()
!
! def makeusermenus(self):
! self.filemenu = m = FrameWork.Menu(self.menubar, "File")
! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit)
!
! def quit(self, *args):
! self._quit()
!
! def showPICT(self, resid):
! w = PICTwindow(self)
! w.open(resid)
! #EasyDialogs.Message('Show PICT %r' % (resid,))
!
! def findPICTresources(self):
! num = Res.CountResources('PICT')
! rv = []
! for i in range(1, num+1):
! Res.SetResLoad(0)
! try:
! r = Res.GetIndResource('PICT', i)
! finally:
! Res.SetResLoad(1)
! id, type, name = r.GetResInfo()
! rv.append((id, name))
! return rv
!
class PICTwindow(FrameWork.Window):
! def open(self, (resid, resname)):
! if not resname:
! resname = '#%r' % (resid,)
! self.resid = resid
! self.picture = Qd.GetPicture(self.resid)
! # Get rect for picture
! sz, t, l, b, r = struct.unpack('hhhhh', self.picture.data[:10])
! self.pictrect = (l, t, r, b)
! width = r-l
! height = b-t
! if width < MINWIDTH: width = MINWIDTH
! elif width > MAXWIDTH: width = MAXWIDTH
! if height < MINHEIGHT: height = MINHEIGHT
! elif height > MAXHEIGHT: height = MAXHEIGHT
! bounds = (LEFT, TOP, LEFT+width, TOP+height)
!
! self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
! self.do_postopen()
!
! def do_update(self, *args):
! currect = self.fitrect()
! Qd.DrawPicture(self.picture, currect)
!
! def fitrect(self):
! """Return self.pictrect scaled to fit in window"""
! graf = self.dlg.GetWindowPort()
! screenrect = graf.GetPortBounds()
! picwidth = self.pictrect[2] - self.pictrect[0]
! picheight = self.pictrect[3] - self.pictrect[1]
! if picwidth > screenrect[2] - screenrect[0]:
! factor = float(picwidth) / float(screenrect[2]-screenrect[0])
! picwidth = picwidth / factor
! picheight = picheight / factor
! if picheight > screenrect[3] - screenrect[1]:
! factor = float(picheight) / float(screenrect[3]-screenrect[1])
! picwidth = picwidth / factor
! picheight = picheight / factor
! return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth),
! screenrect[1]+int(picheight))
!
class MyDialog(FrameWork.DialogWindow):
! "Main dialog window for PICTbrowse"
! def open(self, id, contents):
! self.id = id
! FrameWork.DialogWindow.open(self, ID_MAIN)
! self.dlg.SetDialogDefaultItem(MAIN_SHOW)
! self.contents = contents
! self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST)
! h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart,
! Controls.kControlListBoxListHandleTag)
! self.list = List.as_List(h)
! self.setlist()
! def setlist(self):
! self.list.LDelRow(0, 0)
! self.list.LSetDrawingMode(0)
! if self.contents:
! self.list.LAddRow(len(self.contents), 0)
! for i in range(len(self.contents)):
! v = repr(self.contents[i][0])
! if self.contents[i][1]:
! v = v + '"' + self.contents[i][1] + '"'
! self.list.LSetCell(v, (0, i))
! self.list.LSetDrawingMode(1)
! self.list.LUpdate(self.wid.GetWindowPort().visRgn)
!
! def getselection(self):
! items = []
! point = (0,0)
! while 1:
! ok, point = self.list.LGetSelect(1, point)
! if not ok:
! break
! items.append(point[1])
! point = point[0], point[1]+1
! values = []
! for i in items:
! values.append(self.contents[i])
! return values
!
! def do_show(self, *args):
! selection = self.getselection()
! for resid in selection:
! self.parent.showPICT(resid)
!
! def do_close(self):
! self.close()
!
! def do_itemhit(self, item, event):
! if item == MAIN_SHOW:
! self.do_show()
main()
Index: cicnbrowse.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Demo/PICTbrowse/cicnbrowse.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** cicnbrowse.py 12 Feb 2004 17:35:12 -0000 1.9
--- cicnbrowse.py 18 Jul 2004 05:58:04 -0000 1.10
***************
*** 28,163 ****
def main():
! macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc")
! CIconbrowse()
class CIconbrowse(FrameWork.Application):
! def __init__(self):
! # First init menus, etc.
! FrameWork.Application.__init__(self)
! # Next create our dialog
! self.main_dialog = MyDialog(self)
! # Now open the dialog
! contents = self.findcicnresources()
! self.main_dialog.open(ID_MAIN, contents)
! # Finally, go into the event loop
! self.mainloop()
!
! def makeusermenus(self):
! self.filemenu = m = FrameWork.Menu(self.menubar, "File")
! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit)
!
! def quit(self, *args):
! self._quit()
!
! def showCIcon(self, resid):
! w = CIconwindow(self)
! w.open(resid)
! #EasyDialogs.Message('Show cicn %r' % (resid,))
!
! def findcicnresources(self):
! num = Res.CountResources('cicn')
! rv = []
! for i in range(1, num+1):
! Res.SetResLoad(0)
! try:
! r = Res.GetIndResource('cicn', i)
! finally:
! Res.SetResLoad(1)
! id, type, name = r.GetResInfo()
! rv.append((id, name))
! return rv
!
class CIconwindow(FrameWork.Window):
! def open(self, (resid, resname)):
! if not resname:
! resname = '#%r' % (resid,)
! self.resid = resid
! self.picture = Icn.GetCIcon(self.resid)
! l, t, r, b = 0, 0, 32, 32
! self.pictrect = (l, t, r, b)
! width = r-l
! height = b-t
! if width < MINWIDTH: width = MINWIDTH
! elif width > MAXWIDTH: width = MAXWIDTH
! if height < MINHEIGHT: height = MINHEIGHT
! elif height > MAXHEIGHT: height = MAXHEIGHT
! bounds = (LEFT, TOP, LEFT+width, TOP+height)
!
! self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
! self.do_postopen()
!
! def do_update(self, *args):
! currect = self.fitrect()
! Icn.PlotCIcon(currect, self.picture)
!
! def fitrect(self):
! """Return self.pictrect scaled to fit in window"""
! graf = self.wid.GetWindowPort()
! screenrect = graf.GetPortBounds()
! picwidth = self.pictrect[2] - self.pictrect[0]
! picheight = self.pictrect[3] - self.pictrect[1]
! if picwidth > screenrect[2] - screenrect[0]:
! factor = float(picwidth) / float(screenrect[2]-screenrect[0])
! picwidth = picwidth / factor
! picheight = picheight / factor
! if picheight > screenrect[3] - screenrect[1]:
! factor = float(picheight) / float(screenrect[3]-screenrect[1])
! picwidth = picwidth / factor
! picheight = picheight / factor
! return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth),
! screenrect[1]+int(picheight))
!
class MyDialog(FrameWork.DialogWindow):
! "Main dialog window for cicnbrowse"
! def open(self, id, contents):
! self.id = id
! FrameWork.DialogWindow.open(self, ID_MAIN)
! self.dlg.SetDialogDefaultItem(MAIN_SHOW)
! self.contents = contents
! self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST)
! h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart,
! Controls.kControlListBoxListHandleTag)
! self.list = List.as_List(h)
! self.setlist()
! def setlist(self):
! self.list.LDelRow(0, 0)
! self.list.LSetDrawingMode(0)
! if self.contents:
! self.list.LAddRow(len(self.contents), 0)
! for i in range(len(self.contents)):
! v = repr(self.contents[i][0])
! if self.contents[i][1]:
! v = v + '"' + self.contents[i][1] + '"'
! self.list.LSetCell(v, (0, i))
! self.list.LSetDrawingMode(1)
! self.list.LUpdate(self.wid.GetWindowPort().visRgn)
!
! def getselection(self):
! items = []
! point = (0,0)
! while 1:
! ok, point = self.list.LGetSelect(1, point)
! if not ok:
! break
! items.append(point[1])
! point = point[0], point[1]+1
! values = []
! for i in items:
! values.append(self.contents[i])
! return values
!
! def do_show(self, *args):
! selection = self.getselection()
! for resid in selection:
! self.parent.showCIcon(resid)
!
! def do_close(self):
! self.close()
!
! def do_itemhit(self, item, event):
! if item == MAIN_SHOW:
! self.do_show()
main()
--- 28,163 ----
def main():
! macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc")
! CIconbrowse()
class CIconbrowse(FrameWork.Application):
! def __init__(self):
! # First init menus, etc.
! FrameWork.Application.__init__(self)
! # Next create our dialog
! self.main_dialog = MyDialog(self)
! # Now open the dialog
! contents = self.findcicnresources()
! self.main_dialog.open(ID_MAIN, contents)
! # Finally, go into the event loop
! self.mainloop()
!
! def makeusermenus(self):
! self.filemenu = m = FrameWork.Menu(self.menubar, "File")
! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit)
!
! def quit(self, *args):
! self._quit()
!
! def showCIcon(self, resid):
! w = CIconwindow(self)
! w.open(resid)
! #EasyDialogs.Message('Show cicn %r' % (resid,))
!
! def findcicnresources(self):
! num = Res.CountResources('cicn')
! rv = []
! for i in range(1, num+1):
! Res.SetResLoad(0)
! try:
! r = Res.GetIndResource('cicn', i)
! finally:
! Res.SetResLoad(1)
! id, type, name = r.GetResInfo()
! rv.append((id, name))
! return rv
!
class CIconwindow(FrameWork.Window):
! def open(self, (resid, resname)):
! if not resname:
! resname = '#%r' % (resid,)
! self.resid = resid
! self.picture = Icn.GetCIcon(self.resid)
! l, t, r, b = 0, 0, 32, 32
! self.pictrect = (l, t, r, b)
! width = r-l
! height = b-t
! if width < MINWIDTH: width = MINWIDTH
! elif width > MAXWIDTH: width = MAXWIDTH
! if height < MINHEIGHT: height = MINHEIGHT
! elif height > MAXHEIGHT: height = MAXHEIGHT
! bounds = (LEFT, TOP, LEFT+width, TOP+height)
!
! self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
! self.do_postopen()
!
! def do_update(self, *args):
! currect = self.fitrect()
! Icn.PlotCIcon(currect, self.picture)
!
! def fitrect(self):
! """Return self.pictrect scaled to fit in window"""
! graf = self.wid.GetWindowPort()
! screenrect = graf.GetPortBounds()
! picwidth = self.pictrect[2] - self.pictrect[0]
! picheight = self.pictrect[3] - self.pictrect[1]
! if picwidth > screenrect[2] - screenrect[0]:
! factor = float(picwidth) / float(screenrect[2]-screenrect[0])
! picwidth = picwidth / factor
! picheight = picheight / factor
! if picheight > screenrect[3] - screenrect[1]:
! factor = float(picheight) / float(screenrect[3]-screenrect[1])
! picwidth = picwidth / factor
! picheight = picheight / factor
! return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth),
! screenrect[1]+int(picheight))
!
class MyDialog(FrameWork.DialogWindow):
! "Main dialog window for cicnbrowse"
! def open(self, id, contents):
! self.id = id
! FrameWork.DialogWindow.open(self, ID_MAIN)
! self.dlg.SetDialogDefaultItem(MAIN_SHOW)
! self.contents = contents
! self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST)
! h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart,
! Controls.kControlListBoxListHandleTag)
! self.list = List.as_List(h)
! self.setlist()
! def setlist(self):
! self.list.LDelRow(0, 0)
! self.list.LSetDrawingMode(0)
! if self.contents:
! self.list.LAddRow(len(self.contents), 0)
! for i in range(len(self.contents)):
! v = repr(self.contents[i][0])
! if self.contents[i][1]:
! v = v + '"' + self.contents[i][1] + '"'
! self.list.LSetCell(v, (0, i))
! self.list.LSetDrawingMode(1)
! self.list.LUpdate(self.wid.GetWindowPort().visRgn)
!
! def getselection(self):
! items = []
! point = (0,0)
! while 1:
! ok, point = self.list.LGetSelect(1, point)
! if not ok:
! break
! items.append(point[1])
! point = point[0], point[1]+1
! values = []
! for i in items:
! values.append(self.contents[i])
! return values
!
! def do_show(self, *args):
! selection = self.getselection()
! for resid in selection:
! self.parent.showCIcon(resid)
!
! def do_close(self):
! self.close()
!
! def do_itemhit(self, item, event):
! if item == MAIN_SHOW:
! self.do_show()
main()
Index: oldPICTbrowse.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Demo/PICTbrowse/oldPICTbrowse.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** oldPICTbrowse.py 12 Feb 2004 17:35:12 -0000 1.7
--- oldPICTbrowse.py 18 Jul 2004 05:58:04 -0000 1.8
***************
*** 22,159 ****
def main():
! macresource.need('DLOG', ID_MAIN, "oldPICTbrowse.rsrc")
! PICTbrowse()
class PICTbrowse(FrameWork.Application):
! def __init__(self):
! # First init menus, etc.
! FrameWork.Application.__init__(self)
! # Next create our dialog
! self.main_dialog = MyDialog(self)
! # Now open the dialog
! contents = self.findPICTresources()
! self.main_dialog.open(ID_MAIN, contents)
! # Finally, go into the event loop
! self.mainloop()
!
! def makeusermenus(self):
! self.filemenu = m = FrameWork.Menu(self.menubar, "File")
! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit)
!
! def quit(self, *args):
! self._quit()
!
! def showPICT(self, resid):
! w = PICTwindow(self)
! w.open(resid)
! #EasyDialogs.Message('Show PICT %r' % (resid,))
!
! def findPICTresources(self):
! num = Res.CountResources('PICT')
! rv = []
! for i in range(1, num+1):
! Res.SetResLoad(0)
! try:
! r = Res.GetIndResource('PICT', i)
! finally:
! Res.SetResLoad(1)
! id, type, name = r.GetResInfo()
! rv.append((id, name))
! return rv
!
class PICTwindow(FrameWork.Window):
! def open(self, (resid, resname)):
! if not resname:
! resname = '#%r' % (resid,)
! self.resid = resid
! picture = Qd.GetPicture(self.resid)
! # Get rect for picture
! print repr(picture.data[:16])
! sz, t, l, b, r = struct.unpack('hhhhh', picture.data[:10])
! print 'pict:', t, l, b, r
! width = r-l
! height = b-t
! if width < 64: width = 64
! elif width > 480: width = 480
! if height < 64: height = 64
! elif height > 320: height = 320
! bounds = (LEFT, TOP, LEFT+width, TOP+height)
! print 'bounds:', bounds
!
! self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
! self.wid.SetWindowPic(picture)
! self.do_postopen()
!
class MyDialog(FrameWork.DialogWindow):
! "Main dialog window for PICTbrowse"
! def open(self, id, contents):
! self.id = id
! FrameWork.DialogWindow.open(self, ID_MAIN)
! self.dlg.SetDialogDefaultItem(MAIN_SHOW)
! tp, h, rect = self.dlg.GetDialogItem(MAIN_LIST)
! rect2 = rect[0]+1, rect[1]+1, rect[2]-17, rect[3]-17 # Scroll bar space
! self.list = List.LNew(rect2, (0, 0, 1, len(contents)), (0,0), 0, self.wid,
! 0, 1, 1, 1)
! self.contents = contents
! self.setlist()
! def setlist(self):
! self.list.LDelRow(0, 0)
! self.list.LSetDrawingMode(0)
! if self.contents:
! self.list.LAddRow(len(self.contents), 0)
! for i in range(len(self.contents)):
! v = repr(self.contents[i][0])
! if self.contents[i][1]:
! v = v + '"' + self.contents[i][1] + '"'
! self.list.LSetCell(v, (0, i))
! self.list.LSetDrawingMode(1)
! self.list.LUpdate(self.wid.GetWindowPort().visRgn)
!
! def do_listhit(self, event):
! (what, message, when, where, modifiers) = event
! Qd.SetPort(self.wid)
! where = Qd.GlobalToLocal(where)
! print 'LISTHIT', where
! if self.list.LClick(where, modifiers):
! self.do_show()
!
! def getselection(self):
! items = []
! point = (0,0)
! while 1:
! ok, point = self.list.LGetSelect(1, point)
! if not ok:
! break
! items.append(point[1])
! point = point[0], point[1]+1
! values = []
! for i in items:
! values.append(self.contents[i])
! return values
!
! def do_show(self, *args):
! selection = self.getselection()
! for resid in selection:
! self.parent.showPICT(resid)
!
! def do_rawupdate(self, window, event):
! tp, h, rect = self.dlg.GetDialogItem(MAIN_LIST)
! Qd.SetPort(self.wid)
! Qd.FrameRect(rect)
! self.list.LUpdate(self.wid.GetWindowPort().visRgn)
!
! def do_activate(self, activate, event):
! self.list.LActivate(activate)
!
! def do_close(self):
! self.close()
!
! def do_itemhit(self, item, event):
! if item == MAIN_LIST:
! self.do_listhit(event)
! if item == MAIN_SHOW:
! self.do_show()
main()
--- 22,159 ----
def main():
! macresource.need('DLOG', ID_MAIN, "oldPICTbrowse.rsrc")
! PICTbrowse()
class PICTbrowse(FrameWork.Application):
! def __init__(self):
! # First init menus, etc.
! FrameWork.Application.__init__(self)
! # Next create our dialog
! self.main_dialog = MyDialog(self)
! # Now open the dialog
! contents = self.findPICTresources()
! self.main_dialog.open(ID_MAIN, contents)
! # Finally, go into the event loop
! self.mainloop()
!
! def makeusermenus(self):
! self.filemenu = m = FrameWork.Menu(self.menubar, "File")
! self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit)
!
! def quit(self, *args):
! self._quit()
!
! def showPICT(self, resid):
! w = PICTwindow(self)
! w.open(resid)
! #EasyDialogs.Message('Show PICT %r' % (resid,))
!
! def findPICTresources(self):
! num = Res.CountResources('PICT')
! rv = []
! for i in range(1, num+1):
! Res.SetResLoad(0)
! try:
! r = Res.GetIndResource('PICT', i)
! finally:
! Res.SetResLoad(1)
! id, type, name = r.GetResInfo()
! rv.append((id, name))
! return rv
!
class PICTwindow(FrameWork.Window):
! def open(self, (resid, resname)):
! if not resname:
! resname = '#%r' % (resid,)
! self.resid = resid
! picture = Qd.GetPicture(self.resid)
! # Get rect for picture
! print repr(picture.data[:16])
! sz, t, l, b, r = struct.unpack('hhhhh', picture.data[:10])
! print 'pict:', t, l, b, r
! width = r-l
! height = b-t
! if width < 64: width = 64
! elif width > 480: width = 480
! if height < 64: height = 64
! elif height > 320: height = 320
! bounds = (LEFT, TOP, LEFT+width, TOP+height)
! print 'bounds:', bounds
!
! self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
! self.wid.SetWindowPic(picture)
! self.do_postopen()
!
class MyDialog(FrameWork.DialogWindow):
! "Main dialog window for PICTbrowse"
! def open(self, id, contents):
! self.id = id
! FrameWork.DialogWindow.open(self, ID_MAIN)
! self.dlg.SetDialogDefaultItem(MAIN_SHOW)
! tp, h, rect = self.dlg.GetDialogItem(MAIN_LIST)
! rect2 = rect[0]+1, rect[1]+1, rect[2]-17, rect[3]-17 # Scroll bar space
! self.list = List.LNew(rect2, (0, 0, 1, len(contents)), (0,0), 0, self.wid,
! 0, 1, 1, 1)
! self.contents = contents
! self.setlist()
! def setlist(self):
! self.list.LDelRow(0, 0)
! self.list.LSetDrawingMode(0)
! if self.contents:
! self.list.LAddRow(len(self.contents), 0)
! for i in range(len(self.contents)):
! v = repr(self.contents[i][0])
! if self.contents[i][1]:
! v = v + '"' + self.contents[i][1] + '"'
! self.list.LSetCell(v, (0, i))
! self.list.LSetDrawingMode(1)
! self.list.LUpdate(self.wid.GetWindowPort().visRgn)
!
! def do_listhit(self, event):
! (what, message, when, where, modifiers) = event
! Qd.SetPort(self.wid)
! where = Qd.GlobalToLocal(where)
! print 'LISTHIT', where
! if self.list.LClick(where, modifiers):
! self.do_show()
!
! def getselection(self):
! items = []
! point = (0,0)
! while 1:
! ok, point = self.list.LGetSelect(1, point)
! if not ok:
! break
! items.append(point[1])
! point = point[0], point[1]+1
! values = []
! for i in items:
! values.append(self.contents[i])
! return values
!
! def do_show(self, *args):
! selection = self.getselection()
! for resid in selection:
! self.parent.showPICT(resid)
!
! def do_rawupdate(self, window, event):
! tp, h, rect = self.dlg.GetDialogItem(MAIN_LIST)
! Qd.SetPort(self.wid)
! Qd.FrameRect(rect)
! self.list.LUpdate(self.wid.GetWindowPort().visRgn)
!
! def do_activate(self, activate, event):
! self.list.LActivate(activate)
!
! def do_close(self):
! self.close()
!
! def do_itemhit(self, item, event):
! if item == MAIN_LIST:
! self.do_listhit(event)
! if item == MAIN_SHOW:
! self.do_show()
main()
- Previous message: [Python-checkins] python/dist/src/Mac/Demo/applescript makedisk.py,
1.1, 1.2
- Next message: [Python-checkins] python/dist/src/Mac/Demo/applescript/Disk_Copy
Special_Events.py, 1.2, 1.3 Standard_Suite.py, 1.2,
1.3 Utility_Events.py, 1.1, 1.2 __init__.py, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Python-checkins
mailing list