请问怎么在tkinter def pause() 函数添加暂停按钮,可以暂停和继续运作程序,谢谢!
#!/usr/bin/python# _*_ coding=utf-8 _*_
import tkinter
from subprocess import Popen
import pyautogui
import openpyxl as vb
import openpyxl.utils as vbu
import pyperclip
import cv2
import pygame
import threading
from time import sleep
pyautogui.FAILSAFE=True
def thread_it(func,*args):
t = threading.Thread(target=func,args=args)
t.setDaemon(True)
t.start()
class Caozuo():
def __init__(self,getwsrow):
self.l=getwsrow
def get_pz(self):
m=)]
sleep(0.2)
# os.system("pause")
if m == '1':
print(self.l,self.l,self.l,self.l)
elif m == '5':
print(self.l,self.l,self.l,self.l,self.l)
elif m == '7':
print(self.l,self.l,self.l,self.l,self.l)
else :
print(self.l,self.l,self.l,self.l,self.l,self.l)
def run(worksheet):
pznum = 0
key = 0
for row in list(worksheet.rows):
# 按行 把每列的值 赋值到L数组
wsrow=
input_kb = cv2.waitKey(1) & 0xFF
if input_kb == ord(' '):
sleep(0.2)
print('paused')
cv2.waitKey(0)
print('continued')
else :
if wsrow is not None:
number = Caozuo(wsrow)
number.get_pz()
else:
pznum +=1
print('完成第',pznum,"张凭证录入")
exit()
def star():
thread_it(run,ws)
def pause():
def stop():
top.destroy()
if __name__=="__main__":
wb=vb.load_workbook('序时账.xlsx')
ws=wb.active
top = tkinter.Tk()
top.title("金算盘自动做账")
thelable=tkinter.Label(top,text="需要结束程序,请先按下空格暂停")
top.geometry('300x200') # Size 200, 200
startButton = tkinter.Button(top, height=3, width=20, text ="开始",
command = star)
pauseButton = tkinter.Button(top, height=3, width=20, text ="暂停",
command = pause)
stopButton = tkinter.Button(top, height=3, width=20, text ="结束",
command = stop)
thelable.pack()
startButton.pack()
pauseButton.pack()
stopButton.pack()
top.mainloop() <font color="red">[已解决]</font>请教关于tkinter添加开始 结束暂停继续四个按钮控制程序运行
https://fishc.com.cn/thread-212199-1-1.html
(出处: 鱼C论坛)
也是我问的 但是不知道怎么弄进去
页:
[1]