스레드를 파이썬에서 쓰레드를 얻으려는 데 문제가있어서 Appjar package을 사용하지 않습니다.파이썬 appjar 함수는
다음 프로그램은 목록을 통해 계산하고 진행률 표시 줄을 동시에 업데이트해야합니다. 나는 appjar documentation for threading를 따라했지만, 당신이 기능 PARAMS를 삽입하는 것을 의미하고있는 app.thread
(라인 35)에 NameError: name 'percent_complete' is not defined
을 반환하는 것 - 내 코드는 다음과 같습니다 : 나는하여 오류를 제거 할 수
from appJar import gui
import time
# define method the counts through a list of numbers, and updates the progress meter
def press(btn):
objects = [1,3,6]
total = len(objects)
current_object = 0
for i in objects:
print(i)
current_object += 1
current_percent_complete = (current_object/total) * 100
updateMeter(current_percent_complete)
time.sleep(1)
def updateMeter(percent_complete):
app.queueFunction(app.setMeter, "progress", percent_complete)
# create a GUI variable called app
app = gui("Login Window")
app.setBg("orange")
app.setFont(18)
# add GUI elements : a label, a meter, & a button
app.addLabel("title", "COUNTER")
app.setLabelBg("title", "blue")
app.setLabelFg("title", "orange")
app.addMeter("progress")
app.setMeterFill("progress", "green")
app.addButton("START COUNTING", press)
# put the updateMeter function in its own thread
app.thread(updateMeter, percent_complete)
# start the GUI
app.go()
과 같이 percent_complete
정의 : GUI로드와 버튼을 누를 때
from appJar import gui
import time
# define method the counts through a list of numbers, and updates the progress meter
percent_complete = 0
def press(btn):
...
그러나, 그것은 스레드하지 않습니다. 대신 목록을 반복하고 나중에 진행률 막대를 업데이트합니다.
같은 문제가있는 사람이 있습니까? 어떤 통찰력이라도 대단히 감사 할 것입니다! 감사합니다.