Q:

Calling GUI method/sub-class from separate class

I'm trying to create a script that creates an instance of a GUI class, which on its own has sub-classes to represent the various pages that I want to display.  
The goal is to create a sequence file that calls a specific GUI page to show, and once that GUI page is shown and a button is clicked, it runs the sequence from the sequence file, which then dictates which GUI pages to show. 
The Seqeuncer looks something like this (criteria for showing test pages is simplified)
import gui

class Sequencer():

    def __init__(self):
        pass

    def run_gui(self):
        # Create instance of the Test GUI
        self.my_gui = gui. TestGUI()
        self.my_gui.mainloop()

    def run_test(self, entry):
if x = 1:
        gui. TestGUI().show_page(PageOne)
if x = 2:
        gui. TestGUI().show_page(PageTwo)

The GUI looks like:
import sequencer

class TestGUI(tk. Tk):

    def __init__(self):

        # Initialize the container
        tk. Tk.__init__(self)
        container = tk. Frame(self)
        container.pack(side="top", fill="both", expand = True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        # Make the container a fixed size
        tk. Tk.resizable(self, False, False)

        # Set up the pages for the GUI
        self.pages = {}
        list_of_pages = [
            PageOne,
            PageTwo
        ]
        for P in list_of_pages:
            frame = P(container, self)
            self.pages[P] = frame
            frame.grid(row=0, column=0, sticky="nsew")

        # Set the Main Page
        self.show_page(MainPage)

    def show_page(self, page):

        frame = self.pages[page]
        frame.tkraise()

class PageOne(tk. Frame):

    def __init__(self, parent, controller):
        tk. Frame.__init__(self,parent)

        entry = tk. Entry(self, width=40, font="Arial 16", justify="center")
        entry.place(relx=0.5, rely=0.5, anchor="center")

        # Create Binding for the Return Key
        entry.bind("<Return>", lambda event: sequencer. Sequencer().run_test(entry.get()))

class PageTwo(tk. Frame):
    def __init__(self, parent, controller):
        tk. Frame.__init__(self,parent)

I then create a top-level script (main.py) that creates an instance of the Sequencer and runs the gui.  Instead of showing the pages that are supposed to be shown, I get an error. 
Am I doing this wrong? 

A:

You should not be creating a new instance of Sequencer.  Instead, pass in a reference or provide a way for the other classes to access the instance. 
What I would do is pass in the sequencer to your GUI like so:
class Sequencer():
    def run_gui(self):
        ...
        self.my_gui = gui. TestGUI(sequencer=self)
        ...

class TestGUI(tk. Tk):
    def __init__(self, sequencer):
        self.sequencer = sequencer
        ...

Because each of your subpages is given the instance of TestGUI as the controller, you can reference the existing sequencer by removing the import and then using the controller to get a reference to the sequencer:
class PageOne(tk. Frame):

    def __init__(self, parent, controller):
        ...
        self.controller = controller
        ...

        entry.bind("<Return>", lambda event: self.controller.sequencer.run_test(entry.get()))

Though, the code will be easier to read and debug if you replace lambda with a proper function.  I find it to be a good rule of thumb to never use lambda unless you absolutely must.  In this case, there's really no advantage to using lambda. 
Example:
class PageOne(tk. Frame):

    def __init__(self, parent, controller):
        ...
        self.entry = tk. Entry(...)
        self.entry.bind("<Return>", self.run_test)
        ...

    def run_test(self):
        data = self.entry.get()
        self.controller.sequencer.run_test(data)

With that, it becomes much easier to do debugging on the code since you can examine the data prior to calling run_test.  In this simple case that might not be necessary, but if you get in the habit of coding like this it will come in handy when you find yourself making more complex commands. 
You also need to change the run_test function to reuse the existing TestGUI instance rather than creating a new one every time. 
def run_test(self, entry):
    ...
        self.mygui.show_page(PageOne)
    ...

