Title: Entry text not set if all of 'Font', 'Foreground' and 'Justify' are set
Type: enhancement Stage: needs patch
Components: Documentation, Tkinter Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: bruno.dupuis, docs@python, gpolo, iarspider, serhiy.storchaka
Priority: normal Keywords:

Created on 2010-10-31 02:10 by iarspider, last changed 2012-11-30 19:51 by bruno.dupuis. This issue is now closed.

File name Uploaded Description Edit iarspider, 2010-10-31 02:10 Code to reproduce problem bruno.dupuis, 2012-11-30 13:34 updated to 3k, added traces.
Messages (9)
msg120030 - (view) Author: Ivan Razumov (iarspider) Date: 2010-10-31 02:10
OS: Windows 7 x86
Python: 2.6.4

An Entry with both Font and Foreground properties changed (i.e. not OS-default) does not display text set with textvariable.set method. 

Attached an example of such behavior.
msg120031 - (view) Author: Ivan Razumov (iarspider) Date: 2010-10-31 02:34
The bug only appears if "Align" is not "Left".
msg120032 - (view) Author: Ivan Razumov (iarspider) Date: 2010-10-31 02:34
Typo: align -> Justify
msg120151 - (view) Author: Ivan Razumov (iarspider) Date: 2010-11-01 18:23
The bug doesn't seem to be Windows-specific - tested on Ubuntu 10.10 (Python 2.6.6)
msg176685 - (view) Author: Bruno Dupuis (bruno.dupuis) Date: 2012-11-30 13:34
I updated the script to 3k. Now the behaviour is very odd :

Python 2.7: works only if `justify="right"` is commented out.

Python 3.3: Shroedinger-like behaviour (sometimes dead, sometimes alive, nobody knows before we check) whith `justify="right"`

Looks like some kind of race-condition or something, so this results may only be relevant on my hardware (2 yo low-end PC).

I'm not a tkinter expert, so even if the app code looks good I need someone that knows tk to double-check if there is some oddities in the script before we go further.
msg176689 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-11-30 14:49
I confirm this. The bug appears sporadically on 3.x.

When the entry displays text, self.entry1['textvariable'] is 'PY_VAR0'. When it does not, self.entry1['textvariable'] is '0' (actually the value of "text" parameter).

The bug is due to the fact that option "text" is applied after the option "textvariable". Due to string hash randomization it occurs in 50% on 3.3+ (and always or never on default 2.7, depending on other options used in this call). For work around this bug you should not use both "text" and "textvariable" keyword or dict parameters in one call. Probably it is worth to mention in the documentation (unfortunately the Tkinter documentation is almost non-existent).
msg176690 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2012-11-30 16:01
Calm down for a moment. This is just incorrect usage of Entry. There is no "text" parameter documented for this class (see its docstring, for a quick reference on that). Also, there is a lot of Tkinter documentation, the official one at can be found at, which includes links for further documentation.

This is actually unrelated to string hash randomization, it is only barely related to the unordered nature of the hash implementation. What actually happens is that the tk lib usually accepts abbreviations of parameter names. So specifying "text" and "textvariable" is the same for tk.
msg176699 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-11-30 18:15
> So specifying "text" and "textvariable" is the same for tk.

Thanks for clarifying.
msg176707 - (view) Author: Bruno Dupuis (bruno.dupuis) Date: 2012-11-30 19:51
Thank you for the review, Guilherme.
Date User Action Args
2012-11-30 19:51:19bruno.dupuissetmessages: + msg176707
2012-11-30 18:15:41serhiy.storchakasetmessages: + msg176699
2012-11-30 16:01:00gpolosetstatus: open -> closed
resolution: not a bug
messages: + msg176690
2012-11-30 14:50:15serhiy.storchakasetcomponents: + Tkinter
2012-11-30 14:49:49serhiy.storchakasetassignee: docs@python
type: behavior -> enhancement
components: + Documentation, - Tkinter

nosy: + docs@python, serhiy.storchaka
messages: + msg176689
stage: needs patch
2012-11-30 13:34:46bruno.dupuissetfiles: +
versions: + Python 2.7, Python 3.2, Python 3.3, Python 3.4, - Python 2.6
nosy: + gpolo, bruno.dupuis

messages: + msg176685
2010-11-01 18:23:03iarspidersetmessages: + msg120151
2010-10-31 02:34:41iarspidersetmessages: + msg120032
2010-10-31 02:34:30iarspidersettitle: Entry text not set if all of 'Font', 'Foreground' and 'Align' are set -> Entry text not set if all of 'Font', 'Foreground' and 'Justify' are set
2010-10-31 02:34:08iarspidersetmessages: + msg120031
2010-10-31 02:33:00iarspidersettitle: Entry text not set if both 'Font' and 'fg' are set -> Entry text not set if all of 'Font', 'Foreground' and 'Align' are set
2010-10-31 02:10:54iarspidercreate