我们从Python开源项目中,提取了以下13个代码示例,用于说明如何使用gtk.Builder()。
def __init__(self, parent, clients, execute): self.wTree = gtk.Builder() self.wTree.add_from_file('netbenchmark.ui') self.wTree.connect_signals(self) self.get = self.wTree.get_object self.parent = parent self.execute = execute self.clients_par = clients self.clients = {} self.iperf = None self.processes = {} self.results = {} self.dlg = self.get('benchmark_dialog') self.dlg.set_transient_for(self.parent) self.table = self.get('results_treeview') self.graph = None self.measurements_n = 0 self.timeleft = 0 self.timeout = 5 self.output_timeout = None self.more_output = None
def __init__(self, choices, backend): self.page_classes = [Welcome, Luks, UsbKey, Unmount, ConfirmUsbKey, \ Format, Gpg, BootScheme, Commit, Finish] self.builder = gtk.Builder() self.builder.add_from_file(os.path.join(sys.prefix, "share/lfde-installer/gui/gtk/main.glade")) self.builder.connect_signals({"on_win_main_destroy" : self.gui_quit, "on_btn_forward_clicked" : self.gui_forward, "on_btn_back_clicked" : self.gui_back, "on_btn_quit_clicked" : self.gui_quit }) # allow our threads to work normally gtk.gdk.threads_init() self.win_main = self.builder.get_object("win_main") self.lbl_step_title = self.builder.get_object("lbl_step_title") self.builder.add_from_file(os.path.join(sys.prefix, "share/lfde-installer/gui/gtk/entropy.glade")) self.win_entropy = self.builder.get_object("win_entropy") self.lbl_step = self.builder.get_object("lbl_step") self.btn_forward = self.builder.get_object("btn_forward") GenericFrontend.__init__(self, choices, backend)
def __init__(self, kind='float'): self.dro = None self.original_text = None # Glade setup if kind == 'float': gladefile = os.path.join(IMAGEDIR, 'float_numpad.glade') else: gladefile = os.path.join(IMAGEDIR, 'int_numpad.glade') self.builder = gtk.Builder() self.builder.add_from_file(gladefile) self.builder.connect_signals(self) self.window = self.builder.get_object("window") self.window.set_keep_above(True) # Handles all the character buttons
def __init__(self, selected, execute): self.wTree = gtk.Builder() self.wTree.add_from_file('client_information.ui') self.wTree.connect_signals(self) self.get = self.wTree.get_object self.selected = selected self.dlg = self.get('infodlg') self.edit_button = self.get('edit_alias_button') set = lambda wdg, txt: self.get(wdg).set_text(txt.strip()) for client in selected: inst = client[C_INSTANCE] handle = inst.hsystem or client[C_SESSION_HANDLE] if handle: execute(handle, 'echo $RAM').addCallback( lambda r: set('client_ram', r.strip()+' MB')) execute(handle, 'echo $CPU').addCallback( lambda r: set('client_cpu', r)) execute(handle, 'echo $VGA').addCallback( lambda r: set('client_vga', r)) set('client_alias', inst.alias) set('client_hostname', inst.hostname) set('client_mac', inst.mac) set('client_ip', handle.split(':')[0]) set('client_type', inst.type) user = '--' if client[C_SESSION_HANDLE]: uname, realname = inst.users[client[C_SESSION_HANDLE]].values() user = uname if realname: user += ' (%s)' %realname set('client_online_user', user) self.dlg.set_title(_('Properties of %s') %inst.get_name())
def __init__(self): self.wTree = gtk.Builder() self.wTree.add_from_file('remote_assistance.ui') self.wTree.connect_signals(self) self.get = self.wTree.get_object
def __init__(self): self.wTree = gtk.Builder() self.wTree.add_from_file('about_dialog.ui') self.wTree.connect_signals(self) self.get = self.wTree.get_object self.dialog = self.get('aboutdialog') logo = gtk.gdk.pixbuf_new_from_file_at_size( '../icons/hicolor/scalable/apps/epoptes.svg', 64, 64) self.dialog.set_logo(logo) self.dialog.set_version(__version__) self.dialog.set_translator_credits(_("translator-credits")) self.dialog.set_artists(["Andrew Wedderburn (application icon)"])
def __init__(self,width,height): self.builder = gtk.Builder() self.builder.add_from_file("example2.xml") self.window = self.builder.get_object("window") self.screen = self.builder.get_object("screen") self.builder.connect_signals(self) self.size = (width,height)
def __init__(self): # Glade setup gladefile = os.path.join(UIDIR, 'progressbar.glade') self.builder = gtk.Builder() self.builder.add_from_file(gladefile) self.window = self.builder.get_object("window") self.window.connect('destroy', self.destroy) self.window.set_keep_above(True) self.progressbar = self.builder.get_object("progressbar")
def __init__(self): # Glade setup gladefile = os.path.join(UIDIR, 'spinner.glade') self.builder = gtk.Builder() self.builder.add_from_file(gladefile) self.window = self.builder.get_object("window") self.window.connect('destroy', self.destroy) self.window.set_keep_above(True) self.spinner = self.builder.get_object("spinner")
def __init__(self, dialog_type=DialogTypes.YES_NO): """ 0 = yes/no, 1 = ok/cancel, 2 = error """ super(Dialogs, self).__init__() # Initialize the gtk.Dialog super class # Glade setup if dialog_type == DialogTypes.YES_NO or dialog_type == DialogTypes.OK_CANCEL: gladefile = os.path.join(UIDIR, 'dialog.glade') else: gladefile = os.path.join(UIDIR, 'error_dialog.glade') self.builder = gtk.Builder() self.builder.add_from_file(gladefile) self.builder.connect_signals(self) self.dialog_window = self.builder.get_object("window") self.message_label = self.builder.get_object("mesage_label") self.running = False self.result = False if dialog_type == DialogTypes.YES_NO: self.builder.get_object("button1").set_label("YES") self.builder.get_object("button2").set_label("NO") elif dialog_type == DialogTypes.OK_CANCEL: self.builder.get_object("button1").set_label("OK") self.builder.get_object("button2").set_label("CANCEL")
def __init__(self): # Glade setup self.builder = gtk.Builder() self.builder.add_from_file("ui/standalone.glade") self.window = self.builder.get_object("window1") self.builder.connect_signals(self) # Filechooser setup self.filechooser = filechooser.Filechooser() box = self.builder.get_object("hbox1") filechooser_widget = self.filechooser.get_filechooser_widget() box.add(filechooser_widget) # Initialize keyboard if we found it if KEYBOARD: self.keyboard = Keyboard() # Connect signals emited by filechooser self.filechooser.connect('file-activated', self.on_file_activated) self.filechooser.connect('selection-changed', self.on_file_selection_changed) self.filechooser.connect('filename-editing-started', self.on_file_name_editing_started) self.filechooser.connect('error', self.on_error) self.builder.get_object('paste').set_sensitive(False) # Set up file ext filters self.filechooser.add_filter('gcode', ['.ngc', '.TAP', '.txt']) self.filechooser.add_filter('all', ['*']) self.filechooser.set_filter('all') # Set show hidden (defaults to False if not set) self.filechooser.set_show_hidden(False) #print self.filechooser.get_filter() #print self.filechooser.get_filters() # Show the whole shebang self.window.show()
def __init__(self): self.builder = gtk.Builder() self.builder.add_from_file("data/gui.glade") self.builder.connect_signals(self) self.t = None
def __init__(self): self.entry = None self.parent = None self.persistent = False # Glade setup gladefile = os.path.join(IMAGEDIR, 'keyboard.glade') self.builder = gtk.Builder() self.builder.add_from_file(gladefile) self.builder.connect_signals(self) self.window = self.builder.get_object("window") self.wait_counter = 0 self.window.set_keep_above(True) self.letters = 'abcdefghijklmnopqrstuvwxyz ' # Now I've said my abc's # Don't remove the space character ^ It's named ' ' in glade too! self.numbers = '`1234567890-=' # Now I've said my 1 2 3's # Relate special character to their glade names. self.characters = {'`':'~', '1':'!', '2':'@', '3':'#', '4':'$', '5':'%', '6':'^', '7':'&', '8':'*', '9':'(', '0':')', '-':'_', '=':'+', '[':'{', ']':'}', '\\':'|', ';':':', "'":'"', ',':'<', '.':'>', '/':'?'} # Now I've said my @#$%^%! self.letter_btn_dict = dict((l, self.builder.get_object(l)) for l in self.letters) self.number_btn_dict = dict((n, self.builder.get_object(n)) for n in self.characters) # Connect letter button press events for l, btn in self.letter_btn_dict.iteritems(): btn.connect("pressed", self.emulate_key) #self.on_button_pressed) # Connect number button press events for l, btn in self.number_btn_dict.iteritems(): btn.connect("pressed", self.emulate_key) #self.on_button_pressed) # ========================================================= # Keyboard Settings # ========================================================= # Caps Lock