Re: [pygtk] Dialogs demo
Marco> You may also like the tools explained in this article: Marco> http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html Marco> It is about the LazyPython and pythonstartup.py tools that , Marco> among other things, provides autocompletion , like bash: Thanks, yes, I use rlcompleter and readline. They helpful when you know the prefix of the thing you want, but less so when you don't, e.g.: >>> dirpat(gtk, "(?i)right") ['ARROW_RIGHT', 'CORNER_BOTTOM_RIGHT', 'CORNER_TOP_RIGHT', 'DIRECTION_RIGHT', 'DIR_RIGHT', 'JUSTIFY_RIGHT', 'LEFT_RIGHT', 'POS_RIGHT', 'PROGRESS_LEFT_TO_RIGHT', 'PROGRESS_RIGHT_TO_LEFT', 'SCROLL_PAGE_RIGHT', 'SCROLL_STEP_RIGHT', 'SIDE_RIGHT', 'STOCK_JUSTIFY_RIGHT', 'TEXT_WINDOW_RIGHT'] -- Skip Montanaro ([EMAIL PROTECTED] - http://www.mojam.com/) ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] Dialogs demo
Skip Montanaro ([EMAIL PROTECTED]) wrote: > There are so many symbols in the gtk and gtk.gdk modules (> 1100 all told), > that I added a modified dir() function and a dirpat() function to my > PYTHONSTARTUP file: [snip] > It produces what I find to be useful output: > > >>> dirpat(gtk, "(?i)dialog") > ['ColorSelectionDialog', 'DIALOG_DESTROY_WITH_PARENT', 'DIALOG_MODAL', Very interesting. You may also like the tools explained in this article: http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html It is about the LazyPython and pythonstartup.py tools that , among other things, provides autocompletion , like bash: >>> import gtk >>> gtk.DI gtk.DIALOG_DESTROY_WITH_PARENT gtk.DIR_LEFT gtk.DIALOG_MODALgtk.DIR_RIGHT gtk.DIALOG_NO_SEPARATOR gtk.DIR_TAB_BACKWARD gtk.DIR_DOWNgtk.DIR_TAB_FORWARD gtk.DIRECTION_LEFT gtk.DIR_UP gtk.DIRECTION_RIGHT The tools are available at: http://www.idyll.org/~n8gray/code/index.html Very useful for interactive sessions. Hope it helps. -- Buy a copy of a baby naming book and you'll never be at a loss for variable names. - How To Write Unmaintainable Code ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] Dialogs demo
>> Where are GtkDialogFlags defined? I can find them in gtk-types.defs, >> but I don't know how to access them. Matt> They are: Matt> gtk.DIALOG_MODAL, gtk.DIALOG_DESTROY_WITH_PARENT, etc. There are so many symbols in the gtk and gtk.gdk modules (> 1100 all told), that I added a modified dir() function and a dirpat() function to my PYTHONSTARTUP file: from __builtin__ import dir as _dir def dir(o=globals,showall=0): if not showall and hasattr(o, "__all__"): x = list(o.__all__) x.sort() return x return _dir(o) import re def dirpat(o, pat): """like dir, but only return strings matching re pat""" names = dir(o, showall=1) return [x for x in names if re.search(pat, x) is not None] It produces what I find to be useful output: >>> dirpat(gtk, "(?i)dialog") ['ColorSelectionDialog', 'DIALOG_DESTROY_WITH_PARENT', 'DIALOG_MODAL', 'DIALOG_NO_SEPARATOR', 'Dialog', 'FontSelectionDialog', 'ICON_SIZE_DIALOG', 'InputDialog', 'MessageDialog', 'STOCK_DIALOG_ERROR', 'STOCK_DIALOG_INFO', 'STOCK_DIALOG_QUESTION', 'STOCK_DIALOG_WARNING'] >>> dirpat(gtk, "DIALOG") ['DIALOG_DESTROY_WITH_PARENT', 'DIALOG_MODAL', 'DIALOG_NO_SEPARATOR', 'ICON_SIZE_DIALOG', 'STOCK_DIALOG_ERROR', 'STOCK_DIALOG_INFO', 'STOCK_DIALOG_QUESTION', 'STOCK_DIALOG_WARNING'] >>> dirpat(gtk, "Dialog") ['ColorSelectionDialog', 'Dialog', 'FontSelectionDialog', 'InputDialog', 'MessageDialog'] YMMV... -- Skip Montanaro ([EMAIL PROTECTED] - http://www.mojam.com/) ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] Dialogs demo
Michele Campeotto wrote: > And as you can imagine, I have two problems with this, too... > > How do I do gtk_label_new_with_mnemonics()? > > Where are GtkDialogFlags defined? I can find them in gtk-types.defs, >but I don't know how to access them. > > > Am I annoying somebody? Can I keep posting these? > The following should give do the equivalent of new_with_mnemonic: label = gtk.Label('Sp_am') label.set_use_underline(gtk.TRUE) James. -- Email: [EMAIL PROTECTED] WWW: http://www.daa.com.au/~james/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] Dialogs demo
On Wed, Jan 16, 2002 at 07:07:52PM +0100, Michele Campeotto wrote: > > How do I do gtk_label_new_with_mnemonics()? label = gtk.Label('_Change the above color') label.set_property("use-underline", gtk.TRUE) > Where are GtkDialogFlags defined? I can find them in gtk-types.defs, > but I don't know how to access them. They are: gtk.DIALOG_MODAL, gtk.DIALOG_DESTROY_WITH_PARENT, etc. > Am I annoying somebody? Can I keep posting these? Keep it coming, it's a good learning exercise. And I've had to fix several bugs when porting other demos myself... Matt ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] Dialogs demo
And as you can imagine, I have two problems with this, too... How do I do gtk_label_new_with_mnemonics()? Where are GtkDialogFlags defined? I can find them in gtk-types.defs, but I don't know how to access them. Am I annoying somebody? Can I keep posting these? -- -- Michele - www.moleskine.f2s.com An NT server can be run by an idiot, and usually is. -- Tom Holub in alt.humor.best-of-internet #!/usr/bin/env python """Dialog and Message Boxes Dialog widgets are used to pop up a transient window for user feedback.""" description = "Dialog and Message Boxes" import gtk window = None entry1 = None entry2 = None counter = 1 def message_dialog_clicked(w): global window, counter dialog = gtk.MessageDialog(window, 0, # FIXME: Where are these defined? #gtk.DIALOG_MODAL + #gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, "This message box has been popped up %d time%s." % (counter, counter > 1 and 's' or '')) dialog.run() dialog.destroy() counter += 1 def interactive_dialog_clicked(w): global window, entry1, entry2 dialog = gtk.Dialog("Interactive Dialog", window, 0, (gtk.STOCK_OK, gtk.RESPONSE_OK, "_Non-stock button", gtk.RESPONSE_CANCEL)) hbox = gtk.HBox(gtk.FALSE, 8) hbox.set_border_width(8) dialog.vbox.pack_start(hbox, gtk.FALSE, gtk.FALSE, 0) stock = gtk.image_new_from_stock( gtk.STOCK_DIALOG_QUESTION, gtk.ICON_SIZE_DIALOG) hbox.pack_start(stock, gtk.FALSE, gtk.FALSE, 0) table = gtk.Table(2, 2) table.set_row_spacings(4) table.set_col_spacings(4) hbox.pack_start(table, gtk.TRUE, gtk.TRUE, 0) label = gtk.Label("Entry _1") table.attach_defaults(label, 0, 1, 0, 1) local_entry1 = gtk.Entry() local_entry1.set_text(entry1.get_text()) table.attach_defaults(local_entry1, 1, 2, 0, 1) label.set_mnemonic_widget(local_entry1) label = gtk.Label("Entry _2") table.attach_defaults(label, 0, 1, 1, 2) local_entry2 = gtk.Entry() local_entry2.set_text(entry2.get_text()) table.attach_defaults(local_entry2, 1, 2, 1, 2) label.set_mnemonic_widget(local_entry2) dialog.show_all() response = dialog.run() if response == gtk.RESPONSE_OK: entry1.set_text(local_entry1.get_text()) entry2.set_text(local_entry2.get_text()) dialog.destroy() def main(): global window, entry1, entry2 window = gtk.Window() window.set_title("Dialogs") window.set_border_width(8) if __name__ == '__main__': window.connect('destroy', lambda win: gtk.main_quit()) frame = gtk.Frame("Dialogs") window.add(frame) vbox = gtk.VBox(gtk.FALSE, 8) vbox.set_border_width(8) frame.add(vbox) # Standard message dialog hbox = gtk.HBox(gtk.FALSE, 8) vbox.pack_start(hbox) button = gtk.Button("_Message Dialog") button.connect('clicked', message_dialog_clicked) hbox.pack_start(button, gtk.FALSE, gtk.FALSE, 0) vbox.pack_start(gtk.HSeparator(), gtk.FALSE, gtk.FALSE, 0) # Interactive dialog hbox = gtk.HBox(gtk.FALSE, 8) vbox.pack_start(hbox, gtk.FALSE, gtk.FALSE, 0) vbox2 = gtk.VBox() button = gtk.Button("_Interactive Dialog") button.connect('clicked', interactive_dialog_clicked) hbox.pack_start(vbox2, gtk.FALSE, gtk.FALSE, 0) vbox2.pack_start(button, gtk.FALSE, gtk.FALSE, 0) table = gtk.Table(2, 2) table.set_row_spacings(4) table.set_col_spacings(4) hbox.pack_start(table, gtk.FALSE, gtk.FALSE, 0) # FIXME: How do I make a GtkLabel with mnemonics? label = gtk.Label("Entry _1") table.attach_defaults(label, 0, 1, 0, 1) entry1 = gtk.Entry() table.attach_defaults(entry1, 1, 2, 0, 1) label.set_mnemonic_widget(entry1) label = gtk.Label("Entry _2") table.attach_defaults(label, 0, 1, 1, 2) entry2 = gtk.Entry() table.attach_defaults(entry2, 1, 2, 1, 2) label.set_mnemonic_widget(entry2) window.show_all() if __name__ == '__main__': gtk.main() if __name__ == '__main__': main()