【发布时间】:2015-09-26 21:20:05
【问题描述】:
我正在尝试使用循环创建小部件。这是我尝试过的:
def set_runways(self, airfield):
i = 0
for rwy in airfield['Runways']:
frame = Gtk.Frame()
frame.set_label('-'.join([rwy['Runway_1'], rwy['Runway_2']]))
frame.set_shadow_type(1)
self.runways_layout.attach(frame, (i / 2), (i % 2), 1, 1)
rwy_layout = Gtk.Grid()
frame.add(rwy_layout)
# Just for testing :
label = Gtk.Label('Hello, World')
rwy_layout.attach(label, 0, 0, 1, 1)
我将我的runways_layout 导入我的__init__ 和self.runways_layout = builder.get_object('runwaysGrid'),这是一个Gtk.Grid,然后我用self.set_runways(airfield) 调用我的函数。但即使这样,我的窗口也没有显示Hello World,我有一个空白窗口......为什么?
我指定我的rwy 不为空。
感谢您的帮助。
编辑:
好的,我尝试了这个简单的事情:
self.runways_layout = builder.get_object('runwaysGrid')
label = Gtk.Label('Coucou')
self.runways_layout.attach(label, 0, 0, 1, 1)
而且它也不起作用...... O_o
【问题讨论】:
标签: python python-3.x pygobject