classification
Title: 2.7.7 ttk widgets not themed
Type: behavior Stage: resolved
Components: Tkinter, Windows Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zach.ware Nosy List: les.bothwell, loewis, python-dev, serhiy.storchaka, steve.dower, zach.ware
Priority: normal Keywords:

Created on 2014-06-04 23:18 by les.bothwell, last changed 2014-07-22 17:28 by python-dev. This issue is now closed.

Messages (15)
msg219775 - (view) Author: Les Bothwell (les.bothwell) Date: 2014-06-04 23:18
I developed a number of small apps using ttk in 2.7.6.  After installing 2.7.7 all the ttk widgets look like standard Tkinter ones.  I reverted to 2.7.6 and everything looks Ok again. (I tried reinstalling 2.7.7 again with the same result)
Windows 7 X64 using 32 bit python.
msg219779 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-06-05 04:49
Could you please provide minimal example?
msg219781 - (view) Author: Les Bothwell (les.bothwell) Date: 2014-06-05 07:29
The code below shows a "windows themed" button with 2.7.6 but a plain "tkinter" button with 2.7.7. Functionality is Ok both cases.

from win32api import GetMonitorInfo, MonitorFromWindow
from win32con import MONITOR_DEFAULTTONEAREST

from Tkinter import *
import ttk
root = Tk()
root.title("Get Desktop Size")      # set title
root.resizable(0, 0)                # disable resizing (also changes border)
root.attributes("-toolwindow", 1)   # remove max and min buttons

hwnd = int(eval(root.wm_frame()))   # get the root window handle
txDesk = StringVar()

def OnClick(*args):
    hMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST)
    Info = GetMonitorInfo(hMonitor)["Work"]
    txDesk.set("%d x %d" % (Info[2] - Info[0], Info[3] - Info[1]))


But1 = ttk.Button(root, text="Click me on each monitor", command=OnClick)
Lbl1 = ttk.Label(root, textvariable=txDesk, anchor="center")
txDesk.set('')
But1.pack(side=TOP)
Lbl1.pack(side=TOP)
root.mainloop()
msg219783 - (view) Author: Les Bothwell (les.bothwell) Date: 2014-06-05 07:57
Here's an even simpler example (from book: Modern Tkinter for busy python programmers).

from Tkinter import *
import ttk
root = Tk()
ttk.Button(root, text="Hello World!").grid()
root.mainloop()

I have screenshots of both progs for 2.7.6 and 2.7.7 if interested.
msg219785 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-06-05 08:17
Thanks. It looks themed on Linux. Looks as this is Windows specific issue.
msg219819 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-06-05 15:25
I can confirm this on the current 2.7 branch and, oddly, on a fresh build of v2.7.6.  This looks like it was caused by the way Tcl/Tk was compiled, specifically the 'COMPILERFLAGS=-DWINVER=0x0500' and 'OPTS=noxp' options which are supposed to be for Win2k support.  Removing just 'OPTS=noxp' causes a compilation failure (due to WINVER redefinition), but removing both makes ttk work properly.

Steve: how did you compile Tcl/Tk for the 2.7.7 installer?

Martin: how have you compiled Tcl/Tk for past installers?  In particular, Python 3.2's ttk works perfectly Win2k, but is properly themed on Windows 7, which leads me to believe that you did not use the 'Win2k compatibility' options.
msg219826 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-06-05 17:02
New changeset baac4ea2901b by Zachary Ware in branch '3.4':
Clean up Tcl/Tk building in the Windows buildbot scripts.
http://hg.python.org/cpython/rev/baac4ea2901b

New changeset b3063de0dbd9 by Zachary Ware in branch 'default':
Issue #21665: Don't use 'OPTS=noxp' when compiling Tk.
http://hg.python.org/cpython/rev/b3063de0dbd9
msg219856 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2014-06-05 23:29
I compiled with COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=0 for tcl and tix, and with just COMPILERFLAGS=-DWINVER=0x0500 DEBUG=0 for tk. These should have matched the buildbot scripts, and I'm fairly sure they haven't changed since 2.7.6, which means the newer tk/tcl versions probably need different options.
msg219859 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-06-06 01:58
Are you sure you didn't swap that; OPTS=noxp for Tk and no OPTS for the other two?  OPTS=noxp would do nothing for Tcl and Tix (and might cause errors, I'm not sure), and not giving OPTS=noxp along with WINVER=0x0500 would definitely have caused an error building Tk, cutting compilation short before most of ttk could be compiled (if I remember my test from this morning correctly).

(For the record, my testing this morning included completely fresh builds of the tip of 2.7 with Tcl/Tk 8.5.15, tip of 2.7 with Tcl/Tk 8.5.2, v2.7.6 (which had Tcl/Tk 8.5.2), and default with Tcl/Tk 8.6.1, all built using the buildbot scripts, and all showed Les's issue.  I removed the noxp option in each case, and ttk worked correctly in each. To me, that says that our buildbot scripts have been wrong for a long time, but fortunately Martin has been using better options when he has built installers in the past, though I'd still like confirmation on that before I make any changes to 2.7's buildbot scripts.  Since there's no concern about keeping Win2k compatibility on 3.4 and default, I went ahead and fixed those this morning.)
msg219910 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2014-06-07 03:35
You're right, I had OPTS for tk and tix. I think I'm going to modify my build scripts to use the buildbot scripts wherever possible. I also need to parameterise msi.py a bit so I don't have to modify it for releases.
msg219913 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2014-06-07 04:48
The buildbot scripts don't build tix and the build_tkinter.py script has a blatant error which prevents it from ever working (and old version numbers). I have no experience with the buildbots, but I don't see how they can possibly be producing correct builds of tk and friends.

Am I missing something?
msg219915 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-06-07 05:01
Tix was finally added to the pcbuild solution for 3.5 a couple months
ago, until that point it was never built on the buildbots.  If my
understanding of history is correct, build_tkinter.py has never been
used regularly, but was an initial push towards building Tcl/Tk/Tix
the same way OpenSSL is built in <3.4.  See #15968 and #21141 if you
want more information on the situation in 3.5.  The buildbot scripts
for 2.7 and 3.4 do build usable, debug versions of Tcl and Tk, though.
 The lack of Tix is hard to notice since there are absolutely no tests
for it yet.

I'm wary of backporting the Tcl/Tk/Tix building changes, especially to
2.7, but it should be possible to tack Tix onto the current buildbot
scripts.  I'll open an issue for that.
msg219917 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2014-06-07 05:16
That's fine for 2.7.

I'm working on streamlining the project files for 3.5 to make my life easier dealing with both installers and the multiple compiler situation, so I'll no doubt poke that project at some point until my grand vision of single-click-install-build-sign-test comes true :)
msg223675 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-07-22 17:17
2.7.8 seems fine and there haven't been any reports about Tkinter not working on Win2k yet, so I'll go ahead and change the 2.7 buildbot scripts and close the issue.
msg223677 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-07-22 17:28
New changeset 73fcf00b9e0c by Zachary Ware in branch '2.7':
Closes #21665: Don't use OPTS=noxp or -DWINVER=0x0500 when compiling Tcl/Tk
http://hg.python.org/cpython/rev/73fcf00b9e0c
History
Date User Action Args
2014-07-22 17:28:28python-devsetstatus: open -> closed
resolution: fixed
messages: + msg223677

stage: resolved
2014-07-22 17:17:43zach.waresetassignee: zach.ware
messages: + msg223675
2014-06-07 05:16:48steve.dowersetmessages: + msg219917
2014-06-07 05:01:57zach.waresetmessages: + msg219915
2014-06-07 04:48:05steve.dowersetmessages: + msg219913
2014-06-07 03:35:15steve.dowersetmessages: + msg219910
2014-06-06 01:58:35zach.waresetmessages: + msg219859
2014-06-05 23:29:51steve.dowersetmessages: + msg219856
2014-06-05 17:02:04python-devsetnosy: + python-dev
messages: + msg219826
2014-06-05 15:25:14zach.waresetnosy: + loewis
messages: + msg219819
2014-06-05 08:17:45serhiy.storchakasetmessages: + msg219785
2014-06-05 07:57:07les.bothwellsetmessages: + msg219783
2014-06-05 07:29:04les.bothwellsetmessages: + msg219781
2014-06-05 04:49:55serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg219779
2014-06-04 23:34:34ned.deilysetnosy: + zach.ware, steve.dower
2014-06-04 23:18:32les.bothwellcreate