나는 다음과 같은 코드를 가지고 :이 스크립트를 실행하는 경우Tkinter를 -tkinter.TclError
from Tkinter import *
from urllib import urlretrieve
import webbrowser
import ttk
def get_latest_launcher():
webbrowser.open("johndoe.com/get_latest")
global percent
percent = 0
def report(count, blockSize, totalSize):
percent += int(count*blockSize*100/totalSize)
homepage = "http://Johndoe.com"
root = Tk()
root.title("Future of Wars launcher")
Button(text="get latest version", command=get_latest_launcher).pack()
global mpb
mpb = ttk.Progressbar(root, orient="horizontal", variable = percent,length="100",
mode="determinate")
mpb.pack()
root.mainloop()
urlretrieve("https://~url~to~my~file.com",
"Smyprogram.exe",reporthook=report)
그러나, 그것은 진행 막대가 표시되지 않습니다, 그것은 단지 버튼이 표시됩니다. 파일을 다운로드하지도 않고 커서가 깜박입니다. 그러나 GUI 창을 닫으면 다음 코드가 표시됩니다.
Traceback(most recent call last):
File "C:\Users\user\Desktop\downloader.py", line 28 in <module>
mpb = ttk.Progressbar(root, orient="horizontal", variable =
percent,length="100",mode="determinate")
File "C:\Users/user\Desktop\pyttk-0.3\ttk.py" line 1047, in __init__
Widget.__init__(self, master, "ttk::progressbar", kw)
File "C:\Users/user\Desktop\pyttk-0.3\ttk.py", line 574, in __init__
Tkinter.Widget.__init__(self, master, widgetname, kw=kw)
File "C:\Python26\lib\lib-tk\Tkinter.py", line 1930, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: this isn't a Tk applicationNULL main window
무엇이 잘못 되었습니까?
이 코드는 Linux에서 작동합니다. pyttk 0.3.2는'pip install pyttk' 명령을 사용하여 설치했습니다. (Python 2.7.5) – furas
@furas 정말요? 나는 창문을 사용하고 있고, ttk가 설치되어 있는데, 나는 어떤 문제를 겪고 있는가? – user3167683
Tkinter는'ttk :: progressbar'를 실행하려고 시도하지만 Tcl/Tk가 그것을 찾을 수 없다고 생각합니다. 나는 당신이 데스크톱에서 pyttk을 가지고있는 것을 본다 - 나는 python을 Python 폴더에 설치하고 의존성을 다운로드해야하는'pip' 명령을 사용하여 설치하려고 시도 할 것이다. – furas