Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^2: Can GTK3 be driven externally?

by holandes777 (Scribe)
on Jan 30, 2020 at 17:18 UTC ( #11112115=note: print w/replies, xml ) Need Help??

in reply to Re: Can GTK3 be driven externally?
in thread Can GTK3 be driven externally?

Thank you, I am OK with socket programming. My question is: how do I blend the socket server with the GTK3 main loop?
What I am trying to do is to use the GTK3 window as a display attached to a server that receives messages and changes the display to what the messages say needs to be displayed.
Additionally, I'd like to have a button in GTK3 which would allow a user to select something.

Replies are listed 'Best First'.
Re^3: Can GTK3 be driven externally?
by haukex (Bishop) on Jan 30, 2020 at 17:50 UTC

    Disclaimer: This is still just from quick Googling, I actually haven't done this myself, but I hope these pointers help. It looks to me like you would set up a GSocketService which has an incoming event, get the GSocketConnection's GSocket file descriptor, and then register that with a GIOChannel via g_io_add_watch. It also appears that one can write a handler for the client in a blocking manner in a separate thread via GThreadedSocketService.

Re^3: Can GTK3 be driven externally?
by holandes777 (Scribe) on Jan 30, 2020 at 17:38 UTC
    As an example:
    I have a GTK3 display that displays 3 choices:
    However the backend system (another program) finds we are out of Rats, we do, however, have scorpions. The backend system contacts the display and sends a message "change the third button to Scorpions", without any user interaction at the display. The result:
Re^3: Can GTK3 be driven externally?
by Anonymous Monk on Feb 01, 2020 at 00:05 UTC
      Thanks for answering
      This almost certainly is what I need
      My application seg faulted, I will research why, but if you have a clue, please tell me!
      use Gtk3; my $window = Gtk3::Window->new ('toplevel'); my $button = Gtk3::Button->new ('Quit'); $button->signal_connect (clicked => sub { Gtk3::main_quit }); $window->add ($button); $window->show_all; my $id = Gtk3->timeout_add(1000, \&handler, $data); Gtk3::main; sub handler { my ($data) = @_; print "timed out ... \n"; # return 1 if you want the handler to be called again later # return 0 to stop the handler from being called again return 1; } result: perl Segmentation fault (core dumped)
      Thank you, I will check it out

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11112115]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2020-10-21 16:03 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (219 votes). Check out past polls.