【发布时间】:2016-11-28 10:59:01
【问题描述】:
我正在尝试在 wx python 中制作工具栏。我可以在我的主文件中制作它,但我使用了许多 .py 文件来使编程更清晰。
在我的主文件中,我有以下代码:
from microanalysis_menubar_view import TBar as toolbar_view
class Main(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id)
self.panel = wx.Panel(self, wx.ID_ANY)
self.SetTitle('Microanalysis')
# add menubar
self.menubar = menubar_view()
self.SetMenuBar(self.menubar)
#add toolbar
self.toolbar = toolbar_view()
在我的其他文件 (microanalysis_menubar_view) 我有这个:
class TBar(wx.ToolBar):
def __init__(self):
wx.ToolBar.__init__(self)
toolbar = self.CreateToolBar()
qtool = toolbar.AddLabelTool(wx.ID_ANY, 'Quit', wx.Bitmap('exit.png'))
toolbar.Realize()
我得到这个错误:
TypeError:找不到所需的参数“父级”(位置 1)
我也遇到了以这种方式添加菜单栏的问题,但我解决了这个问题。这个比较难。
我尝试将 'toolbar.Realize() 切换到我的主文件:
self.toolbar.Realize(self.toolbar)
这也不起作用。 提前发送
【问题讨论】:
标签: python class wxpython toolbar