slotUI/SlotUi.py

Fri, 09 Dec 2011 22:02:34 +0100

author
Malte Bayer <mbayer@neo-soft.org>
date
Fri, 09 Dec 2011 22:02:34 +0100
changeset 65
8960bfa02f63
parent 24
84f6f0592555
permissions
-rwxr-xr-x

connected pitlane to main track (correct bit setting)

#!/usr/bin/env python

import pygtk
pygtk.require('2.0')
import gtk

class Window:
    """
    Base Window Class
    """
    def delete_event(self, widget, event, data=None):
        return False

    def __init__(self, title="unnamed window"):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect("delete_event", self.delete_event)
        self.window.set_title(title)

class SlotCars(Window):
    """
    Car configuration window
    """
    def __init__(self):
        Window.__init__(self, "Car configuration")
        #self.slot = gtk.ComboBox("Select car")
        #self.slot.show()
        #window.add(self.slot)

class SlotUi(Window):
    """
    Graphical User Interface
    using GTK
    """
    def delete_event(self, widget, event, data=None):
        if widget == self.window:
            self.destroy(widget, data)
        Window.delete_event(self, widget, event, data)
        return False

    def destroy(self, widget, data=None):
        gtk.main_quit()

    def __init__(self):
        Window.__init__(self, "FreeSlot UI")

        # define toolbar buttons
        self.buttons = {
                "config":       gtk.Button("Settings"),
                "cars":         gtk.Button("Car Config"),
            }
        self.buttons["config"].connect("clicked", self.openwindow, "config")
        self.buttons["cars"].connect("clicked", self.openwindow, "cars")
        #setup the toolbar box
        self.toolbar = gtk.HBox(False, 0)
        self.toolbar.show()
        for btn in self.buttons:
            self.toolbar.add(self.buttons[btn])
            self.buttons[btn].show()

        # create subwindow objects
        self.cars = SlotCars()
        self.windows = {
            "config": None,
            "cars": self.cars.window,
            }

        self.window.add(self.toolbar)
        self.window.show()

    def openwindow(self, widget, name):
        self.windows[name].show()

    def main(self):
        gtk.main()

if __name__ == "__main__":
    print "FreeSlot UI starting..."
    print "Note: this will be part of paepke development, no function at the moment :)"
    app = SlotUi()
    app.main()

mercurial