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 7617293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:06:44+00:00 2026-05-31T03:06:44+00:00

I get the error NameError: global name ‘entryWidget’ is not defined in the following

  • 0

I get the error “NameError: global name ‘entryWidget’ is not defined” in the following piece of Python 3 tkinter code:

from tkinter import *
import tkinter

def displayText():
    tkinter.messagebox.showinfo("Tkinter Entry Widget", "Text value =" + entryWidget)

class Application(Frame):

    def createWidgets(self):

        root.title("TITLE")

        textFrame = Frame(root)
        entryLabel = Label(textFrame)
        entryLabel["text"] = "Enter the text:"
        entryLabel.pack(side=LEFT)

        entryWidget = Entry(textFrame)
        entryWidget["width"] = 50
        entryWidget.pack(side=LEFT)
        textFrame.pack()
        button = Button(root, text="Submit", command=displayText)
        button.pack()

        self.QUIT = Button(self)
        self.QUIT["text"] = "QUIT"
        self.QUIT["fg"] = "red"
        self.QUIT["command"] = self.quit
        self.QUIT.pack()


    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        self.createWidgets()

root = Tk()
app = Application(master=root)
app.mainloop()
root.destroy()

The code itself is designed to create a text box (with text next to it), an enter button for the text box and a quit button. When text is entered in the text box and enter is pressed then a message box should appear telling the user what they entered. The quit button just quits the script.

How can I fix the error I am getting (I am aware what the error means, just don’t know how to fix it in this scenario). Note that I am new to tkinter and GUI code.

  • 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-05-31T03:06:45+00:00Added an answer on May 31, 2026 at 3:06 am

    What about something like that:

    from tkinter import *
    import tkinter
    
    
    class Application(Frame):
    
        def createWidgets(self):
    
            root.title("TITLE")
    
            textFrame = Frame(root)
            entryLabel = Label(textFrame)
            entryLabel["text"] = "Enter the text:"
            entryLabel.pack(side=LEFT)
    
            self.entryWidget = Entry(textFrame)
            self.entryWidget["width"] = 50
            self.entryWidget.pack(side=LEFT)
            textFrame.pack()
            button = Button(root, text="Submit", command=self.displayText)
            button.pack()
    
            self.QUIT = Button(self)
            self.QUIT["text"] = "QUIT"
            self.QUIT["fg"] = "red"
            self.QUIT["command"] = self.quit
            self.QUIT.pack()
    
        def displayText(self):
            tkinter.messagebox.showinfo("Tkinter Entry Widget", "Text value =" + self.entryWidget.get())
    
        def __init__(self, master=None):
            Frame.__init__(self, master)
            self.pack()
            self.createWidgets()
    
    root = Tk()
    app = Application(master=root)
    app.mainloop()
    root.destroy()
    

    I don’t have tkinter here so I can’t check it. But I hope it will help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Python-coded AppEngine application, I'm getting the following error code: NameError: global name
I get: TemplateSyntaxError at /blog/post/test Caught NameError while rendering: global name 'forms' is not
In Python 2: raw_input() In Python 3, I get an error: NameError: name 'raw_input'
I am using following PHP code for trigger creation but always get error, please
When I try this code in Python 3.x, I get an error message that
Django's get_or_create function always cause get() returned more than one Model name error in
Why I get error with this query on my live server but not on
I use the following jquery statements but i get error in this function onGetDataSuccess(result)
I'm calling a sikuli function, inside Sikuli IDE, but I get this error NameError:
I have the following Python (3.2) code: from pygame import * class Application: def

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.