简体   繁体   English

如何将python窗口保持在所有其他窗口之上(python 3.1)

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

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. 如果GUI保持在活动游戏窗口的顶部,那么使用起来会更容易,因此用户可以正在播放,然后按下面板上的按钮而不必先将其带到前面。

Any help on how to do this would be great. 任何有关如何做到这一点的帮助都会很棒。 Thanks 谢谢

EDIT: Using tkinter 编辑:使用tkinter

You will need to provide the information on which GUI framework you are using for detailed answer at SO. 您需要提供有关您正在使用哪个GUI框架的信息,以便在SO处获得详细答案。

On windows you could do something like this with the handle of your window. 在Windows上,您可以使用窗口的句柄执行此类操作。

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. 还有Tkinter,您可能想尝试一下。 I have not tried it though. 我没有尝试过。

root = Tk()
root.wm_attributes("-topmost", 1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM