Python 3.x 在gtk3 python3中创建vbox时出现属性错误
我在gtk3中有一个对话框,我正在尝试创建一个vbox和hbox,这两个对话框都会因为无法设置属性错误而失败。我已经看过文档,正在尝试spacing=x的变体,并直接调用新方法Python 3.x 在gtk3 python3中创建vbox时出现属性错误,python-3.x,attributes,gtk3,Python 3.x,Attributes,Gtk3,我在gtk3中有一个对话框,我正在尝试创建一个vbox和hbox,这两个对话框都会因为无法设置属性错误而失败。我已经看过文档,正在尝试spacing=x的变体,并直接调用新方法 class MacroDialog(Gtk.Dialog): def __init__(self, parent, id_): Gtk.Dialog.__init__(self, 'Record Macros', parent) self.set_default_size(150,
class MacroDialog(Gtk.Dialog):
def __init__(self, parent, id_):
Gtk.Dialog.__init__(self, 'Record Macros', parent)
self.set_default_size(150, 100)
self.set_has_resize_grip(False)
#create widgets, layout
self.box = self.get_content_area()
self.vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 10)
self.hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 6)
我无法理解为什么会发生此属性错误,是否有人能提供一些见解最终通过重命名self.vbox、self.hbox=>self.v_盒和self.h_盒来解决此问题 通过设置方向,还将框self.get_content_区域重新用作我的v_框,如下所示:
class MacroDialog(Gtk.Dialog):
def __init__(self, parent, id_):
Gtk.Dialog.__init__(self, 'Record Macros', parent)
self.set_default_size(150, 100)
self.set_has_resize_grip(False)
#create widgets, layout
self.v_box = self.get_content_area()
self.v_box.set_orientation(Gtk.Orientation.VERTICAL)
#self.v_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
self.h_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
self.scrollWindow = Gtk.ScrolledWindow()
self.scrollWindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self.macroEdit = Gtk.TextView()
self.macroEdit.set_editable(False)
self.scrollWindow.add(self.macroEdit)
self.clearBtn = Gtk.Button('Clear')
self.saveBtn = Gtk.Button('Save')
#add widgets
self.v_box.pack_start(self.scrollWindow, True, True, 0)
self.h_box.pack_start(self.clearBtn, True, True, 0)
self.h_box.pack_start(self.saveBtn, True, True, 0)
self.v_box.pack_start(self.h_box, True, True, 0)
self.v_box.add(self.h_box)