Re: [pygtk] small patch for libglade.py
Graham Ashton writes: > > --- libglade.py.orig Thu May 16 16:32:26 2002 > > +++ libglade.pyThu May 16 16:34:01 2002 > > @@ -11,6 +11,8 @@ > > class GladeXML(_gtk.GtkData): > >def __init__(self, filename=None, root=None, domain=None, _obj=None): > >if _obj: self._o = _obj; return > > + open(filename, 'r') ##raises an exception if file does not exist > > + close(filename) ## or is not readable > > I would have thought the intention of the code would be more apparent > (i.e. no need for comment) if you said something like (untested): > > if not os.path.exists(filename): > raise IOError, "No such file or directory: '%s'" % filename > > In general, if you can re-write your code to make the comment redundant, > it's usually a good idea. You are so utterly and completely right. Furthermore, the patch I posted was totally bogus because "close(filename)" is not the way to close a file, it's "file_object.close()". I don't know how that patch made it past the rigorous testing of my QC department! Time to fire that QC engineer, I guess. ;-) I would like to withdraw this patch. I think an even better approach, which I will try to pursue, would be to catch any errors which occur while importing the Glade file, and turn them into exceptions. The problem of the file being missing or not having read permission is just one special case of a more general error reading/parsing the XML, which currently is not reported back to the user/developer in a very clear way... I think that it would be better to raise an exception than to just emit a complaint to stderr and continue. Opionions? ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] gnome crash
This problem has been solved after updating various pygnome py* software from XIMIAN. -- Anthony Tekatch On Sat, 25 May 2002 20:03:26 -0400, Anthony Tekatch <[EMAIL PROTECTED]> wrote: > > > I have a GUI application that crashes (GNOME crash) when closing the > window. I think it is a timing problem with GNOME. If I let the > application close itself then everything is OK, also if I maximize the > application the use the application close button (app_destroy) then also > everything is OK, but if the window is restored in size and I use > app_destroy then I get the following crash report: > > --- Gnome Error Dialog: > Application "/usr/bin/python" process(26096) has crashed > due to a fatal error. > (Segmentation fault) > [Close] [Submit a bug report] > > > I think that maybe Gnome is forcing the application closed before my > Python program receives the mainquit signal. > > Any ideas would be appreciated. > > > -- > Anthony Tekatch ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] small patch for libglade.py
On Thu, 2002-05-16 at 22:42, Charles Waldman wrote: > > If you try to do GladeXML("somefile.glade") where "somefile.glade" > does not exist or is not readable, you get a "WARNING: document is not > well-formed" message. This error message is misleading; it does not > lead one to the real cause of the problem. Hence this trivial patch: > > --- libglade.py.orig Thu May 16 16:32:26 2002 > +++ libglade.py Thu May 16 16:34:01 2002 > @@ -11,6 +11,8 @@ > class GladeXML(_gtk.GtkData): > def __init__(self, filename=None, root=None, domain=None, _obj=None): > if _obj: self._o = _obj; return > + open(filename, 'r') ##raises an exception if file does not exist > + close(filename) ## or is not readable I would have thought the intention of the code would be more apparent (i.e. no need for comment) if you said something like (untested): if not os.path.exists(filename): raise IOError, "No such file or directory: '%s'" % filename In general, if you can re-write your code to make the comment redundant, it's usually a good idea. Cheers. -- Graham Ashton ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] canvas
Hi is it possible to create custom CanvasItem in pygtk2??? ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/