Bug 3808 - hgk: [ttk::style theme use] without theme name does not work on e.g. RHEL6
Summary: hgk: [ttk::style theme use] without theme name does not work on e.g. RHEL6
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: earlier
Hardware: PC Linux
: urgent bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-05 06:20 UTC by hakan.olsson
Modified: 2017-11-01 18:05 UTC (History)
4 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description hakan.olsson 2013-02-05 06:20 UTC
After switching to Ttk instead of Tk (changeset 0f93bbe8deb7), the following code causes an error on e.g. RHEL6 machines with Tk-8.5.7 installed:

$ cat -n /usr/bin/hgk | less
...
   109  # end of win32 section
   110  } else {
   111  
   112  if {[ttk::style theme use] eq "default"} {
   113      ttk::style theme use clam
   114  }
...

Apparently, 'ttk::style theme use' requires the extra arg in this Tk version (and asking for current theme may thus not be supported).

$ hg view
Error in startup script: wrong # args: should be "ttk::style theme use theme"
    while executing
"ttk::style theme use"
    invoked from within
"if {[tk windowingsystem] eq "win32"} {
...(etc)

For now I've worked around it by just removing the condition (lines 112+114).
Comment 1 kiilerix 2013-02-05 06:38 UTC
Regression.

Forwarded to author of http://selenic.com/hg/rev/0f93bbe8deb7 .
Comment 2 kiilerix 2013-02-05 07:44 UTC
Andew says:

Asked guys at #tcl, it
seems like the API has changed somewhere around 8.5.7, so the preferred
way of getting the current theme is now [ttk::style theme use], while
the deprecated (but still working) is $::ttk::currentTheme. So this
patch will probably fix the issue.

From: Andrew Shadura <bugzilla@tut.by>
Date: Tue, 05 Feb 2013 12:58:21 +0100

ttk: Support the old way of getting the current Ttk theme: ::ttk::currentTheme

diff --git a/contrib/hgk b/contrib/hgk
--- a/contrib/hgk
+++ b/contrib/hgk
@@ -109,7 +109,12 @@ bind all <MouseWheel> [list ::tk::MouseW
 # end of win32 section
 } else {
 
-if {[ttk::style theme use] eq "default"} {
+if {[catch {
+    set theme [ttk::style theme use]
+}]} {
+    set theme $::ttk::currentTheme
+}
+if {$theme eq "default"} {
     ttk::style theme use clam
 }
Comment 3 hakan.olsson 2013-02-05 10:13 UTC
Yup, with that diff hgk starts without problems.
Comment 4 kiilerix 2013-02-06 07:27 UTC
Patch is now in crew.
Comment 5 HG Bot 2013-02-07 07:45 UTC
Fixed by http://selenic.com/repo/hg/rev/7365d031d457
Andrew Shadura <bugzilla@tut.by>
hgk: support the old way of getting the current Ttk theme (issue3808)

It seems like the API has changed somewhere around 8.5.7, so the preferred way
of getting the current theme is now [ttk::style theme use], while the
deprecated (but still working) is $::ttk::currentTheme.

(please test the fix)