Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

tk::button on Mac: configure options ignored

59 views
Skip to first unread message

Aldo Buratti

unread,
Oct 2, 2017, 8:02:44 PM10/2/17
to
I just discovered that tk::buttons on Mac are not 'classic buttons'; they behave like native buttons, ignoring many configuration options.

Example: (wish 8.6.4)

tk::button .b -text Hello -bg red ; pack .b
will create a "white" button, despite that
.b get -bg
returns "red"

Is there a way to create 'standard/classic' buttons on Mac ?




Brad Lanam

unread,
Oct 2, 2017, 8:33:43 PM10/2/17
to
A 'label' and 'frame' (non-ttk) will accept background colors.

1) You could create a label with the appropriate bindings that acts like a button.

2) Create a frame wrapper around the button to act as a highlight color around the button (this doesn't really look that great, as there's also a grey border around the button, don't know if that can be removed).

3) Use some other non-aqua theme. This will freak out your users.

4) Add an image to your button that has the color. Swap out the image when the condition changes. (I use something like this -- I have some toggle buttons that have an image of an LED that is on or off).

aldo.www...@gmail.com

unread,
Oct 3, 2017, 6:12:58 AM10/3/17
to
Thanks Brad, I will follow your suggestion 1)

Just for the full history, I need some "rounded buttons", i.e buttons with a partially transparent image; the background of this rounded-buttons should be adapted to the container's background color, i.e. if these rounded-buttons are placed in a "red" frame, then the background of these button should be set to red.

Up to now, this works (on Window/Linux) if this rounded-button is implemented as a "tk::button", but as noted before it does not work on Mac (since the tk::buttons background is fixed and unchangeable).

I will try to implement these rounded-buttons using the label widget (plus some bindings for Button-Pressed, Button-release, etc ..).


My only complaint is the the Tk reference manuals don't report this subtle difference about tk::button on Mac.

Gerald Lester

unread,
Oct 3, 2017, 8:40:29 AM10/3/17
to
From the button man page (button is the same as tk::button and the -bg
that you are using is short for -background):

PLATFORM NOTES

On Aqua/Mac OS X, some configuration options are ignored for the purpose
of drawing of the widget because they would otherwise conflict with
platform guidelines. The configure and cget subcommands can still
manipulate the values, but do not cause any variation to the look of the
widget. The options affected notably include -background and -relief.


--
+----------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald...@kng-consulting.net |
+----------------------------------------------------------------------+

Don Porter

unread,
Oct 3, 2017, 8:58:15 AM10/3/17
to
On 10/02/2017 08:02 PM, Aldo Buratti wrote:
> Is there a way to create 'standard/classic' buttons on Mac ?

You might be happier using X11 Tk on XQuartz?

--
| Don Porter Applied and Computational Mathematics Division |
| donald...@nist.gov Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|

Brad Lanam

unread,
Oct 3, 2017, 11:31:17 AM10/3/17
to
On Tuesday, October 3, 2017 at 5:58:15 AM UTC-7, Don Porter wrote:
> On 10/02/2017 08:02 PM, Aldo Buratti wrote:
> > Is there a way to create 'standard/classic' buttons on Mac ?
>
> You might be happier using X11 Tk on XQuartz?

Going that far wouldn't be necessary -- a different theme is generally all that's needed.

Brad Lanam

unread,
Oct 3, 2017, 11:42:01 AM10/3/17
to
If they need to be rounded, it will be difficult. Generally the rounded buttons in all the themes are using some sort of graphics to display that effect. You may end up having to writing your own ttk::style, using your own graphics to get the buttons you want.

If many of these widgets actually had transparent backgrounds, it would solve quite a few issues. I really wish label text would have a transparent backgrounds.

There are other annoying differences for the aqua theme on Mac. I dislike having the 'if $theme eq aqua' code in my application.

I outlined some of the issues with the mac here: http://wiki.tcl.tk/44444
Some are genuine bugs (some need verification), some issues on the mac just need to be dealt with in the code.

Aldo Buratti

unread,
Oct 3, 2017, 4:54:39 PM10/3/17
to
Thanks Brad, I'll take care of these differences.
I'm going to re-vitalize "Pod", one of my oldest widgets http://wiki.tcl.tk/19773, and I recently discovered that its look&feel is now damned ugly on Mac !

Aldo Buratti

unread,
Oct 3, 2017, 4:59:45 PM10/3/17
to
Thank you Gerald, I was wrong.
This confirm my opinion that TclTk manuals are excellent !
0 new messages