Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
UCC
virtualsnack
Commits
8ee0e8f3
Commit
8ee0e8f3
authored
Oct 17, 2014
by
Mark Tearle
Browse files
Connect up Door widget callback
parent
9e9d7af9
Changes
2
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
8ee0e8f3
...
@@ -2,3 +2,6 @@ virtualsnack
...
@@ -2,3 +2,6 @@ virtualsnack
============
============
Curses based emulator of the UCC Snack Machine ROM
Curses based emulator of the UCC Snack Machine ROM
Requirements:
npyscreen 4.6.1 or later
virtualsnack.py
View file @
8ee0e8f3
...
@@ -36,7 +36,6 @@ class VirtualSnack(npyscreen.Form):
...
@@ -36,7 +36,6 @@ class VirtualSnack(npyscreen.Form):
self
.
textdisplay
.
value
=
self
.
parentApp
.
textdisplay
self
.
textdisplay
.
value
=
self
.
parentApp
.
textdisplay
self
.
display
()
self
.
display
()
def
create
(
self
,
*
args
,
**
keywords
):
def
create
(
self
,
*
args
,
**
keywords
):
super
(
VirtualSnack
,
self
).
create
(
*
args
,
**
keywords
)
super
(
VirtualSnack
,
self
).
create
(
*
args
,
**
keywords
)
...
@@ -53,7 +52,7 @@ class VirtualSnack(npyscreen.Form):
...
@@ -53,7 +52,7 @@ class VirtualSnack(npyscreen.Form):
self
.
reset
=
self
.
add
(
npyscreen
.
MiniButton
,
name
=
"RESET"
,
relx
=
kpx
+
7
,
rely
=
kpy
)
self
.
reset
=
self
.
add
(
npyscreen
.
MiniButton
,
name
=
"RESET"
,
relx
=
kpx
+
7
,
rely
=
kpy
)
self
.
dip
=
self
.
add
(
npyscreen
.
MultiSelect
,
name
=
"Door"
,
max_width
=
15
,
relx
=
4
,
rely
=
10
,
max_height
=
4
,
value
=
[],
values
=
[
"DOOR"
],
scroll_exit
=
True
)
self
.
dip
=
self
.
add
(
npyscreen
.
MultiSelect
,
name
=
"Door"
,
max_width
=
15
,
relx
=
4
,
rely
=
10
,
max_height
=
4
,
value
=
[],
values
=
[
"DOOR"
],
scroll_exit
=
True
,
value_changed_callback
=
self
.
parentApp
.
when_door_toggled
)
self
.
dip
=
self
.
add
(
npyscreen
.
MultiSelect
,
name
=
"DIP Switch"
,
max_width
=
45
,
rely
=
3
,
relx
=
30
,
max_height
=
10
,
value
=
[],
values
=
[
"DIP1"
,
"DIP2"
,
"DIP3"
,
"DIP4"
,
"DIP5"
,
"DIP6"
,
"DIP7"
,
"DIP8"
],
scroll_exit
=
True
)
self
.
dip
=
self
.
add
(
npyscreen
.
MultiSelect
,
name
=
"DIP Switch"
,
max_width
=
45
,
rely
=
3
,
relx
=
30
,
max_height
=
10
,
value
=
[],
values
=
[
"DIP1"
,
"DIP2"
,
"DIP3"
,
"DIP4"
,
"DIP5"
,
"DIP6"
,
"DIP7"
,
"DIP8"
],
scroll_exit
=
True
)
...
@@ -165,6 +164,18 @@ class VirtualSnackApp(npyscreen.NPSAppManaged):
...
@@ -165,6 +164,18 @@ class VirtualSnackApp(npyscreen.NPSAppManaged):
self
.
sent
=
data
self
.
sent
=
data
# Callbacks
def
when_door_toggled
(
self
,
*
args
,
**
keywords
):
# See
# https://code.google.com/p/npyscreen/source/detail?r=9768a97fd80ed1e7b3e670f312564c19b1adfef8#
# for callback info
if
keywords
[
'widget'
].
get_selected_objects
():
self
.
do_send
(
'401 door closed
\n
'
)
else
:
self
.
do_send
(
'400 door open
\n
'
)
# Snack Emulator code below
# Snack Emulator code below
def
do_prompt
(
self
):
def
do_prompt
(
self
):
...
@@ -358,14 +369,6 @@ if __name__ == "__main__":
...
@@ -358,14 +369,6 @@ if __name__ == "__main__":
# key = '0'+key
# key = '0'+key
# self.do_send('2'+key+' keypress\n')
# self.do_send('2'+key+' keypress\n')
# FIXME
# def door_changed(self, widget):
# self.switches.set_door_open(not widget.get_active())
# if widget.get_active():
# self.do_send('401 door closed\n')
# else:
# self.do_send('400 door open\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
...
...
Write
Preview
Markdown
is supported
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