summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui.py29
1 files changed, 21 insertions, 8 deletions
diff --git a/gui.py b/gui.py
index 93a14c0..9fe06ab 100644
--- a/gui.py
+++ b/gui.py
@@ -1,11 +1,11 @@
import urwid.curses_display
import urwid
-import time
+import sys,time
class Conversation(object):
def __init__(self):
self.column1_edit = urwid.Edit(caption="Send: ")
- self.column1_check = urwid.CheckBox("Link to other",state=True)
+ self.column1_check = urwid.CheckBox("Link to other",state=True,on_state_change=self.on_link1_changed)
self.column1_disconnect = urwid.Button("Disconnect", lambda x:
self.add_message(time.strftime("%H:%M:%S: ") + "FOO")
)
@@ -15,7 +15,7 @@ class Conversation(object):
urwid.AttrWrap(self.column1_disconnect,'button')])
self.column2_edit = urwid.Edit(caption="Send: ")
- self.column2_check = urwid.CheckBox("Link to other",state=True)
+ self.column2_check = urwid.CheckBox("Link to other",state=True,on_state_change=self.on_link2_changed)
self.column2_disconnect = urwid.Button("Disconnect", lambda x:
self.add_message(time.strftime("%H:%M:%S: ") + "FOO")
)
@@ -30,7 +30,7 @@ class Conversation(object):
self.textbox = urwid.ListBox(self.messages)
self.body = urwid.Pile([self.columns,self.textbox])
- self.widget_header = urwid.Text("F1 ... | ... | F8 - EXIT")
+ self.widget_header = urwid.Text("F2 Toggle Link 1 | F3 Toggle Link 2 | | F10 - EXIT")
self.top = urwid.Frame(body=self.body, header=urwid.AttrWrap(self.widget_header,'header'))
@@ -53,7 +53,7 @@ class Conversation(object):
self.ui.register_palette([
('header', 'black', 'dark cyan', 'standout'),
('button', 'white', 'dark blue', 'standout'),
-# ('I say', 'default', 'default', 'bold'),
+ ('keylabel', 'white', 'dark cyan', 'standout'),
])
self.ui.run_wrapper( self.run )
@@ -61,9 +61,11 @@ class Conversation(object):
size = self.ui.get_cols_rows()
while True:
- keys = self.ui.get_input()
- if "f8" in keys:
- break
+ try:
+ keys = self.ui.get_input()
+ except KeyboardInterrupt:
+ sys.exit(0)
+
for k in keys:
if k == "window resize":
size = self.ui.get_cols_rows()
@@ -85,6 +87,12 @@ class Conversation(object):
pair[0].set_focus(pair[1])
self.focus_ring.insert(0,elem)
self.focus_ring.reverse()
+ elif k == "f2":
+ self.column1_check.toggle_state()
+ elif k == "f3":
+ self.column2_check.toggle_state()
+ elif k == "f10":
+ sys.exit(0)
else:
self.top.keypress( size, k )
@@ -94,4 +102,9 @@ class Conversation(object):
canvas = self.top.render( size, focus=True )
self.ui.draw_screen( size, canvas )
+ def on_link1_changed(self,a,b):
+ pass
+ def on_link2_changed(self,a,b):
+ pass
+
Conversation().main()