• Re: A button inside a button

    From et99@21:1/5 to Luc on Wed May 10 17:42:24 2023
    On 5/8/2023 5:55 PM, Luc wrote:
    I've more or less successfully created a button inside a button. I never
    knew it was possible, but it seems it is.

    I really like it except that the buttons (they will be tabs) ...

    Not sure what you are trying to do, but if by tabs you mean a notebook with tabs and each having a pane, I use BWidget's for that. In particular,

    https://wiki.tcl-lang.org/page/notebook


    I usually just start with one of the examples there.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luc@21:1/5 to All on Wed May 10 22:21:33 2023
    On Wed, 10 May 2023 17:42:24 -0700, et99 wrote:

    Not sure what you are trying to do,


    I was trying to do this:
    https://0x0.st/HNir.png


    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From et99@21:1/5 to Luc on Wed May 10 20:28:40 2023
    On 5/10/2023 6:21 PM, Luc wrote:
    On Wed, 10 May 2023 17:42:24 -0700, et99 wrote:

    Not sure what you are trying to do,


    I was trying to do this:
    https://0x0.st/HNir.png


    Here's how I might approach that using BWidget's (windows fonts):


    package require BWidget
    wm geom . 877x161+92+213

    set nb [NoteBook .nb -side top -bd 2 -font {{consolas bold italic} 12} ]

    foreach tab {notebook tiletable dragdrop2 ver} {
    $nb insert end $tab -text " $tab.tcl "
    }

    set pane [$nb getframe notebook]
    text $pane.hello -font {{comic sans MS} 20}
    $pane.hello insert end "hello notebook\nhere is some text"
    pack $pane.hello -fill both -side top -expand 1

    foreach {tab fill} {tiletable both dragdrop2 y ver x} {
    pack [ttk::button [$nb getframe $tab].foo -text "$tab-button"] -fill $fill -expand true
    }

    pack $nb -fill both -expand 1
    $nb raise notebook

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From et99@21:1/5 to All on Wed May 10 20:33:25 2023
    On 5/10/2023 8:28 PM, et99 wrote:
       package require BWidget
        wm geom . 877x161+92+213
        set nb [NoteBook .nb -side top -bd 2  -font {{consolas bold italic} 12} ]
        foreach tab {notebook tiletable dragdrop2 ver} {
            $nb insert end $tab -text "   $tab.tcl   "
        }
        set pane [$nb getframe notebook]
        text $pane.hello  -font {{comic sans MS} 20}
        $pane.hello insert end  "hello notebook\nhere is some text"
        pack $pane.hello  -fill both -side top -expand 1
        foreach {tab fill} {tiletable both dragdrop2 y ver x} {
            pack [ttk::button [$nb getframe $tab].foo -text "$tab-button"]  -fill $fill -expand true
        }
        pack $nb -fill both -expand 1
        $nb raise notebook

    Let me try to paste that again :(

    package require BWidget
    wm geom . 877x161+92+213

    set nb [NoteBook .nb -side top -bd 2 -font {{consolas bold italic} 12} ]

    foreach tab {notebook tiletable dragdrop2 ver} {
    $nb insert end $tab -text " $tab.tcl "
    }

    set pane [$nb getframe notebook]
    text $pane.hello -font {{comic sans MS} 20}
    $pane.hello insert end "hello notebook\nhere is some text"
    pack $pane.hello -fill both -side top -expand 1

    foreach {tab fill} {tiletable both dragdrop2 y ver x} {
    pack [ttk::button [$nb getframe $tab].foo -text "$tab-button"] -fill $fill -expand true
    }

    pack $nb -fill both -expand 1
    $nb raise notebook

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andreas Leitgeb@21:1/5 to Luc on Thu May 11 11:34:47 2023
    Luc <luc@sep.invalid> wrote:
    I will try your suggestion for the sake of learning, [...]

    You're welcome. That's what my comment was meant for.

    That "buttons inside buttons" is not a good design had been
    made clear by others already. Happy playing!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luc@21:1/5 to All on Thu May 11 10:58:51 2023
    On Wed, 10 May 2023 20:33:25 -0700, et99 wrote:

    Let me try to paste that again :(

    package require BWidget
    wm geom . 877x161+92+213

    set nb [NoteBook .nb -side top -bd 2 -font {{consolas bold italic} 12} ]

    foreach tab {notebook tiletable dragdrop2 ver} {
    $nb insert end $tab -text " $tab.tcl "
    }

    set pane [$nb getframe notebook]
    text $pane.hello -font {{comic sans MS} 20}
    $pane.hello insert end "hello notebook\nhere is some text"
    pack $pane.hello -fill both -side top -expand 1

    foreach {tab fill} {tiletable both dragdrop2 y ver x} {
    pack [ttk::button [$nb getframe $tab].foo -text "$tab-button"]
    -fill $fill -expand true }

    pack $nb -fill both -expand 1
    $nb raise notebook


    Thank you. But your design, like so many others, doesn't provide
    buttons for closing the tabs.


    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From saitology9@21:1/5 to Luc on Thu May 11 11:41:36 2023
    On 5/11/2023 9:58 AM, Luc wrote:


    Thank you. But your design, like so many others, doesn't provide
    buttons for closing the tabs.




    Button has a "-compound" option that lets you display text as well as an
    image. Perhaps this is what you have been after all long?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luc@21:1/5 to All on Thu May 11 14:46:48 2023
    On Thu, 11 May 2023 11:41:36 -0400, saitology9 wrote:

    On 5/11/2023 9:58 AM, Luc wrote:


    Thank you. But your design, like so many others, doesn't provide
    buttons for closing the tabs.


    Button has a "-compound" option that lets you display text as well as an image. Perhaps this is what you have been after all long?


    Yes, it can display an image, but I don't think that image can be
    "pushed" and run a command.

    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Luc on Thu May 11 18:26:40 2023
    Luc <luc@sep.invalid> wrote:
    On Thu, 11 May 2023 11:41:36 -0400, saitology9 wrote:

    On 5/11/2023 9:58 AM, Luc wrote:


    Thank you. But your design, like so many others, doesn't provide
    buttons for closing the tabs.


    Button has a "-compound" option that lets you display text as well as an
    image. Perhaps this is what you have been after all long?


    Yes, it can display an image, but I don't think that image can be
    "pushed" and run a command.

    It can, provided you check in the command linked to the button where
    the mouse cursor was positioned when the button was pressed.

    If the mouse cursor is positioned over the pixels that are the image,
    then "the image" was pushed, and your code can do something else other
    than what it would do if the cursor was not over the image.

    This falls down for keyboard traversal however, you don't have the
    mouse cursor above the button in that case. So if you need keyboard
    triggering to work, you'd have to find some other way.


    However, if all you are after is a "close button" why do the code
    examples under "Adding an icon to notebook tabs (i.e., close icon)" on
    the Tcl wiki not do what you want?

    https://wiki.tcl-lang.org/page/ttk%3A%3Anotebook

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luc@21:1/5 to Rich on Thu May 11 15:57:53 2023
    On Thu, 11 May 2023 18:26:40 -0000 (UTC), Rich wrote:

    Yes, it can display an image, but I don't think that image can be
    "pushed" and run a command.

    It can, provided you check in the command linked to the button where
    the mouse cursor was positioned when the button was pressed.

    If the mouse cursor is positioned over the pixels that are the image,
    then "the image" was pushed, and your code can do something else other
    than what it would do if the cursor was not over the image.

    This falls down for keyboard traversal however, you don't have the
    mouse cursor above the button in that case. So if you need keyboard triggering to work, you'd have to find some other way.


    However, if all you are after is a "close button" why do the code
    examples under "Adding an icon to notebook tabs (i.e., close icon)" on
    the Tcl wiki not do what you want?

    https://wiki.tcl-lang.org/page/ttk%3A%3Anotebook


    1. I would have to make three icons/images, one for "normal," one for
    "pushed" and another one for whenever the mouse pointer hovers over it
    and program all the three reactions accordingly because, well, because
    it's not a real button, it's a hack.

    2. None of the examples in the page you referred me to has working
    buttons. Some don't even have buttons at all.

    3. Experience has shown me that relying on pixel coordinates can be
    very unreliable. I, in the lofty capacity of Supreme Commander and
    Totalitarian Overseer Of This Here Application, hereby rule that such
    approach is not an acceptable option. There are others. I don't like
    them much either, but I think they're better than x/y coordinates.


    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From et99@21:1/5 to Luc on Thu May 11 12:39:23 2023
    On 5/11/2023 11:57 AM, Luc wrote:
    On Thu, 11 May 2023 18:26:40 -0000 (UTC), Rich wrote:

    Yes, it can display an image, but I don't think that image can be
    "pushed" and run a command.

    It can, provided you check in the command linked to the button where
    the mouse cursor was positioned when the button was pressed.

    If the mouse cursor is positioned over the pixels that are the image,
    then "the image" was pushed, and your code can do something else other
    than what it would do if the cursor was not over the image.

    This falls down for keyboard traversal however, you don't have the
    mouse cursor above the button in that case. So if you need keyboard
    triggering to work, you'd have to find some other way.


    However, if all you are after is a "close button" why do the code
    examples under "Adding an icon to notebook tabs (i.e., close icon)" on
    the Tcl wiki not do what you want?

    https://wiki.tcl-lang.org/page/ttk%3A%3Anotebook


    1. I would have to make three icons/images, one for "normal," one for "pushed" and another one for whenever the mouse pointer hovers over it
    and program all the three reactions accordingly because, well, because
    it's not a real button, it's a hack.

    2. None of the examples in the page you referred me to has working
    buttons. Some don't even have buttons at all.

    3. Experience has shown me that relying on pixel coordinates can be
    very unreliable. I, in the lofty capacity of Supreme Commander and Totalitarian Overseer Of This Here Application, hereby rule that such approach is not an acceptable option. There are others. I don't like
    them much either, but I think they're better than x/y coordinates.




    With BWidgets NoteBook, and the examples page, there's a snippit of code
    to add a right click popup menu to the active tab. Perhaps that might be
    how you could add a close. It would also allow you to add additional options
    as well.

    I see that ttk::notebook is the newer way to do tabs, but I've been using BWidgets for years and I also use their scrolled frames and windows. They
    are still my favorite mega-widgets.

    The following now includes a right-click close tab menu item:



    package require BWidget
    wm geom . 877x161+92+213

    set nb [NoteBook .nb -side top -bd 2 -font {{consolas bold italic} 12} ]

    foreach tab {notebook tiletable dragdrop2 ver} {
    $nb insert end $tab -text " $tab.tcl "
    }

    set pane [$nb getframe notebook]
    text $pane.hello -font {{comic sans MS} 20}
    $pane.hello insert end "hello notebook\nhere is some text"
    pack $pane.hello -fill both -side top -expand 1

    foreach {tab fill} {tiletable both dragdrop2 y ver x} {
    pack [ttk::button [$nb getframe $tab].foo -text "$tab-button"] -fill $fill -expand true
    }

    pack $nb -fill both -expand 1
    $nb raise notebook

    # make a popup menu for the tabs
    menu .popup -tearoff 0 -activeborderwidth 0
    .popup add command -label "close tab" -command [list close $::nb]

    # bind right mouse button to the popup menus
    $nb bindtabs <Button-3> [list popup .popup %X %Y]

    proc popup {win X Y pane} {
    # check to see if current click is on the top tab
    if {[string equal [$::nb raise] $pane]} {
    tk_popup $win $X $Y
    }
    }
    proc close {pathname} {
    set pane [$pathname raise] ;# current pane
    $pathname delete $pane
    $pathname raise [$pathname pages 0] ;# activate first one

    }

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luc@21:1/5 to All on Thu May 11 17:51:48 2023
    On Thu, 11 May 2023 12:39:23 -0700, et99 wrote:

    With BWidgets NoteBook, and the examples page, there's a snippit of code
    to add a right click popup menu to the active tab. Perhaps that might be
    how you could add a close. It would also allow you to add additional
    options as well.

    I see that ttk::notebook is the newer way to do tabs, but I've been using BWidgets for years and I also use their scrolled frames and windows. They
    are still my favorite mega-widgets.

    The following now includes a right-click close tab menu item:


    Thank you for the code and the discussion. I appreciate it.

    But I don't think it's fair with the user to require one additional pair
    of aim+click just to close a tab. I'm doing this for me too, of course,
    and I know I would hate to use that.

    Making my own tabs has these advantages:

    1. They will be more flexible about looks, behavior, features etc.
    For example: You want scrolling tabs? No problem. Multiple rows of tabs?
    No problem either. In fact, I believe no existing Tcl/Tk tab package or implementation has multiple rows. Keyboard traversal? Please. I can code something much better than basic keyboard traversal.

    2. I will be learning and having fun while at it. That's always good
    since it's the top priority.


    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Luc on Thu May 11 20:20:20 2023
    Luc <luc@sep.invalid> wrote:
    On Thu, 11 May 2023 18:26:40 -0000 (UTC), Rich wrote:

    Yes, it can display an image, but I don't think that image can be
    "pushed" and run a command.

    It can, provided you check in the command linked to the button where
    the mouse cursor was positioned when the button was pressed.

    If the mouse cursor is positioned over the pixels that are the image,
    then "the image" was pushed, and your code can do something else other
    than what it would do if the cursor was not over the image.

    This falls down for keyboard traversal however, you don't have the
    mouse cursor above the button in that case. So if you need keyboard
    triggering to work, you'd have to find some other way.


    However, if all you are after is a "close button" why do the code
    examples under "Adding an icon to notebook tabs (i.e., close icon)" on
    the Tcl wiki not do what you want?

    https://wiki.tcl-lang.org/page/ttk%3A%3Anotebook


    1. I would have to make three icons/images, one for "normal," one for "pushed" and another one for whenever the mouse pointer hovers over it
    and program all the three reactions accordingly because, well, because
    it's not a real button, it's a hack.

    Well, yes, that is what is involved in creating GUI's at the lower
    levels.

    2. None of the examples in the page you referred me to has working
    buttons. Some don't even have buttons at all.

    Interesting. I go to that page, scroll down to the referenced section,
    and paste this code (copied exactly from the wiki page) into a wish
    shell:

    bind TNotebook <ButtonPress-1> {+puts [%W identify %x %y]}
    catch {console show}
    ttk::style layout TNotebook.Tab {
    Notebook.tab -children {
    Notebook.padding -side top -children {
    Notebook.focus -side top -children {
    Notebook.text -side left
    Notebook.image -side right
    }
    }
    }
    }
    pack [ttk::notebook .nb] -fill both -expand true

    ttk::frame .nb.f1
    .nb add .nb.f1 -text {tab 1} \
    -image [image create photo -width 36 -height 36]

    I get this window appearing:

    https://0x0.st/HNKt.png

    Yes, the 'button' is blank, that is because the example just created a
    blank 36x36 image -- the example's intent is to substitute your own
    image.

    Then, by clicking the mouse on the "label" side, or on the "image"
    side, gives:

    % text
    image
    text
    image

    in the wish shell from the example binding.

    What's left by the example is the exercise of doing something different
    in the binding depending upon whether the 'identify' command says the
    text or the image was clicked.

    3. Experience has shown me that relying on pixel coordinates can be
    very unreliable. I, in the lofty capacity of Supreme Commander and Totalitarian Overseer Of This Here Application, hereby rule that such approach is not an acceptable option. There are others. I don't like
    them much either, but I think they're better than x/y coordinates.

    However, at some point in the stack, *everything* that is happening in
    a GUI relies on pixel coordinates. The difference with Tk is the
    existing widgets hide their internal pixel coordinates work from you.
    But if you want something that they don't provide, eventually, at some
    point, you'll often end up needing to use pixel coordinates to get done
    what you want to get done.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luc@21:1/5 to Rich on Thu May 11 17:58:51 2023
    On Thu, 11 May 2023 20:20:20 -0000 (UTC), Rich wrote:

    Interesting. I go to that page, scroll down to the referenced section,
    and paste this code (copied exactly from the wiki page) into a wish
    shell:

    Oh. That.

    Yes, I remember that. I ran it, it looked nothing like what I wanted
    (it doesn't even look like a button at all) and I dismissed it. My bad.

    Anyway, that approach still involves this problem I pointed out previously:

    1. I would have to make three icons/images, one for "normal," one for "pushed" and another one for whenever the mouse pointer hovers over it
    and program all the three reactions accordingly because, well, because
    it's not a real button, it's a hack.

    Well, yes, that is what is involved in creating GUI's at the lower
    levels.

    So both that solution and my solution require some building from scratch, neither is completely turnkey for my specific case so I guess I'll be
    better off writing from scratch. And in this case, I don't mind that at all.


    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From et99@21:1/5 to Luc on Thu May 11 15:24:29 2023
    On 5/11/2023 1:51 PM, Luc wrote:
    On Thu, 11 May 2023 12:39:23 -0700, et99 wrote:

    With BWidgets NoteBook, and the examples page, there's a snippit of code
    to add a right click popup menu to the active tab. Perhaps that might be
    how you could add a close. It would also allow you to add additional
    options as well.

    I see that ttk::notebook is the newer way to do tabs, but I've been using
    BWidgets for years and I also use their scrolled frames and windows. They
    are still my favorite mega-widgets.

    The following now includes a right-click close tab menu item:


    Thank you for the code and the discussion. I appreciate it.

    But I don't think it's fair with the user to require one additional pair
    of aim+click just to close a tab. I'm doing this for me too, of course,
    and I know I would hate to use that.

    Making my own tabs has these advantages:

    1. They will be more flexible about looks, behavior, features etc.
    For example: You want scrolling tabs? No problem. Multiple rows of tabs?
    No problem either. In fact, I believe no existing Tcl/Tk tab package or implementation has multiple rows. Keyboard traversal? Please. I can code something much better than basic keyboard traversal.

    2. I will be learning and having fun while at it. That's always good
    since it's the top priority.



    Turns out the newer version of BWidget's notebook (in magicsplat 8.6.13
    and BWidget 1.9.15) has right side images and a command callback.

    Here's the new code, with a * for an image (closest one I could find on
    the wiki to an X close button image)

    I'm leaving in the popup menu since that's still useful. Also, there's
    already built in a tab scroll with an arrow button on left or right side
    of notebook when the window is smaller.



    package require BWidget
    wm geom . 877x161+92+213

    set nb [NoteBook .nb -side top -bd 2 -font {{consolas bold italic} 12} -arcradius 8]

    set star [image create bitmap -data {
    #define plus_width 11
    #define plus_height 11
    static char plus_bits = {
    0x00, 0x00, 0x22, 0x02, 0x24, 0x01, 0xa8, 0x00, 0x70, 0x00, 0xfe,
    0x03, 0x70, 0x00, 0xa8, 0x00, 0x24, 0x01, 0x22, 0x02, 0x00, 0x00
    }
    }]

    foreach tab {notebook tiletable dragdrop2 ver} {
    $nb insert end $tab -text " $tab.tcl " -rimage $star -rimagecmd [list close $nb]
    }

    set pane [$nb getframe notebook]
    text $pane.hello -font {{comic sans MS} 20}
    $pane.hello insert end "hello notebook\nhere is some text"
    pack $pane.hello -fill both -side top -expand 1

    foreach {tab fill} {tiletable both dragdrop2 y ver x} {
    pack [ttk::button [$nb getframe $tab].foo -text "$tab-button"] -fill $fill -expand true
    }

    pack $nb -fill both -expand 1
    $nb raise notebook

    # make a popup menu for the tabs
    menu .popup -tearoff 0 -activeborderwidth 0
    .popup add command -label "close tab" -command [list close $::nb]

    # bind right mouse button to the popup menus
    $nb bindtabs <Button-3> [list popup .popup %X %Y]

    proc popup {win X Y pane} {
    # check to see if current click is on the top tab
    if {[string equal [$::nb raise] $pane]} {
    tk_popup $win $X $Y
    }
    }
    proc close {pathname args} {
    set pane [$pathname raise] ;# current pane
    $pathname delete $pane
    $pathname raise [$pathname pages 0] ;# activate first one

    }

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From et99@21:1/5 to Luc on Thu May 11 16:07:14 2023
    On 5/11/2023 4:00 PM, Luc wrote:
    On Thu, 11 May 2023 15:24:29 -0700, et99 wrote:

    Turns out the newer version of BWidget's notebook (in magicsplat 8.6.13
    and BWidget 1.9.15) has right side images and a command callback.

    Here's the new code, with a * for an image (closest one I could find on
    the wiki to an X close button image)

    I'm leaving in the popup menu since that's still useful. Also, there's
    already built in a tab scroll with an arrow button on left or right side
    of notebook when the window is smaller.


    Your code won't work for me.

    unknown option "-rimage"
    while executing
    "Widget::init NoteBook::Page $f $args"
    (procedure "::NoteBook::insert" line 10)
    invoked from within
    "::NoteBook::insert .nb end notebook -text { notebook.tcl } -rimage image1 -rimagecmd {close .nb}"
    ("eval" body line 1)
    invoked from within
    "eval [linsert $args 0 ::NoteBook::$cmd .nb]"
    (procedure ".nb" line 1)
    invoked from within
    "$nb insert end $tab -text " $tab.tcl " -rimage $star -rimagecmd [list close $nb]"
    ("foreach" body line 2)
    invoked from within
    "foreach tab {notebook tiletable dragdrop2 ver} {
    $nb insert end $tab -text " $tab.tcl " -rimage $star -rimagecmd [list close $nb]
    }"
    (file "buttons3.tcl" line 16)
    Compilation failed.


    I have BWidget 1.9.10. Maybe -rimage was added in a later version.
    This is exactly why I'm not a big fan of using packages.


    Yes, mine failed too, until I tried 1.9.15

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luc@21:1/5 to All on Thu May 11 20:00:32 2023
    On Thu, 11 May 2023 15:24:29 -0700, et99 wrote:

    Turns out the newer version of BWidget's notebook (in magicsplat 8.6.13
    and BWidget 1.9.15) has right side images and a command callback.

    Here's the new code, with a * for an image (closest one I could find on
    the wiki to an X close button image)

    I'm leaving in the popup menu since that's still useful. Also, there's already built in a tab scroll with an arrow button on left or right side
    of notebook when the window is smaller.


    Your code won't work for me.

    unknown option "-rimage"
    while executing
    "Widget::init NoteBook::Page $f $args"
    (procedure "::NoteBook::insert" line 10)
    invoked from within
    "::NoteBook::insert .nb end notebook -text { notebook.tcl } -rimage image1 -rimagecmd {close .nb}"
    ("eval" body line 1)
    invoked from within
    "eval [linsert $args 0 ::NoteBook::$cmd .nb]"
    (procedure ".nb" line 1)
    invoked from within
    "$nb insert end $tab -text " $tab.tcl " -rimage $star -rimagecmd [list close $nb]"
    ("foreach" body line 2)
    invoked from within
    "foreach tab {notebook tiletable dragdrop2 ver} {
    $nb insert end $tab -text " $tab.tcl " -rimage $star -rimagecmd [list close $nb]
    }"
    (file "buttons3.tcl" line 16)
    Compilation failed.


    I have BWidget 1.9.10. Maybe -rimage was added in a later version.
    This is exactly why I'm not a big fan of using packages.

    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From et99@21:1/5 to All on Thu May 11 16:45:30 2023
    On 5/11/2023 4:07 PM, et99 wrote:
    On 5/11/2023 4:00 PM, Luc wrote:
    On Thu, 11 May 2023 15:24:29 -0700, et99 wrote:

    Turns out the newer version of BWidget's notebook (in magicsplat 8.6.13
    and BWidget 1.9.15) has right side images and a command callback.

    Here's the new code, with a * for an image (closest one I could find on
    the wiki to an X close button image)

    I'm leaving in the popup menu since that's still useful. Also, there's
    already built in a tab scroll with an arrow button on left or right side >>> of notebook when the window is smaller.


    Your code won't work for me.

    unknown option "-rimage"
         while executing
    "Widget::init NoteBook::Page $f $args"
         (procedure "::NoteBook::insert" line 10)
         invoked from within
    "::NoteBook::insert .nb end notebook -text {   notebook.tcl  } -rimage image1 -rimagecmd {close .nb}"
         ("eval" body line 1)
         invoked from within
    "eval [linsert $args 0 ::NoteBook::$cmd .nb]"
         (procedure ".nb" line 1)
         invoked from within
    "$nb insert end $tab -text "   $tab.tcl  " -rimage $star  -rimagecmd [list close $nb]"
         ("foreach" body line 2)
         invoked from within
    "foreach tab {notebook tiletable dragdrop2 ver} {
          $nb insert end $tab -text "   $tab.tcl  " -rimage $star  -rimagecmd [list close $nb]
    }"
         (file "buttons3.tcl" line 16)
    Compilation failed.


    I have BWidget 1.9.10. Maybe -rimage was added in a later version.
    This is exactly why I'm not a big fan of using packages.


    Yes, mine failed too, until I tried 1.9.15


    Actually, from comparing download zips, it adds -rimage and friends
    in 1.19.12

    BTW Bwidgets is pure tcl, so you can modify it all you want. You can
    get it here:

    https://sourceforge.net/projects/tcllib/files/BWidget/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andreas Leitgeb@21:1/5 to All on Fri May 12 07:37:23 2023
    As I follow this thread, I think, that adding a button within the
    Tab-button might actually be the only reasonable approach.

    I start with some demo code:

    button .b -text "Button1 *" -command {puts B1}
    button .b.b -text "X" -command {puts X}
    pack .b ;# just anything to make .b visible, could be any GM.
    pack propagate .b 0; # avoid outer button to shrinkwrap around inner one
    pack .b.b -side right -padx 2 -pady 2

    I noticed a specific misbehaviour, namely:

    if you just move the mouse over the inner button and then back to the
    outer one, it will still go down on click, but not do the -command action.

    I think this is really a bug of Button's standard bindings, where
    element "window" of the "Priv" array gets overwritten in the <Leave>
    for the inner Button, but the outer Button remains in state "active".

    To work around this, the handler for the inner button's <Leave> should
    check the outer button's -state, and if it is "active", then send it
    an extra <Enter> (or just call the action for it)

    bind .b.b <Leave> {
    tk::ButtonLeave %W ;# default <Leave> action (for .b.b)
    set p [winfo parent %W]; # TODO add code to check, if parent is a button
    if {[$p cget -state] eq "active"} { tk::ButtonEnter $p } ;# the workround
    break ;# avoid default "Button <Leave>" event from being fired afterwards.
    }

    That should get it working, where .b.b is direct child of .b .

    This misbehaviour with "not receiving, but needing a new <Enter> after
    leaving the inner button" may be the reason, why all the Tab-widgets do
    not yet offer close-buttons on the tab-headers ... (merely speculating.)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From et99@21:1/5 to Andreas Leitgeb on Fri May 12 03:15:32 2023
    On 5/12/2023 12:37 AM, Andreas Leitgeb wrote:
    As I follow this thread, I think, that adding a button within the
    Tab-button might actually be the only reasonable approach.

    BWidget's supports images on the left and right side of tabs. The
    addition of the right side image was added in 2018 and would seem
    that it's motivation was to implement a tab close icon.

    However, Tk being Tk, rather than limit a right side image to
    just closing the tab it instead added 2 options

    -rimage image
    -rimagecmd command

    so one could use the right side image for any use.

    In 3 or 4 postings prior to this, I provided an example of how to use these two commands to implement a tab close option.

    It requires a recent version of BWidgets, however, 1.9.12 or later I believe.
    I know it works with 1.9.13 or later.

    I didn't look at the code, but my widget tree display utility shows the notebook
    uses both frame and canvas widgets. There are also 2 widgets where [winfo class]
    says ArrowButton, for scrolling tabs left/right.

    I didn't see any button widgets.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luc@21:1/5 to Andreas Leitgeb on Sat May 13 07:29:38 2023
    On Fri, 12 May 2023 07:37:23 -0000 (UTC), Andreas Leitgeb wrote:

    As I follow this thread, I think, that adding a button within the
    Tab-button might actually be the only reasonable approach.

    Finally, someone understands me! :-)



    I noticed a specific misbehaviour, namely:

    if you just move the mouse over the inner button and then back to the
    outer one, it will still go down on click, but not do the -command action.

    That doesn't happen to me. The -command action works.



    To work around this, the handler for the inner button's <Leave> should
    check the outer button's -state, and if it is "active", then send it
    an extra <Enter> (or just call the action for it)

    I'm not sure the fix is needed, but well, I guess it won't hurt either.


    Your solution looks really good. I didn't know about "pack propagate"!
    There is a lot about Tcl/Tk I haven't learned yet. :-\

    I will probably use your solution. Thank you!


    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andreas Leitgeb@21:1/5 to Luc on Mon May 15 10:07:21 2023
    Luc <luc@sep.invalid> wrote:
    On Fri, 12 May 2023 07:37:23 -0000 (UTC), Andreas Leitgeb wrote:
    if you just move the mouse over the inner button and then back to the
    outer one, it will still go down on click, but not do the -command action.
    That doesn't happen to me. The -command action works.

    I've retried with version 8.6.8 and still see it.

    But it all look fine, if the click only just causes the window to become
    active - e.g. if you were typing to the console before.

    click the "tab"-button, so the toplevel becomes active. and the -command
    is done. then, without letting the mouse move out of the tab-button,
    let it move over the "x" and back out of the "x" again, without ever
    leaving the boundaries of the tab-button. Now click it again, and it
    will go down on buttonpress will come up on release, but the -command
    won't fire.

    If you can't reproduce it, then please share the "info patchlevel"
    output from the tcl shell, so I can see if that has been already
    fixed since my (oldish) version.

    I will probably use your solution. Thank you!

    You're welcome!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luc@21:1/5 to Andreas Leitgeb on Mon May 15 14:13:37 2023
    On Mon, 15 May 2023 10:07:21 -0000 (UTC), Andreas Leitgeb wrote:

    Luc <luc@sep.invalid> wrote:
    On Fri, 12 May 2023 07:37:23 -0000 (UTC), Andreas Leitgeb wrote:
    if you just move the mouse over the inner button and then back to the
    outer one, it will still go down on click, but not do the -command
    action.
    That doesn't happen to me. The -command action works.

    I've retried with version 8.6.8 and still see it.

    But it all look fine, if the click only just causes the window to become active - e.g. if you were typing to the console before.

    click the "tab"-button, so the toplevel becomes active. and the -command
    is done. then, without letting the mouse move out of the tab-button,
    let it move over the "x" and back out of the "x" again, without ever
    leaving the boundaries of the tab-button. Now click it again, and it
    will go down on buttonpress will come up on release, but the -command
    won't fire.

    If you can't reproduce it, then please share the "info patchlevel"
    output from the tcl shell, so I can see if that has been already
    fixed since my (oldish) version.

    I will probably use your solution. Thank you!

    You're welcome!


    I haven't tried your button version yet because I've been focused on
    other parts of the GUI. I will probably implement them later today
    or maybe tomorrow.

    Meanwhile, pray tell, how do you "retry with version 8.6.8"? I mean,
    do you have multiple parallel Tcl installations that coexist without
    any clashes? I would like to have that and test my applications in
    older versions of Tcl/Tk to see if anything breaks.

    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Luc on Mon May 15 18:33:27 2023
    Luc <luc@sep.invalid> wrote:
    Meanwhile, pray tell, how do you "retry with version 8.6.8"? I mean,
    do you have multiple parallel Tcl installations that coexist without
    any clashes? I would like to have that and test my applications in
    older versions of Tcl/Tk to see if anything breaks.

    That is relatively easy to do, but you can't do so using your Linux distributions package manager.

    You need to compile Tcl/Tk yourself, and then install each version into
    a separate directory on your system. The "DESTDIR=" variable to make
    when doing make install helps quite a lot for this.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rolf Ade@21:1/5 to Rich on Mon May 15 23:34:27 2023
    Rich <rich@example.invalid> writes:
    Luc <luc@sep.invalid> wrote:
    Meanwhile, pray tell, how do you "retry with version 8.6.8"? I mean,
    do you have multiple parallel Tcl installations that coexist without
    any clashes? I would like to have that and test my applications in
    older versions of Tcl/Tk to see if anything breaks.

    That is relatively easy to do, but you can't do so using your Linux distributions package manager.

    You need to compile Tcl/Tk yourself, and then install each version into
    a separate directory on your system. The "DESTDIR=" variable to make
    when doing make install helps quite a lot for this.

    I typically do (in the unix directory of the source tree)

    ./configure --prefix=/some/place/you/prefer ?other options?

    (For a default build no "other options" are needed). If you have write
    rights to /some/place/you/prefer - I have a couples of tcl builds from
    8.4 (I think) until 9.0 with varius build options in a subtree somewhere
    below my home dir, for example - then just do

    make -j install

    and after thats finished all is in place and working.

    To have the according Tk build and installed is just two very similar
    commands away. In the unix directory of the Tk source tree do

    ./configure --with-tcl=/some/place/your/prefer/lib

    (note the /lib at the end of the path)

    make -j install

    Ready.

    Try

    /some/place/you/prefer/bin/wish8.6

    rolf

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andreas Leitgeb@21:1/5 to Rich on Mon May 15 22:16:16 2023
    Rich <rich@example.invalid> wrote:
    Luc <luc@sep.invalid> wrote:
    Meanwhile, pray tell, how do you "retry with version 8.6.8"? I mean,
    do you have multiple parallel Tcl installations that coexist without
    any clashes? I would like to have that and test my applications in
    older versions of Tcl/Tk to see if anything breaks.

    That is relatively easy to do, but you can't do so using your Linux distributions package manager.

    You need to compile Tcl/Tk yourself, and then install each version into
    a separate directory on your system. The "DESTDIR=" variable to make
    when doing make install helps quite a lot for this.

    It's even simpler... I have more than one PC ;-)

    That said, even with just one machine and sticking to the package manager,
    and not building my own versions, I could still have some tclkits...

    Anyway, my other machine has 8.6.11 and it shows the same symptoms.
    both machines are running Ubuntu linux.

    Tomorrow I could try it with some tclkit on a windows machine...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luc@21:1/5 to Andreas Leitgeb on Mon May 15 23:26:43 2023
    On Mon, 15 May 2023 22:16:16 -0000 (UTC), Andreas Leitgeb wrote:

    It's even simpler... I have more than one PC ;-)

    That said, even with just one machine and sticking to the package manager, and not building my own versions, I could still have some tclkits...

    Anyway, my other machine has 8.6.11 and it shows the same symptoms.
    both machines are running Ubuntu linux.

    Tomorrow I could try it with some tclkit on a windows machine...


    Where do you get your tclkits? I used to get them at equi4.com, but
    that was a loooong time ago...

    Or maybe I should try installing Tcl/Tk with stow:

    https://www.gnu.org/software/stow/


    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Luc on Tue May 16 03:22:51 2023
    Luc <luc@sep.invalid> wrote:
    On Mon, 15 May 2023 22:16:16 -0000 (UTC), Andreas Leitgeb wrote:

    It's even simpler... I have more than one PC ;-)

    That said, even with just one machine and sticking to the package manager, >> and not building my own versions, I could still have some tclkits...

    Anyway, my other machine has 8.6.11 and it shows the same symptoms.
    both machines are running Ubuntu linux.

    Tomorrow I could try it with some tclkit on a windows machine...


    Where do you get your tclkits? I used to get them at equi4.com, but
    that was a loooong time ago...

    Or maybe I should try installing Tcl/Tk with stow:

    https://www.gnu.org/software/stow/

    Try Roy Keene's Kit Creator:

    https://kitcreator.rkeene.org/kitcreator

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andreas Leitgeb@21:1/5 to Andreas Leitgeb on Thu May 18 09:55:20 2023
    Andreas Leitgeb <avl@logic.at> wrote:
    Tomorrow I could try it with some tclkit on a windows machine...

    That took a bit longer...

    On Windows (tclkit of version 8.6.10), the behaviour was even more weird:

    Additional to the not-execution of the "-command" (after moving over the
    inner button), it also happened that when clicking the outer button, then
    the inner one visually "disappeared", only to reappear again when next
    entering and leaving the region where the inner button had been.

    So, the workaround would have to be extended, to add code to the button-
    down and -up events for the outer button to force immediate re-appearance
    of the inner button.

    That was with normal buttons...

    with ttk::buttons, the "-side right" of pack gets ignored,
    and the inner button completely covers the outer one.

    This behaviour with ttk::button also shows on linux.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luc@21:1/5 to Andreas Leitgeb on Thu May 18 12:36:49 2023
    On Thu, 18 May 2023 09:55:20 -0000 (UTC), Andreas Leitgeb wrote:

    Andreas Leitgeb <avl@logic.at> wrote:
    Tomorrow I could try it with some tclkit on a windows machine...

    That took a bit longer...

    On Windows (tclkit of version 8.6.10), the behaviour was even more weird:

    Additional to the not-execution of the "-command" (after moving over the inner button), it also happened that when clicking the outer button, then
    the inner one visually "disappeared", only to reappear again when next entering and leaving the region where the inner button had been.

    So, the workaround would have to be extended, to add code to the button-
    down and -up events for the outer button to force immediate re-appearance
    of the inner button.

    That was with normal buttons...

    with ttk::buttons, the "-side right" of pack gets ignored,
    and the inner button completely covers the outer one.

    This behaviour with ttk::button also shows on linux.

    Many thanks for that too!

    I need some old Tclkits to run tests like these.

    Rich suggested Try Roy Keene's Kit Creator: https://kitcreator.rkeene.org/kitcreator

    But it keeps failing on me so I gave up. :-(

    Easily available Tclkits are missed.

    --
    Luc


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