virtualsnack.py 1.03 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
class VirtualSnack(npyscreen.Form):
6

Mark Tearle's avatar
Mark Tearle committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
    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"
23
24
25
26
27
28
	self.add_handlers({"^T": self.exit_application})


    def exit_application(self,name):
        self.parentApp.setNextForm(None)
        self.editing = False
Mark Tearle's avatar
Mark Tearle committed
29
30
31
32
33
34
35


class VirtualSnackApp(npyscreen.NPSAppManaged):
    keypress_timeout_default = 2

    def onStart(self):
	self.addForm("MAIN", VirtualSnack, name="Virtual Snack")
36
37
38
39
40


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