Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #102601 > unrolled thread

Re: Simple tkinter query about creating a tk,StringVar() failure

Started byMRAB <python@mrabarnett.plus.com>
First post2016-02-07 01:52 +0000
Last post2016-02-07 01:52 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Re: Simple tkinter query about creating a tk,StringVar() failure MRAB <python@mrabarnett.plus.com> - 2016-02-07 01:52 +0000

#102601 — Re: Simple tkinter query about creating a tk,StringVar() failure

FromMRAB <python@mrabarnett.plus.com>
Date2016-02-07 01:52 +0000
SubjectRe: Simple tkinter query about creating a tk,StringVar() failure
Message-ID<mailman.54.1454809970.2317.python-list@python.org>
On 2016-02-07 00:38:14, paul.hermeneutic@gmail.com wrote:

>I know this may be more suited to the tutor list. I tried to
>subscribe, but no response yet.
>
>Why does this interactive instantiation fail when it seems to work
>when run in a script?
>
>(py35-64) C:\src\pygui>python
>Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:54:25) [MSC v.1900
>64 bit (AMD64)] on win32
>Type "help", "copyright", "credits" or "license" for more information.
>>>>  import tkinter as tk
>>>>  name = tk.StringVar()
>Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "C:\Program Files\Python35\lib\tkinter\__init__.py", line 329,
>in __init__
>     Variable.__init__(self, master, value, name)
>   File "C:\Program Files\Python35\lib\tkinter\__init__.py", line 233,
>in __init__
>     self._root = master._root()
>AttributeError: 'NoneType' object has no attribute '_root'
It's just down to the way that tkinter works.

It's normally called within a GUI program which has windows and an event 
loop, and it's trying to get the root (top-level) window, but there 
isn't one.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web