Balloon box with optionmenu in tkinter (python) - python

I am creating a GUI that contains a drop-down box (called an optionmenu in tkinter). I have it populated with entries.
This is what I want to do but can't figure out the proper commands. If a user hovers their mouse over a specific entry in the option menu, I want a hoverbox/balloon box/tooltip (whatever you want to call it) to appear and show a description of the option they are hovering over.
I assume I have to use some sort of event but I am not sure. Does anyone know how?

Related

normal button that acts like menubutton python tkinter

I am trying to write code that you can turn a normal Tkinter button into a dropdown menu but the dropdown menu button is in the main window, not in the menu bar. kind of like notepad++ how the menu bar is on the window, but I am making a dropdown button like that but that shows in the window. Can someone help? I don't really know how to explain this, but I am a beginner. I am using python and Tkinter on pycharm on a mac.
here is a video I made to explain more:
https://www.hippovideo.io/video/play/nuvNU03a6Hg7_oQC39uy1wgopPijjQQGCLH18VC0KiA
You can create popup-menus with menu.tk_popup(x, y).
So just add master.bind('<Button-3>', lambda e:menu.tk_popup(x, y).
x and y are values which you choose. If you want to place the menu at the mouse-pointer, you can use master.geometry(), but to be honset, I have no idea how to use master.geometry() exactly. But there are other Solutions too, e.g. tkinter.Spinbox().

Doubts about checking if button is already displayed and making a list of radio buttons

I have two questions regarding tkinter that I cant seem to find the answer too.
1) I currently have 2 radio buttons. I have programmed them in such a way that when one of them is clicked another definition is called and that creates a regular button on the screen. Now my problem is, if the user toggles between the both radio buttons, each time a new button will be created (instead of just having 1 the first time he toggles the options). Is there any way I can stop the extra buttons from being created if one already exsists?
2) Is there a widget that can easily be used to create check box lists?
EDIT: Sorry, I meant check box list not radio button list.
1> Define you button outside the eventHandler of the radiobutton.
inside the event handler only grid/pack it,whenever the radiobutton is pressed. In this way the button will not be defined multiple times.
N.B. Use fix row & column with the grid if you need.

PyQt Button Selection

I have a PyQt GUI set up that has a selection of QPushButtons and a QLineEdit text box (among other things). The text box is set up so as to call a function upon returnPressed(). My problem is that when I click on the text box and put in text, one of the buttons becomes selected which means that when I press enter in the text box it activates both the button and the text box function.
Is there a way around this? Some way to stop any buttons from being selected while the text box is being edited?
The code is fairly long so I can't add it here but if there are any questions regarding layout or anything that may be relevant, please ask.
Thank you for any help you can offer
From your question and comments, I'm guessing that the buttons and line-edit are in a QDialog, and that the selection/highlighting occurs due to the default/autoDefault property of buttons.
Normally, these properties will be set to False, but in a QDialog they are automatically set to True. The button that is the current default gets an additional frame drawn around it (even when it doesn't have the keyboard focus), and is activated whenever the return key is pressed.
You can of course prevent this behaviour by simply doing:
button.setDefault(False)
button.setAutoDefault(False)
for each button in the dialog.

How to set selection of a listbox in wxpython?

I am using the Drag and drop feature of wxpython with a Listbox.
This unallows me to select an element in the listbox. I am wondering how could I select an element from the listbox (but still be able to use the drag and drop)?
Here is a picture of me clicking the listbox.
I may also wonder if there is a way to make our own mouse event to solve the problem.

Keep selection on Tkinter Entry widget despite not having focus

When a user selects a portion of text in a Tkinter Entry widget it becomes highlighted. However, when the user clicks away from the widget the highlighting disappears.
Is there any way to keep the selected text highlighted despite the Entry widget not having focus?
I'm attempting to make a custom right-click menu not based on the Tkinter Menu widget (it's based on a Tkinter Toplevel widget), and I would like the text to remain highlighted despite the menu having focus.
You want to set the exportselection option of the text widget to False
text_widget.configure(exportselection=False)

Categories