I'd like to get the current background color of my textview to change it and restore it later.
here what I tried:
context = textview.get_style_context()
state = Gtk.StateFlags.NORMAL
color = context.get_background_color(state)
I tried all possible states, but none returns the correct background color (white in my case)
Any idea how to get it?
I'm not exactly sure what you specific problem is without seeing more code, but here is a quick example that overrides the background and then restores it on a button click:
from gi.repository import Gtk, Gdk
import sys
class MyWindow(Gtk.ApplicationWindow):
def __init__(self, app):
Gtk.Window.__init__(self, title="Textview example", application=app)
self.set_default_size(250, 100)
self.set_border_width(10)
self.view = Gtk.TextView()
self.style_context = self.view.get_style_context()
self.default_bg_color = self.style_context.get_background_color(Gtk.StateFlags.NORMAL)
self.view.override_background_color(Gtk.StateFlags.NORMAL,
Gdk.RGBA(0, 0, 0, 1))
self.btn = Gtk.Button(label="Click Here")
self.btn.connect("clicked", self.on_btn_clicked)
box = Gtk.VBox()
box.pack_start(self.view, True, True, 0)
box.pack_start(self.btn, False, False, 0)
self.add(box)
def on_btn_clicked(self, widget):
current_bg = self.style_context.get_background_color(Gtk.StateFlags.NORMAL)
if current_bg == self.default_bg_color:
self.view.override_background_color(Gtk.StateFlags.NORMAL,
Gdk.RGBA(0, 0, 0, 1))
else:
self.view.override_background_color(Gtk.StateFlags.NORMAL,
self.default_bg_color)
class MyApplication(Gtk.Application):
def __init__(self):
Gtk.Application.__init__(self)
def do_activate(self):
win = MyWindow(self)
win.show_all()
def do_startup(self):
Gtk.Application.do_startup(self)
app = MyApplication()
exit_status = app.run(sys.argv)
sys.exit(exit_status)
Related
I'm working on a GTK+ frontend for libvlc in python using python-vlc. So far I followed this guide, which is working fine, except that when I resize the window, the DrawingArea gets messed up as you can see in the picture (there's probably a word for that phenomenon I don't know).
I'm getting these warnings in the console, but am not sure if this is related:
[00007fce1c014eb0] main filter error: Failed to create video converter
[00007fce2807ff70] vdpau_avcodec generic error: Xlib is required for VDPAU
I already tried setting the background color of the window using the css styling for GTK+ but it had no effect.
I think this should not happen, am I missing something? I'm on wayland by the way.
Using Google and checking different examples I created code which fills background in DrawingArea with black color.
Assign drawing function to DrawingArea
self.draw_area = Gtk.DrawingArea()
self.draw_area.connect("draw", self.da_draw_event)
Function which fills area
def da_draw_event(self, widget, cairo_ctx):
cairo_ctx.set_source_rgb(0, 0, 0)
cairo_ctx.paint()
Full code
import sys
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
gi.require_version('GdkX11', '3.0')
from gi.repository import GdkX11
import vlc
MRL = ""
class ApplicationWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="Python-Vlc Media Player")
self.player_paused=False
self.is_player_active = False
self.connect("destroy", Gtk.main_quit)
def show(self):
self.show_all()
def setup_objects_and_events(self):
self.playback_button = Gtk.Button()
self.stop_button = Gtk.Button()
self.play_image = Gtk.Image.new_from_icon_name(
"gtk-media-play",
Gtk.IconSize.MENU
)
self.pause_image = Gtk.Image.new_from_icon_name(
"gtk-media-pause",
Gtk.IconSize.MENU
)
self.stop_image = Gtk.Image.new_from_icon_name(
"gtk-media-stop",
Gtk.IconSize.MENU
)
self.playback_button.set_image(self.play_image)
self.stop_button.set_image(self.stop_image)
self.playback_button.connect("clicked", self.toggle_player_playback)
self.stop_button.connect("clicked", self.stop_player)
self.draw_area = Gtk.DrawingArea()
self.draw_area.set_size_request(300, 300)
self.draw_area.connect("realize",self._realized)
self.draw_area.connect("draw", self.da_draw_event)
self.hbox = Gtk.Box(spacing=6)
self.hbox.pack_start(self.playback_button, True, True, 0)
self.hbox.pack_start(self.stop_button, True, True, 0)
self.vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.add(self.vbox)
self.vbox.pack_start(self.draw_area, True, True, 0)
self.vbox.pack_start(self.hbox, False, False, 0)
def da_draw_event(self, widget, cairo_ctx):
#print('da_draw_event')
#print('widget:', widget)
#print('cairo_ctx:', cairo_ctx)
cairo_ctx.set_source_rgb(0, 0, 0)
cairo_ctx.paint()
def stop_player(self, widget, data=None):
self.player.stop()
self.is_player_active = False
self.playback_button.set_image(self.play_image)
def toggle_player_playback(self, widget, data=None):
"""
Handler for Player's Playback Button (Play/Pause).
"""
if self.is_player_active == False and self.player_paused == False:
self.player.play()
self.playback_button.set_image(self.pause_image)
self.is_player_active = True
elif self.is_player_active == True and self.player_paused == True:
self.player.play()
self.playback_button.set_image(self.pause_image)
self.player_paused = False
elif self.is_player_active == True and self.player_paused == False:
self.player.pause()
self.playback_button.set_image(self.play_image)
self.player_paused = True
else:
pass
def _realized(self, widget, data=None):
self.vlcInstance = vlc.Instance("--no-xlib")
self.player = self.vlcInstance.media_player_new()
win_id = widget.get_window().get_xid()
self.player.set_xwindow(win_id)
self.player.set_mrl(MRL)
self.player.play()
self.playback_button.set_image(self.pause_image)
self.is_player_active = True
if __name__ == '__main__':
if not sys.argv[1:]:
print("Exiting \nMust provide the MRL.")
sys.exit(1)
if len(sys.argv[1:]) == 1:
MRL = sys.argv[1]
window = ApplicationWindow()
window.setup_objects_and_events()
window.show()
Gtk.main()
window.player.stop()
window.vlcInstance.release()
As #furas pointed out in the comments, constantly drawing a black rectangle on the DrawingArea works very well. I use the following code inside a widget that derives from Gtk.DrawingArea:
def draw(self, c, *args):
rect = self.get_allocation()
win = self.get_window().get_position()
c.set_source_rgb(0, 0, 0)
c.rectangle(rect.x - win.x, rect.y - win.y, rect.width, rect.height)
c.fill()
self.connect("draw", draw)
Edit: See #furas answer for an even simpler approach.
I am a beginner when it gomes to GUI programming with Python so I am guessing my problem has a simple solution even if I have not found a solution searching with google, wikis, documentation, examples ...
What I am trying to achive is that a value in an entry widget should constantly increase up to a max value as long as a button is pressed.
I have tried using callback for the event "button-press-event" but get the same response as with callback for the signal "clicked".
When connecting to "clicked" the application works as expected, e.g. the value is incremented each click but when I use a connection to the event "button-press-event" I still only get increment for each click (press and release)
I am using this with Python3.2 (on a Raspberry Pi 2)
Below is the working code that acts on each click:
#!/usr/bin/python
from gi.repository import Gtk, Gdk
from time import sleep
class MyWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="ST")
MAX_SPD = 3000
self.set_default_size(100,100)
self.set_size_request(100,100)
self.set_resizable(False)
spdEntry = Gtk.Entry()
spdEntry.set_has_frame(True)
spdEntry.set_text("0")
spdEntry.connect("activate", self.inputSpd, MAX_SPD)
start = Gtk.Button("Start")
start.connect("clicked", self.clicked_start)
stop = Gtk.Button("Stop")
stop.connect("clicked", self.clicked_stop)
inc = Gtk.Button("inc")
inc.connect("clicked", self.pressed_inc, spdEntry, MAX_SPD)
fixed = Gtk.Fixed()
fixed.put(start, 0, 0)
fixed.put(spdEntry, 0, 40)
fixed.put(stop, 0, 70)
fixed.put(inc, 120, 0)
self.add(fixed)
def clicked_start(self, widget):
self.set_title("GO")
def clicked_stop(self, widget):
self.set_title("ST")
def pressed_inc(self, widget, entry, maxSpd):
speed = int(entry.get_text())
speed = speed+1
if speed > maxSpd:
speed = maxSpd
entry.set_text(str(speed))
def inputSpd(self, entry, maxSpd):
speed = int(entry.get_text())
if speed > maxSpd:
speed = maxSpd
entry.set_text(str(speed))
win = MyWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
This is the non working code that should increment as long button is pressed:
#!/usr/bin/python
from gi.repository import Gtk, Gdk
from time import sleep
class MyWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="ST")
MAX_SPD = 3000
self.set_default_size(100,100)
self.set_size_request(100,100)
self.set_resizable(False)
spdEntry = Gtk.Entry()
spdEntry.set_has_frame(True)
spdEntry.set_text("0")
spdEntry.connect("activate", self.inputSpd, MAX_SPD)
start = Gtk.Button("Start")
start.connect("clicked", self.clicked_start)
stop = Gtk.Button("Stop")
stop.connect("clicked", self.clicked_stop)
inc = Gtk.Button("inc")
inc.connect("button-press-event", self.pressed_inc, spdEntry, MAX_SPD)
inc.connect("button-release-event", self.left_inc)
fixed = Gtk.Fixed()
fixed.put(start, 0, 0)
fixed.put(spdEntry, 0, 40)
fixed.put(stop, 0, 70)
fixed.put(inc, 120, 0)
self.add(fixed)
def clicked_start(self, widget):
self.set_title("GO")
def clicked_stop(self, widget):
self.set_title("ST")
def pressed_inc(self, widget, event, entry, maxSpd):
if event.type == Gdk.EventType.BUTTON_PRESS:
speed = int(entry.get_text())
speed = speed+1
if speed > maxSpd:
speed = maxSpd
entry.set_text(str(speed))
return True
def left_inc(self, widget, event):
if event.type == Gdk.EventType.BUTTON_RELEASE:
return True
def inputSpd(self, entry, maxSpd):
speed = int(entry.get_text())
if speed > maxSpd:
speed = maxSpd
entry.set_text(str(speed))
win = MyWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
You can do this by using GLib.timeout_add(). However, I agree to gianmt that it is better to just use a Gtk.SpinButton
#!/usr/bin/python
from gi.repository import Gtk, Gdk, GLib
class MyWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="ST")
self.MAXSPEED = 3000
self.set_default_size(100,100)
self.set_resizable(False)
self.entry = Gtk.Entry()
self.entry.set_text("0")
start = Gtk.Button(label="Start")
start.connect("clicked", self.clicked_start)
stop = Gtk.Button(label="Stop")
stop.connect("clicked", self.clicked_stop)
inc = Gtk.Button(label="inc")
inc.connect("button-press-event", self.pressed_inc)
inc.connect("button-release-event", self.left_inc)
fixed = Gtk.Fixed()
fixed.put(start, 0, 0)
fixed.put(self.entry, 0, 40)
fixed.put(stop, 0, 70)
fixed.put(inc, 120, 0)
self.add(fixed)
def clicked_start(self, widget):
self.set_title("GO")
def clicked_stop(self, widget):
self.set_title("ST")
def pressed_inc(self, widget, event):
self.inc_id = GLib.timeout_add(100, self.increase)
def left_inc(self, widget, event,):
GLib.source_remove(self.inc_id)
def increase(self):
speed = int(self.entry.get_text()) + 1
if speed > self.MAXSPEED:
self.entry.set_text(str(self.MAXSPEED))
else:
self.entry.set_text(str(speed))
return True
win = MyWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
There was also a from time import sleep as an import on top of your code. It was not used and I do not know about the rest of your application but using time.sleep(), while you are not in a thread, will block the Gtk.main() loop and make your application unresponsive.
I'm writing an app using Gtk3 and Python. I have a revealer as a sidebar to select the content and a webkit webview to display the main content. When the revealer is hidden the webview doesn't fill the entire window space and I don't know why. Any help would be appreciated.
from gi.repository import Gtk, Gio
from gi.repository import WebKit
HEIGHT = 500
WIDTH = 800
class MainWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="Resolution")
self.set_border_width(0)
self.set_default_size(WIDTH, HEIGHT)
hb = Gtk.HeaderBar()
hb.props.show_close_button = True
hb.props.title = "Resolution"
self.set_titlebar(hb)
button = Gtk.Button()
icon = Gio.ThemedIcon(name="emblem-system-symbolic")
image = Gtk.Image.new_from_gicon(icon, 1)
button.add(image)
button.connect("clicked", self.sidebarShowHide)
button.set_focus_on_click(False)
hb.pack_start(button)
sidebarbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
toplevelbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
self.add(toplevelbox)
self.sidebar = Gtk.Revealer()
self.sidebar.set_transition_duration(0)
self.sidebar.set_reveal_child(False)
toplevelbox.pack_start(self.sidebar, False, False, 0)
self.sidebar.add(sidebarbox)
self.searchentry = Gtk.SearchEntry()
self.searchentry.connect("search-changed", self.search_changed)
sidebarbox.pack_start(self.searchentry, False, False, 0)
label = Gtk.Label("Contents Selector")
sidebarbox.pack_start(label, True, True, 0)
scroller = Gtk.ScrolledWindow()
content = WebKit.WebView()
scroller.add(content)
toplevelbox.pack_start(scroller, True, True, 0)
content.open("/home/oliver/resolution/placeholder.html")
def sidebarShowHide(self, button):
if self.sidebar.get_reveal_child():
self.sidebar.set_reveal_child(False)
else:
self.sidebar.set_reveal_child(True)
def search_changed(self, searchentry):
pass
win = MainWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
Well, i have done some GtkRevealer few months ago and it works. It drive me nuts to see this piece of code was not.
I opened my project again and look inside where that part is, and it turn out the toplevel container where the Gtk.Revealer resides, has to has Gtk.Orientation.VERTICAL.. if you change your "toplevelbox" orientation to that, it will work, but it wont be sidebar. It will coming from top or bottom. It goes the same if you change GtkBox with GtkGrid. If I were to guess it depends on the children default orientation.
Workaround on that, is to use widget hide/show mechanism (believe me, i ransack your code and it works).
from gi.repository import Gtk, Gio
from gi.repository import WebKit
HEIGHT = 500
WIDTH = 800
class MainWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="Resolution")
self.set_border_width(0)
self.set_default_size(WIDTH, HEIGHT)
hb = Gtk.HeaderBar()
hb.props.show_close_button = True
hb.props.title = "Resolution"
self.set_titlebar(hb)
button = Gtk.Button()
icon = Gio.ThemedIcon(name="emblem-system-symbolic")
image = Gtk.Image.new_from_gicon(icon, 1)
button.add(image)
button.connect("clicked", self.sidebarShowHide)
button.set_focus_on_click(False)
hb.pack_start(button)
sidebarbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
toplevelbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
self.add(toplevelbox)
self.sidebar = Gtk.Box()
toplevelbox.pack_start(self.sidebar, False, False, 0)
self.sidebar.add(sidebarbox)
self.searchentry = Gtk.SearchEntry()
self.searchentry.connect("search-changed", self.search_changed)
sidebarbox.pack_start(self.searchentry, False, False, 0)
label = Gtk.Label("Contents Selector")
sidebarbox.pack_start(label, True, True, 0)
scroller = Gtk.ScrolledWindow()
content = WebKit.WebView()
scroller.add(content)
toplevelbox.pack_start(scroller, True, True, 0)
content.open("/home/oliver/resolution/placeholder.html")
def sidebarShowHide(self, button):
if self.sidebar.get_visible():
self.sidebar.hide ()
else:
self.sidebar.show ()
def search_changed(self, searchentry):
pass
win = MainWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
This smells like a bug.
As a workaround, you could use
def sidebarShowHide(self, button):
self.sidebarbox.set_visible(not self.sidebarbox.get_visible())
but this does not yield any transition animation, but does remove its allocated space for the time being invisible.
Actually the C demo provided within the git repo resizes as expected, so this might in fact have to do something with the child widgets prefered orientation.
i am very new to python. I want to open a Python GTK Window which should display a moving text just like a marquee in HTML. Kindly anyone suggest a solution
i am using this piece of code:
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
class MyProgram:
def __init__(self):
# create a new window
app_window = gtk.Window(gtk.WINDOW_TOPLEVEL)
app_window.set_size_request(800, 350)
app_window.set_border_width(15)
app_window.set_title("Volks Electronics")
app_window.connect("delete_event", lambda w,e: gtk.main_quit())
vbox_app = gtk.VBox(False, 0)
app_window.add(vbox_app)
vbox_app.show()
label_app = gtk.Label("Sample Page ")
label_app.show()
vbox_app.pack_start(label_app, False, False, 1)
# Draw Table() to layout text:
table_layout = gtk.Table(rows=5, columns=5, homogeneous=True)
label_a = gtk.Label("Train Name:")
label_a.show()
table_layout.attach(label_a, 0, 1, 0, 1, 0,0,0,0)
label_c = gtk.Label("Train No:")
label_c.show()
table_layout.attach(label_c, 0, 1, 2, 3, 0,0,0,0)
label_d = gtk.Label("Departed From:")
label_d.show()
table_layout.attach(label_d, 0, 1, 3, 4, 0,0,0,0)
label_b = gtk.Label("Next Station:")
label_b.show()
table_layout.attach(label_b, 0, 1, 1, 2, 0,0,0,0)
table_layout.show()
vbox_app.add(table_layout)
# Use HBox() to layout text and button next to each other:
hbox_close = gtk.HBox(False, 0)
label_close = gtk.Label("Close aplication: ")
hbox_close.pack_start(label_close, True, True, 0)
label_close.show()
button_close = gtk.Button(stock=gtk.STOCK_CLOSE)
button_close.connect("clicked", lambda w: gtk.main_quit())
button_close.set_flags(gtk.CAN_DEFAULT)
hbox_close.pack_start(button_close, True, True, 0)
button_close.show()
hbox_close.show()
vbox_app.add(hbox_close)
# Place after association to hbox/vbox to avoid the following error:
# GtkWarning: gtkwidget.c:5460: widget not within a GtkWindow
button_close.grab_default()
app_window.show()
return
def main():
gtk.main()
return 0
if __name__ == "__main__":
MyProgram()
main()
I want to put some text after that close button which should work like a moving banner(marquee in HTML). I couldn't find any code which works like a marquee in a GTK window. Please suggest any way to do this
I like this.
#!/usr/bin/python
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GObject
class MyWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="Hello World")
self.box = Gtk.Box(spacing=6)
self.add(self.box)
self.label = Gtk.Label()
self.box.pack_start(self.label, True, True, 0)
self.gibberish = "Spam and eggs, spam and eggs, spam and eggs!"
self.a = 0
self.z = 40
def marquee(self, text):
if self.a < len(text):
self.a = self.a + 1
self.z = self.z + 1
if self.a >= len(text):
self.a = 0
self.z = 40
return str(text[self.a:self.z])
# Displays Marquee
def displayMarquee(self):
# putting our text into our function and setting our label to the result.
# we need to return "True" to ensure the timer continues to run, otherwise it will only run once.
self.label.set_label(self.marquee(self.gibberish))
return True
# Initialize Marquee
def startMarquee(self):
# this takes 2 args: (how often to update in millisec, the method to run)
GObject.timeout_add(500, self.displayMarquee)
win = MyWindow()
win.connect("destroy", Gtk.main_quit)
win.show_all()
win.startMarquee()
Gtk.main()
I've got a gtk.Expander object, containing in its label a gtk.HBox, which packed a gtk.Image and a gtk.Label.
I want to launch a Webbrowser when the HBox is right-clicked.
Here is my code:
def launchBrowser(widget, host, event):
print event
print host
if event.type == gtk.gdk.BUTTON_PRESS:
if event.button == 3:
webbrowser.open(host, 1)
print "right click"
def addServer(self, loginfo):
main_expand = gtk.Expander()
main_led = gtk.Image()
if int(loginfo["main"]) == 0:
main_led.set_from_stock(gtk.STOCK_STOP, gtk.ICON_SIZE_BUTTON)
else:
main_led.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_BUTTON)
main_srvname = gtk.Label(loginfo["srvname"])
expand_title = gtk.HBox(False, 2)
expand_title.pack_start(main_led, False, True, 0)
expand_title.pack_start(main_srvname, True, True, 0)
main_srvname.add_events(gtk.gdk.BUTTON_PRESS_MASK)
main_srvname.connect_object('event', self.launchBrowser, loginfo["host"])
main_srvname.emit('event', gtk.gdk.Event(gtk.gdk.BUTTON_PRESS_MASK))
main_expand.set_property("label-widget", expand_title)
Problem is that when I pass my cursor on this HBox, I correctly received the event. But when I clicked nothing happen. I think it's because the click event is intercept by the Expander.
Anyhelp is welcome =)
Thanks in advance!
EDIT:
I also tried that:
main_srvname = gtk.Label(loginfo["srvname"])
eventbox = gtk.EventBox()
eventbox.add(main_srvname)
eventbox.connect_object('button-press-event', self.launchBrowser, loginfo["host"])
# Titre de l'expand box
expand_title = gtk.HBox(False, 2)
expand_title.pack_start(main_led, False, True, 0)
expand_title.pack_start(eventbox, True, True, 0)
Not working either...
EDIT2:
As requested by Jeremy, here a self-contained code, just copy-paste it you lazyboy!
import pygtk
pygtk.require('2.0')
import gtk
class MainWindow(gtk.Window):
def __init__(self):
gtk.Window.__init__(self)
self.set_default_size(300, 300)
self.addServer()
def launchBrowser(widget, host, event):
print event
if event.type == gtk.gdk.BUTTON_PRESS:
if event.button == 3:
print "click"
def addServer(self):
main_expand = gtk.Expander()
main_led = gtk.Image()
main_led.set_from_stock(gtk.STOCK_STOP, gtk.ICON_SIZE_BUTTON)
main_srvname = gtk.Label("srvname")
main_srvname.add_events(gtk.gdk.BUTTON_PRESS_MASK)
main_srvname.connect_object('button-press-event', self.launchBrowser, "host")
expand_title = gtk.HBox(False, 2)
expand_title.pack_start(main_led, False, True, 0)
expand_title.pack_start(main_srvname, True, True, 0)
main_expand.set_property("label-widget", expand_title)
self.add(main_expand)
self.show_all()
def main():
MainWindow()
gtk.main()
if __name__ == '__main__':
main()
Small change in your code.
Add "button-press-event" on Expander widget instead of Label widget
import pygtk
pygtk.require('2.0')
import gtk
class MainWindow(gtk.Window):
def __init__(self):
gtk.Window.__init__(self)
self.set_default_size(300, 300)
self.addServer()
def launchBrowser(self, widget, event, host, *args):
if event.type == gtk.gdk.BUTTON_PRESS:
if event.button == 3:
print "click"
# Normal behaviour of Expander on single click
expand = widget.get_expanded()
if not expand: widget.set_expanded(True)
else: widget.set_expanded(False)
def addServer(self):
main_expand = gtk.Expander()
main_led = gtk.Image()
main_led.set_from_stock(gtk.STOCK_STOP, gtk.ICON_SIZE_BUTTON)
main_srvname = gtk.Label("srvname")
main_expand.add_events(gtk.gdk.BUTTON_PRESS_MASK)
main_expand.connect('button-press-event', self.launchBrowser, 'host')
expand_title = gtk.HBox(False, 2)
expand_title.pack_start(main_led, False, True, 0)
expand_title.pack_start(main_srvname, True, True, 0)
main_expand.set_property("label-widget", expand_title)
self.add(main_expand)
self.show_all()
def main():
MainWindow()
gtk.main()
if __name__ == '__main__':
main()