私はRosettaCodeでPythonコードの例を試していました。これは、プログラミングのchrestomathyサイトであり、同じタスクのソリューションが可能な限り多くの異なるプログラミング言語で提示されています。このタスクの目標は、グラフィカルユーザーインターフェイスから文字列と整数75000を入力することです。コードを以下に示します。
import tkSimpleDialog
number = tkSimpleDialog.askinteger("Integer", "Enter a Number")
string = tkSimpleDialog.askstring("String", "Enter a String")
ただし、コードを実行しようとすると、次のエラーが発生します。
Traceback (most recent call last):
File "C:\Users\vix\Documents\.cache\GUIexample.py", line 3, in <module>
number = tkSimpleDialog.askinteger("Integer", "Enter a Number")
File "C:\Python27\lib\lib-tk\tkSimpleDialog.py", line 262, in askinteger
d = _QueryInteger(title, prompt, **kw)
File "C:\Python27\lib\lib-tk\tkSimpleDialog.py", line 189, in __init__
Dialog.__init__(self, parent, title)
File "C:\Python27\lib\lib-tk\tkSimpleDialog.py", line 53, in __init__
if parent.winfo_viewable():
AttributeError: 'NoneType' object has no attribute 'winfo_viewable'
問題はどこにあるのでしょうか?
ありがとう