()とをdestroy()のメソッドで使用しているときに問題が発生しました。私はラムの状態とプロセッサの状態を監視しているときにメニウを作成しました。私が最初のdefを呼び出しているときは大丈夫ですが、2番目のdefを呼び出すと、フレーム内の情報が数ミリ秒間表示され、次にRAMステータスに関する情報が繰り返し表示されます。私は避けるために、この問題を行うことになって何PythonでDestroy()と衝突した後に
http://i.imgur.com/SqAeBUN.gif
def ram():
root.after(1000,ram)
for widget in app.winfo_children():
widget.destroy()
iram = psutil.virtual_memory()
total = iram.total/(1024*1024)
available = iram.available /(1024*1024)
percent = iram.percent
used = iram.used /(1024*1024)
inf = Label(app, text="Information about RAM status")
inf.grid(row=0,column=1, pady=10)
total_1 = Label(app, text="Total memory RAM")
total_1.grid(row=1,column=0)
total1 = Label(app, text=total,fg="blue")
total1.grid(row=1, column=1,pady=5)
available_1 = Label(app, text="Available memory RAM")
available_1.grid(row=2,column=0)
available1 = Label(app, text=available,fg="blue")
available1.grid(row=2, column=1,pady=5)
percent_1 = Label(app, text="Used memory RAM in %")
percent_1.grid(row=3,column=0)
percent1 = Label(app, text=percent,fg="red")
percent1.grid(row=3, column=1,pady=5)
used_1 = Label(app, text="Used memory RAM")
used_1.grid(row=4,column=0)
used1 = Label(app, text=used,fg="blue")
used1.grid(row=4, column=1,pady=5)
def help():
for widget in app.winfo_children():
widget.destroy()
help_1=Label(app, text="This aplication was created with Python 3.5 \n")
help_1.grid(row=0,column=0)
root = Tk()
app = Frame(root)
app.grid()
root.title("S.M.A.R.T.")
root.geometry("500x300")
root.resizable(0,0)
menubar = Menu(root)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="Battery Status", command=battery_status)
filemenu.add_command(label="Disk's Status", command=disk_status)
filemenu.add_command(label="Processor Status", command=processor)
filemenu.add_command(label="PC's Status", command=pc)
filemenu.add_command(label="RAM's Status", command=ram)
filemenu.add_command(label="Windows Status", command=windows)
filemenu.add_command(label="Exit", command=root.quit)
filemenu.add_separator()
menubar.add_cascade(label="File", menu=filemenu)
helpmenu = Menu(menubar, tearoff=0)
helpmenu.add_command(label="Help", command=help)
menubar.add_cascade(label="Help", menu=helpmenu)
helpmenu.add_separator()
root.config(menu=menubar)
root.mainloop()
root.destroy()
?これらのサブメニューを思い出して、フレーム内の情報を理解することは不可能です。
問題を示すコードを投稿してください。 – mhawke