Add an OK button!
This commit is contained in:
parent
0def577866
commit
5792d1e6a5
1 changed files with 16 additions and 5 deletions
|
@ -15,19 +15,30 @@ class PromptWindow(Gtk.Window):
|
||||||
self.set_size_request(500, 100)
|
self.set_size_request(500, 100)
|
||||||
self.set_border_width(10)
|
self.set_border_width(10)
|
||||||
|
|
||||||
|
vbox = Gtk.Box(spacing=10)
|
||||||
|
self.add(vbox)
|
||||||
|
|
||||||
self.entry = Gtk.Entry()
|
self.entry = Gtk.Entry()
|
||||||
self.entry.set_text(task)
|
self.entry.set_text(task)
|
||||||
|
|
||||||
self.entry.connect("activate", self.save)
|
self.entry.connect("activate", self.save)
|
||||||
|
|
||||||
self.add(self.entry)
|
vbox.pack_start(self.entry, True, True, 0)
|
||||||
|
|
||||||
|
hbox = Gtk.Box(spacing=6)
|
||||||
|
|
||||||
|
self.button_ok = Gtk.Button.new_with_label("OK")
|
||||||
|
self.button_ok.connect("clicked", self.save)
|
||||||
|
hbox.pack_start(self.button_ok, True, True, 0)
|
||||||
|
|
||||||
|
vbox.pack_start(hbox, True, True, 0)
|
||||||
|
|
||||||
|
|
||||||
# self.set_title("Entry")
|
# self.set_title("Entry")
|
||||||
self.connect("destroy", Gtk.main_quit)
|
|
||||||
|
|
||||||
def save(self, entry):
|
def save(self, item):
|
||||||
task = entry.get_text()
|
# Note: item is the entry directly if enter is pressed, but the button
|
||||||
|
# (i guess) if the button is pressed, so we do not use it.
|
||||||
|
task = self.entry.get_text()
|
||||||
print(task)
|
print(task)
|
||||||
# A little concerned this might be sort of the nuclear option here.
|
# A little concerned this might be sort of the nuclear option here.
|
||||||
Gtk.main_quit()
|
Gtk.main_quit()
|
||||||
|
|
Loading…
Reference in a new issue