1
2
3 """
4 IceTray connections frame for GtkIcetraConfig application
5
6 copyright (c) 2005 the icecube collaboration
7
8 @version: $Revision: $
9 @date: $Date: $
10 @author: Juan Carlos Diaz Velez <juancarlos@icecube.wisc.edu>
11 """
12
13 import pygtk
14 pygtk.require("2.0")
15 import gtk, gobject
16 from iceprod.core.dataclasses import Parameter
17 import logging
18
19 logger = logging.getLogger('GtkParameterList')
20
22 """ The GUI class is the controller for our application """
23 - def __init__(self,parent,iconfig,connection):
24
25
26 self.parent = parent
27 self.iconfig = iconfig
28 self.root = gtk.Window(type=gtk.WINDOW_TOPLEVEL)
29 self.root.set_title("Connection")
30 self.root.set_size_request(310, 180)
31 self.table = gtk.Table(2, 4)
32
33 self.vbox = gtk.VBox()
34 self.vbox.pack_start(self.table)
35
36
37 self.b = gtk.Button(stock=gtk.STOCK_APPLY)
38 self.b.connect('clicked', self.commit)
39 self.hbok = gtk.HButtonBox()
40 self.hbok.pack_start(self.b)
41 self.vbox.pack_end(self.hbok)
42
43 separator = gtk.HSeparator()
44 self.vbox.pack_end(separator)
45
46
47 inbox = connection.GetInbox()
48 self.inbox = inbox
49 outbox = connection.GetOutbox()
50 self.outbox = outbox
51
52 modulemenu1 = gtk.Menu()
53 outmodule = outbox.GetModule()
54 item1 = self.make_menu_item (outmodule,self.edit_connection,outmodule,outbox)
55 modulemenu1.append(item1)
56
57 modulemenu2 = gtk.Menu()
58 inmodule = inbox.GetModule()
59 item2 = self.make_menu_item (inmodule,self.edit_connection,inmodule,inbox)
60 modulemenu2.append(item2)
61
62 for module in self.iconfig.GetModules():
63
64 if module.GetName() != outmodule:
65 item1 = self.make_menu_item (module.GetName(),
66 self.edit_connection,module.GetName(),outbox)
67 modulemenu1.append(item1)
68
69 if module.GetName() != inmodule:
70 item2 = self.make_menu_item (module.GetName(),
71 self.edit_connection, module.GetName(),inbox)
72 modulemenu2.append(item2)
73
74 modopt1 = gtk.OptionMenu()
75 modopt1.set_menu(modulemenu1)
76 modopt2 = gtk.OptionMenu()
77 modopt2.set_menu(modulemenu2)
78
79 from_frame = gtk.Frame()
80 from_label = gtk.Label()
81 from_label.set_markup("<b>From</b>")
82 from_frame.add(from_label)
83 self.table.attach(from_frame,0,1,0,1,xpadding=1,ypadding=1)
84
85 outbox_frame = gtk.Frame()
86 outbox_label = gtk.Label()
87 outbox_label.set_markup("<b>Outbox</b>")
88 outbox_frame.add(outbox_label)
89 self.table.attach(outbox_frame,1,2,0,1,xpadding=1,ypadding=1)
90
91 self.table.attach(modopt1,0,1,1,2)
92 self.outbox_entry = gtk.Entry(10)
93 self.outbox_entry.connect("activate", self.commit)
94 self.outbox_entry.set_text(outbox.GetBoxName())
95 self.table.attach(self.outbox_entry,1,2,1,2)
96
97 to_frame = gtk.Frame()
98 to_label = gtk.Label()
99 to_label.set_markup("<b>To</b>")
100 to_frame.add(to_label)
101 self.table.attach(to_frame,0,1,2,3,xpadding=1,ypadding=1)
102
103 inbox_frame = gtk.Frame()
104 inbox_label = gtk.Label()
105 inbox_label.set_markup("<b>Inbox</b>")
106 inbox_frame.add(inbox_label)
107 self.table.attach(inbox_frame,1,2,2,3,xpadding=1,ypadding=1)
108
109 self.table.attach(modopt2,0,1,3,4)
110 self.inbox_entry = gtk.Entry(10)
111 self.inbox_entry.connect("activate", self.commit)
112 self.inbox_entry.set_text(inbox.GetBoxName())
113 self.table.attach(self.inbox_entry,1,2,3,4)
114
115
116 self.root.add(self.vbox)
117 self.root.show_all()
118 return
119
121 item = gtk.MenuItem(name)
122 item.connect("activate", callback, module,box)
123 item.show()
124 return item
125
127 """
128 Canges the value of the connection
129 """
130 logger.debug("Change '%s' to '%s'" % (box.GetBoxName(),module))
131 box.SetModule(module)
132
143