/
touchIF.py
executable file
·105 lines (79 loc) · 3.34 KB
/
touchIF.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/python
import time, Tkinter, os, sys
from imageshow import ShowImageApp
from mpdshow import MpdControl, MpdStatus
from pprint import pformat, pprint
import Logging
import configobj
#from optparse import OptionParser
CFG = 'touchIF.conf'
NAME = 'TouchIF'
VERSION = '1.0.0'
SIZE = 800,600
PICTURE_WAIT = 1000*60*15
PICTURE_DIRS = ["/home/sven/python/Thailand2010",
"/home/sven/python/DD_grillabend",
"/home/sven/python/Gozo07",
]
PICTURE_WAIT = 1000*1
PICTURE_DIRS = ['./pics']
class MainApp(Tkinter.Frame):
def __init__(self, master=None, config=None, logger = None):
Tkinter.Frame.__init__(self, master)
self.pack()
self.root = master
self._config = config or {}
self.log = logger or Logging.getLogger(self.__class__.__name__)
if self.log.isEnabledFor('debug'):
self.log.logBlock('debug', pformat(self._config))
self.showImage()
#self.showMpd()
def showImage(self):
self.log.debug('---> showImage called')
self.mpdStatus = MpdStatus(self._config, logger = self.log)
self.imageFrame = ShowImageApp(self, config = self._config, onQuit = self.quitImage, statusFunc = self.mpdStatus.printStatus)
#self.root.protocol("WM_DELETE_WINDOW", self.quitImage)
def quitImage(self, event = None):
self.log.debug('---> quitImage called')
self.imageFrame.destroy()
self.mpdStatus.destroy()
self.imageFrame = None
self.mpdStatus = None
self.showMpd()
def showMpd(self):
self.log.debug('---> showMpd called')
self.mpdFrame = MpdControl (self, config = self._config, onQuit = self.quitMpd)
#self.mpdFrame.protocol("WM_DELETE_WINDOW", self.quitMpd)
def quitMpd(self, event = None):
self.log.debug('---> quitMpd called')
self.mpdFrame.destroy()
self.mpdFrame = None
self.showImage()
#self.after(1000, )
if __name__ == "__main__":
# usage = "usage %prog [options]"
# parser = OptionParser(usage=usage, version='%prog ' + VERSION)
# parser.add_option("-c", "--config", dest='configfile', default=CFG, help="configuration file", metavar="CONFIG")
# parser.add_option("-d", "--debug", dest='debug', default=False, help="enables stdout")
# (options, args) = parser.parse_args()
#config = configobj.ConfigObj(ioptions.configfile)
config = configobj.ConfigObj(CFG)
if not config:
print "could not find CFG %s" % CFG
sys.exit()
L = Logging.startLoggingTo('TouchIF', config['main'].get('logfile', 'stdio'),
config['main'].get('loglevel', 'info'))
L.info('starting %s (ver %s)' % (NAME, VERSION))
if config['image'].get('path'):
config['image']['dirs'] = [path for path, dirs, files in os.walk(config['image']['path'])
if '/.' not in path]
root = Tkinter.Tk()
root.overrideredirect(True)
root.config(bg="grey")
#root.bind("<Button>", button_click_exit_mainloop)
config['main']['sizepos'] = tuple([int(i) for i in config['main'].get('size', SIZE) + config['main'].get('pos', (0,0))])
print pformat(config)
root.geometry('%dx%d+%d+%d' % config['main']['sizepos'])
app = MainApp(master=root, config = config, logger = L)
app.mainloop()
root.destroy()