Re: Which widget that can show output?



"Mee Com" wrote:

I know that the widget which to use for create "input text" is
Gtkwidget *entry.
But I want to know that which widget that we can use for show
"output"? such as  I want to insert some input(text message)(such as
"hello world") to "Gtkwidget *entry" , and I want to show the output
in the same window(such as "hello world" will appear above the entry
widget") and after I insert some text to the entry widget again(such
as "how do you do"),I want this message append "hello world" in the
new line and show output like this......

(first input)        hello world
(second input)   how do you do

I had tried so many widgets,but I only found that the widget that can
use for show output is "dialog widget",which is not my point,because I
want the output to show in the same window widget,but "dialog widget"
will show the output in another window.
Which widget that can use for show output?(I don't think that I should
need to use stack,right?)
Could anybody help me,please?
Thank a lots to all of your advise!

Now I understand you as asking for two things:

1. which widget class to use for text output (of arbitrary size), where
   the text is to be appended frequently?
2. how to put a text input and a text output widget into the same
   window?

The answer to 1. is: you should use GtkTextBuffer to store your text
contents and GtkTextView to display them at an arbitrary size. You would
probably set the "editable" flag to FALSE to make the GtkTextView
read-only. User input would be entered via another GtkEntry only, as you
suggested. The contents of a GtkTextBuffer can be modified (appended,
inserted, cut, deleted, changed) by your program just as you desire.

Putting an input (GtkEntry) and output (GtkTextView) widget into the
same window is not a matter of which widget classes are used. It's
rather a matter of a proper layout, using (and understanding) the GTK+
layout containers. The simpliest way for a window with a single-line
GtkEntry and a multi-line GtkTextView would be to use a GtkVBox to
separate them. Additional GtkHBoxes or GtkTables would be required if
additional GUI elements like buttons or other are to be placed into the
same window.

For an introduction to / overview of GtkTextBuffer + GtkTextView see:
http://developer.gnome.org/doc/API/2.0/gtk/TextWidget.html

To make a GtkTextView read-only see:
http://developer.gnome.org/doc/API/2.0/gtk/GtkTextView.html#gtk-text-view-set-editable
http://developer.gnome.org/doc/API/2.0/gtk/GtkTextView.html#GtkTextView--editable

To understand how to put input and output widgets into the same window
(this is *essential* GTK+ programming knowledge!) see:
http://www.gtk.org/tutorial/ch-packingwidgets.html

For an overview of available container classes (including GtkVBox) see:
http://developer.gnome.org/doc/API/2.0/gtk/LayoutContainers.html



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