单击时,tkinters条目画布上的小部件效果

时间:2019-10-07 15:44:38

标签: python tkinter tkinter-canvas tkinter-entry

当输入小部件在画布上并单击时,该窗口会产生我想避免的效果。 这是一个示例,这样您就可以看到即时消息在说什么:

import tkinter as tk


class GUI:
    def __init__(self, master, x, y):
        self.canvas = tk.Canvas(master, width=x, height=y)
        self.canvas.pack()
        self.entry = tk.Entry(self.canvas)
        p0x, p0y = x/2, y/2
        self.canvas.create_window(p0x, p0y, anchor="center", window=self.entry)


xroot = 1080
yroot = 720

root = tk.Tk()
gui = GUI(root, xroot, yroot)
root.mainloop()

0 个答案:

没有答案