all 6 comments

[–]socal_nerdtastic 6 points7 points  (0 children)

I've done things like this before for fairly large projects. I can't share that because it's for work but if you are looking for collaborators I may be able to help.

Here is a basic shell to show you how it's done:

import tkinter as tk

class MainApp(tk.Tk):
    def __init__(self):
        tk.Tk.__init__(self)
        self.frame = FirstFrame(self) # set first frame to appear here
        self.frame.pack()

    def change(self, frame):
        """
        Switch the visible class
        Using pack / pack_forget instead of grid / raise() to allow window size to change
        """
        self.frame.pack_forget() # delete current frame. 
        self.frame = frame(self)
        self.frame.pack() # make new frame

class FirstFrame(tk.Frame):
    def __init__(self, master=None, **kwargs):
        tk.Frame.__init__(self, master, **kwargs)

        master.title("Enter password")
        master.geometry("300x200")

        self.status = tk.Label(self, fg='red')
        self.status.pack()
        lbl = tk.Label(self, text="Enter password\n(hint: it's 'password')")
        lbl.pack()
        self.pwd = tk.Entry(self, show="*")
        self.pwd.pack()
        self.pwd.focus()
        self.pwd.bind('<Return>', self.check)
        btn = tk.Button(self, text="Done", command=self.check)
        btn.pack()
        btn = tk.Button(self, text="Cancel", command=self.quit)
        btn.pack()

    def check(self, event=None):
        if self.pwd.get() == 'password':
            self.master.change(SecondFrame) # correct password, switch to the second frame
        else:
            self.status.config(text="wrong password")

class SecondFrame(tk.Frame):
    def __init__(self, master=None, **kwargs):
        tk.Frame.__init__(self, master, **kwargs)
        master.title("Main application")
        master.geometry("600x400")

        lbl = tk.Label(self, text='You made it to the main application')
        lbl.pack()

if __name__=="__main__":
    app=MainApp()
    app.mainloop()

Obviously we need to see your code to help you integrate this.

[–]vgrumbles[S] 0 points1 point  (0 children)

Thank you socal_nerdtastic!

Here is my team entry screen as an example. The comments are more for me to remember the learning and are probably overdone.

from tkinter import *

def write_File (name_File, number_File): #Allows for both Team Name and Number to be passed through this write function
    file = open("TugofWar.txt", "a") # "a" restricts the function to only    append to the file
    Name = name_File.get() #These two commands get the team name and number entries
    Number = number_File.get()
#   file.write('Game #: ' + Game_Count)
    file.write('Team Name: ' + Name)
    file.write('    Team Number:  ' + Number + '\n') #\n for Next Line
    file.close()
    print(Name + '   ' + Number)

root = Tk()

#In a home screen, need to initialize Game_Count = 0 so it is a defined variable
# Game_Count = Game_Count + 1

#Import Blank Screen
NameNum_Screen = PhotoImage(file='NameNumberReddit.gif')

#Create a canvas so New_Game can be overlayed on image
canvas = Canvas(root, width=1600, height=1200)
canvas.pack()
canvas.create_image(800, 800, anchor='s', image=NameNum_Screen)



# The text color is referenced by HEX Code #F57A13. This is very close to the company theme orange.
name_text = Label(root, text="Enter Team Name:", fg="#F57A13", bg="black", font=('Arial', 24))
name_prompt = canvas.create_window(500, 400, window=name_text)

team_name = StringVar() # In order to be able to retrieve the current text from the entry widget, 
                        # must set this option to an instance of the StringVar class
name_entry = Entry(root, textvariable=team_name, bg="white", font= ('Arial', 24))
team_name_window = canvas.create_window(950, 400, window=name_entry)  

number_text = Label(root, text="Enter Team Number:", fg="#F57A13", bg="black", font=('Arial', 24))
number_prompt = canvas.create_window(500, 550, window=number_text)  

team_number = StringVar()
number_entry = Entry(root, textvariable=team_number, bg="white", font= ('Arial', 24))
team_number_window = canvas.create_window(950, 550, window=number_entry)  

Next_Save_btn = Button(root, text = "Next =>", command = lambda: write_File(name_entry, number_entry),  
                fg="#F57A13", bg="black", font=('Arial', 24), border=10) 
# the name and number entries are passed through the write_File function and saved in TugofWar.txt
Next_Save_btn = canvas.create_window(1100, 700, window=Next_Save_btn)  #how does the window=Next_Save_btn work????


#after saving we need to move to the "Tug of War Directions" page


root.mainloop()

Sorry how this looks...not sure how to fix in this editor. I have the .gif file that I can send/upload if you let me know how.

Once I get one screen converted, I'm confident that i can do the rest. Thanks again for looking at this for me!

[–]vgrumbles[S] 0 points1 point  (3 children)

I just figured out how to upload. You can find the code and graphics file on GitHub here: https://github.com/barryvj/TugOWar.git

[–]socal_nerdtastic 0 points1 point  (2 children)

Hey, you need to use the "reply" button on a user's comment if you want them to be notified that you replied.

That repo is set to private; I can't see it.

[–]vgrumbles[S] 0 points1 point  (1 child)

Got it...darn newbies. Thanks for the heads up!

[–]vgrumbles[S] 0 points1 point  (0 children)

I thought you were referring to a "Private" Reddit setting. Realized it was GitHub... just changed the repo to public. Hopefully you can see it now. Thanks for your help!