aboutsummaryrefslogtreecommitdiff
path: root/h-client/hclient.py
blob: 72611c54ed0e768918509508c8668e41a9d39af9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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()