1

In my application I want to create buttons, minus the whole button part. Like clicking a URL, I guess, with some basic functionality like a subtle change in color or style upon hover/click.

I've accomplished this so far with wx.StaticText, but my problem is in getting a left click event to be recognized. Here's the relevant code:

self.text = wx.StaticText(self.background, -1, 'Text test')
self.text.Bind(wx.EVT_COMMAND_LEFT_CLICK, self.DoSomething)

It just doesn't have any effect at all. Any ideas or alternatives?

edit: Got it. Should have called wx.EVT_LEFT_UP.

1 Answer 1

1

PlateButtons (wx.lib.platebtn) will give you a lot of control over the buttons, including a "flat" button (with no border), and mouse over color changes, etc. (There is also style=wx.NO_BORDER for a regular button, but this isn't reliable on Macs.)

Depending on what you want to do, it's probably better to use a button than StaticText since there are a lot of issues like focus, sizing, disabling, changing image on click, etc, which are less noticed but still expected and/or useful in buttons. There are a number of examples of Python code which creates buttons, including PlateButtons and GenericButtons, where you can see what's involved in making a good button. It's not impossible, but a hassle if you don't need to do it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.