Python gtk.Builder() Examples

The following are 3 code examples of 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 gtk , or try the search function .
Example #1
Source File: window_vm.py    From openxenmanager with GNU General Public License v2.0 6 votes vote down vote up
def on_btundockconsole_clicked(self, widget, data=None):
        """
        Function called when you press "undock"
        """
        #create a new window and append the vnc
        if self.selected_ref not in self.vnc_builders.keys():
            self.noclosevnc = True
            self.builder.get_object("console_area").remove(self.vnc[self.selected_ref])
            glade_dir = os.path.join(utils.module_path(), 'ui')
            self.vnc_builders[self.selected_ref] = gtk.Builder()
            self.vnc_builders[self.selected_ref].add_from_file(os.path.join(glade_dir,"window_vnc.glade"))
            self.vnc_builders[self.selected_ref].get_object("console_area3").add(self.vnc[self.selected_ref])
            self.vnc_builders[self.selected_ref].get_object("btredockconsole").connect("clicked", self.on_btredockconsole_clicked,self.selected_ref)
            self.vnc_builders[self.selected_ref].get_object("btredockconsole").connect("destroy", self.on_btredockconsole_clicked,self.selected_ref)
            self.vnc_builders[self.selected_ref].get_object("btsendctrlaltdel1").connect("clicked", self.on_btsendctraltdel_clicked,self.selected_ref)
            self.vnc_builders[self.selected_ref].get_object("windowvncundock").set_title(self.selected_name)
            self.vnc_builders[self.selected_ref].get_object("windowvncundock").show_all()
            
        else:
            #If the vnc window already exists (partially covered or minimized), present it to the user.
            self.vnc_builders[self.selected_ref].get_object("windowvncundock").present() 
Example #2
Source File: prefseditor.py    From NINJA-PingU with GNU General Public License v3.0 5 votes vote down vote up
def __init__ (self, term):
        self.config = config.Config()
        self.term = term
        self.builder = gtk.Builder()
        self.keybindings = Keybindings()
        try:
            # Figure out where our library is on-disk so we can open our 
            (head, _tail) = os.path.split(config.__file__)
            librarypath = os.path.join(head, 'preferences.glade')
            gladefile = open(librarypath, 'r')
            gladedata = gladefile.read()
        except Exception, ex:
            print "Failed to find preferences.glade"
            print ex
            return 
Example #3
Source File: hazzygremlin.py    From hazzy with GNU General Public License v2.0 3 votes vote down vote up
def __init__(self, inifile, width, height):
        gobject.GObject.__init__(self)

        super(HazzyGremlin, self).__init__(inifile)

        self.width = width
        self.height = height

        self.percent = 0
        self.mouse_mode = None
        self.zoom_in_pressed = False
        self.zoom_out_pressed = False

        self.set_display_units('in')

        # Gremlin3D width = width - 40 to allow room for the controls
        self.set_size_request(self.width - 40, self.height)

        # Add gremlin back-plot
        self.gremlin_view = gtk.HBox()
        fixed = gtk.Fixed()
        fixed.put(self, 0, 0)
        self.gremlin_view.add(fixed)
        self.connect('button_press_event', self.on_gremlin_clicked)

        # Add touchscreen controls
        gladefile = os.path.join(UIDIR, 'controls.glade')
        self.builder = gtk.Builder()
        self.builder.add_from_file(gladefile)
        self.builder.connect_signals(self)
        controls = self.builder.get_object('controls')
        controls.set_size_request(40, self.height)
        self.gremlin_view.add(controls)

        # Add progress label
        self.label = gtk.Label()
        self.label.modify_font(pango.FontDescription('FreeSans 11'))
        self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color('White'))
        labelbox = gtk.EventBox()
        labelbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('Black'))
        labelbox.set_size_request(-1, 20)
        labelbox.add(self.label)
        fixed.put(labelbox, 0 , self.height - 20)


#    def fileloading(self, current_line):
#        self.progressbar.show()
#        percent = current_line * 100 / self.line_count
#        if self.percent != percent:
#            self.percent = percent
#            msg = "Generating preview {}%".format(self.percent)
#            self.progressbar.set_text(msg)
#            self.progressbar.set_fraction(self.percent / 100)
#            log.debug(msg)
#            self.emit('loading_progress', percent)