更多 wxPython 挫败感 - 工具栏
我正在尝试向可以容纳 128 像素 png 的窗口添加一个工具栏(代码如下)。我可以显示所有内容,但我似乎无法更改图标的大小。我遇到过类似的帖子,并尝试了它建议的方法来解决这个问题,但没有成功。
有趣的是删除最后的行:
self.SetToolBar(工具栏)
确实增加了图标的大小,但随后我失去了通过 SetToolbar() 调用获得的更好的格式。如果有什么不同,我正在运行 mac OS-X Snow Leopard/python2.7
import wx
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title=title,size=(400, 350))
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
self.panel = wx.Panel(self)
toolbar = wx.ToolBar(self, size=(-1, 128))
toolbar.SetToolBitmapSize((128,128))
bmp2 = wx.ArtProvider.GetBitmap(wx.ART_ADD_BOOKMARK, wx.ART_OTHER, (128,128))
toolbar.AddLabelTool(-1, label="Add", bitmap=bmp2,
shortHelp="Add", kind=wx.ITEM_NORMAL)
toolbar.Realize()
self.SetToolBar(toolbar)
if __name__ == '__main__':
app = wx.App()
Example(None, title='')
app.MainLoop()
I'm trying to add a toolbar to a window that can hold 128-pix png's (code below). I can get everything showing, but I just don't seem to be able to change the size of the icons. I've come across a similar post and tried the approach it suggests to overcome the problem but to no avail.
Interestingly deleting the line at the end:
self.SetToolBar(toolbar)
does increase the size of the icon, but I then lose the nicer formatting gained via the SetToolbar() call. In case it makes a difference, I'm running mac OS-X snow Leopard/python2.7
import wx
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title=title,size=(400, 350))
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
self.panel = wx.Panel(self)
toolbar = wx.ToolBar(self, size=(-1, 128))
toolbar.SetToolBitmapSize((128,128))
bmp2 = wx.ArtProvider.GetBitmap(wx.ART_ADD_BOOKMARK, wx.ART_OTHER, (128,128))
toolbar.AddLabelTool(-1, label="Add", bitmap=bmp2,
shortHelp="Add", kind=wx.ITEM_NORMAL)
toolbar.Realize()
self.SetToolBar(toolbar)
if __name__ == '__main__':
app = wx.App()
Example(None, title='')
app.MainLoop()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果它是 Mac 的问题,您也许可以通过使用面板、大小调整器和一组位图按钮创建自己的工具栏来解决它。我认为这对你有用。
If it is a Mac thing, you might be able to work around it by creating your own toolbar using a panel, a sizer and a set of BitmapButtons. I would think that that would work for you.