【发布时间】:2016-11-27 15:57:43
【问题描述】:
我有一个带有一些标签/页面的Notebook 类(继承自wx.Panel)。
我目前在Notebook 类中检测到右键单击,一切正常。唯一的问题是,当我右键单击某个特定选项卡时,我想将其设置为焦点。
我该怎么做?我能够做到这一点的唯一方法是左键单击它。
TabContent 类:
class TabContent(wx.Panel) :
def __init__(self, parent, id) :
# Calls the constructor for wx.Panel
wx.Panel.__init__(self, parent = parent, id = id)
# Creates a vertical sizer
sizer = wx.BoxSizer(wx.VERTICAL)
# Creates an empty multi-line wx.TextCtrl
textArea = wx.TextCtrl(self, style = wx.TE_MULTILINE)
# Adds the text area to the sizer
sizer.Add(textArea, 1, wx.EXPAND | wx.ALL, 2)
# Sets the previously created sizer as this panel's sizer
self.SetSizer(sizer)
笔记本类:
class Notebook(wx.Notebook) :
def __init__(self, parent) :
wx.Notebook.__init__(self, parent, id = wx.ID_ANY, style = wx.BK_DEFAULT)
# Initialises tab number to 1
self.untitledCounter = 1
# Adds an empty tab
self.addTab()
# Sets up events
self.Bind(wx.EVT_RIGHT_DOWN, self.onMouseRightClicked)
def onMouseRightClicked(self, event) :
print("Left button was clicked on tab " + str(self.GetCurrentPage().GetId()))
【问题讨论】:
标签: python-3.x wxpython