# -*- coding: utf-8 -*- # h-client, a python library to manage the database of an h-source node # Copyright (C) 2011 Antonio Gallo # # # h-client is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # h-client is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with h-client. If not, see . 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()