【发布时间】:2022-10-13 04:09:19
【问题描述】:
这是我的代码
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
class Window(Gtk.Window):
def __init__(self):
super().__init__(title="GUi")
self.ui()
def ui(self):
self.connect("destroy", Gtk.main_quit)
button1 = Gtk.Button(label="Button 1")
button2 = Gtk.Button(label="Button 2")
grid = Gtk.Grid()
self.add(grid)
grid.attach(button1, 0, 0, 1, 1)
grid.attach(button2, 0, 3, 2, 2)
self.show_all()
window = Window()
Gtk.main()
this 是我的输出,但我已经提到按钮 2 出现在第 3 列,并将其行和列跨度设为 2,但是这两个都没有按预期工作我做错了什么?
【问题讨论】:
-
这回答了你的问题了吗? Insert empty row in GtkGrid c
-
另外,请注意,当调用它时:
grid.attach(button2, 0, 3, 2, 2),第一个整数参数是列。这意味着button2不在第三列,而是在第一列(从 0 开始)。见the reference。
标签: python user-interface grid gtk positioning