SHOW:
|
|
- or go back to the newest paste.
| 1 | #!/usr/bin/env python | |
| 2 | ||
| 3 | import gtk | |
| 4 | import time | |
| 5 | ||
| 6 | ###GUI### | |
| 7 | def responseToDialog(entry, dialog, response): | |
| 8 | dialog.response(response) | |
| 9 | print "Enter" | |
| 10 | ||
| 11 | def gtk_getpass(message): | |
| 12 | dialog = gtk.MessageDialog(type=gtk.MESSAGE_QUESTION, | |
| 13 | buttons=gtk.BUTTONS_OK) | |
| 14 | entry = gtk.Entry() | |
| 15 | entry.set_visibility(False) | |
| 16 | dialog.set_markup(message) | |
| 17 | - | entry.connect("activate", responseToDialog, dialog, gtk.RESPONSE_OK)
|
| 17 | + | #entry.connect("activate", responseToDialog, dialog, gtk.RESPONSE_OK)
|
| 18 | dialog.set_default_response(gtk.RESPONSE_OK) # Use this to set a dialog default response | |
| 19 | entry.set_activates_default(True) # Use this to make an entry activate the default widget on enter | |
| 20 | hbox = gtk.HBox() | |
| 21 | hbox.pack_start(gtk.Label("Password:"), False, 5, 5)
| |
| 22 | hbox.pack_end(entry) | |
| 23 | dialog.vbox.pack_end(hbox, True, True, 0) | |
| 24 | dialog.show_all() | |
| 25 | dialog.run() | |
| 26 | text = entry.get_text() | |
| 27 | - | print(gtk_getpass("CAKE")) |
| 27 | + | dialog.destroy() # this seems to work |
| 28 | return text | |
| 29 | ||
| 30 | print(gtk_getpass("CAKE"))
| |
| 31 | raw_input() # wait for console input.... |