Hi, I’m new to wxPython and am seeing a few weird things in my small sample program. I am trying to create a clickable label class. macOS Catalina and latest wxPython (python3.8).
- When I click to the left of the label (between the label and the window frame - cursor is double-headed arrow), it seems to be sending two click events (counter increases twice).
- When I double click in this same spot (when cursor shows the double-headed arrow cursor), the window expands in width (all the way to the left hand side of the screen. Is this expected/documented behaviour?
- If I resize the window and then click anywhere inside the frame it “counts” as a click on the label. This seems weird to me as I would expect only a direct click on the label would count as a label click event.
Thanks in advance.
import wx class ClickableLabel(wx.StaticText): def __init__(self, parent, **kwargs): super().__init__(parent, **kwargs) self.Bind(wx.EVT_LEFT_UP, self.clicked) self.click_cnt = 0 def clicked(self, event): self.click_cnt += 1 self.SetLabel(str(self.click_cnt)) class MyFrame(wx.Frame): def __init__(self): super().__init__(None, title='Test ClickLabel') label = ClickableLabel(self, label='Click Me') self.Show() if __name__ == '__main__': app = wx.App(redirect=False) frame = MyFrame() app.MainLoop()