在 Tkinter Python 中禁用窗口移动 [英] Disable window move in Tkinter Python

查看:43
本文介绍了在 Tkinter Python 中禁用窗口移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看来我是在等待继续轰炸问题.这么短,有没有可能在不删除这个顶栏的情况下禁用Tkinter窗口的移动?

it seems that I was pending to continue the bombardment of questions. It this is short, Is it possible to disable the movement of the Tkinter window without deleting the top bar of this?

它会提供最少且可重现的代码,但如果这样做,它只会是两行,那就没用了.

It would give a minimal and reproducible code, but if it did it would only be two lines, it would be useless.

推荐答案

为你的窗口绑定一个事件,并设置窗口 .geometry()

Bind a event for your window,and set the window .geometry()

但是现在你不能通过拖动窗口的边框来修改窗口大小(但它可以最大化窗口.)

But now you can not revise the window size by dragging the window's border(But it can maximize the window.).

以下是代码示例:

import tkinter

def GetWindowPos():
    global X,Y
    X = win.winfo_geometry().split("+")[1]
    Y = win.winfo_geometry().split("+")[2]
    win.bind_all('<Configure>', HoldOn)

def HoldOn(event):
    win.geometry("+{}+{}".format(X,Y))

win = tkinter.Tk()
win.geometry("400x400+{}+{}".format(12,12))
tkinter.Label(win,text="Halo!").grid()
win.after(100,GetWindowPos)

win.mainloop()

这篇关于在 Tkinter Python 中禁用窗口移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆