wx.ToolBar 中奇怪的 wx.CheckBox 绘图
这是我的工具栏的代码:
JS_TOOLBAR_BUTTON = 0
JS_TOOLBAR_SEPARATOR = 1
JS_TOOLBAR_MONTHCONTROL = 2
JS_TOOLBAR_CHECKBOX = 3
def createToolbar(self):
self.tb = wx.ToolBar(self, style=wx.TB_HORIZONTAL|wx.NO_BORDER|wx.TB_FLAT)
self.tb.SetToolBitmapSize((16,16))
id=0
for toolType,hint,pic,proc in self.toolbarData():
if toolType==JS_TOOLBAR_BUTTON:
id += 10
self.tb.AddLabelTool(id, hint, pic.GetBitmap(), shortHelp=hint)
self.Bind(wx.EVT_TOOL, proc, id=id)
self.Bind(wx.EVT_TOOL_RCLICKED, proc, id=id)
elif toolType==JS_TOOLBAR_SEPARATOR:
self.tb.AddSeparator()
elif toolType==JS_TOOLBAR_CHECKBOX:
self.tb.AddControl(wx.CheckBox(self.tb, label=hint))
self.tb.Realize()
def toolbarData(self):
return((JS_TOOLBAR_BUTTON, u"Добавить работника", pictures.add_staff, self.grid.on_insert),
(JS_TOOLBAR_BUTTON, u"Удалить работника", pictures.del_staff, self.grid.on_delete),
(JS_TOOLBAR_SEPARATOR, None, None, None),
(JS_TOOLBAR_CHECKBOX, u"Показывать только работающих", None, self.grid.on_delete))
结果我在复选框之外有奇怪的角:
Python 2.7, wx-2.9 .2、Win7x64下
Here is a code of my toolbar:
JS_TOOLBAR_BUTTON = 0
JS_TOOLBAR_SEPARATOR = 1
JS_TOOLBAR_MONTHCONTROL = 2
JS_TOOLBAR_CHECKBOX = 3
def createToolbar(self):
self.tb = wx.ToolBar(self, style=wx.TB_HORIZONTAL|wx.NO_BORDER|wx.TB_FLAT)
self.tb.SetToolBitmapSize((16,16))
id=0
for toolType,hint,pic,proc in self.toolbarData():
if toolType==JS_TOOLBAR_BUTTON:
id += 10
self.tb.AddLabelTool(id, hint, pic.GetBitmap(), shortHelp=hint)
self.Bind(wx.EVT_TOOL, proc, id=id)
self.Bind(wx.EVT_TOOL_RCLICKED, proc, id=id)
elif toolType==JS_TOOLBAR_SEPARATOR:
self.tb.AddSeparator()
elif toolType==JS_TOOLBAR_CHECKBOX:
self.tb.AddControl(wx.CheckBox(self.tb, label=hint))
self.tb.Realize()
def toolbarData(self):
return((JS_TOOLBAR_BUTTON, u"Добавить работника", pictures.add_staff, self.grid.on_insert),
(JS_TOOLBAR_BUTTON, u"Удалить работника", pictures.del_staff, self.grid.on_delete),
(JS_TOOLBAR_SEPARATOR, None, None, None),
(JS_TOOLBAR_CHECKBOX, u"Показывать только работающих", None, self.grid.on_delete))
As a result I have strange horns outside the checkbox:
Python 2.7, wx-2.9.2, under Win7x64
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的解决方案是使用 CheckLabelTool 而不是 CheckBox:
The solution for me is to use CheckLabelTool instead of CheckBox: