Global variables code confusion
<p>I am having trouble getting data input from one class to another and I cant seem to get the global function to work. The part i need help with is in the last function but it only works if you have the whole code.</p>

<pre><code>import tkinter as tk
import os

self = tk
TITLE_FONT = ("AmericanTypewriter", 18, "bold")



#exit function
def Exit():

    os._exit(0)

#Functions end

class SampleApp(tk.Tk):

    def __init__(self, *args, **kwargs):
        tk.Tk.__init__(self, *args, **kwargs)

        # the container is where we'll stack a bunch of frames
        # on top of each other, then the one we want visible
        # will be raised above the others
        container = tk.Frame(self)
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.frames = {}
        for F in (Home, Population, Survival, Birth,NEW, data, Quit):
            page_name = F.__name__
            frame = F(parent=container, controller=self)
            self.frames[page_name] = frame

            # put all of the pages in the same location;
            # the one on the top of the stacking order
            # will be the one that is visible.
            frame.grid(row=0, column=0, sticky="nsew")

        self.show_frame("Home")

    def show_frame(self, page_name):
        '''Show a frame for the given page name'''
        frame = self.frames[page_name]
        frame.tkraise()


class Home(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.controller = controller
        label = tk.Label(self, text="Home", font=TITLE_FONT)
        label.pack(side="top", fill="x", pady=10)

        button1 = tk.Button(self, text="Population",
                            command=lambda: controller.show_frame("Population"))
        button5 = tk.Button(self, text = "Quit",
                            command=lambda: controller.show_frame("Quit"))
        button1.pack()
        button5.pack()


class Population(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.controller = controller
        label = tk.Label(self, text="Enter Generation 0 Values", font=TITLE_FONT)
        label.pack(side="top", fill="x", pady=10)


        #Function


        def EnterPopulation():
            b1 = populationa.get()
            print (str(populationa.get()))
            bj = populationj.get()
            print (str(populationj.get()))
            bs = populations.get()
            print (str(populations.get()))




        def cal(*args):
            total = population_juveniles + population_adults + population_seniles

        #Population
        population = tk.Label(self, text="Value for the Populations")
        population.pack()

        labela= tk.Label(self, text= 'Population of Adults')
        populationa = tk.Entry(self)
        labela.pack()
        populationa.pack()
        population3 = tk.Button(self, text="Enter", command = EnterPopulation)
        population3.pack()

        labelj= tk.Label(self, text= 'Population of Juvenile')
        populationj = tk.Entry(self)
        labelj.pack()
        populationj.pack()
        population5 = tk.Button(self, text="Enter", command = EnterPopulation)
        population5.pack()

        labels= tk.Label(self, text= 'Population of Seniles')
        populations = tk.Entry(self)
        labels.pack()
        populations.pack()
        population6 = tk.Button(self, text="Enter", command = EnterPopulation)
        population6.pack()

        buttonS = tk.Button(self, text = "Survival Rates",
                        command=lambda: controller.show_frame("Survival"))

        buttonS.pack()

class Survival(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.controller = controller
        label = tk.Label(self, text="Survival Rates", font=TITLE_FONT)
        label.pack(side="top", fill="x", pady=10)

        def EnterSurvival(*self):
            S = survivalaa.get()  
            ss = survivalj.get()
            sss =survivals.get()
            print(str(survivalaa.get()))

        #Survival


        Survival = tk.Label(self, text="Value of Survival Rates between 0-1")
        Survival.pack()

        survivala= tk.Label(self, text= 'Survival rates of Adults')
        survivalaa = tk.Entry(self)
        survivala.pack()
        survivalaa.pack()
        survival69= tk.Button(self, text="Enter", command = EnterSurvival)
        survival69.pack()

        survivaljj= tk.Label(self, text= 'Survival rates of Juvenile')
        survivalj = tk.Entry(self)
        survivaljj.pack()
        survivalj.pack()
        survival5 = tk.Button(self, text="Enter", command = EnterSurvival)
        survival5.pack()

        labelss= tk.Label(self, text= 'Survival rates of Seniles')
        survivals = tk.Entry(self)
        labelss.pack()
        survivals.pack()
        survival6 = tk.Button(self, text="Enter", command = EnterSurvival)
        survival6.pack()

        buttonS = tk.Button(self, text = "Birth Rates",
                command=lambda: controller.show_frame("Birth"))

        buttonS.pack()

class Birth(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.controller = controller
        label = tk.Label(self, text="Birth Rates", font=TITLE_FONT)
        label.pack(side="top", fill="x", pady=10)


        def EnterBirth(*args):
            Birth1 = Birth2.get()

        Birtha = tk.Label(self, text="Birth rates")
        Birtha.pack()
        Birth2 = tk.Entry(self)
        Birth2.pack()
        Birth3 = tk.Button(self, text="OK", command = EnterBirth)
        Birth3.pack()

        buttonB = tk.Button(self, text = "New Generatons",
                            command=lambda: controller.show_frame("NEW"))

        buttonB.pack()

        #Number of New Generations To Model

class NEW(tk.Frame):
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.controller = controller
        label = tk.Label(self, text="New Generations", font=TITLE_FONT)
        label.pack(side="top", fill="x", pady=10)

        def EnterNew(*args):
            print (New2.get())
            news = New2.get()

        New = tk.Label(self, text="Number of New Generatiions 5 - 25")
        New.pack()

        New2 = tk.Entry(self)
        New2.pack()

        New3 = tk.Button(self, text="OK", command = EnterNew)
        New3.pack()


        button = tk.Button(self, text="BACK To Home",
                           command=lambda: controller.show_frame("data"))
        button.pack()


class data(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.controller = controller
        label = tk.Label(self, text="Data", font=TITLE_FONT)
        label.pack(side="top", fill="x", pady=10)

        no = tk.Button(self, text = "No",
                    command = lambda: controller.show_frame("Home"))
        no.pack()

        global Birth1 
        global s
        global ss
        global sss
        global b1
        global bj
        global bs
        global news

        spja= b1 * s
        spjb = bj * ss
        spjs= bs * sss
        st = spja + spjb + spjs
        born = spja* rebirth
        old = b1 + bj + bs

        labelold = tk.Label(self, text = 'Orignal populaton'+str(old))
        labelold.pack()
        labelto = tk.Label(self, text='Adults that survived = '+str(spja)+ 'Juveniles = ' +str(spjb)+ 'Seniles = '+str(spjs)+ '/n Total= '+str(st))   
        labelto.pack()
        Labelnew= tk.Label(self, text='New Juveniles = '+str(born))
        Labelnew.pack()
        # function for export data

class Quit(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.controller = controller
        label = tk.Label(self, text="Are you sure you want to quit?", font=TITLE_FONT)
        label.pack(side="top", fill="x", pady=10)


        yes = tk.Button(self, text="Yes", command = Exit)
        yes.pack()

        no = tk.Button(self, text = "No",
                       command = lambda: controller.show_frame("Home"))
        no.pack()



if __name__ == "__main__":
    app = SampleApp()
    app.mainloop(
</code></pre>

<p>If you want to use global variables, you need to do this:</p>

<pre><code>var1 = &lt;some value&gt;
var2 = &lt;some other value&gt;
s1 = &lt;yet another value here&gt;

# then create your classes

class Whatever(tk.whatever_you_want):
    def __init__(self, arg1, arg2, whatever_arg):
       global var1   #whis tells the function to use the variable you defined already in the module scope
       local_var_1 = var1 * 100  # 
</code></pre>

<p>Of course, perhaps you don't know this already, global variables are usually considered bad to start with, but I don't think it matters much for you. It's going to matter when you modify and read the variables from waaay too many places to keep track of, but I'm not sure you're building that big of a script.</p>

python python-3.x global-variables