-3
Tkinterコードに問題はありませんが、実行すると何も表示されません。なにが問題ですか?Python 2.7 Tkinterコード
私はPython 2.7を使用しています。
import Tkinter as tk
from Tkinter import StringVar
import ttk
from random import randint , choice ,uniform
class Window(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
container = tk.Frame(self)
container.pack(side="top", fill="both", expand = True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
self.frames = {}
for F in (StartPage, Easy, Hard):
frame = F(container, self)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame(StartPage)
def show_frame(self, cont):
frame = self.frames[cont]
frame.tkraise()
class StartPage():
tk.Label(text = "Welcome!" , font = ("Verdana", 12)).pack()
ttk.Button(text = "Play" , command = lambda: Window().show_frame(Play()))
class Play():
def loop():
q = randint(0, 10)
p = uniform(1.50 , 10.50)
t = uniform(.1, .9)
p2 = p*q
p3 = p2*t
g = StringVar()
ttk.Entry(textvariable=g).pack()
ttk.Label(text = "Price Per Pizza: " + str(p) + " Amount: " + str(q) + " Tax: " + str(t))
if g == p3 : ttk.Label(text = "Correct!")
elif g != p3: ttk.Label(text = "Try Again.")
loop()
ttk.Button(text = "Play" , command = lambda: loop())
Window.mainloop
'Window.mainloop'は関数呼び出しではありません。そしてここに問題のコードを含めるべきです。 –
'Window'クラスに' mainloop'という関数がないので、 'Window.mainloop'はどこにもありません。 [良い質問をする方法](http://stackoverflow.com/help/how-to-ask)とあなたの投稿を編集することを検討してください。 – Ian
デバッグのヘルプを求める質問(** "なぜこのコードは動作していないのですか?")は、質問自体に*必要な動作、*特定の問題またはエラー*および*それを再現するのに必要な最短コード* **。 **明確な問題文**のない質問は他の読者には役に立たない。参照:[最小限で完全で検証可能な例を作成する方法](http://stackoverflow.com/help/mcve) – MattDMo