A friend of mine asked me today to help him with a little bit of code. Basically, he needed to get a number for a user from a Python script. While he is a good coder, he doesn't know PyGtk all that well.
So here's the code that I wrote for him, it grabs a string as a tag from the user:
dialog = gtk.Dialog("Bug Tag",None,gtk.DIALOG_MODAL,(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
content_area = dialog.get_content_area()
hbox = gtk.HBox(2, 5)
label = gtk.Label("Tag:")
entry = gtk.Entry()
hbox.pack_start(label,False, False)
hbox.pack_end(entry, False, True)
content_area.pack_start(hbox)
hbox.show()
label.show()
entry.show()
result = dialog.run()
dialog.destroy()
if result == gtk.RESPONSE_ACCEPT:
tag = entry.get_text()
else:
return
What? I have to refer to six separate objects just to show a simple dialog? The code should be more like:
result, input = whatever_I_name_this_function("Title")
dialog.destroy()
if result == gtk.RESPONSE_ACCEPT:
tag = input
else:
return
I don't think this will take me all that long to right, though making the dialog return a tuple may be a tad harder than I expect, I'll see what I can do. Maybe I'll make a simple object to create instead of a single function call ...
Don't forget:
ReplyDeletedialog.set_has_separator(False)
content_area.set_border_width(5)
the defaults really should be changed...
I'm using a subclass of gtk.MessageDialog for simple text input in one of my projects which looks like: http://paste.ubuntu.com/341767
ReplyDeleteCanned dialogs were probably of those things that, sadly, in Gtk were thought to be a part of GNOME.
ReplyDelete
ReplyDeletethis is Brother Printer Drivers Support and brother printer drivers download , update brother printer driver and brother drivers printer
----------------------------
this is Brother Printer Support Assistant and brother printer software
ReplyDeletethis is Brother Printer Troubleshooting Guide and brother printer troubleshooting
-----------------------------
this is Brother Printer Wireless Setup as well as brother printer wireless setup wizard
ReplyDeletethis is Brother Printer Offline Fix and brother printer offline fix windows 10
---------------------------------------
this is Brother Airprint Printer Not Found as well as brother printer airprint not working