LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   A good simple text display widget in GTK (not Label) (https://www.linuxquestions.org/questions/programming-9/a-good-simple-text-display-widget-in-gtk-not-label-312385/)

vharishankar 04-12-2005 08:26 AM

A good simple text display widget in GTK (not Label)
 
I am looking for a simple text display widget in GTK2 that will easily display the numbers in a calculator application that I'm creating.

I tried using GtkLabel. Too simple. I cannot set text and background colour for this widget.

I tried using GtkTextView. Here I could set the text and background colour, but too complex. I don't need a full editor where I cannot easily set/retrieve the text values.

I tried using GtkEntry. Here it is easy to use, but I cannot set the alignment to right (which is a prerequisite for displaying a calculator view.

Is there any other widget which I can use which I can:

1. Set the text and retrieve it with one simple function call.
2. Set the background and text colour?
3. Will have an option to text align right?

Thanks.

Harmaa Kettu 04-12-2005 10:42 AM

Quote:

I tried using GtkLabel. Too simple. I cannot set text and background colour for this widget.
You can! Put the label into a GtkEventBox and use gtk_widget_modify_* -functions on the eventbox.

Quote:

I tried using GtkEntry. Here it is easy to use, but I cannot set the alignment to right (which is a prerequisite for displaying a calculator view.
There is gtk_entry_set_alignment(), but it requires gtk 2.4 or newer.

vharishankar 04-12-2005 10:14 PM

Thank you, Harmaa Kettu, for the tip with regard to GtkEntry. It works now.

Gitti 05-18-2006 05:44 AM

GtkEntry
 
Quote:

Originally Posted by Harishankar
I am looking for a simple text display widget in GTK2 that will easily display the numbers in a calculator application that I'm creating.

I tried using GtkLabel. Too simple. I cannot set text and background colour for this widget.

I tried using GtkTextView. Here I could set the text and background colour, but too complex. I don't need a full editor where I cannot easily set/retrieve the text values.

I tried using GtkEntry. Here it is easy to use, but I cannot set the alignment to right (which is a prerequisite for displaying a calculator view.

Is there any other widget which I can use which I can:

1. Set the text and retrieve it with one simple function call.
2. Set the background and text colour?
3. Will have an option to text align right?

Thanks.

Hello,
I will set the color in a GtkEntry, but under SuSE 9.3 with KDE does not work.
My sourcecode:
entry = gtk_entry_new();
gtk_box_pack_start_defaults( GTK_BOX(vbox), GTK_WIDGET(entry));
gtk_entry_set_text( GTK_ENTRY(entry), "Zweites Editfeld" );
gdk_color_parse("red", &color);
gtk_widget_modify_text(entry, GTK_STATE_NORMAL, &color);

gtk_widget_show_all(GTK_WIDGET(fenster));

Who can help me? Thanks


All times are GMT -5. The time now is 07:38 PM.