Re: What is the minimum number of lines to update a gui window without user clicking a button



On 08/11/2013 09:54 AM, Chris Vine wrote:
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
Thanks, Chris.

I learned from my previous thread how to actually update the gui window. I agree that I don't have the terminology to put it into technical words how it's done. But that part is very simple. I believe you're still trying to answer that question in this new thread. I believe you think that I'm ungrateful for not changing to the conversation.

You're also responding to an example I showed you about sending something to the console. You're trying to change the discussion to how to best react with the system, since the few lines of a 500 line program had a system call in it. I appreciate also that part of the discussion. But I have already mentioned that I have 10's of programs. That particular example that I should is the only popen() call in all my 10's of C++ program. If I spent a lot of time on using gtkmm to replace that call, I'm still lost with my question of how to update a gui window. I'm just trying to stay focus on this.

I understand that you might have reasons for not wanting to discuss that part of my question. It might be too basic for you, or it might be to complex for you to fill that you can relate it to me. But outputing and updating a gui window is what I'm hoping to have addressed by people willing to help, such as "Kjell's" references in the threads.


The gui output part, while described as being very complicated, I have learned from the previous thread is actually simple. At present I'm trying to learn how to apply that simplicity to Kjell's example. I believe responding to Kjell's recent message might help me to clarify where I'm stuck. I'm actually trying to figure out how to blank out everything that I won't be using in the simplest example that will allow me to have a textview window and at will, append to it.

I have it working at this time. I'm trying to clean up my example and share it with the group, and hopefully get some educated opinions on how to clean it up.

I really appreciate you taking the time that you're taking to try to help. I don't take any message or any suggestion lightly. But again, some of them are not focus directly on the actual point where I'm having problems, and I'm just trying to be clear.

You don't have to respond. But when I post my updated code before the day is over, I'd appreciate all the input I can get.

-- L. James

--
L. D. James
ljames apollo3 com
www.apollo3.com/~ljames


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]