# -*- coding: utf-8 -*- import pygtk pygtk.require('2.0') import gtk from hlibrary import * class hclient: #the device that has to be displaced in the right window currentDevice = '' #set the device that has to be displaced in the right window def setCurrentDevice(self, widget, data): self.currentDevice = data print self.currentDevice # another callback def delete_event(self, widget, event, data=None): gtk.main_quit() return False def __init__(self): #start the client object self.client = Client('h-source') self.client.createDevices() # Create a new window self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) # This is a new call, which just sets the title of our # new window to "Hello Buttons!" self.window.set_title("h-client") #self.window.set_size_request(200, 100) # Here we just set a handler for delete_event that immediately # exits GTK. self.window.connect("delete_event", self.delete_event) # Sets the border width of the window. self.window.set_border_width(10) self.bottomWindow = gtk.HBox(False, 0) #add the bottom box self.window.add(self.bottomWindow) ## build the left window ## #start the left vertical box self.leftWindow = gtk.VBox(False, 0) #start the right vertical box self.rightWindow = gtk.VBox(False, 0) self.frame = gtk.Frame("Your devices") self.bottomWindow.pack_start(self.frame, True, True, 0) self.bottomWindow.pack_start(self.rightWindow, True, True, 0) for key,dev in self.client.devices.iteritems(): self.button = gtk.Button(dev[0].getType()) self.button.connect("clicked", self.setCurrentDevice, key) self.leftWindow.pack_start(self.button, False, True, 0) self.button.show() self.frame.add(self.leftWindow) self.bottomWindow.show() self.frame.show() self.leftWindow.show() self.rightWindow.show() self.window.show() def main(): gtk.main() if __name__ == "__main__": Client = hclient() main()