Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7755807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:39:24+00:00 2026-06-01T12:39:24+00:00

This is a piece of code I write for this question: Entry text on

  • 0

This is a piece of code I write for this question: Entry text on a different window?

It is really strange what happened at mySubmitButton, it appears that the button does not want to appear when it is first started, it will, however appear when you click on it. Even if you click on it and release it away from the button, that way it won’t be send. I am suspecting if this only happen on a mac, or it only happen to my computer, because it is a very minor problem. Or it is something silly I did with my code.

self.mySubmitButton = tk.Button(top, text='Hello', command=self.send)
self.mySubmitButton.pack()

Am I missing something? I googled and found this question and answer on daniweb. And I do a diff on them, can’t figure out what he did “fixed”, but I did see the line is changed to command=root.quit. But it is different from mine anyway…

Here is the full source code, and there is no error message, but the button is just missing.

import tkinter as tk

class MyDialog:
    def __init__(self, parent):
        top = self.top = tk.Toplevel(parent)
        self.myLabel = tk.Label(top, text='Enter your username below')
        self.myLabel.pack()

        self.myEntryBox = tk.Entry(top)
        self.myEntryBox.pack()

        self.mySubmitButton = tk.Button(top, text='Hello', command=self.send)
        self.mySubmitButton.pack()

    def send(self):
        global username
        username = self.myEntryBox.get()
        self.top.destroy()

def onClick():
    inputDialog = MyDialog(root)
    root.wait_window(inputDialog.top)
    print('Username: ', username)

username = 'Empty'
root = tk.Tk()
mainLabel = tk.Label(root, text='Example for pop up input box')
mainLabel.pack()

mainButton = tk.Button(root, text='Click me', command=onClick)
mainButton.pack()

root.mainloop()

enter image description here

enter image description here

  1. Adding another button right after this one, the second one actually appear. I thought it might be because I didn’t call the same function, but I called the same one and it does the exact same thing it appears…
  2. Adding a empty label between them, doesn’t work. The button still isn’t being draw.

enter image description here

PS: I am using Mac OS 10.5.8, and Tk 8.4.7.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:39:26+00:00Added an answer on June 1, 2026 at 12:39 pm

    I see the hello button, but I’m on windows 7.

    I did a quick re-write of your example. I’ll be curious if it makes any difference for you.

    import tkinter as tk
    
    class GUI(tk.Tk):
        def __init__(self):
            tk.Tk.__init__(self)
    
            mainLabel = tk.Label(self, text='Example for pop up input box')
            mainLabel.pack()
    
            mainButton = tk.Button(self, text='Click me', command=self.on_click)
            mainButton.pack()
    
            top = self.top = tk.Toplevel(self)
            myLabel = tk.Label(top, text='Enter your username below')
            myLabel.pack()
    
            self.myEntryBox = tk.Entry(top)
            self.myEntryBox.pack()
    
            mySubmitButton = tk.Button(top, text='Hello', command=self.send)
            mySubmitButton.pack()
    
            top.withdraw()
    
        def send(self):
            self.username = self.myEntryBox.get()
            self.myEntryBox.delete(0, 'end')
            self.top.withdraw()
            print(self.username)
    
        def on_click(self):
            self.top.deiconify()
    
    gui = GUI()
    gui.mainloop()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote this piece of code that is supposed to redirect something written on
I'm trying to write a xml schema that will validate this piece of xml:
I'm trying to write a piece of code that will do the following: Take
I've wrote this simple piece of code. And I have a slight problem with
This piece of code compiles and runs as expected on GCC 3.x and 4.x:
This piece of code is from Adobe docs : package { import flash.display.Loader; import
This piece of code is supposed to go through a list and preform some
This piece of code gives a syntax error at the colon of elif process.loop(i,
This piece of code used to work in MVC 1 but it does not
this piece of code worked fine on my machine, but it doesn't on my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.