0
から変数を取得するので、(tkinterを使用して)このGUIプログラムをコーディングしています。同じ機能で3つのEntryboxesを使用しています。私はmain関数でその値を使用したいので、ある種類のグローバル変数に値を取得する方法や、別の関数で値を使用する方法はありますか?Entry PYTHON 3
def options():
options_root = Tk()
textFrame = Frame(options_root)
textFrame.grid()
widthlabel = Label(textFrame, text="w:", justify=LEFT)
widthlabel.grid(column="0", row="0")
widthinput = Entry(textFrame)
widthinput.grid(column="1", row="0")
heightlabel = Label(textFrame, text="h:", justify=LEFT)
heightlabel.grid(column="0", row="1")
heightinput = Entry(textFrame)
heightinput.grid(column="1", row="1")
mlabel = Label(textFrame, text="m:", justify=LEFT)
mlabel.grid(column="0", row="2")
minput = Entry(textFrame)
minput.grid(column="1", row="2")
width = widthinput.get()
height = heightinput.get()
m = minput.get()
start_game_button = Button(options_root, text="Start", justify=LEFT, command=lambda:tabort(options_root))
start_game_button.grid(column="0",row="3")
exit_button = Button(options_root, text = "Exit", justify=LEFT, command=exit)
exit_button.grid(column="1", row="3")
mainloop()
def main():
options()
w = widthinput.get()
h = heightinput.get()
m = minput.get()
main()
これで、クラスでこれを実行しました。 w = ins.width() TypeError: 'int'オブジェクトは呼び出し可能ではありません – tivon
@tivon:thtエトルメッセージのどの部分を理解できませんか?それはあなたにエラーが何であるかを正確に伝えています。あなたは 'width'は関数だと思っているようですが、Pythonはそれがintだと思っています。 –