[Python] Using Glade 3.12 widgets in python

Discussão em 'Python' iniciado por Stack, Maio 29, 2025.

  1. Stack

    Stack Membro Participativo

    Just as some history, I have been using python for about 5 years now and have finally decided to make my first gui app in Glade.

    I started with something basic, I have a button, a Gtkentry and gtktextview This is what I am trying to accomplish:

    on button press, take from the text from gtk.entry and have it appended to the gtk.textview

    now the main problem I have is that I can not find descent documentation for how to use the widgets, and the examples I find on the Internet reference both a builder variation as well as another variation of glade project which I can only assume has been discontinued. I would like to learn how builder fits into the python / glade collaboration.

    my code so far:

    import gtk
    import pygtk

    def onDeleteWindow(self, *args):
    Gtk.main_quit(*args)

    def hello(button):
    text_buffer.set_text(txtinput.get_text())



    builder = gtk.Builder()
    builder.add_from_file("dagui.glade")

    handlers = {
    "onDeleteWindow": gtk.main_quit,
    "buttondown": hello
    }
    builder.connect_signals(handlers)

    textarea = builder.get_object("textview1")
    window = builder.get_object("window1")
    txtinput = builder.get_object("entry1")
    window.show_all()

    gtk.main()
    window.show_all()

    gtk.main()


    now this all works and pressing the button will print what ever is in the gtk.entry but I can not find how to append it to the textview. I also am not sure what to search for to find documentation, I tried "gtk builder gtk.textview" and pygtk build gtk.textview append" and all other variations.

    Though knowing how to simply add the text to the text view would be great, having a link to somewhere where I can get in plain english how to use these widgets I would be forever great-full.

    Continue reading...

Compartilhe esta Página