From baykiwi at gmail.com Thu Dec 9 10:37:48 2010 From: baykiwi at gmail.com (Colin Brown) Date: Thu, 9 Dec 2010 22:37:48 +1300 Subject: [Pygui] Application exit on Main Window close Message-ID: Hi I seem to be missing something here. I am running PyGUI on OSX 10.5.8 but cannot figure out how to make the python application exit when I close the main PyGUI window? Cheers Colin From greg.ewing at canterbury.ac.nz Thu Dec 9 23:07:00 2010 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Fri, 10 Dec 2010 11:07:00 +1300 Subject: [Pygui] Application exit on Main Window close In-Reply-To: References: Message-ID: <4D015304.8020602@canterbury.ac.nz> Colin Brown wrote: > I am running PyGUI on OSX 10.5.8 > but cannot figure out how to make the python application exit when I > close the main PyGUI window? One way would be to override the close_cmd() method of the window and have it call quit_cmd() on the application. Another way is to override zero_windows_allowed() on the application and have it return False, although that's not an official part of the API at the moment, so it might change. -- Greg From baykiwi at gmail.com Sun Dec 12 05:24:12 2010 From: baykiwi at gmail.com (Colin Brown) Date: Sun, 12 Dec 2010 17:24:12 +1300 Subject: [Pygui] Application exit on Main Window close Message-ID: <9C3A4908-569E-4551-8439-5603E25C8F36@gmail.com> Greg Ewing wrote: > One way would be to override the close_cmd() method of the > window and have it call quit_cmd() on the application. > Another way is to override zero_windows_allowed() on the > application and have it return False, although that's not > an official part of the API at the moment, so it might > change. Thanks Greg, both these work. It was a little frustrating having to repeatedly kill my terminal session during development ;-) Cheers Colin -------------- next part -------------- An HTML attachment was scrubbed... URL: From baykiwi at gmail.com Sun Dec 12 10:24:05 2010 From: baykiwi at gmail.com (Colin Brown) Date: Sun, 12 Dec 2010 22:24:05 +1300 Subject: [Pygui] Show_text only appearing in last widget Message-ID: <3D793C05-AA25-4FB6-BA19-40DCD1B2A866@gmail.com> Hi I am expecting to see text written into each of the coloured squares but I can only see text in the last square; why is this? Cheers Colin Brown Code as run on MacOSX: from GUI import Application, Document, Window, FileType, View from GUI.StdColors import black, green class myApp(Application): def __init__(self): Application.__init__(self) self.item_type = FileType(name="Item Document", suffix = 'itm') self.file_type = self.item_type def open_app(self): self.new_cmd() def make_document(self, fileref): return ItemDoc(file_type = self.item_type) def make_window(self, document): win = Window(size=(300,160), title='Named block test', document=document) view = ItemView(model=document) win.place(view, left=0, top=0, right=0, bottom=0, sticky='nsew') win.show() def zero_windows_allowed(self): return class ItemView(View): def __init__(self,*args, **kargs): View.__init__(self,*args, **kargs) for n in range(5): for m in range(2): self.model.add_item(Item((50*(n+1),50*(m+1)), 'x%sy%s' % (n,m))) def draw(self, canvas, update_rect): canvas.fillcolor = green canvas.pencolor = black for item in self.model.items: item.draw(canvas) class ItemDoc(Document): def new_contents(self): self.items = [] def add_item(self, item): self.items.append(item) self.changed() self.notify_views('item_changed', item) class Item: def __init__(self, c, t): self.rect, self.text = (c[0]-20,c[1]-20,c[0]+20,c[1]+20), t def contains(self, x, y): return pt_in_rect((x,y), self.rect) def draw(self, canvas): l,t,r,b = self.rect canvas.moveto(l,t) canvas.lineto(r,t) canvas.lineto(r,b) canvas.lineto(l,b) canvas.closepath() canvas.fill_stroke() canvas.moveto(l+9,t+24) canvas.show_text(self.text) myApp().run() From greg.ewing at canterbury.ac.nz Sun Dec 12 23:47:44 2010 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Mon, 13 Dec 2010 11:47:44 +1300 Subject: [Pygui] Application exit on Main Window close In-Reply-To: <9C3A4908-569E-4551-8439-5603E25C8F36@gmail.com> References: <9C3A4908-569E-4551-8439-5603E25C8F36@gmail.com> Message-ID: <4D055110.8080203@canterbury.ac.nz> Colin Brown wrote: > Thanks Greg, both these work. It was a little frustrating having to > repeatedly kill my terminal session during development ;-) The Quit command should still work, unless you've removed it from the main menu bar, which isn't recommended if you want the app to work in a Mac-like way. -- Greg From greg.ewing at canterbury.ac.nz Mon Dec 13 00:15:27 2010 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Mon, 13 Dec 2010 12:15:27 +1300 Subject: [Pygui] Show_text only appearing in last widget In-Reply-To: <3D793C05-AA25-4FB6-BA19-40DCD1B2A866@gmail.com> References: <3D793C05-AA25-4FB6-BA19-40DCD1B2A866@gmail.com> Message-ID: <4D05578F.8010701@canterbury.ac.nz> Colin Brown wrote: > I am expecting to see text written into each of the coloured squares > but I can only see text in the last square; why is this? You need a canvas.newpath() call before drawing the rect. Otherwise you're building up a single path that includes all the previous rects and draws over the text you've written before. def draw(self, canvas): l,t,r,b = self.rect canvas.newpath() # <-- add this here canvas.moveto(l,t) -- Greg From baykiwi at gmail.com Mon Dec 13 09:36:45 2010 From: baykiwi at gmail.com (Colin Brown) Date: Mon, 13 Dec 2010 21:36:45 +1300 Subject: [Pygui] Show_text only appearing in last widget Message-ID: Greg Ewing wrote: > You need a canvas.newpath() call before drawing the rect. Otherwise > you're building up a single path that includes all the previous > rects and draws over the text you've written before. Oh! The Canvas.html help document under Current Path says "Once constructed, a path can be used in the following ways: It can be stroked with the current pen colour and size using the stroke method. It can be filled with the current fill colour using the fill method. It can be both filled and stroked using the fill_stroke method. It can be erased with the current background colour using the erase method. It can be used to restrict the current clipping region (see below) using the clip method. After a path has been used by one of these methods, it is automatically cleared." I had thought that the fill_stroke would have cleared the path? Colin -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg.ewing at canterbury.ac.nz Tue Dec 14 00:08:52 2010 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Tue, 14 Dec 2010 12:08:52 +1300 Subject: [Pygui] Show_text only appearing in last widget In-Reply-To: References: Message-ID: <4D06A784.9050806@canterbury.ac.nz> Colin Brown wrote: > After a path has been used by one of these methods, it is automatically cleared." > > I had thought that the fill_stroke would have cleared the path? Hmmm, there does seem to be an inconsistency between documentation and reality here, although I'm not sure which one I intended to be correct. I'll look into the matter. -- Greg From baykiwi at gmail.com Tue Dec 14 09:08:24 2010 From: baykiwi at gmail.com (Colin Brown) Date: Tue, 14 Dec 2010 21:08:24 +1300 Subject: [Pygui] Pixmap confusion Message-ID: Hi My first hack at a Patch Panel application is progressing. To facilitate rapid screen redraw I planned to use the Pixmap class. However I cannot understand how the same objects that are absolutely referenced to my main Window and also written to the Pixmap, appear row inverted when retrieved from the Pixmap and displayed alongside the main Window-written set? The graphics positioning is upside down but the text drawing in the Pixmap is rightside up. Cheers Colin Brown Code on Mac OSX: from GUI import Application, Document, Window, FileType, View, Frame, Pixmap from GUI.StdColors import black, yellow, green from GUI.Geometry import pt_in_rect class myApp(Application): def __init__(self, title=None): Application.__init__(self, title=title) self.item_type = FileType(name="Item Document", suffix = 'patch') self.file_type = self.item_type self.pm = Pixmap(450,800) def open_app(self): self.new_cmd() def make_document(self, fileref): return ItemDoc(file_type = self.item_type) def make_window(self, document): win = Window(size=(950,800), title='Patch Panel', document=document) view = ItemView(model=document) win.place(view, left=0, top=0, right=0, bottom=0, sticky='nsew') win.show() def zero_windows_allowed(self): return class ItemView(View, Frame): def __init__(self,*args, **kargs): View.__init__(self,*args, **kargs) for n in range(15): for m in range(8): self.model.add_item(Item((50*(m+1),50*(n+1)), '%03i' % (1+m +8*n,))) def draw(self, canvas, update_rect): canvas.fillcolor = yellow canvas.pencolor = black for item in self.model.items: item.draw(canvas) A.pm.draw(canvas,(0,0,450,800),(500,0,950,800)) def mouse_move(self, ev): print self.model.onItem(ev.position) class ItemDoc(Document): def new_contents(self): self.items = [] def add_item(self, item): self.changed() self.notify_views('item_changed', item) self.items.append(item) item.setpm(1) A.pm.with_canvas(item.draw) item.setpm(0) def onItem(self, xy): for n in range(len(self.items)): if self.items[n].contains(xy): return n+1 return 0 class Item: def __init__(self, c, t): self.centre = c self.rect, self.text = (c[0]-20,c[1]-20,c[0]+20,c[1]+20), t self.pm = 0 def contains(self, xy): return pt_in_rect(xy, self.rect) def setpm(self,state): self.pm = state def draw(self, canvas): if self.pm: canvas.fillcolor = green canvas.pencolor = black else: canvas.fillcolor = yellow l,t,r,b = self.rect canvas.newpath() canvas.moveto(l,t) canvas.lineto(r,t) canvas.lineto(r,b) canvas.lineto((r+l)/2,b+3) # Help debug pixmap drawing problem canvas.lineto(l,b) canvas.closepath() canvas.fill_stroke() canvas.moveto(l+9,t+24) canvas.show_text(self.text) A = myApp('Patch Panel') A.run() From greg.ewing at canterbury.ac.nz Wed Dec 15 11:28:18 2010 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Wed, 15 Dec 2010 23:28:18 +1300 Subject: [Pygui] Show_text only appearing in last widget In-Reply-To: References: Message-ID: <4D089842.9030400@canterbury.ac.nz> Colin Brown wrote: > "...After a path has been used by one of these methods, it is automatically cleared." > > I had thought that the fill_stroke would have cleared the path? From studying the code, it seems that I changed my mind on that at some point, so the docs are wrong. I'll remove that sentence in the next release. -- Greg From greg.ewing at canterbury.ac.nz Wed Dec 15 23:37:12 2010 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Thu, 16 Dec 2010 11:37:12 +1300 Subject: [Pygui] Pixmap confusion In-Reply-To: References: Message-ID: <4D094318.4040401@canterbury.ac.nz> Colin Brown wrote: > > I cannot understand how the same objects that > are absolutely referenced to my > main Window and also written to the Pixmap, appear row inverted when > retrieved from the Pixmap It's because Cocoa's default coordinate system for graphics ports has the origin in the lower left with X upwards, like Postscript. I need to invert the coordinate system to make it match the window coordinates. > The graphics > positioning is upside down but the text > drawing in the Pixmap is rightside up. NSGraphicsContext has an isFlipped property that Cocoa uses to flip the text. I need to get that set to True, although that turns out not to be so straightforward for a graphics context attached to a bitmap. I'm making progress, though -- I've got both the text *and* the graphics upside down now. :-) -- Greg From baykiwi at gmail.com Fri Dec 17 08:14:56 2010 From: baykiwi at gmail.com (Colin Brown) Date: Fri, 17 Dec 2010 20:14:56 +1300 Subject: [Pygui] PyGUI-2.3.2 ValueError on MacOSX Message-ID: <97034098-9303-4939-89BF-AF60A89A0610@gmail.com> Hi Greg Thanks for all the effort you are putting in on PyGUI - it shows great promise. However there appears to be a slight problem with version 2.3.2 as when I run the code from my previous email "Pixmap confusion" I get a Traceback on startup. Cheers Colin Macintosh:cb colin$ python link.py /System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/ python/PyObjC/objc/_bridgesupport.py:9: UserWarning: Module site was already imported from /System/Library/Frameworks/Python.framework/ Versions/2.5/lib/python2.5/site.pyc, but /Library/Python/2.5/site- packages/Enstaller-3.0.5-py2.5.egg is being added to sys.path import pkg_resources /System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/ python/PyObjC/objc/_bridgesupport.py:9: UserWarning: Module pkg_resources was already imported from /Library/Python/2.5/site- packages/setuptools-0.6c9-py2.5.egg/pkg_resources.py, but /Library/ Python/2.5/site-packages/Enstaller-3.0.5-py2.5.egg is being added to sys.path import pkg_resources 2010-12-17 19:57:03.112 Python[9990:613] PyObjCPointer created: at 0x1f7a620 of type {CGContext=} Traceback (most recent call last): File "/Library/Python/2.5/site-packages/GUI/Cocoa/Applications.py", line 142, in run GApplication.run(self) File "/Library/Python/2.5/site-packages/GUI/Generic/ GApplications.py", line 122, in run self.process_args(sys.argv[1:]) File "/Library/Python/2.5/site-packages/GUI/Cocoa/Applications.py", line 138, in process_args GApplication.process_args(self, args) File "/Library/Python/2.5/site-packages/GUI/Generic/ GApplications.py", line 251, in process_args self.open_app() File "link.py", line 13, in open_app self.new_cmd() File "/Library/Python/2.5/site-packages/GUI/Generic/ GApplications.py", line 219, in new_cmd self.make_window(doc) File "link.py", line 17, in make_window win = Window(size=(950,800), title='Patch Panel', document=document) File "/Library/Python/2.5/site-packages/GUI/Cocoa/Windows.py", line 53, in __init__ ns_rect, self._ns_style_mask, AppKit.NSBackingStoreBuffered, True) ValueError: NSInvalidArgumentException - *** -focusStack only defined for abstract class. Define -[FlippedNSGraphicsContext focusStack]! From greg.ewing at canterbury.ac.nz Fri Dec 17 23:02:56 2010 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sat, 18 Dec 2010 11:02:56 +1300 Subject: [Pygui] Pixmap confusion In-Reply-To: References: Message-ID: <4D0BDE10.8050003@canterbury.ac.nz> Colin Brown wrote: > > The graphics > positioning is upside down but the text > drawing in the Pixmap is rightside up. I have fully solved this problem now and posted a new release to fix it. -- Greg From greg.ewing at canterbury.ac.nz Fri Dec 17 23:41:07 2010 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sat, 18 Dec 2010 11:41:07 +1300 Subject: [Pygui] PyGUI-2.3.2 ValueError on MacOSX In-Reply-To: <97034098-9303-4939-89BF-AF60A89A0610@gmail.com> References: <97034098-9303-4939-89BF-AF60A89A0610@gmail.com> Message-ID: <4D0BE703.60709@canterbury.ac.nz> Colin Brown wrote: > ValueError: NSInvalidArgumentException - *** -focusStack only defined > for abstract class. Define -[FlippedNSGraphicsContext focusStack]! Hmmm, this may be because you're using an earlier version of MacOSX than me. According to the Apple docs, focusStack only exists in versions up to 10.5. Can you please try adding the following method to class FlippedNSGraphicsContext in GUI/Cocoa/Pixmap.py and tell me whether it fixes the problem for you? def focusStack(self): return self.base.focusStack() Thanks, Greg From baykiwi at gmail.com Sat Dec 18 08:06:58 2010 From: baykiwi at gmail.com (Colin Brown) Date: Sat, 18 Dec 2010 20:06:58 +1300 Subject: [Pygui] PyGUI-2.3.2 ValueError on MacOSX Message-ID: <15BF1F83-B683-42E8-B372-0B772C514A10@gmail.com> Greg Ewing wrote: > Can you please try adding the following method to class > FlippedNSGraphicsContext in GUI/Cocoa/Pixmap.py and tell me > whether it fixes the problem for you? > > def focusStack(self): > return self.base.focusStack() Added the following lines to Pixmaps.py and the code now works okay: def focusStack(self): return self.base.focusStack() def saveGraphicsState(self): return self.base.saveGraphicsState() def restoreGraphicsState(self): return self.base.restoreGraphicsState() Cheers Colin -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg.ewing at canterbury.ac.nz Sun Dec 19 00:15:18 2010 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sun, 19 Dec 2010 12:15:18 +1300 Subject: [Pygui] PyGUI-2.3.2 ValueError on MacOSX In-Reply-To: <15BF1F83-B683-42E8-B372-0B772C514A10@gmail.com> References: <15BF1F83-B683-42E8-B372-0B772C514A10@gmail.com> Message-ID: <4D0D4086.6070401@canterbury.ac.nz> Colin Brown wrote: > Added the following lines to Pixmaps.py and the code now works okay: > > def focusStack(self): > return self.base.focusStack() > > def saveGraphicsState(self): > return self.base.saveGraphicsState() > > def restoreGraphicsState(self): > return self.base.restoreGraphicsState() Great, thanks. I'll incorporate this into the next release. -- Greg From taylorzr at gmail.com Thu Dec 30 18:56:51 2010 From: taylorzr at gmail.com (Zach) Date: Thu, 30 Dec 2010 11:56:51 -0600 Subject: [Pygui] How Can I Contribute? Message-ID: I really like the idea of a native python gui. How can I contribute? Also, the website seems to be down for me. Anyone else having problems? -- Zach -------------- next part -------------- An HTML attachment was scrubbed... URL: