Re: What is the minimum number of lines to update a gui window without user clicking a button
- From: Chris Vine <chris cvine freeserve co uk>
- To: "L. D. James" <ljames apollo3 com>
- Cc: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: What is the minimum number of lines to update a gui window without user clicking a button
- Date: Sun, 11 Aug 2013 14:54:30 +0100
On Sun, 11 Aug 2013 08:33:18 -0400
"L. D. James" <ljames apollo3 com> wrote:
[snip]
I appreciate all the tips from all the experts here. However, I can
tell from many of the comments that a lot of you are thinking I'm
trying to do something different that just learn how to work with a
blank window and add text to it.
I think we all understand that perfectly well. The problem you seem
to have difficulty in accepting is that you have to find a way of doing
that within the GUI's main loop. The numerous responses you have
received have all been for the purpose of showing you how to do this.
What your headline console test case does is launch a process using
popen() and then read its stdout in blocking mode and print it to the
console. You have two choices when faced with doing an equivalent to
this with a GUI:
1. Launch the child process asynchronously and connect that process's
file descriptors to your main loop. I suggested this, and pointed to
the tools glib provides for the purpose, which you thought inadequate
for your purposes. However, it is by far the easiest way to do it
because it avoids threads.
2. Launch the child process synchronously as your console application
does. This requires starting a new thread to carry out the blocking
operations and finding some mechanism (which could be Glib::Dispatcher
or which could more easily, if it is only text, be a pipe) to convey
in a thread-safe way the information you want to convey from the new
thread to the main loop thread.
What I have said is true of any common GUI system which runs its own
main loop, whether GTK+, Qt or Windows. Until you grasp the concept of
this you are going to struggle. You will end up programming by
coincidence and bafflement.
There is no need to respond to this post. But it does set out what
your two options are.
Chris
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]