Python gi.repository.Gtk 模块,Builder() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用gi.repository.Gtk.Builder()

项目:yt-browser    作者:juanfgs    | 项目源码 | 文件源码
def update_list(self,search_result):
        """ Dynamically create widgets and place them on the video list """
        builder = Gtk.Builder()
        builder.add_from_string( self.video_item_string )
        url = search_result["snippet"]["thumbnails"]["default"]["url"]
        download_button = builder.get_object("download-button")
        convert_button = builder.get_object("convert-button")
        video_item_box = builder.get_object("video-item-box")
        video_thumbnail = builder.get_object("video-image")
        video_info = builder.get_object("video-info")
        download_button.connect("clicked",self.on_download_clicked, { "video_id": search_result["id"]["videoId"], "title": search_result["snippet"]["title"], "action": "download" })
        convert_button.connect("clicked",self.on_download_clicked, { "video_id": search_result["id"]["videoId"], "title": search_result["snippet"]["title"], "action": "convert" })

        response = urllib.request.urlopen(url)
        fname = "/tmp/yt-browser-thumb" + url.split("/")[-1]

        f = open(fname, "wb")
        f.write(response.read())
        f.close()
        response.close()
        video_thumbnail.set_from_pixbuf(Pixbuf.new_from_file(fname))

        video_info.set_markup(search_result["snippet"]["title"] )
        self.video_list.add(video_item_box)
项目:susi_linux    作者:fossasia    | 项目源码 | 文件源码
def __init__(self) -> None:
        super().__init__()
        builder = Gtk.Builder()
        builder.add_from_file(os.path.join(
            TOP_DIR, "glade_files/configure.glade"))

        self.window = builder.get_object("configuration_window")
        self.stt_combobox = builder.get_object("stt_combobox")
        self.tts_combobox = builder.get_object("tts_combobox")
        self.auth_switch = builder.get_object("auth_switch")
        self.snowboy_switch = builder.get_object("snowboy_switch")
        self.wake_button_switch = builder.get_object("wake_button_switch")

        self.init_auth_switch()
        self.init_tts_combobox()
        self.init_stt_combobox()
        self.init_hotword_switch()
        self.init_wake_button_switch()

        builder.connect_signals(ConfigurationWindow.Handler(self))
        self.window.set_resizable(False)
项目:Projects    作者:SilverLuke    | 项目源码 | 文件源码
def __init__(self, p, gui):
        builder = Gtk.Builder()
        builder.add_from_file(settings.PATH_UI_ROW)
        builder.get_object("project_name").set_text(p.name)

        self.row  = builder.get_object("project_row")
        self.menu = builder.get_object("popup_menu")
        self.p    = p
        p.spinner = builder.get_object("spinner")
        p.error   = builder.get_object("error")
        self.menu.set_relative_to(self.row)

        handlers = {
            "on_project_row_button_release_event" : (gui.handle_focus, self),
            "on_update_btn_clicked"         : (gui.pm.update, p, gui.set_status),
            "on_compile_btn_clicked"        : (gui.pm.compile, p, gui.set_status),
            "on_update_compile_btn_clicked" : (gui.pm.update_compile, p, gui.set_status),
            "on_settings_btn_clicked"       : (gui.project_window.modify, p),
            "on_open_btn_clicked"           : (gui.open_file_manager, p),
            "on_run_btn_clicked"            : (gui.run_project, p)
        }
        builder.connect_signals(handlers)
项目:ImunesExperimentExporter    作者:patriziotufarolo    | 项目源码 | 文件源码
def __init__(self):
        xml = "ImunesExpExporter.glade"

        self.glade = Gtk.Builder()
        self.glade.add_from_file(os.path.join(os.path.abspath(os.path.dirname(__file__)),xml))
        self.glade.connect_signals(self)
        self.experiments = self.getExperiments()

        go = self.glade.get_object

        self.window = window = go("main_window")
        experimentsList = go("experiments")
        containersList = go("containers")
        experimentsCtl = go("combo_experiments")
        containersCtl = go("tree_containers")
        window.set_title("IMUNES - Export/Import experiment")

        for k in self.experiments:
            experimentsList.append([k])

        experimentsCtl.set_active(0)
        window.show_all()
项目:dell-recovery    作者:dell    | 项目源码 | 文件源码
def base_toggled(self, widget):
        """Called when the radio button for the Builder base image page is
           changed"""
        base_browse_button = self.builder_widgets.get_object('base_browse_button')
        base_page = self.builder_widgets.get_object('base_page')
        wizard = self.widgets.get_object('wizard')
        label = self.builder_widgets.get_object('base_image_details_label')

        label.set_markup("")
        base_browse_button.set_sensitive(True)
        wizard.set_page_complete(base_page, False)

        if self.builder_widgets.get_object('iso_image_radio').get_active():
            self.file_dialog.set_action(Gtk.FileChooserAction.OPEN)
        elif self.builder_widgets.get_object('directory_radio').get_active():
            self.file_dialog.set_action(Gtk.FileChooserAction.SELECT_FOLDER)
        else:
            base_browse_button.set_sensitive(False)
            self.base_file_chooser_picked()
项目:dell-recovery    作者:dell    | 项目源码 | 文件源码
def fid_toggled(self, widget):
        """Called when the radio button for the Builder FID overlay page is changed"""
        wizard = self.widgets.get_object('wizard')
        fid_page = self.builder_widgets.get_object('fid_page')
        label = self.builder_widgets.get_object('fid_overlay_details_label')

        wizard.set_page_complete(fid_page, False)
        self.builder_widgets.get_object('add_dell_recovery_button').set_sensitive(False)

        if self.builder_widgets.get_object('builtin_radio').get_active():
            wizard.set_page_complete(fid_page, True)
            label.set_markup("<b>Builtin</b>: BTO Compatible Image")
            self.add_dell_recovery_deb = ''

        elif self.builder_widgets.get_object('deb_radio').get_active():
            if self.add_dell_recovery_deb:
                wizard.set_page_complete(fid_page, True)
            else:
                label.set_markup("")
            self.builder_widgets.get_object('add_dell_recovery_button').set_sensitive(True)
项目:MokaPlayer    作者:vedard    | 项目源码 | 文件源码
def __init__(self, album_playlist, row_activated, button_press_event, hide_header=False):
        self.album_playlist = album_playlist
        self.builder = Gtk.Builder()
        self.builder.add_from_file(self.GLADE_FILE)

        self.view = self.builder.get_object("view")
        self.grid_songs = self.builder.get_object("grid_songs")
        self.img_cover = self.builder.get_object("img_cover")
        self.lbl_album_name = self.builder.get_object("lbl_album_name")
        self.lbl_year = self.builder.get_object("lbl_year")
        self.header = self.builder.get_object("header")

        self.grid_songs.connect('row-activated', row_activated)
        self.grid_songs.connect('button-press-event', button_press_event)
        self.grid_songs.connect('focus-in-event', self.on_grid_songs_focus_in_event)

        if hide_header:
            self.view.remove(self.header)
        else:
            self.lbl_album_name.set_text(self.album_playlist.album.Name)
            self.lbl_year.set_text(self.album_playlist.album.Year)

        image_helper.set_image(self.img_cover, album_playlist.album.Cover, 220, 220)

        self._build_grid_songs()
项目:MokaPlayer    作者:vedard    | 项目源码 | 文件源码
def __init__(self, songs):
        self.songs = songs

        self.builder = Gtk.Builder()
        self.builder.add_from_file(self.GLADE_FILE)
        self.builder.connect_signals(self)

        self.window = self.builder.get_object("tagseditor_window")
        self.txt_Title = self.builder.get_object("txt_Title")
        self.txt_Artist = self.builder.get_object("txt_Artist")
        self.txt_ArtistAlbum = self.builder.get_object("txt_ArtistAlbum")
        self.txt_Album = self.builder.get_object("txt_Album")
        self.txt_TrackNumber = self.builder.get_object("txt_TrackNumber")
        self.txt_Year = self.builder.get_object("txt_Year")
        self.txt_Genre = self.builder.get_object("txt_Genre")
        self.txt_Added = self.builder.get_object("txt_Added")
        self.txt_Comment = self.builder.get_object("txt_Comment")
        self.txt_Length = self.builder.get_object("txt_Length")
        self.txt_Channels = self.builder.get_object("txt_Channels")
        self.txt_Bitrate = self.builder.get_object("txt_Bitrate")
        self.txt_Path = self.builder.get_object("txt_Path")

        self.load_text()
项目:SolStudio    作者:alianse777    | 项目源码 | 文件源码
def __init__(self):
        self.builder = Gtk.Builder()
        self.builder.add_from_file("main.xml")
        self.win = self.builder.get_object("window_main")
        self.win.connect("delete-event", self.exit)
        self.win.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("white"))
        self.win.show_all()
        self.prefix = "SolStudio"
        self.ws = 0 # TODO: workspaces
        self.ctrl = False
        self.completion = True
        self.saved = [True]
        self.buff = [None]
        self.FILE = [None]
        self.ident = 0
        self.connect()
        self.check_solc()
        self.reopen() # check for the last opened file
        Gtk.main()
项目:luminance    作者:craigcabrey    | 项目源码 | 文件源码
def __init__(self, bridge, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.bridge = bridge

        builder = Gtk.Builder()
        builder.add_from_resource(get_resource_path('ui/groups.ui'))
        builder.connect_signals(self)

        self.content = builder.get_object('content-wrapper')
        self.groups_list = builder.get_object('list')

        self.groups_list.add(ListBoxRow(phue.AllLights(self.bridge)))
        for group in self.bridge.groups:
            self.groups_list.add(ListBoxRow(group))

        self.add(self.content)
项目:nautilus-git    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def __init__(self, git_uri, window):
        self._window = window
        self._git = Git(git_uri)
        self._watchdog = WatchDog(self._git.dir)
        self._watchdog.connect("refresh", self._refresh)

        self._builder = Gtk.Builder()

        self._builder.add_from_resource('/com/nautilus/git/ui/location.ui')
        self._builder.connect_signals({
            "open_remote_clicked": self._open_remote_browser,
            "compare_commits_clicked": self._compare_commits,
            "popover_clicked": self._trigger_popover,
            "branch_clicked": self._update_branch
        })
        self._build_widgets()
项目:nautilus-git    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def __init__(self, git_uri, window):
        GObject.GObject.__init__(self)
        self._git = git_uri

        self._builder = Gtk.Builder()
        self._builder.add_from_resource('/com/nautilus/git/ui/branch.ui')
        self._builder.connect_signals({
            "on_cancel": self._close_window,
            "on_apply": self._update_branch,
            "branch_changed": self._validate_branch_name
        })

        self._window = self._builder.get_object("window")
        self._window.set_transient_for(window)
        self._build_main_widget()
        self._window.show_all()
项目:king-phisher-plugins    作者:securestate    | 项目源码 | 文件源码
def get_object(gtk_object):
    """
    Used to maintain a diction of GTK objects to share through the SFTP Client

    :param str gtk_object: The name of the GTK Object to fetch
    :return: The requested gtk object
    """
    global _builder
    if not _builder:
        _builder = Gtk.Builder()
    if not _gtk_objects:
        _builder.add_from_file(gtk_builder_file)
    if gtk_object in _gtk_objects:
        return _gtk_objects[gtk_object]
    else:
        _gtk_objects[gtk_object] = _builder.get_object(gtk_object)
        return _gtk_objects[gtk_object]
项目:gpt    作者:encarsia    | 项目源码 | 文件源码
def __init__(self):
        self.builder = Gtk.Builder()
        self.builder.set_translation_domain(cli.appname)

        #load tlcalculator and subordinated window glade files
        self.builder.add_from_file(cli.gladefile[0])
        self.builder.add_from_file(cli.gladefile[1])

        #initiate custom css
        #...encode() is needed because CssProvider expects byte type input

        with open(cli.stylesheet,"r") as f:
            css = f.read().encode()

        style_provider = Gtk.CssProvider()
        style_provider.load_from_data(css)

        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(),
            style_provider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
        )
项目:ACYLS    作者:worron    | 项目源码 | 文件源码
def __init__(self):
        # Load GUI
        self.builder = Gtk.Builder()
        self.builder.add_from_file(os.path.join(acyls.dirs['gui'], "toolbar.glade"))

        gui_elements = (
            'toolbar', 'add_color_toolbutton', 'remove_color_toolbutton', 'copy_color_toolbutton',
            'paste_color_toolbutton', 'save_settings_toolbutton', 'load_settings_toolbutton',
            'reset_settings_toolbutton', 'load_filter_toolbutton', 'save_filter_toolbutton',
            'save_as_filter_toolbutton', 'revert_filter_toolbutton', 'edit_filter_toolbutton'
        )
        self.gui = {element: self.builder.get_object(element) for element in gui_elements}

        self.buttons = [e for e in gui_elements if e != 'toolbar']

    # Support functions
项目:SafeEyes    作者:slgobinath    | 项目源码 | 文件源码
def create_gtk_builder(glade_file):
    """
    Create a Gtk builder and load the glade file.
    """
    builder = Gtk.Builder()
    builder.set_translation_domain('safeeyes')
    builder.add_from_file(glade_file)
    # Tranlslate all sub components
    for obj in builder.get_objects():
        if (not isinstance(obj, Gtk.SeparatorMenuItem)) and hasattr(obj, "get_label"):
            label = obj.get_label()
            if label is not None:
                obj.set_label(_(label))
        elif hasattr(obj, "get_title"):
            title = obj.get_title()
            if title is not None:
                obj.set_title(_(title))
    return builder
项目:kickoff-player    作者:jonian    | 项目源码 | 文件源码
def __init__(self, app):
    self.app    = app
    self.stack  = app.channels_stack
    self.filter = None

    self.channels = Gtk.Builder()
    self.channels.add_from_file(relative_path('ui/channels.ui'))
    self.channels.connect_signals(self)

    self.channels_box = self.channels.get_object('box_channels')
    self.stack.add_named(self.channels_box, 'channels_container')

    self.channels_filters = self.channels.get_object('list_box_channels_filters')
    self.channels_list    = self.channels.get_object('flow_box_channels_list')
    self.channels_list.set_filter_func(self.on_channels_list_row_changed)

    GLib.idle_add(self.do_initial_setup)
项目:sticky-notes    作者:rubyAce71697    | 项目源码 | 文件源码
def __init__(self):




        logger.debug(" Initializing the FIND object")
        self.builder = Gtk.Builder()
        d = os.path.abspath(os.path.join(os.path.dirname(__file__)))
        #print d
        d = os.path.join(d,"find.glade")
        #print d
        self.builder.add_from_file(d)
        self.find_window = self.builder.get_object("find_window")
        self.__search_entry = self.builder.get_object('searchentry1')
        self.find_window.set_can_focus(True)
        self.find_window.connect('delete_event',self.hide)
项目:gstation-edit    作者:fengalin    | 项目源码 | 文件源码
def __init__( self ):
        GObject.threads_init()

        self.config = SafeConfigParser(allow_no_value=True)
        config_base_path = os.path.expanduser('~/.config/gstation-edit')
        if not os.path.isdir(config_base_path):
            os.makedirs(config_base_path)
        self.config_path = os.path.join(config_base_path, 'settings.cfg')
        self.config.read(self.config_path)


        gtk_builder_file = os.path.join('gstation_edit/resources',
                                        'gstation-edit-one-window.ui')

        self.gtk_builder = Gtk.Builder()
        self.gtk_builder.add_from_file(gtk_builder_file)

        self.js_sniffer = JStationSniffer(sys.argv[0])
        self.midi_dlg = MidiSelectDlg(self.gtk_builder, self.config, self,
                                      self.js_sniffer,
                                      self.on_connected, self.quit)
        self.midi_dlg.gtk_dlg.connect('destroy', self.quit)
项目:gstation-edit    作者:fengalin    | 项目源码 | 文件源码
def __init__( self ):
        GObject.threads_init()

        self.config = SafeConfigParser(allow_no_value=True)
        config_base_path = os.path.expanduser('~/.config/gstation-edit')
        if not os.path.isdir(config_base_path):
            os.makedirs(config_base_path)
        self.config_path = os.path.join(config_base_path, 'settings.cfg')
        self.config.read(self.config_path)

        gtk_builder_file = os.path.join(DATA_ROOT_DIR,
                                        'gstation-edit-one-window.ui')

        self.gtk_builder = Gtk.Builder()
        self.gtk_builder.add_from_file(gtk_builder_file)

        self.main_window = MainWindow(sys.argv[0], self.config, self.gtk_builder)
        self.main_window.gtk_window.connect('destroy', self.quit)
项目:sound-organiser-offline-app    作者:nils-van-zuijlen    | 项目源码 | 文件源码
def __init__(self, parent=None):
        """
        Creates the main GtkWindow from template

        `parent` is the app stored in app.py
        """
        interface = Gtk.Builder()
        interface.add_from_file(realpath('glade_windows/window.glade'))

        interface.connect_signals(self)

        self.main_box = interface.get_object('main_box')
        self.main_widget = interface.get_object('main_window')

        self.main_widget.maximize()

        self.parent = parent
项目:duck-feed    作者:h0m3stuck    | 项目源码 | 文件源码
def on_finish_btn_clicked(self, btn):
        self.feed_manager.update_json()
        builder2 = Gtk.Builder()
        builder2.add_from_file('feed_reader.glade')
        builder2.connect_signals(ReaderHandler(builder2, self.feed_manager))
        window = builder2.get_object('reader_window')
        window.show_all()
项目:duck-feed    作者:h0m3stuck    | 项目源码 | 文件源码
def main():
    builder = Gtk.Builder()
    builder.add_from_file('main_window.glade')
    builder.connect_signals(MainHandler(builder, FeedManager()))

    window = builder.get_object('main_window')
    window.show_all()

    # Fix keyboard interrupt not working
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    Gtk.main()
项目:yt-browser    作者:juanfgs    | 项目源码 | 文件源码
def __init__(self, backend, *args, **kwargs):

        super().__init__(*args, application_id="org.gnome.ytbrowser",
                         flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE,
                         **kwargs
        )
        with open('/usr/share/YTBrowser/resources/ui/video-item.ui') as ui_file:
            self.video_item_string = ui_file.read()

        self.builder = Gtk.Builder()
        self.builder.add_from_file( '/usr/share/YTBrowser/resources/ui/yt-browser.ui')

        self.menubuilder = Gtk.Builder()
        self.menubuilder.add_from_file( '/usr/share/YTBrowser/resources/ui/menu.ui')

        self.builder.connect_signals(self)
        self.window = None

        #Get objects from ui file
        self.video_list = self.builder.get_object("video_list")
        self.progressbar = self.builder.get_object("progressbar")
        self.progress_dialog = self.builder.get_object("progress_dialog")
        self.settings_box = self.builder.get_object("settings_box")


         #the download queue
        self.download_queue = self.builder.get_object("download_queue")

        self.download_queue_scrolled_window = self.builder.get_object("download_queue_scrolled_window")
        self.download_queue_store = self.builder.get_object("download_queue_store")
        #set download_queue_columns
        #set download callback
        self.downloading_videos = []
        self.main_backend = backend
项目:yt-browser    作者:juanfgs    | 项目源码 | 文件源码
def get_video_item_widgets(self,widget):
        builder = Gtk.Builder()
        builder.add_from_string( self.video_item_string )
        return builder.get_object(widget)
项目:aniwall    作者:worron    | 项目源码 | 文件源码
def __init__(self, *files, elements=(), path=None):
        self.resource_path = path
        self.builder = Gtk.Builder()
        for file_ in files:
            self.builder.add_from_resource(self.resource_path + "ui/" + file_)
        self.gui = {element: self.builder.get_object(element) for element in elements}
项目:susi_linux    作者:fossasia    | 项目源码 | 文件源码
def __init__(self):
        builder = Gtk.Builder()
        builder.add_from_file(os.path.join(
            TOP_DIR, "glade_files/signin.glade"))

        self.window = builder.get_object("login_window")
        self.email_field = builder.get_object("email_field")
        self.password_field = builder.get_object("password_field")
        self.spinner = builder.get_object("signin_spinner")
        self.sign_in_button = builder.get_object("signin_button")
        self.sign_in_button.set_sensitive(False)

        builder.connect_signals(LoginWindow.Handler(self))
        self.window.set_resizable(False)
项目:susi_linux    作者:fossasia    | 项目源码 | 文件源码
def __init__(self):
        super().__init__()
        builder = Gtk.Builder()
        builder.add_from_file(os.path.join(TOP_DIR, "glade_files/susi_app.glade"))

        self.window = builder.get_object("app_window")
        self.user_text_label = builder.get_object("user_text_label")
        self.susi_text_label = builder.get_object("susi_text_label")
        self.root_box = builder.get_object("root_box")
        self.state_stack = builder.get_object("state_stack")
        self.mic_button = builder.get_object("mic_button")
        self.mic_box = builder.get_object("mic_box")
        self.listening_box = builder.get_object("listening_box")
        self.thinking_box = builder.get_object("thinking_box")
        self.error_label = builder.get_object("error_label")
        self.settings_button = builder.get_object("settings_button")

        listeningAnimator = ListeningAnimator(self.window)
        self.listening_box.add(listeningAnimator)
        self.listening_box.reorder_child(listeningAnimator, 1)
        self.listening_box.set_child_packing(listeningAnimator, False, False, 0, Gtk.PackType.END)

        thinkingAnimator = ThinkingAnimator(self.window)
        self.thinking_box.add(thinkingAnimator)
        self.thinking_box.reorder_child(thinkingAnimator, 1)
        self.thinking_box.set_child_packing(thinkingAnimator, False, False, 0, Gtk.PackType.END)

        builder.connect_signals(SusiAppWindow.Handler(self))
        self.window.set_default_size(300, 600)
        self.window.set_resizable(False)
项目:Gnome-Authenticator    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def shortcuts_dialog():
        if Gtk.get_major_version() >= 3 and Gtk.get_minor_version() >= 20:
            builder = Gtk.Builder()
            builder.add_from_resource('/org/gnome/Authenticator/shortcuts.ui')
            shortcuts = builder.get_object("shortcuts")
            return shortcuts
        return None
项目:Gnome-Authenticator    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def about_dialog():
        """
            Shows about dialog
        """
        builder = Gtk.Builder()
        builder.add_from_resource('/org/gnome/Authenticator/about.ui')

        dialog = builder.get_object("AboutDialog")
        return dialog
项目:Gnome-Authenticator    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def generate(self):
        Gtk.Box.__init__(self)
        self.builder = Gtk.Builder()
        self.builder.connect_signals({
            "on_unlock" : self.on_unlock
        })
        self.builder.add_from_resource('/org/gnome/Authenticator/login.ui')
        login_window = self.builder.get_object("loginWindow")
        settings.bind("locked", login_window, "no_show_all", Gio.SettingsBindFlags.INVERT_BOOLEAN)
        settings.bind("locked", login_window, "visible", Gio.SettingsBindFlags.GET)
        self.pack_start(login_window, True, False, 0)
项目:Dict-O-nator    作者:theawless    | 项目源码 | 文件源码
def __init__(self):
        """Get local settings from global settings. Get UI."""
        self.settings = copy.deepcopy(DictonatorSettings.settings)
        self.ui = Gtk.Builder()
        self.ui.add_from_file(CONFIG_DIALOG_UI_PATH)
项目:Dict-O-nator    作者:theawless    | 项目源码 | 文件源码
def __init__(self):
        """Constructor for UI handler."""
        GObject.Object.__init__(self)
        self.bottom_widget = Gtk.Builder()
        self.bottom_widget.add_from_file(BOTTOM_WIDGET_UI_PATH)
        # Get the plugin manager
        self.plugin_manager = DictonatorActionHandler(self.bottom_bar_text_changer, self.bottom_bar_handler)
        logger.debug('UI INIT')
项目:openanalysis    作者:OpenWeavers    | 项目源码 | 文件源码
def __init__(self, ds):
        """
        Constructor
        :param ds: Any data structure, which is an instance of DataStructureBase
        """
        self.ds = ds()  # Instantiate
        self.builder = gtk.Builder()
        self.builder.add_from_file(os.path.join(self.__package_directory, "sd.glade"))
        self.builder.connect_signals(self)
        self.map = [self.ds.insert, self.ds.delete, self.ds.find]
项目:sc-controller    作者:kozec    | 项目源码 | 文件源码
def load(self):
        """
        Performs whatever component needs to get loaded.
        Can be called multiple times without breaking anything, but returns
        True when called first time and then False every to signalize repeated
        call.
        """
        if self.loaded:
            return False
        self.builder = Gtk.Builder()
        self.builder.add_from_file(os.path.join(self.app.gladepath, self.GLADE))
        self.widget = self.builder.get_object(self.NAME)
        self.builder.connect_signals(self)
        self.loaded = True
        return True
项目:sc-controller    作者:kozec    | 项目源码 | 文件源码
def setup_widgets(self):
        self.builder = Gtk.Builder()
        self.builder.add_from_file(os.path.join(self.app.gladepath, self.GLADE))
        self.window = self.builder.get_object("KeyGrab")
        self.builder.connect_signals(self)
项目:sc-controller    作者:kozec    | 项目源码 | 文件源码
def setup_widgets(self):
        self.builder = Gtk.Builder()
        self.builder.add_from_file(os.path.join(self.app.gladepath, self.GLADE))
        lblItemIconName  = self.builder.get_object("lblItemIconName")
        vbChangeItemIcon = self.builder.get_object("vbChangeItemIcon")
        self.window = self.builder.get_object("Dialog")
        self.menu_icon = MenuIcon(None, True)
        vbChangeItemIcon.remove(lblItemIconName)
        vbChangeItemIcon.pack_start(self.menu_icon, False, True, 0)
        vbChangeItemIcon.pack_start(lblItemIconName, True, True, 0)
        self.builder.connect_signals(self)
        headerbar(self.builder.get_object("header"))
项目:sc-controller    作者:kozec    | 项目源码 | 文件源码
def setup_widgets(self):
        self.builder = Gtk.Builder()
        self.builder.add_from_file(os.path.join(self.app.gladepath, self.GLADE))
        self.window = self.builder.get_object("Dialog")
        self.builder.connect_signals(self)
项目:co2monitor    作者:nobodyinperson    | 项目源码 | 文件源码
def load_builder(self):
        # get a GTK builder
        self.builder = Gtk.Builder()
        # load the gladefile
        self.builder.add_from_file(self.config.get('gui-general','gladefile'))

    # set the config
项目:jcchess    作者:johncheetham    | 项目源码 | 文件源码
def __init__(self):

        glade_dir = gv.jcchess.get_glade_dir()
        self.glade_file = os.path.join(glade_dir, "comments.glade")
        self.move_list = jcchess.move_list.get_ref()

        # create comments window
        self.builder = Gtk.Builder()
        self.builder.set_translation_domain(gv.domain)
        self.builder.add_from_file(self.glade_file)
        self.builder.connect_signals(self)

        self.window = self.builder.get_object("comments_window")
        self.window.hide()

        self.moveno = 0  # the moveno the comment applies to

        tv = self.builder.get_object("comments_textview")
        tv.set_editable(True)
        tv.set_wrap_mode(Gtk.WrapMode.WORD)
        self.tb = tv.get_buffer()
        self.tb.connect("changed", self.text_changed)
        self.comment_list = []

    # user has closed the window
    # just hide it
项目:jcchess    作者:johncheetham    | 项目源码 | 文件源码
def show_debug_window(self, b):

        # window already exists and is hidden so just show it
        if self.window is not None:
            # "present" will show the window if it is hidden
            # if not hidden it will raise it to the top
            self.window.present()
            return

        # This is the first time the user has opened the engine debug
        # window so need to create it.
        self.builder = Gtk.Builder()
        self.builder.set_translation_domain(gv.domain)
        self.builder.add_from_file(self.glade_file)
        self.builder.connect_signals(self)

        self.window = self.builder.get_object("engine_debug_window")
        self.tv = self.builder.get_object("engine_debug_textview")
        self.tv.set_editable(False)
        self.tb = self.tv.get_buffer()
        self.tb.set_text(self.debug_text)
        self.debug_text = ""

        # used to type commands and send them to the engine
        self.cmd_entry = self.builder.get_object("engine_debug_entry")

        self.window.show_all()

        # scroll to end
        GObject.idle_add(self.scroll_to_end)
项目:jcchess    作者:johncheetham    | 项目源码 | 文件源码
def __init__(self):

        glade_dir = gv.jcchess.get_glade_dir()
        self.glade_file = os.path.join(glade_dir, "gamelist.glade")

        # create gamelist window
        self.builder = Gtk.Builder()
        self.builder.set_translation_domain(gv.domain)
        self.builder.add_from_file(self.glade_file)
        self.builder.connect_signals(self)

        self.window = self.builder.get_object("gamelist_window")
        self.treeview = self.builder.get_object("gamelist_treeview")
        self.liststore = self.builder.get_object("liststore1")

        cell0 = Gtk.CellRendererText()
        # cell0.set_property("cell-background", Gdk.color_parse("#F8F8FF"))
        tvcolumn0 = Gtk.TreeViewColumn()
        self.treeview.append_column(tvcolumn0)
        tvcolumn0.pack_start(cell0, True)
        tvcolumn0.set_min_width(50)
        tvcolumn0.set_attributes(cell0, text=0)
        self.treeview.connect("row_activated", self.entry_clicked)
        self.tree_selection = self.treeview.get_selection()

        self.window.hide()

    # user has closed the window
    # just hide it
项目:jcchess    作者:johncheetham    | 项目源码 | 文件源码
def common_settings(self, b):

        glade_dir = gv.jcchess.get_glade_dir()
        self.glade_file = os.path.join(glade_dir,
                                       "common_engine_settings.glade")
        self.builder = Gtk.Builder()
        self.builder.set_translation_domain(gv.domain)
        self.builder.add_from_file(self.glade_file)
        self.builder.connect_signals(self)

        dialog = self.builder.get_object("common_engine_settings")
        dialog.set_transient_for(gv.gui.get_window())
        # ponder check button
        checkbutton = self.builder.get_object("ponderbutton")
        checkbutton.set_active(self.ponder)

        # hash value
        adj = self.builder.get_object("adjustment1")
        adj.set_value(self.hash_value)
        adj.set_lower(0.00)
        adj.set_upper(10000.00)
        adj.set_step_increment(1)
        adj.set_page_increment(10)
        adj.set_page_size(0)

        response = dialog.run()

        resp_cancel = 1
        resp_ok = 2
        if response == resp_ok:
            self.hash_value = int(adj.get_value())
            self.ponder = checkbutton.get_active()

        dialog.destroy()
项目:jcchess    作者:johncheetham    | 项目源码 | 文件源码
def preferences(self, action):
        self.builder = Gtk.Builder()
        self.builder.set_translation_domain(gv.domain)
        self.builder.add_from_file(self.glade_file_preferences)
        self.builder.connect_signals(self)
        dialog = self.builder.get_object("preferences")
        dialog.set_transient_for(self.window)
        # show co-ords
        coords_checkbutton = self.builder.get_object("coords_checkbutton")
        coords_checkbutton.set_active(self.show_coords)

        # highlight moves
        highlight_moves_checkbutton = self.builder.get_object(
            "highlight_checkbutton")

        highlight_moves_checkbutton.set_active(self.highlight_moves)

        response = dialog.run()

        resp_cancel = 1
        resp_ok = 2
        if response == resp_ok:
            self.show_coords = coords_checkbutton.get_active()
            self.highlight_moves = highlight_moves_checkbutton.get_active()
            # rect = self.border_eb.get_allocation()
            # gv.board.update()
            self.border_eb.queue_draw()
        dialog.destroy()
项目:furi-kura    作者:benjamindean    | 项目源码 | 文件源码
def __init__(self, indicator):
        # Passing indicator class and create Gtk.Builder()
        self.indicator = indicator
        self.builder = Gtk.Builder()
        self.chooser = None
项目:furi-kura    作者:benjamindean    | 项目源码 | 文件源码
def __init__(self, cfg_cls):

        # Throwing config class here
        self.cfg_cls = cfg_cls

        # Instantiating API handler
        self.request = API(self.cfg_cls)

        # Getting initial config
        self.config = self.cfg_cls.config

        # Init GTK Builder
        self.builder = Gtk.Builder()

        # Dummy local data
        self.local_data = {
            'inbox_count': 0,
            'comment_karma': 0,
            'link_karma': 0
        }

        # Running services
        self.services = {
            'notification': None,
            'timeout': None
        }

        # Init karma view
        self.karma = '? | ?'

        # Init SubredditChooser window
        self.subreddit_chooser = SubredditChooser(self)

        self.init_appindicator()
项目:RetroArch-Playlists-Generator    作者:Kierek    | 项目源码 | 文件源码
def __init__(self):
        from playlist_creator import preferences_file_location, systems_list

        self.settings_file_location = preferences_file_location
        with open(self.settings_file_location) as data_file:
            self.preferences_data = json.load(data_file)

        builder = Gtk.Builder()
        builder.add_from_file("glade/app.glade")
        builder.connect_signals(self)

        self.notebook = builder.get_object("notebook")
        self.renderer_text = Gtk.CellRendererText()

        self.playlists_directory_chooser = builder.get_object("playlists_directory_chooser")
        self.cores_directory_chooser = builder.get_object("cores_directory_chooser")
        self.infos_directory_chooser = builder.get_object("infos_directory_chooser")

        self.playlists_location = self.preferences_data[0]['playlists_location']
        self.cores_location = self.preferences_data[0]['cores_location']
        self.infos_location = self.preferences_data[0]['infos_location']

        self.playlists_directory_chooser.set_current_folder(self.playlists_location)
        self.cores_directory_chooser.set_current_folder(self.cores_location)
        self.infos_directory_chooser.set_current_folder(self.infos_location)

        self.system_names = Gtk.ListStore(str)
        for system_name in systems_list:
            self.system_names.append([system_name])

        # get all cores and populate list
        self.__populate_cores_list__()

        if len(self.preferences_data) > 1:
            for system_from_prefs in self.preferences_data[1]:
                self.create_new_tab(system_from_prefs['system_name'], system_from_prefs['roms_dir'],
                                    system_from_prefs['core_path'], system_from_prefs['core_name'])

        window = builder.get_object("window")
        window.show_all()
        Gtk.main()
项目:python-eduvpn-client    作者:eduvpn    | 项目源码 | 文件源码
def __init__(self):
        """setup UI thingies, don't do any fetching or DBus communication yet"""

        # minimal global state to pass around data between steps where otherwise difficult
        self.selected_meta = None
        self.prefix = get_prefix()
        self.builder = Gtk.Builder()
        for b in builder_files:
            p = os.path.join(self.prefix, 'share/eduvpn/builder', b)
            if not os.access(p, os.R_OK):
                logger.error("Can't find {}! That is quite an important file.".format(p))
                raise Exception
            self.builder.add_from_file(p)

        # the signals coming from the GTK ui
        handlers = {
            "delete_window": Gtk.main_quit,
            "add_config": self.add,
            "del_config": self.delete,
            "select_config": self.select,
            "connect_set": self.switched,
        }

        self.builder.connect_signals(handlers)
        self.window = self.builder.get_object('eduvpn-window')
        self.verifier = make_verifier(verify_key)
        self.window.set_position(Gtk.WindowPosition.CENTER)
项目:simbuto    作者:nobodyinperson    | 项目源码 | 文件源码
def load_builder(self):
        # get a GTK builder
        self.builder = Gtk.Builder()
        # load the gladefile
        self.builder.add_from_file(self.config.get('gui-general','gladefile'))

    # set the config
项目:mcg    作者:coderkun    | 项目源码 | 文件源码
def on_menu_shortcuts(self, action, value):
        builder = Gtk.Builder()
        builder.set_translation_domain(Application.DOMAIN)
        builder.add_from_resource(self._get_resource_path('gtk.shortcuts.ui'))
        shortcuts_dialog = widgets.ShortcutsDialog(builder, self._window)
        shortcuts_dialog.present()