Widgets in GTK What are widgets? Widgets are data structures which house information about a user-interface objects. This in simple terms mean user-interface objects like buttons, text boxes, windows and combo-boxes. So let's see how we can create such widgets. To house these widgets, you'll need to create a GTK container. This container can be either vertical (GtkVBox) or horizontal (GtkHBox). In GtkHBox, all the widgets will align horizontally, while it will align vertically in the case of GtkVbox. We'll create a vertical container for our program.
Let's add a text entry widget to this box:
The above code creates a new GtkEntry widget, sets the text in the field to "Play with Strings" and adds it to the box. The code $box->pack_start($entry); is used to add the entry to the already created box. You can skip the $entry->set_text("Play with Strings") if you do not want to initialize the text and want a blank entry field. Now let's add a button:
This button which is created will have the text "Buttontext" on it. When the button is clicked, the function "buttonfunction" will be called to handle the click. Now how about a tool tip when the mouse hovers over the button?
You can set the Tooltips delay using $tt->set_delay(200) where 200 is amount of delay after which the tooltips will be displayed. You can set tool tips for each widget separately.
blog comments powered by Disqus |