Tkinter如何更改标题?

2024-06-26 18:15:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我怎么改这个标题,我尝试了我知道的方式,但它不起作用。 只是让你知道代码是一个宏点击器

#from PIL import ImageGrab, ImageOps
import pyautogui
import time
import tkinter as tk
from numpy import *



class Coordinates():
#Coordinates can be changed to wherever you want to AutoClick
    replayBtn = (100,350)


# close button (woah)
class YourGUI(tk.Tk):
    def __init__(self):
        # inherit tkinter's window methods
        tk.Tk.__init__(self)

        tk.Label(self, text="ENTER X:").grid(row=0, column=3)
        self.inputX = tk.Entry(self)
        self.inputX.grid(row=0, column=1)

        tk.Label(self, text="ENTER Y:").grid(row=0, column=0)
        self.inputY = tk.Entry(self)
        self.inputY.grid(row=0, column=4)

        tk.Button(self, text="convert", command=self.do_conversion).grid(row=3, column=0, columnspan=2)

        tk.Button(self, text="exit!", command=self.EXITME).grid(row=4, column=0, columnspan=2)

    def EXITME(self):
        exit(0)  # crashed prog so it closes
        # strtoint("crashmE!")

    def do_conversion(self):
        y = self.inputY.get()
        x = self.inputX.get()

        running = True
        try:
            x = int(x)
            y = int(y)
        except:
            print("Invalid point")
            exit(0)
            # strtoint("crashmE!")
        while running:
            pyautogui.click(x, y)


your_gui = YourGUI()
your_gui.mainloop()

Tags: textfromimportselftkinterdefexitcolumn
1条回答
网友
1楼 · 发布于 2024-06-26 18:15:12

如果你想用“this”来设置窗口的标题。你有几种选择。在

选项1

if __name__ == '__main__':    
    your_gui = YourGUI()
    your_gui.title('My Title') # Set title
    your_gui.mainloop()

选项2

^{pr2}$

这两个选项都可以在python3.7.1和python2.7.5中使用

相关问题 更多 >