我正在尝试将许多GtkButton与交叉点对齐,但结果不是我想要的帮助,请
我的代码:它是Gtk3.0(3.6)的python代码我在ubuntu 13.04上
import gi.repository
from gi.repository import Gtk
def dest(widget):
widget.destroy()
Gtk.main_quit()
win = Gtk.Window(Gtk.WindowType.TOPLEVEL)
hbox = Gtk.Box()
bt0 = Gtk.Button.new_with_label("Zero")
bt1 = Gtk.Button.new_with_label("One")
bt2 = Gtk.Button.new_with_label("Two")
bt0.get_style_context().set_junction_sides(Gtk.JunctionSides.RIGHT)
bt1.get_style_context().set_junction_sides(Gtk.JunctionSides.LEFT|Gtk.JunctionSides.RIGHT)
bt2.get_style_context().set_junction_sides(Gtk.JunctionSides.LEFT)
win.connect("destroy", dest)
hbox.pack_start(bt0, False, False, 0)
hbox.pack_start(bt1, False, False, 0)
hbox.pack_start(bt2, False, False, 0)
win.add(hbox)
win.show_all()
Gtk.main()
感谢
答案 0 :(得分:1)
只需将链接样式类添加到父容器:
import gi.repository
from gi.repository import Gtk
def dest(widget):
widget.destroy()
Gtk.main_quit()
win = Gtk.Window(Gtk.WindowType.TOPLEVEL)
hbox = Gtk.Box()
hbox.get_style_context().add_class(Gtk.STYLE_CLASS_LINKED)
bt0 = Gtk.Button.new_with_label("Zero")
bt1 = Gtk.Button.new_with_label("One")
bt2 = Gtk.Button.new_with_label("Two")
win.connect("destroy", dest)
hbox.pack_start(bt0, False, False, 0)
hbox.pack_start(bt1, False, False, 0)
hbox.pack_start(bt2, False, False, 0)
win.add(hbox)
win.show_all()
Gtk.main()