very simple problem, I just try to make tkinter window that you are not able to move with the mouse. the problem is that I don't find a function that can do it, the only thing that I found is making it not resizable and stuff like that, I also found a function that hides the bar and making it not resizable or moveable, but it doesn't help me cause I still want it to have the default window bar, let's just say I have a normal window here:
import tkinter as TK
window = TK.Tk()
window.geometry('1200x800')
window.mainloop()
so just tell me if you know how to make it impossible to move the window with the mouse, how to do that, the code should work fine with fullscreen and other functionality like that by the way.
As the title describes, I am creating a Toplevel tkinter window, but after creation, there is about 300 milliseconds when it is acting normal, but then the main window comes on top of it, blocking out half of it, without taking the focus away from the Toplevel window. Example:
This is manually fixed by bringing the main window into focus, and then clicking back on the Toplevel widget, however is a great inconvenience, as the Toplevel is a notification window, so clicking away from it will destroy it. I have tried using the set_grab() command, however it prevents the main window from coming into focus, disabling the manual solution. The lift() command extends the period in which the Toplevel is in focus, however it still gets pushed into the background within one tick of the mainloop. I also tried focusing the main window with focus() and then focusing the Toplevel, as per the manual solution, but to no avail, as this scenario always arrived, regardless of what I tried.
Why is this happening, and how could I fix it?
MRE:
import tkinter as tk
class Notify(tk.Toplevel):
def __init__(self, master, title, message, time, **messageArgs):
super().__init__(master=master)
self.title(title)
self.message = tk.Label(self, text=message, **messageArgs)
self.message.pack(anchor='center')
self.after(time, self.close)
self.lift() # The most successful one yet, but still does not solve the issue
def close(self):
self.master.focus()
self.destroy()
root = tk.Tk()
Notify(root, 'Blah Blah Blah', 'Spam Spam Spam', 5000)
tk.mainloop()
This answer here: https://stackoverflow.com/a/31927283/12692182 will solve your problem. You need to specify what widgets it is supposed to be on top of in lift():
self.lift(aboveThis=self.master)
instead of:
self.lift()
Note: this was my own answer that I shared to help out others with a similar problem. I still would like help understanding why it works, as well
Basically, I've got a tkinter button with an image on it, and when I disable the button it greys out a square around the image and looks pretty bad. Is there any way to stop this from happening while keeping the button disabled?
Instead of disabling the button, you can unbind the callback:
button['command']=0
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 have developed a Tkinter GUI and need to add a button in the GUI window top panel, next to the minimise, maximise and close buttons. The button then calls a function. How can this be done?
Tkinter doesn't have any support to do what you want. You'll have to find some sort of platform-specific library to alter what is shown in the window border.
Your only other option is to turn off the window border provided by your OS with overrideredirect, and then create your own border with whatever controls you want. This requires a lot of work because you also have to write the code for moving and resizing the window, but it's possible.