slotUI/SlotUi.py

Sun, 02 Dec 2012 18:03:06 +0100

author
Malte Bayer <mbayer@neo-soft.org>
date
Sun, 02 Dec 2012 18:03:06 +0100
changeset 114
313aad7435a8
parent 24
84f6f0592555
permissions
-rwxr-xr-x

fix #688

23
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
1 #!/usr/bin/env python
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
2
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
3 import pygtk
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
4 pygtk.require('2.0')
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
5 import gtk
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
6
24
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
7 class Window:
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
8 """
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
9 Base Window Class
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
10 """
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
11 def delete_event(self, widget, event, data=None):
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
12 return False
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
13
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
14 def __init__(self, title="unnamed window"):
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
15 self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
16 self.window.connect("delete_event", self.delete_event)
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
17 self.window.set_title(title)
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
18
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
19 class SlotCars(Window):
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
20 """
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
21 Car configuration window
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
22 """
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
23 def __init__(self):
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
24 Window.__init__(self, "Car configuration")
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
25 #self.slot = gtk.ComboBox("Select car")
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
26 #self.slot.show()
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
27 #window.add(self.slot)
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
28
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
29 class SlotUi(Window):
23
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
30 """
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
31 Graphical User Interface
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
32 using GTK
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
33 """
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
34 def delete_event(self, widget, event, data=None):
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
35 if widget == self.window:
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
36 self.destroy(widget, data)
24
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
37 Window.delete_event(self, widget, event, data)
23
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
38 return False
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
39
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
40 def destroy(self, widget, data=None):
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
41 gtk.main_quit()
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
42
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
43 def __init__(self):
24
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
44 Window.__init__(self, "FreeSlot UI")
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
45
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
46 # define toolbar buttons
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
47 self.buttons = {
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
48 "config": gtk.Button("Settings"),
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
49 "cars": gtk.Button("Car Config"),
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
50 }
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
51 self.buttons["config"].connect("clicked", self.openwindow, "config")
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
52 self.buttons["cars"].connect("clicked", self.openwindow, "cars")
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
53 #setup the toolbar box
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
54 self.toolbar = gtk.HBox(False, 0)
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
55 self.toolbar.show()
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
56 for btn in self.buttons:
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
57 self.toolbar.add(self.buttons[btn])
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
58 self.buttons[btn].show()
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
59
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
60 # create subwindow objects
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
61 self.cars = SlotCars()
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
62 self.windows = {
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
63 "config": None,
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
64 "cars": self.cars.window,
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
65 }
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
66
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
67 self.window.add(self.toolbar)
23
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
68 self.window.show()
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
69
24
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
70 def openwindow(self, widget, name):
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
71 self.windows[name].show()
23
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
72
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
73 def main(self):
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
74 gtk.main()
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
75
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
76 if __name__ == "__main__":
24
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
77 print "FreeSlot UI starting..."
84f6f0592555 basic example gtk ui to be coded later
Malte Bayer <mbayer@neo-soft.org>
parents: 23
diff changeset
78 print "Note: this will be part of paepke development, no function at the moment :)"
23
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
79 app = SlotUi()
6edcf4666e3b added slotUI path
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
80 app.main()

mercurial