1 # (c) Yves Fischer yvesf - xapek org, 2007, License: GPL-2
6 from pgw
.Plugin
import SidebarPlugin
;
8 class ShowConfigPlugin(SidebarPlugin
):
10 def __init__(self
, ui
):
11 SidebarPlugin
.__init
__(self
, ui
)
13 self
.vbox
= gtk
.VBox()
14 self
.button
= gtk
.Button("Reload")
15 self
.button
.set_property("height-request", 30)
16 self
.vbox
.pack_start(self
.button
, expand
=False, fill
=True, padding
=0)
18 self
.scroll
= gtk
.ScrolledWindow()
20 self
.table
= gtk
.Table(rows
=1, columns
=2, homogeneous
=True)
22 self
.scroll
.add_with_viewport(self
.table
)
24 self
.vbox
.add(self
.scroll
)
28 self
.button
.connect("clicked", self
.button_pressed
)
33 def on_connection(self
):
34 self
.button_pressed(None)
36 def clear_table(self
, widget
, data
=None):
37 self
.table
.remove(widget
)
39 def button_pressed(self
, button
, Data
=None):
41 if self
.db
.is_connected():
43 cursor
= self
.db
.query("SHOW ALL")['cursor']
45 print "cursor == None"
47 ret
= cursor
.fetchall()
50 self
.table
.foreach(self
.clear_table
)
53 self
.table
.resize(rows
=len(ret
), columns
=2)
57 self
.table
.attach(self
.get_cell(line
[0]), \
58 left_attach
=0, right_attach
=1, \
59 top_attach
=n
, bottom_attach
=n
+1, \
60 ) #xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)
62 self
.table
.attach(self
.get_cell(line
[1]), \
63 left_attach
=1, right_attach
=2, \
64 top_attach
=n
, bottom_attach
=n
+1, \
65 ) #xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)
69 self
.table
.foreach(self
.clear_table
)
70 self
.table
.resize(1,2)
71 self
.table
.attach(self
.get_cell("Not Connected"), \
72 left_attach
=0, right_attach
=2, \
73 top_attach
=0, bottom_attach
=1,)
76 def get_cell(self
, caption
):
78 label
= gtk
.Label(caption
)
79 label
.set_property("justify", gtk
.JUSTIFY_LEFT
)
80 hbox
.pack_start(label
, expand
=False)
85 EXPORTS
=[ShowConfigPlugin
]