[Librem-5-dev] PyGTK+ app development and testing on qemu image
rdmailings at duif.net
Wed Oct 30 00:29:12 PDT 2019
On 28/10/2019 14.56, David Boddie via Librem-5-dev wrote:
>> - In Android there is a clear "Activity Lifecycle": what to do when the
>> app is in view or not etc etc. In my case I would want to stop the mqtt
>> messaging while the app is not in focus.
>> But I could not find an PyGTK+ signal which is fired when my application
>> windows get's in focus or so. Did I miss something?
> I think you need to be looking at some of these:
> These are the ones that I would use to monitor the visibility of the
> application window.
Tried the signals of "Gtk.ApplicationWindow" could not receive anything
when I put my app in front the (phone) views....
But I'll also have a look at what LibHandy(?) would mean in this..
>> - While not having a real phone, is testing in the qemu VM a good way to
>> test? (looking at performance etc etc)... because:
> The VM does not perform as well as it should and it's not exactly clear to me
> why. You can also test in your own native workstation environment - assuming
> that you are using a GNU/Linux distribution. When you have got everything
> working, then you can worry about granting the permissions needed for the app
> to run on the phone. You can always generate flatpaks for testing on your
> host system if you want to make sure that you have the permissions set
My problem only appeared on the VM, on my workstation it was ok. But I
think I fixed it (see below). The problem (freezing the app interface)
did not occur when I ran it on my workstation. So I was puzzled...
Key issue I think in my problem is that the MQTT-client lib is started
in a separate thread and is (via signal) calling GTK-gui updates...
The Gnome docs about threading  made me try to use " GLib.idle_add"
see  and now the gui does not freeze anymore.
I can even put my laptop to sleep (with VM running on it) and the app
For future coders see  and  and do not update your gtk ui (like
labels etc) from a separate thread without the call I mentioned above.
Also when you let your 'update'-method return False, the call will only
be called once.
Hope this make sense to others :-)
Thanks for the help!
More information about the Librem-5-dev