Python gi.repository.Gtk.Builder() Examples
The following are 30
code examples of gi.repository.Gtk.Builder().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
gi.repository.Gtk
, or try the search function
.
Example #1
Source File: notification_area.py From gtg with GNU General Public License v3.0 | 6 votes |
def preference_dialog_init(self): self.builder = Gtk.Builder() self.builder.add_from_file(os.path.join( os.path.dirname(os.path.abspath(__file__)), "notification_area.ui")) self.preferences_dialog = self.builder.get_object("preferences_dialog") self.chbox_minimized = self.builder.get_object("pref_chbox_minimized") self.spinbutton_dangerzone = \ self.builder.get_object("pref_spinbutton_dangerzone") SIGNAL_CONNECTIONS_DIC = { "on_preferences_dialog_delete_event": self.on_preferences_cancel, "on_btn_preferences_cancel_clicked": self.on_preferences_cancel, "on_btn_preferences_ok_clicked": self.on_preferences_ok, } self.builder.connect_signals(SIGNAL_CONNECTIONS_DIC)
Example #2
Source File: utility.py From SafeEyes with GNU General Public License v3.0 | 6 votes |
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
Example #3
Source File: __init__.py From king-phisher-plugins with BSD 3-Clause "New" or "Revised" License | 6 votes |
def initialize(self): self.window = None if not os.access(gtk_builder_file, os.R_OK): gui_utilities.show_dialog_error( 'Plugin Error', self.application.get_active_window(), "The GTK Builder data file ({0}) is not available.".format(os.path.basename(gtk_builder_file)) ) return False self._label_summary = None self._rule_context = None self._tv = None self._tv_model = Gtk.ListStore(int, str, bool, str, str) self._tv_model.connect('row-inserted', self.signal_model_multi) self._tv_model.connect('row-deleted', self.signal_model_multi) self.menu_items = {} self.menu_items['edit_rules'] = self.add_menu_item('Tools > Request Redirect Rules', self.show_editor_window) return True
Example #4
Source File: sftp_utilities.py From king-phisher-plugins with BSD 3-Clause "New" or "Revised" License | 6 votes |
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]
Example #5
Source File: uistuff.py From pychess with GNU General Public License v3.0 | 6 votes |
def __init__(self, filename): # TODO: remove this when upstream fixes translations with Python3+Windows if sys.platform == "win32" and not conf.no_gettext: tree = ET.parse(addDataPrefix("glade/%s" % filename)) for node in tree.iter(): if 'translatable' in node.attrib: node.text = _(node.text) del node.attrib['translatable'] if node.get('name') in ('pixbuf', 'logo'): node.text = addDataPrefix("glade/%s" % node.text) xml_text = ET.tostring(tree.getroot(), encoding='unicode', method='xml') self.builder = Gtk.Builder.new_from_string(xml_text, -1) else: self.builder = Gtk.Builder() if not conf.no_gettext: self.builder.set_translation_domain("pychess") self.builder.add_from_file(addDataPrefix("glade/%s" % filename))
Example #6
Source File: general_preferences.py From gtg with GNU General Public License v3.0 | 6 votes |
def __init__(self, req, app): self.req = req self.config = self.req.get_config('browser') builder = Gtk.Builder() builder.add_from_file(self.GENERAL_PREFERENCES_UI) self.ui_widget = builder.get_object("general_pref_window") self.preview_button = builder.get_object("preview_button") self.bg_color_button = builder.get_object("bg_color_button") self.font_button = builder.get_object("font_button") self.app = app self.timer = app.timer self.refresh_time = builder.get_object("time_entry") self.autoclean_enable = builder.get_object("autoclean_enable") self.autoclean_days = builder.get_object("autoclean_days") builder.connect_signals(self) # Following 3 methods: get_name, get_title, get_ui are # required for all children of stack in Preferences class. # Plugins and Synchronisation must have them, too! # They are used for easier, more abstract adding of the # children and setting the headerbar title.
Example #7
Source File: client_information.py From epoptes with GNU General Public License v3.0 | 6 votes |
def __init__(self, parent): builder = Gtk.Builder() builder.add_from_file(locate_resource('client_information.ui')) builder.connect_signals(self) self.dialog = builder.get_object('dlg_client_information') self.dialog.set_transient_for(parent) self.btn_edit_alias = builder.get_object('btn_edit_alias') self.dlg_edit_alias = builder.get_object('dlg_edit_alias') self.ent_alias = builder.get_object('ent_alias') self.lbl_type = builder.get_object('lbl_type') self.lbl_alias = builder.get_object('lbl_alias') self.lbl_hostname = builder.get_object('lbl_hostname') self.lbl_mac = builder.get_object('lbl_mac') self.lbl_ip = builder.get_object('lbl_ip') self.lbl_user = builder.get_object('lbl_user') self.lbl_cpu = builder.get_object('lbl_cpu') self.lbl_ram = builder.get_object('lbl_ram') self.lbl_vga = builder.get_object('lbl_vga') self.client = None
Example #8
Source File: dialog_windows.py From innstereo with GNU General Public License v2.0 | 6 votes |
def __init__(self, main_window): """ Initializes the AboutDialog. Loads the Gtk.Builder and parses the Glade file. Then the signals, that are declared in the Glade file are connected to this class. """ self.builder = Gtk.Builder() self.builder.set_translation_domain(i18n().get_ts_domain()) script_dir = os.path.dirname(__file__) rel_path = "gui_layout.glade" abs_path = os.path.join(script_dir, rel_path) self.builder.add_objects_from_file(abs_path, ("aboutdialog", "")) self.ab = self.builder.get_object("aboutdialog") self.ab.set_transient_for(main_window) self.builder.connect_signals(self) if sys.platform == "win32": translate_gui(self.builder)
Example #9
Source File: widgets.py From badKarma with GNU General Public License v3.0 | 6 votes |
def rename_note(self, widget, note_selected): """ rename a note """ builder = Gtk.Builder() builder.add_from_file(os.path.dirname(os.path.abspath(__file__)) + "/../assets/ui/widgets.glade") self.rename_note_input = builder.get_object("rename-note-input") self.rename_note_win = builder.get_object("rename-note") self.rename_note_save = builder.get_object("rename-note-save") self.rename_note_canc = builder.get_object("rename-note-canc") for idz in note_selected: self.rename_note_win.show() self.rename_note_win.set_title("rename note") self.rename_note_canc.connect('clicked', self._destroy_rename_note) self.rename_note_save.connect('clicked', self._save_rename_note, idz)
Example #10
Source File: __init__.py From gtg with GNU General Public License v3.0 | 6 votes |
def _load_widgets_from_builder(self, builder): """ Loads widgets from the builder .ui file @param builder: a Gtk.Builder """ builder.add_from_file(ViewConfig.BACKENDS_UI_FILE) widgets = { 'dialog': 'backends', 'treeview_window': 'treeview_window', 'central_pane': 'central_pane', 'add_button': 'add_button', 'remove_button': 'remove_button', } for attr, widget in widgets.items(): setattr(self, attr, builder.get_object(widget))
Example #11
Source File: dialog_windows.py From innstereo with GNU General Public License v2.0 | 6 votes |
def __init__(self, main_window, open_project): self.builder = Gtk.Builder() self.builder.set_translation_domain(i18n().get_ts_domain()) script_dir = os.path.dirname(__file__) rel_path = "gui_layout.glade" abs_path = os.path.join(script_dir, rel_path) self.builder.add_objects_from_file(abs_path, ("filechooserdialog_open", "")) self.dialog = self.builder.get_object("filechooserdialog_open") self.dialog.set_transient_for(main_window) filter_json = Gtk.FileFilter() filter_json.add_pattern("*.json") filter_json.set_name("JSON") self.dialog.add_filter(filter_json) filter_all = Gtk.FileFilter() filter_all.add_pattern("*") filter_all.set_name(_("All Files")) self.dialog.add_filter(filter_all) self.open_project = open_project self.builder.connect_signals(self) if sys.platform == "win32": translate_gui(self.builder)
Example #12
Source File: alttoolbar_rb3compat.py From alternative-toolbar with GNU General Public License v3.0 | 6 votes |
def load_from_file(self, rb2_ui_filename, rb3_ui_filename): """ utility function to load the menu structure :param rb2_ui_filename: `str` RB2.98 and below UI file :param rb3_ui_filename: `str` RB2.99 and higher UI file """ self.builder = Gtk.Builder() try: from coverart_browser_prefs import CoverLocale cl = CoverLocale() self.builder.set_translation_domain(cl.Locale.LOCALE_DOMAIN) except: pass if is_rb3(self.shell): ui_filename = rb3_ui_filename else: ui_filename = rb2_ui_filename self.ui_filename = ui_filename self.builder.add_from_file(rb.find_plugin_file(self.plugin, ui_filename))
Example #13
Source File: sms.py From deskcon-desktop with GNU General Public License v3.0 | 6 votes |
def __init__(self, ip, port, number): builder = Gtk.Builder() builder.add_from_file(os.getcwd()+"/share/ui/sms.glade") builder.connect_signals(self) self.window = builder.get_object("smswindow") self.numberentry = builder.get_object("numberentry") self.messagetextview = builder.get_object("messagetextview") self.charlabel = builder.get_object("charcountlabel") self.errordialog = builder.get_object("errordialog") self.window.set_wmclass ("DeskCon", "Compose") self.ip = ip self.port = port self.numberentry.set_text(number) self.textbuffer = self.messagetextview.get_buffer() self.window.show_all()
Example #14
Source File: alttoolbar_type.py From alternative-toolbar with GNU General Public License v3.0 | 6 votes |
def initialise(self, plugin): super(AltToolbarCompact, self).initialise(plugin) self._setup_compactbar() if self.shell.props.application.get_menubar() == None: builder = Gtk.Builder() ui = rb.find_plugin_file(self.plugin, 'ui/altmenubar.ui') cl = CoverLocale() builder.set_translation_domain(cl.Locale.RB) builder.add_from_file(ui) menubar = builder.get_object("menubar") self.shell.props.application.link_shared_menus(menubar) self.shell.props.application.set_menubar(menubar) self.load_builder_content(builder)
Example #15
Source File: __init__.py From king-phisher-plugins with BSD 3-Clause "New" or "Revised" License | 5 votes |
def initialize(self): if not os.access(gtk_builder_file, os.R_OK): gui_utilities.show_dialog_error( 'Plugin Error', self.application.get_active_window(), "The GTK Builder data file ({0}) is not available.".format(os.path.basename(gtk_builder_file)) ) return False self.menu_items = {} self.add_submenu('Tools > TOTP Self Enrollment') self.menu_items['setup'] = self.add_menu_item('Tools > TOTP Self Enrollment > Setup', self.enrollment_setup) self.menu_items['remove'] = self.add_menu_item('Tools > TOTP Self Enrollment > Remove', self.enrollment_remove) return True
Example #16
Source File: window.py From dynamic-wallpaper-editor with GNU General Public License v3.0 | 5 votes |
def build_time_popover(self): builder = Gtk.Builder().new_from_resource(UI_PATH + 'start_time.ui') start_time_popover = builder.get_object('start_time_popover') self.year_spinbtn = builder.get_object('year_spinbtn') self.month_spinbtn = builder.get_object('month_spinbtn') self.day_spinbtn = builder.get_object('day_spinbtn') self.hour_spinbtn = builder.get_object('hour_spinbtn') self.minute_spinbtn = builder.get_object('minute_spinbtn') self.second_spinbtn = builder.get_object('second_spinbtn') self.start_btn.set_popover(start_time_popover)
Example #17
Source File: window.py From dynamic-wallpaper-editor with GNU General Public License v3.0 | 5 votes |
def build_menus(self): builder = Gtk.Builder().new_from_resource(UI_PATH + 'menus.ui') self.menu_btn.set_menu_model(builder.get_object('window-menu')) self.apply_btn.set_menu_model(builder.get_object('apply-menu'))
Example #18
Source File: main.py From dynamic-wallpaper-editor with GNU General Public License v3.0 | 5 votes |
def on_startup(self, *args): self.set_gsettings_values() self.build_app_actions() builder = Gtk.Builder().new_from_resource(UI_PATH + 'menus.ui') menubar_model = builder.get_object('menu-bar') self.set_menubar(menubar_model) if self.prefers_app_menu(): menu = builder.get_object('app-menu') self.set_app_menu(menu)
Example #19
Source File: main.py From dynamic-wallpaper-editor with GNU General Public License v3.0 | 5 votes |
def on_shortcuts(self, *args): if self.shortcuts_window is not None: self.shortcuts_window.destroy() builder = Gtk.Builder().new_from_resource(UI_PATH + 'shortcuts.ui') self.shortcuts_window = builder.get_object('shortcuts') self.shortcuts_window.present()
Example #20
Source File: builder.py From pympress with GNU General Public License v2.0 | 5 votes |
def __init__(self): super(Builder, self).__init__()
Example #21
Source File: builder.py From pympress with GNU General Public License v2.0 | 5 votes |
def __recursive_translate_widgets(a_widget): """ Calls gettext on all strings we can find in widgets, and recursively on its children. Args: a_widget (:class:`~GObject.Object`): an object built by the builder, usually a widget """ Builder.__translate_widget_strings(a_widget) if issubclass(type(a_widget), Gtk.Container): # NB: Parent-loop in widgets would cause infinite loop here, but that's absurd (right?) # NB2: maybe forall instead of foreach if we miss some strings? a_widget.foreach(Builder.__recursive_translate_widgets) if issubclass(type(a_widget), Gtk.MenuItem) and a_widget.get_submenu() is not None: Builder.__recursive_translate_widgets(a_widget.get_submenu())
Example #22
Source File: widgets.py From badKarma with GNU General Public License v3.0 | 5 votes |
def __init__(self, database, host, *args, **kwargs): super(host_informations, self).__init__(*args, **kwargs) """ single host information widget """ builder = Gtk.Builder() # glade builder.add_from_file(os.path.dirname(os.path.abspath(__file__)) + "/../assets/ui/widgets.glade") self.info_viewport = builder.get_object("host-info-viewport") self.info_mac = builder.get_object("info-mac") self.info_os = builder.get_object("info-os") self.info_vendor = builder.get_object("info-vendor") self.info_status = builder.get_object("info-status") self.info_address = builder.get_object("info-address") self.info_hostnames = builder.get_object("info-hostnames") self.info_distance = builder.get_object("info-distance") self.info_tcpseq = builder.get_object("info-tcpseq") self.info_uptime = builder.get_object("info-uptime") self.info_latitude = builder.get_object("info-latitude") self.info_longitude = builder.get_object("info-longitude") self.info_isp = builder.get_object("info-isp") self.info_country_code = builder.get_object("info-country_code") self.info_country_name = builder.get_object("info-country_name") self.info_organization = builder.get_object("info-organization") viewport = Gtk.Viewport() viewport.add(self.info_viewport) viewport.set_vexpand(True) viewport.set_hexpand(True) self.add(viewport) self.set_property("height-request", 400) self.show_all() self.database = database self.host = host self.refresh(self.database, self.host)
Example #23
Source File: uibuilder.py From syncthing-gtk with GNU General Public License v2.0 | 5 votes |
def add_from_file(self, filename): """ Builds UI from file """ log.debug("Loading glade file %s", filename) if len(self.conditions) == 0 and not IS_WINDOWS and get_locale_dir() is None: # There is no need to do any magic in this case; Just use # Gtk.Builder directly Gtk.Builder.add_from_file(self, filename) else: with open(filename, "r") as f: self.add_from_string(f.read())
Example #24
Source File: uibuilder.py From syncthing-gtk with GNU General Public License v2.0 | 5 votes |
def __init__(self): Gtk.Builder.__init__(self) self.set_translation_domain(GETTEXT_DOMAIN) self.conditions = set([]) self.icon_paths = [] self.xml = None
Example #25
Source File: dialog_windows.py From innstereo with GNU General Public License v2.0 | 5 votes |
def __init__(self, main_window, data): self.builder = Gtk.Builder() self.builder.set_translation_domain(i18n().get_ts_domain()) self.data = data script_dir = os.path.dirname(__file__) rel_path = "gui_layout.glade" abs_path = os.path.join(script_dir, rel_path) self.builder.add_objects_from_file(abs_path, ("filechooserdialog_save", "")) self.dialog = self.builder.get_object("filechooserdialog_save") self.dialog.set_transient_for(main_window) self.builder.connect_signals(self) if sys.platform == "win32": translate_gui(self.builder)
Example #26
Source File: dialog_windows.py From innstereo with GNU General Public License v2.0 | 5 votes |
def __init__(self, call_overwrite, export_dialog): self.builder = Gtk.Builder() self.builder.set_translation_domain(i18n().get_ts_domain()) self.call_overwrite = call_overwrite script_dir = os.path.dirname(__file__) rel_path = "gui_layout.glade" abs_path = os.path.join(script_dir, rel_path) self.builder.add_objects_from_file(abs_path, ("dialog_overwrite", "")) self.dialog = self.builder.get_object("dialog_overwrite") self.dialog.set_transient_for(export_dialog) self.builder.connect_signals(self) if sys.platform == "win32": translate_gui(self.builder)
Example #27
Source File: dialog_windows.py From innstereo with GNU General Public License v2.0 | 5 votes |
def __init__(self, export_data, main_window): self.builder = Gtk.Builder() self.builder.set_translation_domain(i18n().get_ts_domain()) self.export_data = export_data script_dir = os.path.dirname(__file__) rel_path = "gui_layout.glade" abs_path = os.path.join(script_dir, rel_path) self.builder.add_objects_from_file(abs_path, ("filechooserdialog_export", "")) self.dialog = self.builder.get_object("filechooserdialog_export") self.dialog.set_transient_for(main_window) self.builder.connect_signals(self) if sys.platform == "win32": translate_gui(self.builder)
Example #28
Source File: main_ui.py From innstereo with GNU General Public License v2.0 | 5 votes |
def startup(testing=False): """ Starts the GUI and the application main-loop. Initializes an instance of the Gtk.Builder and loads the GUI from the ".glade" file. Then it initializes the main window and starts the Gtk.main loop. This function is also passed to the window, so it can open up new instances of the program. """ builder = Gtk.Builder() script_dir = os.path.dirname(__file__) rel_path = "gui_layout.glade" abs_path = os.path.join(script_dir, rel_path) builder.set_translation_domain(i18n().get_ts_domain()) objects = builder.add_objects_from_file(abs_path, ("main_window", "image_new_plane", "image_new_faultplane", "image_new_line", "image_new_fold", "image_plane_intersect", "image_best_fitting_plane", "layer_right_click_menu", "image_create_small_circle", "menu_plot_views", "image_eigenvector", "poles_to_lines", "image_linears_to_planes", "image_rotate", "image_pt_axis", "image_mean_vector", "image_fisher")) gui_instance = MainWindow(builder, testing) builder.connect_signals(gui_instance) if testing == False: Gtk.main() return gui_instance
Example #29
Source File: settings.py From innstereo with GNU General Public License v2.0 | 5 votes |
def __init__(self, main_window): """ Initalizes the GUI. Connects to Gio.Settings. Loads the defaults. """ self.builder = Gtk.Builder() self.builder.set_translation_domain(i18n().get_ts_domain()) script_dir = os.path.dirname(__file__) rel_path = "gui_layout.glade" abs_path = os.path.join(script_dir, rel_path) self.builder.add_objects_from_file(abs_path, ("settings_window", "adjustment_def_pixeldens")) self.set_win = self.builder.get_object("settings_window") self.switch_def_legend = self.builder.get_object("switch_def_legend") self.switch_def_grid = self.builder.get_object("switch_def_grid") self.switch_def_cross = self.builder.get_object("switch_def_cross") self.radiobutton_def_area = self.builder.get_object("radiobutton_def_area") self.radiobutton_def_angle = self.builder.get_object("radiobutton_def_angle") self.switch_def_night_mode = self.builder.get_object("switch_def_night_mode") self.spinbutton_def_pixeldens = self.builder.get_object("spinbutton_def_pixeldens") self.adjustment_def_pixeldens = self.builder.get_object("adjustment_def_pixeldens") self.switch_def_highlight = self.builder.get_object("switch_def_highlight") self.set_win.set_transient_for(main_window) self.builder.connect_signals(self) self.g_settings = Gio.Settings.new("org.gtk.innstereo") self.get_defaults() if sys.platform == "win32": translate_gui(self.builder)
Example #30
Source File: file_parser.py From innstereo with GNU General Public License v2.0 | 5 votes |
def __init__(self, text_file, layer_obj, redraw_plot, append_plane, append_line, append_faultplane, main_window): """ Initializes the file parser dialog and connects the signals. The GUI-layout is loaded from the project Glade file. The functions that the dialog needs to import the data and refresh the plot are assigned. Then the treestore and treeview are set up. A few buttons are hidden, depending on the layer that was chosen for the import. Then the signals are connected and the dialog does the first parsing of the file. """ self.builder = Gtk.Builder() script_dir = os.path.dirname(__file__) rel_path = "gui_layout.glade" abs_path = os.path.join(script_dir, rel_path) self.builder.add_objects_from_file(abs_path, ("file_parse_dialog", "liststore_assign_columns", "adjustment_parse_start_line")) self.tfpl_dic = {"0": "ukn", "1": "up", "2": "dn", "3": "dex", "4": "sin"} self.dialog = self.builder.get_object("file_parse_dialog") self.dialog.set_transient_for(main_window) self.redraw_plot = redraw_plot self.layer_obj = layer_obj self.append_plane = append_plane self.append_line = append_plane self.append_faultplane = append_faultplane self.file = text_file self.load_gui_elements() self.create_treeview() self.hide_buttons() self.builder.connect_signals(self) self.parse_file()