File: fan.py

package info (click to toggle)
mc-foo 0.0.13
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 268 kB
  • ctags: 532
  • sloc: python: 1,967; makefile: 6
file content (56 lines) | stat: -rw-r--r-- 1,636 bytes parent folder | download
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
"""an interface to dj"""

import McFoo.client
import sys, os.path
from twisted.python import usage
from Tkinter import *

class Options(usage.Options):
    synopsis = "Usage: %s [options] fan" % os.path.basename(sys.argv[0])

    def __init__(self):
        usage.Options.__init__(self)

    def postOptions(self):
        main()

class McFooClientFan(McFoo.client.McFooClientSimple):
    def __init__(self, TkRoot=None, user=None, password=None,
                 host=None, port=None):
        McFoo.client.McFooClientSimple.__init__(self,
                                                user, password,
                                                host, port)
        self.root=TkRoot

    def handle_login(self, perspective):
        McFoo.client.McFooClientSimple.handle_login(self, perspective)
        pq = McFoo.gui.playqueue.PlayQueue(self.root, self.remote)
        
        pq.history.listbox.config(selectmode=EXTENDED)
        pq.queue.listbox.config(selectmode=EXTENDED)
        self.root.deiconify()

    def handle_failure(self, message):
        McFoo.client.McFooClientSimple.handle_failure(self, message)
        self.root.quit()

    def handle_disconnect(self):
        McFoo.client.McFooClientSimple.handle_disconnect(self)
        print "Disconnected."
        self.root.quit()

def main():
    import McFoo.gui.playqueue
    import twisted.internet.tksupport
    from twisted.internet import reactor
    root = Tk()
    root.withdraw()
    twisted.internet.tksupport.install(root)
    McFooClientFan(TkRoot=root)

    try:
        root.mainloop()
    except KeyboardInterrupt:
        pass

    reactor.stop()