virtualsnack.py 1.92 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 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
    def while_waiting(self):
        self.date_widget.value = datetime.now()
        self.display()

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

        self.wStatus1 = self.add(npyscreen.FixedText, value="Last Command", editable=False)


        self.wStatus2 = self.add(npyscreen.FixedText, value="", editable=False)

        self.wStatus1.important = True
	
	self.date_widget = self.add(npyscreen.FixedText, value=datetime.now(), editable=False)
        self.date_widget.value = "Hello"
26 27
	self.add_handlers({"^T": self.exit_application})

Mark Tearle's avatar
Mark Tearle committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
	self.dip = self.add(npyscreen.MultiSelect, name = "DIP Switch", max_width = 45, relx = 2, max_height=10, value = [], values = ["DIP1", "DIP2", "DIP3","DIP4","DIP5","DIP6","DIP7","DIP8"], scroll_exit=True)
	self.dip = self.add(npyscreen.MultiSelect, name = "Door", max_width=15, relx = 2, max_height=4, value = [], values = ["DOOR"], scroll_exit=True)

	self.nickel= self.add(npyscreen.MiniButton,name="0.05")
	self.dime= self.add(npyscreen.MiniButton,name="0.10")
	self.quarter= self.add(npyscreen.MiniButton,name="0.25")
	self.dollar= self.add(npyscreen.MiniButton,name="1.00")

	self.mode= self.add(npyscreen.MiniButton,name="MODE")
	self.reset= self.add(npyscreen.MiniButton,name="RESET")

	self.kpbuttons = []
	for keypad in range(0,10):
		self.kpbuttons.append(self.add(npyscreen.MiniButton,name="%d"%keypad))
		
43 44 45 46

    def exit_application(self,name):
        self.parentApp.setNextForm(None)
        self.editing = False
Mark Tearle's avatar
Mark Tearle committed
47 48 49 50 51 52 53


class VirtualSnackApp(npyscreen.NPSAppManaged):
    keypress_timeout_default = 2

    def onStart(self):
	self.addForm("MAIN", VirtualSnack, name="Virtual Snack")
54 55 56 57 58


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