Python gtk 模块,STATE_NORMAL 实例源码

我们从Python开源项目中,提取了以下23个代码示例,用于说明如何使用gtk.STATE_NORMAL

项目:learning-texas-holdem    作者:gjgregory    | 项目源码 | 文件源码
def _set_card_image(self, box, image, card):
        """Helper function to set card box's background color and image according to
        the specified image path."""
        #get appropriate color/image
        if card.rank == None:
            color = DARK_SLATE_BLUE
            img_path = FACE_DOWN
        else:
            color = GHOST_WHITE
            img_path = 'art_assets/' + RankStrings[card.rank] + SuitStrings[card.suit] + '.png'
        #change background color of widget
        box.modify_bg(gtk.STATE_NORMAL, color)
        #assign (presumably transparent) image to widget
        pixbuf = gtk.gdk.pixbuf_new_from_file(img_path)
        scaled_pixbuf = pixbuf.scale_simple(100, 150, gtk.gdk.INTERP_BILINEAR)
        image.set_from_pixbuf(scaled_pixbuf)
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def setTheme(self, widget, theme, *args):
        if widget is None or widget.get_active():
            SETTINGS['theme'] = theme
            saveSettings()
            if SETTINGS['theme'] == 'dark':
                colour = gtk.gdk.color_parse(DARKCOL)
            else:
                colour = gtk.gdk.color_parse(LIGHTCOL)

            for w in OPENWINDOWS:
                w.window.modify_bg(gtk.STATE_NORMAL, colour)

                mgr = gtkSourceView.style_scheme_manager_get_default()
                w.style_scheme = mgr.get_scheme('tango' if SETTINGS['theme']=='light' else 'oblivion')
                for f in self.notebook:
                    f.get_child().props.buffer.set_style_scheme(self.style_scheme)
                w.serialConsole.window.modify_bg(gtk.STATE_NORMAL, colour)
                if SENDIMAGE: w.serialConsole.imageCreator.window.modify_bg(gtk.STATE_NORMAL, colour)
                w.serialConsole.consoleBody.props.buffer.set_style_scheme(w.style_scheme)
                w.consoleBody.props.buffer.set_style_scheme(w.style_scheme)
项目:wahcade    作者:sairuk    | 项目源码 | 文件源码
def _create_list_labels(self):
        """create labels as rows"""
        #remove any existing rows
        [self.fixd.remove(row[0]) for row in self._rows]
        #create labels
        self._rows = []
        for i in range(self.num_rows):
            eb = gtk.EventBox()
            lbl = gtk.Label()
            lbl.modify_font(self._pango_font_desc)
            lbl.modify_fg(gtk.STATE_NORMAL, self._fg_col)
            lbl.modify_bg(gtk.STATE_NORMAL, self._hl_bg_col)
            lbl.set_property('xalign', self.properties['xalign'])
            lbl.set_angle(self.angle)
            lbl.show()
            eb.add(lbl)
            eb.add_events(gtk.gdk.BUTTON_PRESS_MASK)
            eb.connect('button-press-event', self._on_mouse_button, i)
            eb.show()
            eb.set_visible_window(False)
            self.fixd.add(eb)
            self._rows.append((eb, lbl))
        #colours
        self.modify_fg(gtk.STATE_NORMAL, self._fg_col)
        self.modify_highlight_bg(gtk.STATE_NORMAL, self._hl_bg_col)
项目:learning-texas-holdem    作者:gjgregory    | 项目源码 | 文件源码
def _set_button(self, button, label, color):
        """Helper function to set a button's label and background color."""
        #change background color of button (normal and mouseover)
        button.modify_bg(gtk.STATE_NORMAL, color)
        button.modify_bg(gtk.STATE_PRELIGHT, color)
        #set button caption and default size
        button.set_label(label)
        button.set_size_request(70, 70)
        button.show()
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def console(self, message):
        self.set_point(self.get_length())
        self.freeze()
        previous_kind = None
        style = self.get_style()
        style_cache = {}
        try:
            for element in message:
                if element[0] == 'exception':
                    s = traceback.format_list(element[1]['traceback'])
                    s.extend(element[1]['exception'])
                    s = string.join(s, '')
                else:
                    s = element[1]

                if element[0] != previous_kind:
                    style = style_cache.get(element[0], None)
                    if style is None:
                        gtk.rc_parse_string(
                            'widget \"Manhole.*.Console\" '
                            'style \"Console_%s\"\n'
                            % (element[0]))
                        self.set_rc_style()
                        style_cache[element[0]] = style = self.get_style()
                # XXX: You'd think we'd use style.bg instead of 'None'
                # here, but that doesn't seem to match the color of
                # the backdrop.
                self.insert(style.font, style.fg[gtk.STATE_NORMAL],
                            None, s)
                previous_kind = element[0]
            l = self.get_length()
            diff = self.maxBufSz - l
            if diff < 0:
                diff = - diff
                self.delete_text(0,diff)
        finally:
            self.thaw()
        a = self.get_vadjustment()
        a.set_value(a.upper - a.page_size)
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def create_error_vbox(self, error_msg):
        vbox_error = gtk.VBox()

        traceback.print_exc()
        err_label = gtk.Label(error_msg)
        err_label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("red"))
        vbox_error.pack_start(err_label)

        return vbox_error
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def run(self):
        result = super(SettingsDialog, self).run()
        if result == gtk.RESPONSE_OK:
            SETTINGS["quickstart"] = self.s1.get_active()
            SETTINGS["theme"] = "dark" if self.rb2.get_active() else "light"
            SETTINGS["mbitLocation"] = self.fcb1.get_filename() if self.fcb1.get_filename() else SETTINGS["mbitLocation"]
            saveSettings()

            if SETTINGS['theme'] == 'dark':
                colour = gtk.gdk.color_parse(DARKCOL)
            else:
                colour = gtk.gdk.color_parse(LIGHTCOL)

            for w in OPENWINDOWS:
                w.window.modify_bg(gtk.STATE_NORMAL, colour)

                mgr = gtkSourceView.style_scheme_manager_get_default()
                w.style_scheme = mgr.get_scheme('tango' if SETTINGS['theme']=='light' else 'oblivion')
                for f in w.notebook:
                    f.get_child().props.buffer.set_style_scheme(w.style_scheme)
                w.serialConsole.window.modify_bg(gtk.STATE_NORMAL, colour)
                if SENDIMAGE: w.serialConsole.imageCreator.window.modify_bg(gtk.STATE_NORMAL, colour)
                w.serialConsole.consoleBody.props.buffer.set_style_scheme(w.style_scheme)
                w.consoleBody.props.buffer.set_style_scheme(w.style_scheme)

        self.destroy()
项目:srcsim2017    作者:ZarjRobotics    | 项目源码 | 文件源码
def float_entry_changed(self, entry):
        try:
            val = float(entry.get_text())
            entry.modify_text(gtk.STATE_NORMAL, gtk.gdk.color_parse("black"))
        except ValueError:
            entry.modify_text(gtk.STATE_NORMAL, gtk.gdk.color_parse("red"))
项目:vivisect-py3    作者:bat-serjo    | 项目源码 | 文件源码
def __init__(self, graph, layout, scrollwin=None, ):
        gtk.DrawingArea.__init__(self)
        self._vg_graph = graph
        self._vg_layout = layout
        self._vg_scrollwin = scrollwin

        self.connect('expose-event', self.expose_event_cb)
        self.connect('button_press_event', self.button_press_event)
        self.set_events( self.get_events() | gtk.gdk.BUTTON_PRESS_MASK)

        self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color())
        self.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(green=65535))

        if scrollwin != None:
            scrollwin.connect('destroy', self.scroll_destroy_cb)
项目:vivisect-py3    作者:bat-serjo    | 项目源码 | 文件源码
def expose_event_cb(self, layout, event):

        style = self.get_style()
        gc = style.fg_gc[gtk.STATE_NORMAL]

        rect = self.get_allocation()

        owidth = rect.width
        oheight = rect.height

        lwidth, lheight = self._vg_layout.getLayoutSize()

        for nid, ninfo in self._vg_graph.getNodes():

            nwidth, nheight = ninfo.get('size', zero_zero)
            if nwidth == 0:
                continue

            xpos, ypos = ninfo.get('position', zero_zero)

            drawx = ((xpos * owidth) / lwidth)
            drawy = (ypos * oheight) / lheight

            sizex = owidth * nwidth / lwidth
            sizey = oheight * nheight / lheight

            colorstr = ninfo.get('color')
            if colorstr == None:
                colorstr = '#0f0'

            color = gtk.gdk.color_parse(colorstr)

            #self.modify_fg(gtk.STATE_NORMAL, color)
            self.window.draw_rectangle(gc, False, drawx, drawy, sizex, sizey)

            #c = self.window.cairo_create()
            #c.set_source_rgb(color.red / float(65535), color.green / float(65535), color.blue / float(65535))
            #c.rectangle(drawx, drawy, sizex, sizey)# event.area.x, event.area.y, event.area.width, event.area.height)
            #c.set_line_width(0.5)
            #c.stroke()
项目:vivisect-py3    作者:bat-serjo    | 项目源码 | 文件源码
def __init__(self, graph):
        gtk.Layout.__init__(self)
        vg_render.GraphRenderer.__init__(self, graph)

        self._vg_lines = []

        self.connect('expose-event', self.expose_event_cb)
        self.connect('button_press_event', self.button_press_event)

        self.set_events( self.get_events() | gtk.gdk.BUTTON_PRESS_MASK)

        self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color())
        self.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(green=65535))
项目:vivisect-py3    作者:bat-serjo    | 项目源码 | 文件源码
def setNodeSizes(self, graph):

        for nid, ninfo in graph.getNodes():

            # Skip "ghost" nodes...
            if ninfo.get('ghost'):
                continue

            widget = ninfo.get('widget')
            if widget == None:
                widget = gtk.Label(str(nid))
                widget.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color())
                widget.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(green=65535))
                ninfo['widget'] = widget

            # Put them all at 0,0 for now...
            self.put(widget, 0, 0)

        # Get them all to render...
        self.show_all()
        vw_main.doiterations()

        # Now that we have rendered them...
        for nid, ninfo in graph.getNodes():
            widget = ninfo.get('widget')
            if widget == None:
                continue

            size = widget.size_request()
            ninfo['size'] = size
项目:vivisect-py3    作者:bat-serjo    | 项目源码 | 文件源码
def expose_event_cb(self, layout, event):

        style = self.get_style()

        gc = style.fg_gc[gtk.STATE_NORMAL]

        for points in self._vg_lines:
            self.bin_window.draw_lines(gc, points)
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def console(self, message):
        self.set_point(self.get_length())
        self.freeze()
        previous_kind = None
        style = self.get_style()
        style_cache = {}
        try:
            for element in message:
                if element[0] == 'exception':
                    s = traceback.format_list(element[1]['traceback'])
                    s.extend(element[1]['exception'])
                    s = string.join(s, '')
                else:
                    s = element[1]

                if element[0] != previous_kind:
                    style = style_cache.get(element[0], None)
                    if style is None:
                        gtk.rc_parse_string(
                            'widget \"Manhole.*.Console\" '
                            'style \"Console_%s\"\n'
                            % (element[0]))
                        self.set_rc_style()
                        style_cache[element[0]] = style = self.get_style()
                # XXX: You'd think we'd use style.bg instead of 'None'
                # here, but that doesn't seem to match the color of
                # the backdrop.
                self.insert(style.font, style.fg[gtk.STATE_NORMAL],
                            None, s)
                previous_kind = element[0]
            l = self.get_length()
            diff = self.maxBufSz - l
            if diff < 0:
                diff = - diff
                self.delete_text(0,diff)
        finally:
            self.thaw()
        a = self.get_vadjustment()
        a.set_value(a.upper - a.page_size)
项目:gui-o-matic    作者:mailpile    | 项目源码 | 文件源码
def _set_background_image(self, container, image):
        themed_image = self._theme_image(image)
        img = gtk.gdk.pixbuf_new_from_file(themed_image)
        def draw_background(widget, ev):
            alloc = widget.get_allocation()
            pb = img.scale_simple(alloc.width, alloc.height,
                                  gtk.gdk.INTERP_BILINEAR)
            widget.window.draw_pixbuf(
                widget.style.bg_gc[gtk.STATE_NORMAL],
                pb, 0, 0, alloc.x, alloc.y)
            if (hasattr(widget, 'get_child') and
                    widget.get_child() is not None):
                widget.propagate_expose(widget.get_child(), ev)
            return False
        container.connect('expose_event', draw_background)
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def on_txtSearch_focus(self, widget, *args):
        if widget.get_text() == _('buscar...'):
            widget.modify_text(gtk.STATE_NORMAL, gtk.gdk.Color('black'))
            widget.set_text('')
    #-- Wmain.on_txtSearch_focus }

    #-- Wmain.on_txtSearch_focus_out_event {
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def on_txtSearch_focus_out_event(self, widget, *args):
        if widget.get_text() == '':
            widget.modify_text(gtk.STATE_NORMAL, gtk.gdk.Color('darkgray'))
            widget.set_text(_('buscar...'))
    #-- Wmain.on_txtSearch_focus_out_event }

    #-- Wmain.on_btnSearchBack_clicked {
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def change_color(self, color):
        self.eb.modify_bg(gtk.STATE_ACTIVE, color)
        self.eb2.modify_bg(gtk.STATE_ACTIVE, color)
        self.eb.modify_bg(gtk.STATE_NORMAL, color)
        self.eb2.modify_bg(gtk.STATE_NORMAL, color)
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def restore_color(self):
        bg = self.label.style.bg
        self.eb.modify_bg(gtk.STATE_ACTIVE, bg[gtk.STATE_ACTIVE])
        self.eb2.modify_bg(gtk.STATE_ACTIVE, bg[gtk.STATE_ACTIVE])
        self.eb.modify_bg(gtk.STATE_NORMAL, bg[gtk.STATE_NORMAL])
        self.eb2.modify_bg(gtk.STATE_NORMAL, bg[gtk.STATE_NORMAL])
项目:gimp-fanim    作者:douglasvini    | 项目源码 | 文件源码
def highlight(self,state):
        if state:
            self.set_state(gtk.STATE_SELECTED)
        else :
            self.set_state(gtk.STATE_NORMAL)
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def _colorize(self, _self):
        value = self.get_text()
        if value.startswith("0x"):
            value = value[2:]
        value = value.replace("0", "")
        if not value:
            self.modify_text(gtk.STATE_NORMAL, None)
        else:
            self.modify_text(gtk.STATE_NORMAL, gtk.gdk.color_parse('red'))
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        self.window = gtk.Window()
        self.window.set_title("Create An Image")
        self.window.set_icon_from_file(os.path.join(WORKINGDIR, "data", "icon.png"))
        colour = gtk.gdk.color_parse(DARKCOL)
        self.window.modify_bg(gtk.STATE_NORMAL, colour)

        self.vvbox = gtk.VBox()
        self.table = gtk.Table(5, 5)
        self.table.set_border_width(2)
        self.table.set_row_spacings(2)
        self.table.set_col_spacings(2)
        self.buttons = {}

        for y in range(5):
            for x in range(5):
                eb = gtk.EventBox()
                i = gtk.Image()
                i.set_from_file(os.path.join(WORKINGDIR, "data", "selected.png"))
                i.show()
                eb.add(i)
                eb.hide()
                eb.modify_bg(gtk.STATE_NORMAL, colour)
                eb.connect_object("button-press-event", self.togglePart, (x, y))

                eb2 = gtk.EventBox()
                i2 = gtk.Image()
                i2.set_from_file(os.path.join(WORKINGDIR, "data", "unselected.png"))
                i2.show()
                eb2.add(i2)
                eb2.show()
                eb2.modify_bg(gtk.STATE_NORMAL, colour)
                eb2.connect_object("button-press-event", self.togglePart, (x, y))

                self.buttons[(x, y)] = (eb, eb2)

                self.table.attach(eb, x, x + 1, y, y + 1)
                self.table.attach(eb2, x, x + 1, y, y + 1)

        self.table.show()
        self.vvbox.pack_start(self.table)
        hbox = gtk.HBox()
        self.confirmButton = gtk.Button("Okay")
        self.confirmButton.show()
        self.confirmButton.connect("clicked", self.okay)
        hbox.pack_start(self.confirmButton, True, False)
        cancelButton = gtk.Button("Cancel")
        cancelButton.connect("clicked", self.destroy)
        cancelButton.show()
        hbox.pack_end(cancelButton, True, False)
        hbox.show()
        self.vvbox.pack_start(hbox)
        self.vvbox.show()
        self.window.add(self.vvbox)
        self.onOkay = None

        self.running = True
        self.destoryed = False
项目:hazzy    作者:KurtJacobson    | 项目源码 | 文件源码
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')

        # Gremlin 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)