Search Results

Search found 10 results on 1 pages for 'gtkbuilder'.

Page 1/1 | 1 

  • Gtkbuilder subclasses

    - by Masterofpsi
    Hi all. I'm developing an application with Gtk and Glade. My impression is that it's common practice to create a subclass of GtkWindow for your main window, but I'm stuck on how I would construct my subclass from a GtkBuilder definition. Does anyone know how?

    Read the article

  • Creating widgets using GtkBuilder

    - by user72943
    I am using Glade to design a Box with widgets and then load these widgets into my UI at run-time. To create each Box with widgets at run-time, I create a new GtkBuilder, call add_from_string passing in the text from the .ui file Glade creates, and then use the object returned from get_object("box1") in the UI. I know I could create the widgets with code, but for now, I'd like to use the .ui files Glade creates. It seems inefficient though to instantiate a new GtkBuilder object and the wasted Window object for every Box I want to create. Is there a more efficient method to load .ui files without creating a new GtkWidget object and wasted Window object? Thanks, Vance

    Read the article

  • How to repeatedly show a Dialog with PyGTK / Gtkbuilder?

    - by Julian
    I have created a PyGTK application that shows a Dialog when the user presses a button. The dialog is loaded in my __init__ method with: builder = gtk.Builder() builder.add_from_file("filename") builder.connect_signals(self) self.myDialog = builder.get_object("dialog_name") In the event handler, the dialog is shown with the command self.myDialog.run(), but this only works once, because after run() the dialog is automatically destroyed. If I click the button a second time, the application crashes. I read that there is a way to use show() instead of run() where the dialog is not destroyed, but I feel like this is not the right way for me because I would like the dialog to behave modally and to return control to the code only after the user has closed it. Is there a simple way to repeatedly show a dialog using the run() method using gtkbuilder? I tried reloading the whole dialog using the gtkbuilder, but that did not really seem to work, the dialog was missing all child elements (and I would prefer to have to use the builder only once, at the beginning of the program). [SOLUTION] As pointed out by the answer below, using hide() does the trick. But one has to take care that the dialog is in fact destroyed if one does not catch its "delete-event". A simple example that works is: import pygtk import gtk class DialogTest: def rundialog(self, widget, data=None): self.dia.show_all() result = self.dia.run() def destroy(self, widget, data=None): gtk.main_quit() def closedialog(self, widget, data=None): self.dia.hide() return True def __init__(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("destroy", self.destroy) self.dia = gtk.Dialog('TEST DIALOG', self.window, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT) self.dia.vbox.pack_start(gtk.Label('This is just a Test')) self.dia.connect("delete-event", self.closedialog) self.button = gtk.Button("Run Dialog") self.button.connect("clicked", self.rundialog, None) self.window.add(self.button) self.button.show() self.window.show() if __name__ == "__main__": testApp = DialogTest() gtk.main()

    Read the article

  • How do I programmatically add a widget to a container created from GtkBuilder?

    - by Warner Young
    I've created a window that has some containers and widgets in it, and I want to add a new widget dynamically at run-time to one of the Vboxes in this window. So I have this code, which brings up the window: gtk_builder_add_from_file( g_builder, "window.xml", NULL ); mainwindow = GTK_WIDGET( gtk_builder_get_object( g_builder, "window" )); gtk_widget_show( mainwindow ); Then I create a new label, for example, and add it to one of the existing Vboxes, called "vbox_mid", like this: label = gtk_label_new( "Test label" ); vbox = GTK_WIDGET( gtk_builder_get_object( g_builder, "vbox_mid" )); gtk_box_pack_end( GTK_BOX( vbox ), label, TRUE, TRUE, 0 ); But this doesn't seem to work. I don't see a new label in the vbox. I have a feeling I'm missing something here, but I can't see what it is. I thought perhaps there was a special GtkBuilder call to add a widget dynamically, but I don't see anything that looks like that. I would really appreciate any help on this.

    Read the article

  • Gtk, whether destroying GtkBuilder destroies all the screens and widgets?

    - by PP
    Hi, Question regarding GtkBuilder. When we unref builder pointer does it destroys all the screens/widgets the builder had created? if( builder_ptr ) g_object_unref(G_OBJECT(builder_ptr)); Suppose we have created one screen using Glade/XML with some 2-3 top_level windows in it gtk_builder_add_from_file(builder_ptr, "Test.glade", &error ) and generated GtkBuilder pointer (as above) so after deleting this pointer does it deletes created Windows or do we need to manually delete these windows? Thanks, PP.

    Read the article

  • Segmentation fault when running a python script/GTKBuilder app?

    - by pythonscript
    I'm trying to learn GUI programming using python2 and GTKBuilder, but I get a segmentation fault when I run the code. This is my file, created in Glade as a GTKBuilder file: <?xml version="1.0" encoding="UTF-8"?> <interface> <!-- interface-requires gtk+ 3.0 --> <object class="GtkWindow" id="mainWindow"> <property name="can_focus">False</property> <child> <object class="GtkBox" id="box1"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="orientation">vertical</property> <child> <object class="GtkBox" id="box2"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">start</property> <property name="margin_left">146</property> <property name="margin_right">276</property> <child> <object class="GtkLabel" id="label1"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="label" translatable="yes">label</property> </object> <packing> <property name="expand">True</property> <property name="fill">False</property> <property name="position">0</property> </packing> </child> <child> <object class="GtkEntry" id="entryName"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="margin_bottom">4</property> <property name="hexpand">True</property> <property name="vexpand">True</property> <property name="invisible_char">?</property> <property name="placeholder_text">Please enter your name here...</property> </object> <packing> <property name="expand">True</property> <property name="fill">True</property> <property name="position">1</property> </packing> </child> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> <property name="position">0</property> </packing> </child> <child> <object class="GtkButton" id="buttonWriteNameToFile"> <property name="label" translatable="yes">button</property> <property name="use_action_appearance">False</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="use_action_appearance">False</property> <signal name="clicked" handler="buttonWriteNameToFile_clicked" swapped="no"/> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> <property name="position">1</property> </packing> </child> <child> <placeholder/> </child> <child> <placeholder/> </child> </object> </child> </object> </interface> My python code, based on this question, is this: #!/usr/bin/env python import gtk class NameApp: def __init__(self): filename = "project.glade" builder = gtk.Builder() builder.add_from_file(filename) builder.connect_signals(self) builder.get_object("mainWindow").show_all() def buttonWriteNameToFile_clicked(self, widget): print("File write code...") if __name__ == "__main__": app = NameApp() gtk.main() Running the file with python2 yields this error: name.py:9: Warning: cannot create instance of abstract (non-instantiatable) type `GtkBox' builder.add_from_file(filename) ./geany_run_script.sh: line 5: 14897 Segmentation fault python2 "name.py" I thought I followed that example as closely as possible, and I don't see any differences outside of the GTKBuilder file. However, the example in the linked question runs successfully on my machine. I don't know if it's relevant, but I'm running Arch Linux x86_64.

    Read the article

  • Where can I find the gtk-builder-convert script?

    - by Marty
    I've built a small GUI app for work that uses some .glade files for pop-up windows. Recently, the ground beneath me was shifted - my environment was upgraded. Newer pyGTK versions require GTKBuilder and .xml files instead of Glade and .glade files and now my poor app is broken. I need to convert the .glade file to the newer .xml file. Problem is Glade-3 is not on our system, and I can't find gtk-builder-convert on the web. I've looked at the Gnome GIT Browser, don't know where to start looking or how to search it. Would anyone be kind enough to point me to the gtk-builder-convert python script?

    Read the article

  • Gtk, Does deleting builder pointer deletes all the Widgets created using it.

    - by PP
    I am creating builder pointer as follows. GtkBuilder *builder_ptr; builder_ptr = gtk_builder_new(); if( ! gtk_builder_add_from_file(builder_ptr, "Test.glade", &error ) ) printf("\n Error Builder, Exit!\n"); and i am deleting this builder pointer as follows: g_object_unref(G_OBJECT(m_builder)); this builder pointer contains 2-3 GtkWindows and other widgets. So my question is that do i need to delete all the windows in this builder manually when i delete this builder or all the windows will get destroyed when i delete builder pointer. Thanks, PP.

    Read the article

1