Python Forum
Gnome GUI with glade - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: Gnome GUI with glade (/thread-29465.html)



Gnome GUI with glade - ways - Sep-03-2020

Hi

I'm trying to get into Gnome GUI development. I've created a project in Builder and have a basic UI. My problem is getting access to the widgets created by a glade xml file.

With
> parent = self.get_active_window()

I can get the window. But how can I access the widgets in it?

import sys
import gi
import configparser

gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gio
from .window import BtproxipyGtkWindow

class Application(Gtk.Application):
    project_name = '*'
    config_path = None
    enabled = False
    debug = False

    def __init__(self):
        super().__init__(application_id='org.example.App',
                         flags=Gio.ApplicationFlags.FLAGS_NONE)

        # self.config_path = appdirs.user_config_dir(self.project_name) + '.ini'
        self.config_path = '/home/user/.config/' + self.project_name + '/' + self.project_name + '.ini'

    def do_activate(self):
        win = self.props.active_window
        if not win:
            win = BtproxipyGtkWindow(application=self)
        win.present()

        parent = self.get_active_window()

def main(version):
    app = Application()
    return app.run(sys.argv)