I realized, that the "update" or "update idletasks" command can cause some performance issues when applied in a GUI.
For example: I need to use "update" in order to correctly get values from "winfo reqwidth". This causes a small delay that is perceptible.
The question is: Is there another way to get current values from "winfo reqwidth" without having to use "update"?
Many thanks
Alexandru
On 10/12/2021 11:05, Alexandru wrote:
I realized, that the "update" or "update idletasks" command can cause some performance issues when applied in a GUI.
It matters whether you choose [update idletasks] or [update].
In my experience, a raw [update] is overkill in this case. It may do much more than just induce a
size computation, and therefore it could be a cause of an extra performance penalty.
Erik.
Erik Leunissen schrieb am Freitag, 10. Dezember 2021 um 13:12:10 UTC+1:
On 10/12/2021 11:05, Alexandru wrote:
I realized, that the "update" or "update idletasks" command can cause some performance issues when applied in a GUI.It matters whether you choose [update idletasks] or [update].
In my experience, a raw [update] is overkill in this case. It may do much more than just induce a
size computation, and therefore it could be a cause of an extra performance penalty.
Erik.
Yes, I know. In my specific case though, it make no difference.
Maybe it's a Windows thing. I don't know. But here is where the theory differs from the practice.
I realized, that the "update" or "update idletasks" command can cause some performance issues when applied in a GUI.
For example: I need to use "update" in order to correctly get values from "winfo reqwidth". This causes a small delay that is perceptible.
The question is: Is there another way to get current values from "winfo reqwidth" without having to use "update"?
Many thanks
Alexandru
* Alexandru <alexandr...@meshparts.de>Thanks Ralf.
| For example: I need to use "update" in order to correctly get values
| from "winfo reqwidth". This causes a small delay that is perceptible.
| The question is: Is there another way to get current values from
| "winfo reqwidth" without having to use "update"?
You could try to bind to the <Configure> event (widget changes size), or
to <Map> (widget gets displayed). With <Configure> you need to wait for
a notification where the size reported is > 1x1, so it might or might
not help, depending on your needs.
HTH
R'
On Friday, December 10, 2021 at 2:05:59 AM UTC-8, Alexandru wrote:appearance of sequential coding that may be easer to reason about it's correctness. For example:
I realized, that the "update" or "update idletasks" command can cause some performance issues when applied in a GUI.
For example: I need to use "update" in order to correctly get values from "winfo reqwidth". This causes a small delay that is perceptible.
The question is: Is there another way to get current values from "winfo reqwidth" without having to use "update"?
Many thanksIt has been my experience that the use of [update], in any form, is rarely the correct answer. The only time it is necessary is in a regression test, and even then it is often problematic.
Alexandru
I would first start by rethinking the problem and find a solution that does not require [update]. Ralf's suggestion is one example of a superior solution to using [update] when needing accurate geometry info.
For [update idletasks] I would suggest using [after idle] as a way to generate a one-time pseudo event to trigger the completion of a task after some prior "idle" task that was scheduled. [after idle] can be used within a coroutine to give the
wm deiconify $w
after idle [info coroutine]
yield
set geom [winfo geom $w]
...
return
Dear Alexandru,
please find here my 3 cents:
it is normally not the update, but program structure.
On each update, any event driven code may run.
So, if you have io events or after tasks - they may run within the
update and will cause an arbitrary delay.
If Tk has redraws pending, this will happen with the update.
So, here, update can be very slow, but then, the work is done.
Otherwise, the work would be done after your procedure and you would not measure it.
Take care,
Harald
Am 10.12.2021 um 13:27 schrieb Alexandru:
Erik Leunissen schrieb am Freitag, 10. Dezember 2021 um 13:12:10 UTC+1:
On 10/12/2021 11:05, Alexandru wrote:
I realized, that the "update" or "update idletasks" command can cause some performance issues when applied in a GUI.It matters whether you choose [update idletasks] or [update].
In my experience, a raw [update] is overkill in this case. It may do much more than just induce a
size computation, and therefore it could be a cause of an extra performance penalty.
Erik.
Yes, I know. In my specific case though, it make no difference.
Maybe it's a Windows thing. I don't know. But here is where the theory differs from the practice.
Ralf Fassel schrieb am Freitag, 10. Dezember 2021 um 12:13:20 UTC+1:
* Alexandru <alexandr...@meshparts.de>
| For example: I need to use "update" in order to correctly get values
| from "winfo reqwidth". This causes a small delay that is perceptible.
| The question is: Is there another way to get current values from
| "winfo reqwidth" without having to use "update"?
You could try to bind to the <Configure> event (widget changes size), or
to <Map> (widget gets displayed). With <Configure> you need to wait for
a notification where the size reported is > 1x1, so it might or might
not help, depending on your needs.
HTHThanks Ralf.
R'
I couldn't get the Configure binding working, which should have set a global variable. The vwait to this global variable never completed, meaning the global variable was never set so there was no <Configure> event.
I guess this has something to do with the fact, that I'm trying to display a "menu" type widget which blocks.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 285 |
Nodes: | 16 (2 / 14) |
Uptime: | 22:33:06 |
Calls: | 6,448 |
Files: | 12,050 |
Messages: | 5,254,122 |