From: Jochen V. <vo...@se...> - 2004-11-20 14:10:18
|
Hello, On Sat, Nov 20, 2004 at 11:53:01AM +0800, Steve Chaplin wrote: > I was thinking of something like: >=20 > class VerboseGTK(Verbose): > def report_error(self, s): > dialog =3D gtk.MessageDialog( > parent =3D None, > type =3D gtk.MESSAGE_ERROR, > buttons =3D gtk.BUTTONS_OK, > message_format =3D msg) > dialog.run() > dialog.destroy() Alternatively we could make report_error a figure_manager method. If could default to class FigureManagerBase: def report_error(self, s): sys.stderr.write("error: %s\n"%s) And FigureManagerGTK could overload it with the above code to generate an error box. Reasons why I would prefer this: 1) I do not like these global variables which are set on module import at all. Using the VerboseGTK idea we would get another instance of this, namely something like "currentVerboseClass=3DVerboseBackend" or such. We already have something like this for figure managers, so no new instan= ce of this would be created with my suggestion. Reporting errors would then work like this: manager =3D get_current_fig_manager() manager.canvas.report_error(message) which could be wrapped into a function. 2) The main functionality of the Verbose class seems to be, that the user can select how many messages he wants to see. Error messages (at least fatal ones) should be presented to the user in any case, so for me reporting errors does not look like an application of the Verbose class. What do you think? Jochen --=20 http://seehuhn.de/ |