Tkinter GUI を使用したこの Python プログラムの「BackButton」に問題があります。MainFrame は、動的コンテンツを含むフレームです。
両方の MenuPoint (デバイス構成と SCPI コマンド) で、前のフレーム/ウィンドウ (この場合は MainFrame/MainMenu) に戻る BackButton を実装したいと考えています。「???」を入力した SCPIMenu のマスター フレームと少し混乱しています。
これを実装する方法はありますか?御時間ありがとうございます。
class View(Tk):
    def __init__(self):
        Tk.__init__(self)
        self.title('Device Configurator')
        self.geometry('400x400')
        self.resizable(0,0)
        self.MainFrame = Frame(self, bd = '2', relief = RIDGE)
        self.MainFrame.pack(expand = True, fill="both", padx = 5, pady = 20)
        menubar = Menu(self)
        filemenu = Menu(menubar, tearoff=0)
        filemenu.add_command(label='Configure Devices', command = None)
        filemenu.add_command(label='Exit', command=self.quit)
        menubar.add_cascade(label='File', menu=filemenu)
        infomenu = Menu(menubar, tearoff = 0)
        infomenu.add_command(label='About', command = None)
        menubar.add_cascade(label='Info', menu = infomenu)
        self.config(menu = menubar)
    def mainMenu(self):
        configButton = Button(self.MainFrame, text = 'Device Configuration')
        configButton.place(x=200, y=150,anchor=CENTER)
        SCPIButton = Button(self.MainFrame, text = 'SCPI Command', command = self.SCPIMenu)
        SCPIButton.place(x=200, y=200,anchor=CENTER)
    def SCPIMenu(self):
        self.SCPIFrame = Frame(???, bd = '2', relief = RIDGE)
        self.SCPIFrame.pack(expand = True, fill="both", padx = 5, pady = 20)
        BackButton = Button(???, text = 'Back', command = self.mainMenu)
        BackButton.place(x=350, y=330, anchor=CENTER)
##The controller understands both the model and the view.
class Controller(object):
    def __init__(self):
        self.view = View()
        self.view.mainMenu()
        self.view.mainloop()
c = Controller()