php-gtk3
php-gtk3 copied to clipboard
How to make async Label update?
I'm experimenting here with browser app for Gemini protocol, and can't update GtkLabel text twice on activate event.
I want to write Loading... text in Label tray before page complete to load then update this label by Loading completed text.
By the fact, script uses last construction that overwrites first one
$this->tray->label->set_text('Loading...');
// ...request delay
$this->tray->label->set_text('Loading completed');
Is any ideas about multi-thread / async or maybe GTK solution for PHP?
PHP cannot do async actions without extensions. Maybe you need to install Swoole. This will work like a charm
If you dont want to install that, maybe you need verify every 1 sec for example
Gtk::timeout_add(1000, function () {
$this->tray->label->set_text('Loading...');
// ...request delay
$this->tray->label->set_text('Loading completed');
});
Thanks for advice, but timeout is not an option, because calculating page loading time in ms at this interval.
I'm beginner in GTK, but suppose, I can resolve this issue by using multiple events call - maybe attach Loading... to one event and Loading completed... to another one that finally do this request.