Good Evening!私はクリックすると、別のGUIファイルを同じファイルフォルダにある別の.pyファイルに開く方法を理解しようとしています。 (私は、リモートでこれについて答えるかもしれない他の質問で与えられたすべての答えを試しました)。Tkinter Guiボタンを.pyファイルにリンクして別のGUIを開く
enter code here
#this file is called main.py
from tkinter import *
root1 = Tk()
root1.title("ProQA-ish")
fphoto = PhotoImage(file="../icon/fireorig.png") #change wd to file named icon
fireButton = Button(root1, image=fphoto)
fireButton.config(height=228, width=200)
mphoto = PhotoImage(file="../icon/ems.png") #change wd to file named icon
emsButton = Button(root1, image=mphoto)
emsButton.config(height=224, width=197)
fireButton.pack(side=LEFT)
emsButton.pack(side=RIGHT)
root1.mainloop()
enter code here
#this is called emdmenu.py
from tkinter import *
root = Tk()
root.title("Emergency Medical Dispatch")
root.iconbitmap(default='../icon/fire.ico')
#----Window------
topframe = Frame(root)
topframe.pack()
bottomFrame = Frame(root)
bottomFrame.pack(side=BOTTOM)
#---Create Buttons for choices----
abdominalPnB = Button(topframe, text="01_Abdominal Pain")
abdominalPnB.config(anchor="w", width=20, height=1)
abdominalPnB.grid(row=0, column=0)
allergyrxB = Button(topframe, text="02_Allergic Reaction")
allergyrxB.config(anchor="w", width=20, height=1)
allergyrxB.grid(row=1, column=0)
#ect..
root.mainloop()
ご協力いただきありがとうございます。ありがとうございます。
感謝を!ちょうど私には理解があります。私はimport tkinterの下にimport emdmenu.pyを置いて、次に押したいボタンを押して、他のファイルを表示させます。ちょうどcommand = emdmenu.pyと書かれていますか? (現時点では、最初にemdmenu.pyを起動すると、そのウィンドウを閉じると、開始したいウィンドウがポップアップします) – ChrisCrad
いいえ、 'command = function_Name'関数を呼び出す関数は関数でなければなりません形。インポートされたコードはインポート時に実行されるため、インポートするファイルをチェックし、すべてのロジックが関数内にあることを確認してください。 – Joe
私は非常にthenewbostonをお勧めします。彼らはウェブサイトとYouTubeチャンネルを持っています。あなたが有用と感じるかもしれないtkinterにシリーズ全体があります。 – Joe