python - wxPython toolbar issue -
i have problem code:
import wx class example(wx.frame): def __init__(self, *args, **kwargs): super(example, self).__init__(*args, **kwargs) self.initui() def initui(self): toolbar = self.createtoolbar() qtool = toolbar.addlabeltool(wx.id_any, 'quit', wx.bitmap('texit.png')) toolbar.realize() self.bind(wx.evt_tool, self.onquit, qtool) self.setsize((250, 200)) self.settitle('simple toolbar') self.centre() self.show(true) def onquit(self, e): self.close() def main(): ex = wx.app() example(none) ex.mainloop() if __name__ == '__main__': main()
when run it, get:
traceback (most recent call last): file "...\maintest.py", line 34, in <module> main() file "...\painter3d\maintest.py", line 29, in main example(none) file "...\maintest.py", line 8, in __init__ self.initui() file "...\maintest.py", line 14, in initui toolbar.realize() file "c:\python27\lib\site-packages\wx-2.9.4-msw\wx\_controls.py", line 3797, in realize return _controls_.toolbarbase_realize(*args, **kwargs) wx._core.pyassertionerror: c++ assertion "assert failure" failed @ ..\..\src\msw\toolbar.cpp(796) in wxtoolbar::realize(): invalid tool button bitmap
i use:
win7 python2.7 wxpython2.8 unicode
i'll grateful answer.
your script can't find image called texit.png
.
first, find image in wxpython library installation directory. hint: try finding file called quit.png
in c:\python27\lib\site-packages\wx-3.0-msw\wx\tools\editra\pixmaps\theme\tango\menu
.
then, either copy image same location script, or add python code script specify path location of image.
i'm on windows 7 using python 2.7 64-bit , wxpython 3.0. followed solution on code , worked fine me.
Comments
Post a Comment