tkinterを使ったタイマーアプリ
tkinterを使ってタイマーアプリを作っているのですが、「アプリケーションが応答しませんとなり、ずっと動作しません。どこかで(おそらくwhile文)無限ループなどが起きていると思うのですが、何故かわかりません。よろしくお願いいたします。
python
1import datetime 2import tkinter as tk 3from tkinter import messagebox #モジュールの読み込み 4import time 5 6root = tk.Tk() 7root.title("SimpleTimer") 8root.geometry('300x500') 9 10class Timer: #メインのクラスを定義 11 def __init__(self): 12 messagebox.showinfo('info','時間を入力してください') 13 def time_print(self,time_second): 14 self.time = time 15 i=0 16 while i<=time_second: 17 minute = int(time_second) // 60 18 second = int(time_second) % 60 19 time_label = str(minute) + ':' + str(second) 20 self.time_pr = tk.Label(text=time_label) 21 self.time_pr.pack() 22 time.sleep(1) 23 self.time_pr.pack_forget() 24 time_second-=1 25 26 27 28 def clear_info(self): 29 self.clear=messagebox.askyesno('時間のクリア','時間をクリアしますか?') 30 if self.clear==True: 31 self.time_pr.pack_forget() 32 else: 33 pass 34tm = Timer() 35start=False 36def time_stater(): 37 global start 38 start=True 39 times = time_inter.get() 40 tm.time_print(int(times)) 41 time_inter.pack_forget() 42 starter.pack_forget() 43 44time_inter = tk.Entry() #ユーザー入力を取得 45time_inter.pack() 46starter=tk.Button(text='Ok',command=time_stater) 47starter.pack() 48time_clear=tk.Button(text='時間を初期化',command=tm.clear_info) 49time_clear.pack() 50 51 52root.mainloop() 53 54

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2019/02/16 12:47