小编shu*_*hug的帖子

带有图像和标签的Python GTK3按钮

我正试图获得带有图像和标签的按钮,并没有成功.我可以使用标签或图像的按钮,但不能同时使用.这是我的代码部分:

try:
    pb = Pixbuf.new_from_file_at_size('myimg.jpg', 100, 100)
except:
    pb = None
img = Gtk.Image()
img.set_from_pixbuf(pb)
button1 = Gtk.Button(xalign=0.5, yalign=1)
#button1.set_label(lbl)
button1.set_image(img)
button1.set_image_position(Gtk.PositionType.TOP)
button1.get_style_context().add_class("btn_article")
Run Code Online (Sandbox Code Playgroud)

任何的想法 ?谢谢

python label image button gtk3

2
推荐指数
1
解决办法
2461
查看次数

标签 统计

button ×1

gtk3 ×1

image ×1

label ×1

python ×1