【发布时间】:2018-07-11 23:23:53
【问题描述】:
我有这个代码:
#python 2.7.15
import pyautogui
import time
import msvcrt
from threading import Thread
import win32api
import battle
import Tkinter
from Tkinter import *
#launcher pos x:868 y:975
#rocket pos x:829 y:936
def click():
left = win32api.GetKeyState(0x01)
while True:
click = win32api.GetKeyState(0x01)
if click != left:
left = click
#print(a)
if click < 0:
pyautogui.hotkey("ctrlleft")
time.sleep(1)
def rocket():
rocket = True
while rocket:
pyautogui.hotkey("2")
time.sleep(0.5)
pyautogui.hotkey("7")
time.sleep(20)
root = Tk()
root.geometry("300x200")
root.title("Bot options")
root = Tkinter.Button(root, text = "Click me", command = rocket)
root.pack()
root.mainloop()
"""key = msvcrt.getche()
if key == 'z':
click()
elif key == 'x':
if __name__ == '__main__':
Thread(target = click).start()
Thread(target = battle.battle).start()
Thread(target = rocket).start()"""
问题是,当我在运行时单击所创建窗口内的“单击我”按钮时,窗口停止响应。我尝试将command = rocket 更改为command = rocket() 但没有弹出窗口并且功能开始工作
【问题讨论】:
标签: python python-2.7 tkinter