this is my code i was wondering if somone could help me find out how to put text in the new window created at the red line

from Tkinter import *
import Tkinter as tk

class Application(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.grid()
        self.createsMenuButton()
        self.createsOptionsButton()
        self.createsHelpButton()
        self.createsUsernameWidget()
        self.createsUsernameEntryButton()
        self.createsLoginButton()
        

    #### creates title bar     
    def createsMenuButton(self):
        self.mb = Menubutton (self, text="FILE",
                              relief=FLAT,font=("Arial", 8), )
        self.mb.grid(row=0, column=0)

        self.mb.menu = Menu ( self.mb, tearoff=0 )
        self.mb['menu'] = self.mb.menu


        self.exitVar =IntVar()

        self.mb.menu.add_command (label="QUIT", 
                                       command=self.quit )
        

        

    def createsOptionsButton(self):
        self.mb = Menubutton (self, text="OPTIONS",
                              relief=FLAT,font=("Arial", 8))
        self.mb.grid(row=0, column=1)

        self.mb.menu = Menu ( self.mb, tearoff=0 )
        self.mb['menu'] = self.mb.menu

        self.clearVar = IntVar()
        self.mb.menu.add_checkbutton ( label="Font sizes",
                                       variable=self.clearVar )


    def createsHelpButton(self):
        self.mb = Menubutton (self, text="HELP",
                              relief=FLAT,font=("Arial", 8))
        self.mb.grid(row=0, column=2)

        self.mb.menu = Menu ( self.mb, tearoff=0 )
        self.mb['menu'] = self.mb.menu

        self.helpVar = IntVar()
        self.mb.menu.add_command ( label="help",
                                       command = self.NewWindow )

    def NewWindow(self):
        newWindow = Toplevel (master=None).minsize ( width=30,height=50)
        
        

    
        
    def createsUsernameWidget(self):
        self.username = Label (self, text="username:",
                   relief=FLAT,font=("Arial", 8))
        
        self.username.grid(row=1, column=1)

        
## This function creates the username libary
    def createsUsernameEntryButton(self):
        self.mb = Menubutton (self, 
                              relief=RIDGE,font=("Arial", 8))
        self.mb.grid(row=1, column=2)

        self.mb.menu = Menu ( self.mb, tearoff=0 )
        self.mb['menu'] = self.mb.menu

        self.helpVar = IntVar()
        self.helpVar2 = IntVar()
        self.helpVar3 = IntVar()
        self.helpVar4= IntVar()
        self.helpVar5 = IntVar()
        self.helpVar6 = IntVar()
        self.helpVar7 = IntVar()
        self.helpVar8 = IntVar()
##These are the names        
        self.mb.menu.add_checkbutton ( label="Adam Wilson",
                                       variable=self.helpVar )
        self.mb.menu.add_checkbutton ( label="Rhys Cee",
                                       variable=self.helpVar2 )
        self.mb.menu.add_checkbutton ( label="Steven Bee",
                                       variable=self.helpVar3 )
        self.mb.menu.add_checkbutton ( label="Adam eeS",
                                       variable=self.helpVar4 )
        self.mb.menu.add_checkbutton ( label="Aaron eeS",
                                       variable=self.helpVar5 )
        self.mb.menu.add_checkbutton ( label="Tom Arm",
                                       variable=self.helpVar6 )
        self.mb.menu.add_checkbutton ( label="Jamie Beee",
                                       variable=self.helpVar7 )
        self.mb.menu.add_checkbutton ( label="John Wee",
                                       variable=self.helpVar8 )
        

    def createsLoginButton (self):
        self.Button = Button (self, text="Login", command = self.loginPage,
                              relief=RAISED,font=("Arial", 8))
        self.Button.grid(row=2, column=1)
##HereHere
##HereHere
##Here
    def loginPage (self):
        logedInPage = Toplevel (master=None).minsize ( width=30,height=50)###I want to write text in the window created here
        w = Label (self, text("hi "))
        
                              
        


    
        
app = Application()
app.master.title("Wilson Messaging") 
app.mainloop()

Remeber to use the BB code, so it looks like the below.

from Tkinter import *
import Tkinter as tk

class Application(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.grid()
        self.createsMenuButton()
        self.createsOptionsButton()
        self.createsHelpButton()
        self.createsUsernameWidget()
        self.createsUsernameEntryButton()
        self.createsLoginButton()
        

    #### creates title bar     
    def createsMenuButton(self):
        self.mb = Menubutton (self, text="FILE",
                              relief=FLAT,font=("Arial", 8), )
        self.mb.grid(row=0, column=0)

        self.mb.menu = Menu ( self.mb, tearoff=0 )
        self.mb['menu'] = self.mb.menu


        self.exitVar =IntVar()

        self.mb.menu.add_command (label="QUIT", 
                                       command=self.quit )
        

        

    def createsOptionsButton(self):
        self.mb = Menubutton (self, text="OPTIONS",
                              relief=FLAT,font=("Arial", 8))
        self.mb.grid(row=0, column=1)

        self.mb.menu = Menu ( self.mb, tearoff=0 )
        self.mb['menu'] = self.mb.menu

        self.clearVar = IntVar()
        self.mb.menu.add_checkbutton ( label="Font sizes",
                                       variable=self.clearVar )


    def createsHelpButton(self):
        self.mb = Menubutton (self, text="HELP",
                              relief=FLAT,font=("Arial", 8))
        self.mb.grid(row=0, column=2)

        self.mb.menu = Menu ( self.mb, tearoff=0 )
        self.mb['menu'] = self.mb.menu

        self.helpVar = IntVar()
        self.mb.menu.add_command ( label="help",
                                       command = self.NewWindow )

    def NewWindow(self):
        newWindow = Toplevel (master=None).minsize ( width=30,height=50)
        
        

    
        
    def createsUsernameWidget(self):
        self.username = Label (self, text="username:",
                   relief=FLAT,font=("Arial", 8))
        
        self.username.grid(row=1, column=1)

        
## This function creates the username libary
    def createsUsernameEntryButton(self):
        self.mb = Menubutton (self, 
                              relief=RIDGE,font=("Arial", 8))
        self.mb.grid(row=1, column=2)

        self.mb.menu = Menu ( self.mb, tearoff=0 )
        self.mb['menu'] = self.mb.menu

        self.helpVar = IntVar()
        self.helpVar2 = IntVar()
        self.helpVar3 = IntVar()
        self.helpVar4= IntVar()
        self.helpVar5 = IntVar()
        self.helpVar6 = IntVar()
        self.helpVar7 = IntVar()
        self.helpVar8 = IntVar()
##These are the names        
        self.mb.menu.add_checkbutton ( label="Adam Wilson",
                                       variable=self.helpVar )
        self.mb.menu.add_checkbutton ( label="Rhys Cee",
                                       variable=self.helpVar2 )
        self.mb.menu.add_checkbutton ( label="Steven Bee",
                                       variable=self.helpVar3 )
        self.mb.menu.add_checkbutton ( label="Adam eeS",
                                       variable=self.helpVar4 )
        self.mb.menu.add_checkbutton ( label="Aaron eeS",
                                       variable=self.helpVar5 )
        self.mb.menu.add_checkbutton ( label="Tom Arm",
                                       variable=self.helpVar6 )
        self.mb.menu.add_checkbutton ( label="Jamie Beee",
                                       variable=self.helpVar7 )
        self.mb.menu.add_checkbutton ( label="John Wee",
                                       variable=self.helpVar8 )
        

    def createsLoginButton (self):
        self.Button = Button (self, text="Login", command = self.loginPage,
                              relief=RAISED,font=("Arial", 8))
        self.Button.grid(row=2, column=1)
##HereHere
##HereHere
##Here
    def loginPage (self):
        logedInPage = Toplevel (master=None).minsize ( width=30,height=50)###I want to write text in the window created here
        w = Label (self, text("hi "))
        
                              
        


    
        
app = Application()
app.master.title("Wilson Messaging") 
app.mainloop()

Do you mean how to change the text explanation in the label or how to create an Entry or Text widget for entering information by the user?

Edited 6 Years Ago by pyTony: n/a

i mean when the window opens i want text to be in it so that you see the textin the window

Since I have no knowledge of Python GUI libraries whatsoever (only .NET's WPF and WinForms),
I searched "Toplevel" on google and got this:
http://effbot.org/tkinterbook/toplevel.htm

So will this work?

logedInPage = Toplevel()
logedInPage.minsize(width=30,height=50)
logedInPage.title("Message to You!")

msg = Message(logedInPage, text="Logged is misspelled.")
msg.pack()

Edited 6 Years Ago by jcao219: n/a

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