Re: [pygtk] help understanding event loop
"Rob Hodges" <[EMAIL PROTECTED]> writes: > > This is just about it. I wanted non-modal dialog boxes, so I changed > > file_open_box() to file_open_box(modal=FALSE), and added a print so > > you can see what is going on. > > Non-modal dialogs are good, but if you let users open two of the same > dialog it's just confusing. I would suggest (as someone else did a > while back when discussing the naughtiness of modality) to use a > widget.set_sensitive(FALSE) on the button widget that pops up the > dialog [so that they can't pop up another one, but can still use the > rest of the app], and set_sensitive(TRUE) when they close the dialog. > Then you neither have to make the dialog modal, nor worry about what's > getting pushed to this or that stack (the behaviour of which it's > probably not advisable to rely on). An alternative is to have store a reference to the dialog in a global variable or an instance variable and check that variable before creating the dialog. If the dialog already exists, just make sure it's deiconified and raised otherwise create a new dialog. In this setup it's important to connect to the destroy signal of the dialog so you can set the variable to None. This approach has the advantage that you can bind the same callback to several widgets, e.g. a button and a menu item, at once and the function doesn't even have to know to which widgets it's bound. -- Bernhard Herzog | Sketch, a drawing program for Unix [EMAIL PROTECTED] | http://sketch.sourceforge.net/ - To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
Re: [pygtk] PyQt/PyKDE Bindings
On Fri, Mar 24, 2000 at 01:03:58AM +0800, James Henstridge wrote: > On Thu, 23 Mar 2000, Moshe Zadka wrote: > > As long as you're breaking things anyway, let me suggest one change: > > have the "Gtk" prefix stripped from the classes' names (GtkText -> Text, > > etc) and recommend that Gtk is imported via > > I am more in favour of keeping the Gtk prefix, as this seems to be common > in some of the other language bindings (even the java bindings kept the > Gtk prefix when the classes were in a gtk package). Most of your > application is made up of manipulating widgets, rather than constructing > them, so the extra three characters is not that much of a problem. I rather liked Moshe's proposal because it supports the "principle of least surprise". This is especially important when there's any chance of name collision. The issue of three vs. four character prefix, ("Gtk" vs. "Gtk."), seems to be too small to be a consideration. -- Randolph Bentson [EMAIL PROTECTED] - To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
Re: [pygtk] PyQt/PyKDE Bindings
Moshe Zadka writes: > As long as you're breaking things anyway, let me suggest one change: > have the "Gtk" prefix stripped from the classes' names (GtkText -> Text, > etc) and recommend that Gtk is imported via [...] I think (but am not sure) that James meant there would be *some* breakage, not *lots* of breakage. As it stands, my PyGTK code always does: import gtk w = gtk.GtkWindow() # or whatever ... I don't mind the leading Gtk prefix, but wouldn't mind seeing it go, either. If the expected breakage isn't too bad, I'd keep it as-is. What I *really* want to see go is code that does from import * for any value of . This just makes code hard to read. Short, lowercase module names are always best, and they can really make the code more readable. There should be no recommendation that the "import *" form be used (same for Tkinter, which should be named tk or, at worst, Tk). So there. ;) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives - To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
Re: [pygtk] PyQt/PyKDE Bindings
On Thu, 23 Mar 2000, Moshe Zadka wrote: > As long as you're breaking things anyway, let me suggest one change: > have the "Gtk" prefix stripped from the classes' names (GtkText -> Text, > etc) and recommend that Gtk is imported via > > import Gtk > > And accesed via > > Gtk.Text() > > (Simillarily for Gnome/GnomeUI) > > It seems much more Pythonic then > > from gtk import * > > GtkText() > You can currently do: import gtk gtk.GtkText() I am more in favour of keeping the Gtk prefix, as this seems to be common in some of the other language bindings (even the java bindings kept the Gtk prefix when the classes were in a gtk package). Most of your application is made up of manipulating widgets, rather than constructing them, so the extra three characters is not that much of a problem. > > -- > Moshe Zadka <[EMAIL PROTECTED]>. James. - To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
Re: [pygtk] PyQt/PyKDE Bindings
Moshe Zadka writes: > > As long as you're breaking things anyway, let me suggest one change: > have the "Gtk" prefix stripped from the classes' names (GtkText -> Text, > etc) and recommend that Gtk is imported via > > import Gtk > > And accesed via > > Gtk.Text() > > (Simillarily for Gnome/GnomeUI) > > It seems much more Pythonic then > > from gtk import * > > GtkText() I'm in 100% agreement - "import *" is kind of nasty. I'd gladly change code to get around this. Also, the required edits could most likely be automated, and if we really wanted we could make a module "oldgtk" or something to ease the transitions: oldgtk.py: import Gtk GtkText=Gtk.Text ... Then people could do "from oldgtk import *" and have their old code work. - To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
Re: [pygtk] PyQt/PyKDE Bindings
François Pinard <[EMAIL PROTECTED]> writes: > Moshe Zadka <[EMAIL PROTECTED]> writes: > > > As long as you're breaking things anyway, let me suggest one change: > > have the "Gtk" prefix stripped from the classes' names (GtkText -> Text, > > etc) [...] > > For one, I would be happy to make that change, as well (partly > because I've not that much written so far :-). ... > I'm not sure of anything, beside the fact I would like to turn > `GtkText' into `Gtk.Text'. That would be definitely cool. I tend to write `import gtk' rather than `from gtk import *' for two reasons: * It's a good idea in general to avoid `from FOO import *'. Many modules tend to clash in names, e.g. re.split and string.split, etc. * gtk specifically exports a whole bunch of unprefixed names. For example, I really don't want unadorned TRUE and FALSE in my namespace. Having said that, I often note that gtk.GtkWindow looks sort of ugly. In an ideal world, we'd be able to write: import gtk w = gtk.Window(...) w.set_foo(gtk.TRUE, ...) And so on. - To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
Re: [pygtk] help understanding event loop
> This is just about it. I wanted non-modal dialog boxes, so I changed > file_open_box() to file_open_box(modal=FALSE), and added a print so > you can see what is going on. Non-modal dialogs are good, but if you let users open two of the same dialog it's just confusing. I would suggest (as someone else did a while back when discussing the naughtiness of modality) to use a widget.set_sensitive(FALSE) on the button widget that pops up the dialog [so that they can't pop up another one, but can still use the rest of the app], and set_sensitive(TRUE) when they close the dialog. Then you neither have to make the dialog modal, nor worry about what's getting pushed to this or that stack (the behaviour of which it's probably not advisable to rely on). -Rob - To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
Re: [pygtk] PyQt/PyKDE Bindings
Moshe Zadka <[EMAIL PROTECTED]> writes: > As long as you're breaking things anyway, let me suggest one change: > have the "Gtk" prefix stripped from the classes' names (GtkText -> Text, > etc) [...] For one, I would be happy to make that change, as well (partly because I've not that much written so far :-). However, should we write `Gtk.FILL' instead of `FILL'? Just from an aesthetical viewpoint, since we already use `GDK.' to prefix GDK constants, maybe we should import GTK and write `GTK.FILL', or just `from GTK import *' if we like to stay terse with GTK constants. The need of another import might be unwelcome, but on the other hand, `import gtk, GTK, GDK' is easy to write on one line. I'm not sure of anything, beside the fact I would like to turn `GtkText' into `Gtk.Text'. We might even guess that `pygtk' intensive applications/users would like `from gtk import *' still, and just use unprefixed `Text'. What is not nice is having the module name repeated in module objects. -- François Pinard http://www.iro.umontreal.ca/~pinard - To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]