Hello again! I've started a game project for fun, and I used the knowledge I gained a few days ago from a thread I posted. Now I've taken that tried to take that (taking a text Entry out of a GUI and using it outside the class) and apply it to number variables. Also, taking it from one GUI and using it to ichange another another.
This is what I've been able to figure out so far.

from Tkinter import *

""" This is the initial window. It will be a couple choices (buttons) which will spawn another window with the option to select an "select", or "cancel". What I want to happen is each sub window will bring X out, and bring it to the initial window to change if closes (if the option in the sub window was selected) or stays open (sub window was cancelled). Then bring X from all the windows out to outside the classes (which I understand how to do with text, but not with number variables). """

class app1:
    def __init__(self, parent):
        self.windowone = parent
        self.window1 = Frame(parent, width=50, height=50)
        self.window1.pack()

        self.button1 = Button(parent, text="Pick me", padx="1m",
                              pady="1m")
        self.button1.bind("<Button-1>", self.openwindow2)
        self.button1.pack()

        self.button2 = Button(parent, text="Pick me too", padx="1m",
                              pady="1m")
        self.button2.bind("<Button-1>", self.openwindow3)
        self.button2.pack()

    def openwindow2(self, event):
        root=Tk()
        window2 = app2(root)
        root.mainloop()

    def openwindow3(self, event):
        root=Tk()
        window3 = app3(root)
        root.mainloop()

class app2:
    def __init__(self, parent):
        self.windowtwo = parent
        self.window2 = Frame(parent, width=50,
                            height=50)
        self.window2.pack()

        self.entryb = Button(parent, text="Accept",
                             padx="1m", pady="1m")
        self.entryb.pack()

        self.bringout = IntVar()
        self.bringout.set(0)

        self.entryb["variable"] = self.bringout

        self.entryb.bind("<Button-1>",
                         self.printnumber)
        self.cancel = Button(parent, text="cancel",
                             padx="1m", pady="0.5")
        self.cancel.bind("<Button-1>", self.cancelation)
        self.cancel.pack()

    def printnumber(self, event):
        self.bringout.set(1)
        print self.bringout
        self.windowtwo.destroy()
        
    def cancelation(self, event):
        self.windowtwo.destroy()

class app3:
    def __init__(self, parent):
        self.windowthree = parent
        self.window3 = Frame(parent, width=50,
                            height=50)
        self.window3.pack()

        self.entryb = Button(parent, text="Accept",
                             padx="1m", pady="1m")
        self.entryb.pack()

        self.bringout = IntVar()
        self.bringout.set(0)

        self.entryb["variable"] = self.bringout

        self.entryb.bind("<Button-1>",
                         self.printnumber)
        self.cancel = Button(parent, text="cancel",
                             padx="1m", pady="0.5")
        self.cancel.bind("<Button-1>", self.cancelation)
        self.cancel.pack()

    def printnumber(self, event):
        self.bringout.set(1)
        print self.bringout
        self.windowthree.destroy()
        
    def cancelation(self, event):
        self.windowtwo.destroy()

root=Tk()
hope = app1(root)
root.mainloop()

Thank you in advance for any help and anything anyone can teach me.

I think the problem is this line, if I understand you correctly.
self.entryb["variable"] = self.bringout
I think you can only use "StringVar()" and "textvariable=" with a button since there is no data entry or changing of the text, so change the code to something like

self.bringout = StringVar()
        self.bringout.set("0" )
        self.entryb = Button(parent, text="Accept", 
                             textvariable=self.bringout,
                             padx="1m", pady="1m")
        self.entryb.pack()

and then convert to an int, if that is what you want, after the ".get". You can use IntVar for an entry box, radio button, scale, etc.

Thank you very much. I'm going to keep trying but the next step for I want to try is get make the initial window close out as well once I pick an option. Any suggestions on that? As well bring variable to the program to decide which way the program goes from there. Again thank you.

This article has been dead for over six months. Start a new discussion instead.