Commit 8f2cace3 authored by Mark Tearle's avatar Mark Tearle

Connect up keypad

parent 7dc158ef
...@@ -48,7 +48,7 @@ class VirtualSnack(npyscreen.Form): ...@@ -48,7 +48,7 @@ class VirtualSnack(npyscreen.Form):
for keypad in range(0,10): for keypad in range(0,10):
kpx = ((keypad % 4) * 6 ) + 3 kpx = ((keypad % 4) * 6 ) + 3
kpy = int(keypad / 4) + 4 kpy = int(keypad / 4) + 4
self.kpbuttons.append(self.add(npyscreen.MiniButton,name="%d"%keypad, relx = kpx, rely = kpy)) self.kpbuttons.append(self.add(npyscreen.MiniButton,name="%d"%keypad, relx = kpx, rely = kpy, value_changed_callback=self.parentApp.when_keypad_pressed))
self.reset= self.add(npyscreen.MiniButton,name="RESET", relx = kpx + 7, rely = kpy, value_changed_callback=self.parentApp.when_reset_pressed) self.reset= self.add(npyscreen.MiniButton,name="RESET", relx = kpx + 7, rely = kpy, value_changed_callback=self.parentApp.when_reset_pressed)
...@@ -91,7 +91,7 @@ class VirtualSnackApp(npyscreen.NPSAppManaged): ...@@ -91,7 +91,7 @@ class VirtualSnackApp(npyscreen.NPSAppManaged):
self.switches = Switches() self.switches = Switches()
self.textdisplay = "*5N4CK0RZ*" self.textdisplay = "*5N4CK0RZ*"
self.addForm("MAIN", VirtualSnack, name="Virtual Snack") self.F = self.addForm("MAIN", VirtualSnack, name="Virtual Snack")
# socket code # socket code
self.CONNECTION_LIST = [] # list of socket clients self.CONNECTION_LIST = [] # list of socket clients
...@@ -178,7 +178,13 @@ class VirtualSnackApp(npyscreen.NPSAppManaged): ...@@ -178,7 +178,13 @@ class VirtualSnackApp(npyscreen.NPSAppManaged):
def when_reset_pressed(self, *args, **keywords): def when_reset_pressed(self, *args, **keywords):
self.do_send('211 keypress\n') self.do_send('211 keypress\n')
keywords['widget'].value = False keywords['widget'].value = False
keywords['widget'].display() self.F.display()
def when_keypad_pressed(self, *args, **keywords):
key = '0'+ keywords['widget'].name
self.do_send('2'+key+' keypress\n')
keywords['widget'].value = False
self.F.display()
# Snack Emulator code below # Snack Emulator code below
...@@ -364,15 +370,6 @@ if __name__ == "__main__": ...@@ -364,15 +370,6 @@ if __name__ == "__main__":
# #
#####CALLBACKS #####CALLBACKS
# FIXME
# def keypad_clicked(self,widget):
# key = widget.get_label()
# if key == 'RESET':
# key = '11'
# else:
# key = '0'+key
# self.do_send('2'+key+' keypress\n')
# FIXME # FIXME
# def handleNewConnection(self,source,condition): # def handleNewConnection(self,source,condition):
# #source is a socket in GTK v 1 and a fd in version 2 # #source is a socket in GTK v 1 and a fd in version 2
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment