• Need a work around for a bug with tk_setPalette

    From Donald Rozenberg@21:1/5 to All on Tue Jul 11 12:02:57 2023
    Hi,
    I am writing a Python GUI generator as a fork of a Tcl program and am up against a hard place because of a bug in tk_setPalette. tk_setPalette overwrites the foreground color of a text widget even when one is specified when the text widget is created.
    The bug is illustrated by the following code.

    "
    text .t -background #d9d9d9 -foreground black -relief ridge \
    -borderwidth 8 -padx 10 \
    -pady 10 -font {Helvetica -18 bold} -width 20 -height 5

    button .b -text tk_setPalette \
    -command "tk_setPalette background red foreground white"
    pack .t .b
    .t insert 1.0 "Hello\nWorld\n"
    .t insert end "A new line\n"
    "

    Notice that when the button is selected the background color is not changed but the foreground color is.

    I really need a workaround that will preserve the specified foreground color and will appreciate any suggestion.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From saitology9@21:1/5 to Donald Rozenberg on Wed Jul 12 05:23:21 2023
    On 7/11/2023 3:02 PM, Donald Rozenberg wrote:

    Notice that when the button is selected the background color is not changed but the foreground color is.

    I really need a workaround that will preserve the specified foreground color and will appreciate any suggestion.

    Not a bug but a documented feature. I believe tk_palette will not
    override widget settings that you have provided explicitly or whose
    values are system defaults. This behavior is explained in more detail in
    the man page. In summary, for options for which you want tk_palette
    settings, do not set widget options explicitly.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)