Jump from PyGTK to C GTK

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Jump from PyGTK to C GTK

Nils Söderman
Hello, i have been using glade to build a GUI, doing an app to fill the
entry-boxes with data. OK so far. But when i wanted to color the boxes
with help of PyGTK according to their content and did not succeed with
that i decided to start using c instead, where i have 20 years more
experience. But i fell on a simple detail, when in PyGTK i wanted a
pointer to an entrybox, using MyBox  = builder.get_object ( "MyBoxID" )
and tried to find an equivalent in GTK c i was in no luck. So, how to
exchange MyBox  = builder.get_object ( "MyBoxID" ) to c-acceptable code?
ALL the example code i have found uses pointer derived with a variant of
'new', not applicable using glade! PLEASE point me right!

--
Nils Söderman    [hidden email]
Gråbergsvägen 15A

SE-752 40 Uppsala Sweden
Ph. +46 18 59 10 10
Ph. +46 18 55 28 27
Mob +46 707 25 30 69


_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: Jump from PyGTK to C GTK

Nicola Fontana-3
Il Tue, 7 Nov 2017 13:52:01 +0100 Nils Söderman <[hidden email]> scrisse:

> Hello, i have been using glade to build a GUI, doing an app to fill the
> entry-boxes with data. OK so far. But when i wanted to color the boxes
> with help of PyGTK according to their content and did not succeed with
> that i decided to start using c instead, where i have 20 years more
> experience. But i fell on a simple detail, when in PyGTK i wanted a
> pointer to an entrybox, using MyBox  = builder.get_object ( "MyBoxID" )
> and tried to find an equivalent in GTK c i was in no luck. So, how to
> exchange MyBox  = builder.get_object ( "MyBoxID" ) to c-acceptable code?
> ALL the example code i have found uses pointer derived with a variant of
> 'new', not applicable using glade! PLEASE point me right!

Hi,

the translation is basically 1:1.

    GtkEntry *MyBox = GTK_ENTRY(gtk_builder_get_object(builder, "MyBoxID"));

Ciao.
--
Nicola
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: Jump from PyGTK to C GTK

Thomas Rønshof
In reply to this post by Nils Söderman
Hi Nils,

Try something like this...

********************

        builder = gtk_builder_new ();
        gtk_builder_add_from_file (builder, "test2.glade", NULL);


        window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
        gtk_builder_connect_signals (builder, NULL);

        but=GTK_WIDGET (gtk_builder_get_object(builder,"print_button"));
        combo1=GTK_WIDGET (gtk_builder_get_object(builder,"combobox1"));
        entry1=GTK_WIDGET (gtk_builder_get_object(builder,"entry1"));

        gtk_widget_set_name(but,"but");
        gtk_widget_set_name(entry1,"entry");
        gtk_widget_set_name(window,"win");

        g_signal_connect (but, "clicked",
                    G_CALLBACK (do_print),
                    NULL);
        g_signal_connect (but, "button_press_event",
                    G_CALLBACK (do_double),
                    NULL);

        g_signal_connect (entry1, "focus-in-event",
                    G_CALLBACK (do_test),
                    NULL);
        g_signal_connect (combo1, "focus-in-event",
                    G_CALLBACK (do_test2),
                    NULL);

        g_signal_connect (window, "destroy",
                    G_CALLBACK (on_window_destroy),
                    NULL);


/Thomas


Den 11/07/2017 kl. 01:52 PM skrev Nils Söderman:

> Hello, i have been using glade to build a GUI, doing an app to fill
> the entry-boxes with data. OK so far. But when i wanted to color the
> boxes with help of PyGTK according to their content and did not
> succeed with that i decided to start using c instead, where i have 20
> years more experience. But i fell on a simple detail, when in PyGTK i
> wanted a pointer to an entrybox, using MyBox  = builder.get_object (
> "MyBoxID" ) and tried to find an equivalent in GTK c i was in no luck.
> So, how to exchange MyBox  = builder.get_object ( "MyBoxID" ) to
> c-acceptable code? ALL the example code i have found uses pointer
> derived with a variant of 'new', not applicable using glade! PLEASE
> point me right!
>


_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list