Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep a python window on top of all others (python 3.1)

Tags:

python

button

I'm writing a little program that basically has a bunch of buttons that when you click one, it inputs a certain line of text into an online game I play. It would be a lot easier to use if the GUI would stay on top of the active game window so the user could be playing and then press a button on the panel without having to bring it to the front first.

Any help on how to do this would be great. Thanks

EDIT: Using tkinter

like image 352
Kefka Avatar asked Oct 29 '25 09:10

Kefka


1 Answers

You will need to provide the information on which GUI framework you are using for detailed answer at SO.

On windows you could do something like this with the handle of your window.

import win32gui
import win32con
win32gui.SetWindowPos(hWnd, win32con.HWND_TOPMOST, 0,0,0,0,
win32con.SWP_NOMOVE | win32con.SWP_NOSIZE)

Also with Tkinter, you might want to try. I have not tried it though.

root = Tk()
root.wm_attributes("-topmost", 1)
like image 174
pyfunc Avatar answered Oct 31 '25 06:10

pyfunc