Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
UCC
virtualsnack
Commits
8f2cace3
Commit
8f2cace3
authored
Oct 17, 2014
by
Mark Tearle
Browse files
Connect up keypad
parent
7dc158ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
virtualsnack.py
View file @
8f2cace3
...
...
@@ -48,7 +48,7 @@ class VirtualSnack(npyscreen.Form):
for
keypad
in
range
(
0
,
10
):
kpx
=
((
keypad
%
4
)
*
6
)
+
3
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
)
...
...
@@ -91,7 +91,7 @@ class VirtualSnackApp(npyscreen.NPSAppManaged):
self
.
switches
=
Switches
()
self
.
textdisplay
=
"*5N4CK0RZ*"
self
.
addForm
(
"MAIN"
,
VirtualSnack
,
name
=
"Virtual Snack"
)
self
.
F
=
self
.
addForm
(
"MAIN"
,
VirtualSnack
,
name
=
"Virtual Snack"
)
# socket code
self
.
CONNECTION_LIST
=
[]
# list of socket clients
...
...
@@ -178,7 +178,13 @@ class VirtualSnackApp(npyscreen.NPSAppManaged):
def
when_reset_pressed
(
self
,
*
args
,
**
keywords
):
self
.
do_send
(
'211 keypress
\n
'
)
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
...
...
@@ -364,15 +370,6 @@ if __name__ == "__main__":
#
#####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
# def handleNewConnection(self,source,condition):
# #source is a socket in GTK v 1 and a fd in version 2
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment