我不知道如何添加Tkinter菜单小部件与我的代码我尝试了一个网站上的代码,但它不会工作。我只是觉得我很傻,但请帮帮我。为了记录在案,我查看了其他堆栈溢出解决方案,但它们不起作用。你知道吗
import pyautogui
import time
import tkinter as tk
class Coordinates():
replayBtn = (100,350)
class YourGUI(tk.Tk):
def __init__(self):
# inherit tkinter's window methods
tk.Tk.__init__(self)
#Enter X field and label ⬇
tk.Label(self, text="ENTER X:").grid(row=0, column=3)
self.inputX = tk.Entry(self)
self.inputX.grid(row=0, column=1)
#Enter Y field and label ⬇
tk.Label(self, text="ENTER Y:").grid(row=0, column=0)
self.inputY = tk.Entry(self)
self.inputY.grid(row=0, column=4)
# Start Button ⬇
tk.Button(self, text="start", command=self.do_conversion).grid(row=3, column=0, columnspan=2)
# close button ⬇
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)
if __name__ == '__main__':
your_gui = YourGUI()
your_gui.title('Macro Clicker') # Set title
your_gui.iconbitmap('favicon.ico') # Set icon
your_gui.resizable(False, False)
your_gui.mainloop()
time.sleep(0)
很抱歉这么说,但是如果你不懒惰的话,你会找到上千个关于tkinter菜单的例子。 甚至你的代码都和tkinter.菜单!? 你知道吗
这是我的一个例子。“信息”菜单是空的,只是向您展示如何创建其他菜单。你知道吗
相关问题 更多 >
编程相关推荐