How to disable window movement in tkinter - python

Quick question, is there any way I can prevent a Tkinter window from being moved by the mouse? I couldn't seem to find any answers on google so I'm asking my own question. Thanks in advance!

A way to do this is by Using
Overrideredirect(1)
However this will ignore completely all window functions from the os window manager.
If you want the rest of the functions you will have to create a new fake window title bar yourself and assign all the functionalities you need (window close, minimize, maximize)

Related

how to make a tkinter window with a lot of properties

I am trying to make a game overlay with python and it needs to support a lot of features for my game overlay to work the way it was intended to.
It needs to have a transparent window, pass clicks both right and left (to the application underneath it), pass all keyboard keys (to the application underneath it), and FINALY can still collect all the mouse movement and keyboard press events.
I don't even know if all of this is possible, or if I need to do this in another pip or language
I am on windows 10
jesus.py :
from tkinter import *
jesus = Tk()
jesus.title("Minecraft's Jesus")
jesus.attributes("-fullscreen", True)
jesus.attributes("-topmost", True)
jesus.attributes("-alpha", 0.002)
jesus.configure(background='grey')
jesus.mainloop()
Edit: I was completely unaware of hooks at the time and now this question is useless. A thanks to Tim Roberts for suggesting to use hooks.

how to change a window border color in tkinter

I'm having a problem with changing the background of this part of the window:
How do I change it?
As I see you are using windows.
This color is set by the theme you are currently using. It is the same for every window.
So I cross out the possibility of only using the Tkinter module for this.
Tkinter is responsible for what is in the window but the window manager decides about the border. For example in Ubuntu the window would look totally different.
I guess, you would need some windows specific calls for that.
You can remove the border with root.overrideredirect(1) if I remember correctly.
PS: put "windows" into the tags of this question.

The proper way to display multiple windows in tkinter?

I am currently working on a project using Python and tkinter.
The problem is that I don't know what's the proper way to display multiple windows, or screens, I don't know how to call them. Let me explain better.
When the application starts the login screen appears. After that, if I click register, I want to go to the register screen, but I don't want it to be a separate window (I don't want to have 2 windows displayed at the same time), but rather another window with different content ?!
How should I handle properly this situation? Create a second window using Toplevel and hiding the first (can I do that?) or changing the widgets of the first?
Code I've written so far
You can do that- just call window.withdraw() on the Toplevel you need to hide after creating a new Toplevel. Changing the widgets in the first is also an option- if you like, you could always try a Notebook widget and disable manual flipping or just put each "screen" in a frame and grid_ or pack_forget them to remove them from the window.

wxPython: Find the focused wxTextCtrl?

I am new to wxPython and trying out some examples. I am using wxFormBuilder to create a simple GUI with many wxTextCtrl. I want to determine the current location of cursor, which is in one of those wxTextCtrl and do some operation. How do I do this? Please help!
Try using the wx.Frame's FindFocus() method. That should return the widget that has focus.
See also:
wxPython: How do I find out which widget has the focus?

hide pygame window on OSX

Pressing command-H in OSX immediately hides the active window. How do I achieve the same effect, programmatically, from Python? Specifically, I'd like to find a particular window that my application creates and then be able to show & hide it programmatically.
I already know how to do this with pywin32 but I'm afraid my expertise there doesn't quite cover OSX as well.
If it helps, the window in question is one created by pygame. I know that pygame has pygame.display.iconify() but that doesn't satisfy my requirements - the window doesn't disappear immediately, but rather the disappearance is animated, and there's no corresponding "uniconify" function that I can find.
Well, this ended up working. When I want to hide the window, I do pygame.display.quit() and make my code properly handle not having a display. When I want to show it, I do pygame.display.set_mode(...) with the former resolution.
The net effect is that of hiding & showing the window. Unfortunately the window gets created in a different spot than where it started, and although apparently you can tell SDL to create the window in a particular spot, I haven't been able to find a way to get the window's location...

Categories