I have a wx.toolbar with some buttons. One of the buttons makes pan left!
I want to click on the button and while I keep it pressed, the pan left is made.
For now I only saw that the wx.EVT_TOOL only works when mouse left is up.
Is there a way to do what I intend ?
In the toolbar button's event, you should be able to get the state of the mouse via wx.GetMouseState.
Alternatively, you can make your own toolbar with a panel and some wx.Buttons (or other button widgets).
Related
So I have used .bind() on all my buttons and basically I would like to see which button is currently 'selected' when I switch between them with tabulator key. I did spend already quite a while on search for solution but didn't found anything useful. I don't know how to grab that moment when after pressing Tab key focus is on a button.
When there is more widgets I can .bind() Tab key to a widget proceeding button to simply just change foreground of a button but this won't work in case when I have only buttons in frame because first button will be omitted and that's not a clean and right solution to my issue.
If I bind Tab key to that button and change foreground then it's changed but after pressing Tab when button was already selected.
I don't know is there any clean solution for that problem or I will have to for frames that have only buttons create some starting_dummy widget that would initiate change for a first button.
Haven't found a way to detect is Tab key focused at this moment on a particular button (like it is with hover and cursor) but I know when it's going to be so I used that and solved case with only buttons in frame. It's based on what I already wrote in the question - I'm binding Tab key with a function to a widget preceding button to change button colour while button is bind to a function that's changing colour back to normal like this:
self.entry.bind("<Tab>", self.focus_in)
self.button.bind('<Tab>', self.focus_out)
def focus_in(self, event):
self.button.configure(fg_color='white')
def focus_out(self, event):
self.button.configure(fg_color='black')
For the case when only widgets in the frame/root are buttons, like in a menu that I got first I focus_set() on the last button and make a functions that circulate colours on and off at on Tab like this:
self.button2.focus_set()
self.button1.bind('<Tab>', self.focus_in)
self.button2.bind('<Tab>', self.focus_out)
def focus_out(self, event):
self.button1.configure(fg_color='white')
self.button2.configure(fg_color='black')
def focus_in(self, event):
self.button1.configure(fg_color='black')
self.button2.configure(fg_color='white')
Whit a custom made buttons it's just matter of replacing fg_color with a image.
If you use a button as an image holder for your logo or so, then just set state='disabled' and it will be omitted.
I need to know how to make a highlighted label(or small box )appears when the mouse is on widget like when you are using browser and put the mouse on (reload/back/etc...) button a small box will appear and tell you what this button do
and i want that for any widget not only widgets on toolbar
As the comment of #ekhumoro says
setToolTip is the solution
I recently started using Bokeh. Overall I am very satisfied. One thing I find annoying though is that it seems I can only play with the left mouse button and need to manually switch tools everytime I want to pan/zoom/etc... It would be great if I could pan with left mouse buttom and zoom in with right mouse button. Is there a way to automatically 'switch' to zoom tool whenever right mouse button held, and switch back when left mouse button held?
Thanks!
I found ways to hide something after pressing a button, but what I would like to do is having an invisible button that can still be pushed. A secret button of some sort, using Tkinter. It doesn't need to do anything yet
You don't need an invisible button to register a secret click Simply bind <1> to the root window and it will register whenever you click on anything (unless you click on some other widget that is listening for that event). You can then check the coordinates of the click to see where the use clicked.
There are two buttons in my little program, start and stop. And what I want is to disable the start button after I click it, and when I hit the stop button it should return to normal. How can I do this? I googled for a while and couldn't find the answer, hope you guys can help me out.
Thanks!
Use the button's Enable and Disable methods in the appropriate event handlers. There's a sample available at the link below:
wxPython Button Demo
In this snippet we are playing around with wxPython's buttons, showing you how to bind the mouse click event, enable and disable, show and hide the buttons. Each button also has a tool-tip (hint) associated with itself.