[Gambas-user] Control GUI (Qt5) Gambas program via Standard Input

james at lixce.com james at lixce.com
Sat Feb 11 05:21:33 CET 2023


I have been beating my head against this for literally years.

In my Gambas based desktop I want to pass data to programs via their Standard Input, for example when I run the weather program I want to pass data to the dock to update the current conditions displayed there.   I'm currently writing this data to a temp file and then sending a signal intercepted  by gb.Signal to prompt the dock to read the file. I have also used gb.inotify to watch for file changes.  Both of those solutions seem rather inelegant to me especially when StdIn is just hanging out doing nothing.

I was very excited to find the Application_Read event handler in the documentation but I have spent days trying to get it to fire without any success. 

I know the application is getting the input when I use:

echo "hello" > /proc/$(pgrep -f std-in-test)/fd/0

because it is echoed in the IDE console or Teminal but I cannot figure out how to intercept and process it.

Here is the code for std-in-test.gambas FMain

Public Sub _New()
  Label1.Text = Application.Id
End

Public Sub Application_Read()
  Debug "App_Read"
End

I've tried hundreds of variations of this.

I've also tried setting a file watch on /proc/Applicantion.Id/fd/0 but I end up with nothing or an endless loop.

Has anyone figured out how to intercept and process standard input in a Gambas 
GUI program?

NOT INTERESTED IN USING DBUS

Thank you for any suggestions.

Regards,
J. Jordan






More information about the User mailing list