GUI change started with Glade

I am just starting to learn Glade with pyGTK. Since Glade generates XML files instead of actual python code, is there a good way to start a project using Glade and then manually pipe the code or customize it?

Are there times or reasons it would be preferable to convey all of this rather than starting from the clearing?

+2


source to share


2 answers


The GUI built with glade is available in code in two ways: libglade or gtkbuilder. I can't comment much on the differences between the two other than that gtkbuilder is newer; there are many pages on google that show how to migrate from libglade to gtkbuilder.

Using gtkbuilder you can create your GUI object by extracting it from an XML file using gtkbuilder. This creates an object with all the settings specified in the clearing. You now have a GUI object that you can manipulate through its normal interface.



builder = gtk.Builder()
builder.add_from_file(glade_path)
builder.connect_signals(self)

main_window = builder.get_object("main_window")
main_window.show()

text_box1 = builder.get_object("textbox1")
text_box1.set_text("enter your name")

      

Line 3 shows how signal handlers are attached when loaded from a clearing. Basically, it looks for the function you specified for the signal in the glade interface and is attached to it; if no function is specified, you will see a warning on the command line.

+4


source


How much do you know about the meadow and the piglet? Glade creates xml files, but you load them with gtk.Builder in python. You can easily customize any widgets created with polarization in python. Read these tutorials to see how you can do it better. You just need to learn more about pigment and glade and it will be obvious.



+2


source







All Articles