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,
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
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
I will try your suggestion for the sake of learning, [...]
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.
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?
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.
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
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:
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.
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:
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.
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.
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.
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.
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
As I follow this thread, I think, that adding a button within the
Tab-button might actually be the only reasonable approach.
As I follow this thread, I think, that adding a button within the
Tab-button might actually be the only reasonable approach.
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.
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)
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 theThat doesn't happen to me. The -command action works.
outer one, it will still go down on click, but not do the -command action.
I will probably use your solution. Thank you!
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 theThat doesn't happen to me. The -command action works.
outer one, it will still go down on click, but not do the -command
action.
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!
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 <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.
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...
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/
Tomorrow I could try it with some tclkit on a windows machine...
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.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 493 |
Nodes: | 16 (2 / 14) |
Uptime: | 35:05:05 |
Calls: | 9,740 |
Files: | 13,741 |
Messages: | 6,183,425 |