Re: Buttons with icons but without boxes on macOS and Tcl::pTk

2019-02-27 Thread Christopher Chavez


> On Feb 27, 2019, at 2:58 AM, welle Ozean via tcltk  wrote:
> 
> Hello,
> 
> using Tcl::pTk I want to move from the ttkButton to a plain clickable (png) 
> icon on gray background. I do not want the icon in a box, which is the 
> standard rendering of buttons, as far as I understand. This looks very odd 
> nowadays. At best, the icon should be accompanied by a test, as this 
> screenshot shows: https://ibb.co/dfYwKvM
> 
> On a mailing list I get the following Tcl/Tk answers:
> 
> 1) If you add -style Toolbutton to the ttk::button, the button will look flat 
> and modern. Adding "-compound top" will allow to specify both image and text.
> 
> 2)  set i1 [image create photo -file icon.png]
>  button .b -image $i1 -text Open -compound top -relief flat
>  pack .b
> Note that colors for the button widget and/or colors/transparency in 
> the png image will need to be adjusted so the icon and the button area 
> fit together seamlessly. 
> 
> No matter how many combinations I tried, I could not achieve my result (I 
> always had boxes around the icons, so that I think that Tcl::pTk does not 
> support much tweaking of the buttons. Has I guess this is the simplest way to 
> display icons on modern interfaces, maybe somebody here has already achieved 
> this result.
> 
> Welle


Hi Welle,

Are you trying this on Tk Aqua? If the ttk theme is set to the 'aqua' theme 
(the default), then it seems neither of those approaches yield box-less 
buttons. I suspect the repliers to your post on comp.lang.tcl were unaware of 
the behavior on aqua, since both approaches seem to work on Windows and 
X11—though on Windows the first approach (ttk Toolbutton) looks better because 
the buttons will actually highlight when hovered, while on X11 the second 
approach (flat regular button) looks better because it highlights without 
showing a raised border when hovered.

A workaround might be to use the first approach (the second approach seems 
unaffected) along with $mw->ttkSetTheme() to select a non-'aqua' ttk theme 
(such as the 'default' theme) for which the buttons render more properly, 
however this will affect *all* ttk widgets. Ideally a bug should be filed with 
Tcl/Tk requesting that Toolbuttons and flat-relief buttons be 
implemented/rendered properly on the 'aqua' theme.

The syntax for both approaches seems already supported in Tcl::pTk. For the 
first approach, use $mw->ttkButton(-style => 'Toolbutton', …). For the second 
approach, use $mw->Button(-relief => 'flat', …).

Hope this helps

Christopher Chavez

Buttons with icons but without boxes on macOS and Tcl::pTk

2019-02-27 Thread welle Ozean via tcltk
Hello,

using Tcl::pTk I want to move from the ttkButton to a plain clickable (png)
icon on gray background. I do not want the icon in a box, which is the
standard rendering of buttons, as far as I understand. This looks very odd
nowadays. At best, the icon should be accompanied by a test, as this
screenshot shows: https://ibb.co/dfYwKvM

On a mailing list I get the following Tcl/Tk answers:

1) If you add -style Toolbutton to the ttk::button, the button will look
flat and modern. Adding "-compound top" will allow to specify both image
and text.

2)  set i1 [image create photo -file icon.png]
 button .b -image $i1 -text Open -compound top -relief flat
 pack .b
Note that colors for the button widget and/or colors/transparency in
the png image will need to be adjusted so the icon and the button area
fit together seamlessly.

No matter how many combinations I tried, I could not achieve my result (I
always had boxes around the icons, so that I think that Tcl::pTk does not
support much tweaking of the buttons. Has I guess this is the simplest way
to display icons on modern interfaces, maybe somebody here has already
achieved this result.

Welle