virtualsnack.py 2.3 KB
Newer Older
1 2
#!/usr/bin/env python
import npyscreen
Mark Tearle's avatar
Mark Tearle committed
3
from datetime import datetime
4

Mark Tearle's avatar
Mark Tearle committed
5 6 7
class ContainedMultiSelect(npyscreen.BoxTitle):
    _contained_widget = npyscreen.TitleMultiSelect

Mark Tearle's avatar
Mark Tearle committed
8
class VirtualSnack(npyscreen.Form):
9

Mark Tearle's avatar
Mark Tearle committed
10
    def while_waiting(self):
Mark Tearle's avatar
Mark Tearle committed
11
        self.date_widget.value = datetime.now().ctime()
Mark Tearle's avatar
Mark Tearle committed
12 13 14 15 16 17
        self.display()

    def create(self, *args, **keywords):
        super(VirtualSnack, self).create(*args, **keywords)


Mark Tearle's avatar
Mark Tearle committed
18 19 20 21 22 23 24 25 26 27 28 29
        self.textdisplay = self.add(npyscreen.FixedText, value="*5N4CK0RZ*", editable=False, relx=9)
        self.textdisplay.important = True
	
	self.kpbuttons = []
	kpx = 1
	kpy = 1
	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.reset= self.add(npyscreen.MiniButton,name="RESET",  relx = kpx + 7, rely = kpy)
Mark Tearle's avatar
Mark Tearle committed
30

Mark Tearle's avatar
Mark Tearle committed
31
	self.dip = self.add(npyscreen.MultiSelect, name = "Door", max_width=15, relx = 4, rely = 10, max_height=4, value = [], values = ["DOOR"], scroll_exit=True)
Mark Tearle's avatar
Mark Tearle committed
32

Mark Tearle's avatar
Mark Tearle committed
33
	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)
34

Mark Tearle's avatar
Mark Tearle committed
35 36 37 38
	self.nickel= self.add(npyscreen.MiniButton,name="0.05", rely= 3, relx=50)
	self.dime= self.add(npyscreen.MiniButton,name="0.10", relx=50)
	self.quarter= self.add(npyscreen.MiniButton,name="0.25", relx=50)
	self.dollar= self.add(npyscreen.MiniButton,name="1.00", relx=50)
Mark Tearle's avatar
Mark Tearle committed
39

Mark Tearle's avatar
Mark Tearle committed
40
	self.mode= self.add(npyscreen.MiniButton,name="MODE", relx=50)
Mark Tearle's avatar
Mark Tearle committed
41

Mark Tearle's avatar
Mark Tearle committed
42 43
        self.wStatus1 = self.add(npyscreen.FixedText, value="Last Command", editable=False, relx=2, rely=12)
        self.wStatus1.important = True
Mark Tearle's avatar
Mark Tearle committed
44

Mark Tearle's avatar
Mark Tearle committed
45 46 47 48 49 50
        self.wStatus2 = self.add(npyscreen.FixedText, value="", editable=False)

	
	self.date_widget = self.add(npyscreen.FixedText, value=datetime.now().ctime(), editable=False)
        self.date_widget.value = "Hello"
	self.add_handlers({"^T": self.exit_application})
51 52 53 54

    def exit_application(self,name):
        self.parentApp.setNextForm(None)
        self.editing = False
Mark Tearle's avatar
Mark Tearle committed
55 56 57 58 59 60 61


class VirtualSnackApp(npyscreen.NPSAppManaged):
    keypress_timeout_default = 2

    def onStart(self):
	self.addForm("MAIN", VirtualSnack, name="Virtual Snack")
62 63 64 65 66


if __name__ == "__main__":
    App = VirtualSnackApp()
    App.run()