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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:24:04+00:00 2026-05-28T00:24:04+00:00

(Python version: 3.1.1) I am having a strange problem with StringVar in tkinter. While

  • 0

(Python version: 3.1.1)

I am having a strange problem with StringVar in tkinter. While attempting to continuously keep a Message widget updated in a project, I kept getting an error while trying to create the variable. I jumped out to an interactive python shell to investigate and this is what I got:

>>> StringVar
<class 'tkinter.StringVar'>
>>> StringVar()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python31\lib\tkinter\__init__.py", line 243, in __init__
    Variable.__init__(self, master, value, name)
  File "C:\Python31\lib\tkinter\__init__.py", line 174, in __init__
    self._tk = master.tk
AttributeError: 'NoneType' object has no attribute 'tk'
>>>

Any ideas? Every example I have seen on tkinter usage shows initializing the variable with nothing sent to the constructor so I am at a loss if I am missing something…

  • 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-28T00:24:05+00:00Added an answer on May 28, 2026 at 12:24 am

    StringVar needs a master:

    >>> StringVar(Tk())
    <Tkinter.StringVar instance at 0x0000000004435208>
    >>> 
    

    or more commonly:

    >>> root = Tk()
    >>> StringVar()
    <Tkinter.StringVar instance at 0x0000000004435508>
    

    When you instantiate Tk a new interpreter is created. Before that nothing works:

    >>> from Tkinter import *
    >>> StringVar()
    Traceback (most recent call last):
      File "<input>", line 1, in <module>
      File "C:\Python26\lib\lib-tk\Tkinter.py", line 251, in __init__
        Variable.__init__(self, master, value, name)
      File "C:\Python26\lib\lib-tk\Tkinter.py", line 182, in __init__
        self._tk = master.tk
    AttributeError: 'NoneType' object has no attribute 'tk'
    >>> root = Tk()
    >>> StringVar()
    <Tkinter.StringVar instance at 0x00000000044C4408>
    

    The problem with the examples you found is that probably in the literature they show only partial snippets that are supposed to be inside a class or in a longer program so that imports and other code are not explicitly indicated.

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

Sidebar

Related Questions

I am having a problem with python lists. The simplified version is: mylist1 =
If I was going to start an open source project using Python what version
I am working to create a version of asteroids using Python and Tkinter. When
I am having the same problem as this thread regarding twilio-python : twilio.rest missing
I am having a problem installing the Python MySQL connector (MySQL-python-1.2.3c1) on my Mac
I'm having trouble setting up the correct python version for mod_wsgi / django setup.
I'm having the following problem in python. I need to do some calculations in
I am having trouble building a working version of Python with ctypes using the
I am unfortunately having to use python with version before 2.4 So I don't
I'm having a problem using imaplib on python 2.6 with the latest django svn.

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.