get integer/real number from gtk_entry_set_text
- From: Rudra Banerjee <bnrj rudra yahoo com>
- To: gtk-app-devel-list gnome org
- Subject: get integer/real number from gtk_entry_set_text
- Date: Sat, 12 May 2012 21:01:39 -0400
Friends,
How can I convert gtk_entry_set_text to an integer/real number?
Below is a minimal example. Please suggest.
#include <stdio.h>
#include <gtk/gtk.h>
void enter_callback( GtkWidget *widget,
GtkWidget *entry )
{
gchar *entry_text;
entry_text = gtk_entry_get_text(GTK_ENTRY(entry));
printf("Entry contents: %s\n", entry_text);
}
int main( int argc,
char *argv[] )
{
GtkWidget *window;
GtkWidget *vbox, *hbox;
GtkWidget *entry;
GtkWidget *button;
GtkWidget *check;
GtkWidget *table;
gtk_init (&argc, &argv);
/* create a new window */
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW (window), "GTK Entry");
gtk_signal_connect(GTK_OBJECT (window), "delete_event",
(GtkSignalFunc) gtk_exit, NULL);
/* CREATE TABLE
*/
table = gtk_table_new (5, 3, TRUE);
gtk_container_add (GTK_CONTAINER (window), table);
/*
*CREATE ENTRY FOR ATOM 1
*/
entry = gtk_entry_new_with_max_length (2);
gtk_table_attach_defaults (GTK_TABLE (table), entry, 0, 1, 0, 1);
gtk_signal_connect(GTK_OBJECT(entry), "activate",
GTK_SIGNAL_FUNC(enter_callback),
entry);
gtk_entry_set_text (GTK_ENTRY (entry), "A");
gtk_widget_show (entry);
gtk_widget_show (button);
gtk_widget_show (table);
gtk_widget_show(window);
gtk_main();
return(0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]