resize window . width 170 height 123resize window .l width 170 height 56
* Mark Summerfield <m.n.summerfield@gmail.com>
| I'm developing a Tcl/Tk 9 app on Linux with menus and toolbars.
| The toolbars use a grid layout and I have a refresh_toolbars
| method for redoing the layout when the user resizes the
| window:
| bind . <Configure> [callback on_window_state_change]
--<snip-snip>--
| This works fine (if a bit flickery), but the binding is
| _not_ called when the maximize/restore button is clicked.
| Can this button be detected?
My guess would be to check the <Map> and <Unmap> events...
HTH
R'
I'm developing a Tcl/Tk 9 app on Linux with menus and toolbars.
The toolbars use a grid layout and I have a refresh_toolbars
method for redoing the layout when the user resizes the
window:
bind . <Configure> [callback on_window_state_change]
oo::define App method on_window_state_change {} {
if {$WindowWidth > 1} {
set height [winfo height .]
set width [winfo width .]
if {abs($WindowWidth - $width) > $::ICON_SIZE ||
abs($WindowHeight - $height) > $::ICON_SIZE} {
set WindowWidth $width
set WindowHeight $height
after idle [callback refresh_toolbars]
}
}
}
This works fine (if a bit flickery), but the binding is
_not_ called when the maximize/restore button is clicked.
Can this button be detected?
The problem was in my code. I _am_ getting the resize events
on maximize/restore.
And so I've simplified to:
oo::define App method on_window_state_change window {
if {$window eq "."} { after 100 [callback refresh_toolbars] }
}
But unfortunately this is also triggered by window _move_.
Is it possible to distinguish between a move event and a resize
event?
* Mark Summerfield <m.n.summerfield@gmail.com>
--<snip-snip>--
| <Configure> binding
| But unfortunately this is also triggered by window _move_.
| Is it possible to distinguish between a move event and a resize
| event?
man bind:
Configure
A Configure event is sent to a window whenever its size, position,
or border width changes, and sometimes when it has changed posi-
tion in the stacking order.
So I guess you would need to remember the width/height of your toplevel,
add %w %h to the binding, and detect changes in width/height in the
binding callback.
R'
On Thu, 30 Oct 2025 13:58:14 +0100, Ralf Fassel wrote:
* Mark Summerfield <m.n.summerfield@gmail.com>
--<snip-snip>--
| <Configure> binding
| But unfortunately this is also triggered by window _move_.
| Is it possible to distinguish between a move event and a resize
| event?
man bind:
Configure
A Configure event is sent to a window whenever its size, position,
or border width changes, and sometimes when it has changed posi-
tion in the stacking order.
So I guess you would need to remember the width/height of your toplevel,
add %w %h to the binding, and detect changes in width/height in the
binding callback.
R'
I finally got it to ignore moves & not to flicker.
I have to keep track of 3 variables:
# at startup
set RefreshingToolbars false
set MainX [winfo x .]
set MainWidth [winfo width .]
oo::define App method refresh_toolbars {} {
if {$RefreshingToolbars} { return }
set RefreshingToolbars true
try {
update
set main_x [winfo x .]
set main_width [winfo width .]
if {$MainX != $main_x && $MainWidth == $main_width} { return }
set MainX $main_x
set MainWidth $main_width
# grid toolbars user wants to see
# ...
} finally {
set RefreshingToolbars false
}
}
When I try it, resizing the main window triggers the configuration event
on the toolbar, moving the main window doesn't (because the tool bar
itself does not move inside the main window)
Christian
| Sysop: | DaiTengu |
|---|---|
| Location: | Appleton, WI |
| Users: | 1,075 |
| Nodes: | 10 (0 / 10) |
| Uptime: | 94:28:43 |
| Calls: | 13,798 |
| Calls today: | 1 |
| Files: | 186,989 |
| D/L today: |
6,264 files (1,782M bytes) |
| Messages: | 2,438,400 |