aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--h-client/hclient.py88
-rw-r--r--h-client/hlibrary.py8
2 files changed, 92 insertions, 4 deletions
diff --git a/h-client/hclient.py b/h-client/hclient.py
new file mode 100644
index 0000000..72611c5
--- /dev/null
+++ b/h-client/hclient.py
@@ -0,0 +1,88 @@
+# -*- 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()
diff --git a/h-client/hlibrary.py b/h-client/hlibrary.py
index c763a76..e45cfbd 100644
--- a/h-client/hlibrary.py
+++ b/h-client/hlibrary.py
@@ -356,16 +356,16 @@ class Client:
def getUserInfo(self):
self.request.perform('users/info/en')
xmldoc = minidom.parseString(self.request.contents)
- status = modelName = xmldoc.getElementsByTagName("status")[0].childNodes[0].data
+ status = xmldoc.getElementsByTagName("status")[0].childNodes[0].data
username = ''
token = ''
groups = ''
if status == 'logged':
- username = modelName = xmldoc.getElementsByTagName("username")[0].childNodes[0].data
- token = modelName = xmldoc.getElementsByTagName("token")[0].childNodes[0].data
- groups = modelName = xmldoc.getElementsByTagName("groups")[0].childNodes[0].data
+ username = xmldoc.getElementsByTagName("username")[0].childNodes[0].data
+ token = xmldoc.getElementsByTagName("token")[0].childNodes[0].data
+ groups = xmldoc.getElementsByTagName("groups")[0].childNodes[0].data
return {'status':status,'username':username,'token':token,'groups':groups}