python类RGBA的实例源码

table.py 文件源码 项目:MTTT 作者: roxana-lafuente 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def cell_in_translation_table_is_being_focused(self, a, b, segment_index):
        if self.last_cell_focused is not None:
            if self.last_cell_focused_index in self.translation_reference_text_TextViews_modified_flag.keys():
                self.last_cell_focused.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0.7, 249, 249, 240))
            else:
                self.last_cell_focused.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(1.0, 1.0, 1.0, 1.0))
        self.last_cell_focused = self.tables_content[self.reference_text_views][segment_index]
        self.last_cell_focused.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0.9, 1, 1, 1))
        self.last_cell_focused_index = segment_index
SettingsWidgets.py 文件源码 项目:lightdm-settings 作者: linuxmint 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, keyfile, settings, key):
        self.key = key
        self.keyfile = keyfile
        try:
            self.value = keyfile.get_string(GROUP_NAME, key)
        except:
            self.value = settings.get_string(key)
        Gtk.ColorButton.__init__(self)
        rgba = Gdk.RGBA()
        rgba.parse(self.value)
        self.set_rgba(rgba)
        self.connect("color-set", self.on_color_set)
drawing.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def color_floats(spec):
    rgba = Gdk.RGBA()
    rgba.parse(spec)
    return rgba.red, rgba.green, rgba.blue
drawing.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def color_floats(spec):
    rgba = Gdk.RGBA()
    rgba.parse(spec)
    return rgba.red, rgba.green, rgba.blue
windows.py 文件源码 项目:htmlDE 作者: freundTech 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, url, posx, posy, width, height, transparent):
        Gtk.Window.__init__(self, Gtk.WindowType.TOPLEVEL, title='')
        self.transparent = transparent
        self.move(posx, posy)
        self.set_default_size(width, height)
        self.set_decorated(False)


        self.webview = WebKit2.WebView()

        settings = self.webview.get_settings()
        settings.set_allow_file_access_from_file_urls(True)
        settings.set_allow_universal_access_from_file_urls(True)
        settings.set_enable_webgl(True)
        self.webview.set_settings(settings)

        self.add(self.webview)

        if (self.transparent):
            self.webview.set_background_color(Gdk.RGBA(0, 0, 0, 0))
            self.installTransparency(self)
            self.installTransparency(self.webview)

        self.connect("delete_event", self.close_application)

        self.webview.connect("context-menu", self.context_menu)
        self.webview.connect("decide-policy", self.navigation_requested)
        self.webview.connect("resource-load-started", self.resource_load_started)

        self.webview.load_uri(url)
        inject_libraries(self.webview)
windows.py 文件源码 项目:htmlDE 作者: freundTech 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def installTransparency(self, component):
        component.set_visual(component.get_screen().get_rgba_visual())

        component.override_background_color(Gtk.StateFlags.ACTIVE, Gdk.RGBA(0, 0, 0, 0))
        component.override_background_color(Gtk.StateFlags.BACKDROP, Gdk.RGBA(0, 0, 0, 0))
        component.override_background_color(Gtk.StateFlags.DIR_LTR, Gdk.RGBA(0, 0, 0, 0))
        component.override_background_color(Gtk.StateFlags.DIR_RTL, Gdk.RGBA(0, 0, 0, 0))
        component.override_background_color(Gtk.StateFlags.FOCUSED, Gdk.RGBA(0, 0, 0, 0))
        component.override_background_color(Gtk.StateFlags.INCONSISTENT, Gdk.RGBA(0, 0, 0, 0))
        component.override_background_color(Gtk.StateFlags.INSENSITIVE, Gdk.RGBA(0, 0, 0, 0))
        component.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0, 0, 0, 0))
        component.override_background_color(Gtk.StateFlags.PRELIGHT, Gdk.RGBA(0, 0, 0, 0))
        component.override_background_color(Gtk.StateFlags.SELECTED, Gdk.RGBA(0, 0, 0, 0))
mate-menu-config.py 文件源码 项目:mate-menu 作者: ubuntu-mate 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def bindGSettingsValueToWidget( self, settings, setting_type, key, widget, changeEvent, setter, getter ):
        settings.notifyAdd( key, self.callSetter, args = [ setting_type, setter ] )
        if setting_type == "color":
            color = Gdk.RGBA()
            color.parse( settings.get( setting_type, key ) )
            setter( color )
        else:
            setter( settings.get( setting_type, key ) )
        widget.connect( changeEvent, lambda *args: self.callGetter( settings, setting_type, key, getter ) )
mate-menu-config.py 文件源码 项目:mate-menu 作者: ubuntu-mate 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def callSetter( self, settings, key, args ):
        if args[0] == "bool":
            args[1]( settings.get_boolean(key) )
        elif args[0] == "string":
            args[1]( settings.get_string(key) )
        elif args[0] == "int":
            args[1]( settings.get_int(key) )
        elif args[0] == "color":
            color = Gdk.RGBA()
            color.parse( settings.get_string(key) )
            args[1]( color )
mate-menu.py 文件源码 项目:mate-menu 作者: ubuntu-mate 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def SetPaneColors( self, items, color = None ):
        for item in items:
            context = item.get_style_context()
            if self.usecustomcolor:
                bgColor = Gdk.RGBA()
                bgColor.parse( self.customcolor )
                item.override_background_color( context.get_state(), bgColor )
            elif color is not None:
                item.override_background_color( context.get_state(), color )
mate-menu.py 文件源码 项目:mate-menu 作者: ubuntu-mate 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def onWindowDraw(self, widget, cr):
        if self.usecustomcolor:
            borderColor = Gdk.RGBA()
            borderColor.parse(self.custombordercolor)
            Gdk.cairo_set_source_rgba(cr, borderColor)
            cr.paint()
        else:
            style = widget.get_style_context()
            req = widget.get_preferred_size()[0]
            Gtk.render_background(style, cr, 0, 0, req.width, req.height)
            Gtk.render_frame(style, cr, 0, 0, req.width, req.height)
        return False
fux-terminal.py 文件源码 项目:fux-terminal 作者: fuxprojesi 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def main(self):
        """
        main: Ana S?n?f?n, Ana Fonksiyonu
        """
        # VTE'nin tan?mlamalar? ve sinyalleri
        terminal.drag_dest_set(0, [], 0)
        terminal.connect("drag_motion", DragDrop.motion_cb)
        terminal.connect("drag_drop", DragDrop.drop_cb)
        terminal.connect("drag_data_received", DragDrop.got_data_cb)
        terminal.connect("button-press-event", RightClick.on_button_press_event)
        terminal.connect("child-exited", Gtk.main_quit)

        # VTE e? zamanl? görüntüleme için bash kabu?u kullan?larak kullan?c? dizinine ayarlan?yor
        terminal.spawn_sync(Vte.PtyFlags.DEFAULT, os.environ["HOME"], 
                            ["/bin/bash"], [], 
                            GLib.SpawnFlags.DO_NOT_REAP_CHILD, 
                            None, None)

        # VTE'nin arkaplan rengi siyah, %90 opak - %10 transparan
        terminal.set_color_background(Gdk.RGBA(0, 0, 0, 0.9))
        # VTE'nin yaz? rengi beyaz ve opak
        terminal.set_color_foreground(Gdk.RGBA(1, 1, 1, 1.0))

        # Font ve Kodlama atamas?
        font = Pango.FontDescription("Monospace Regular 11")
        terminal.set_font(font)
        terminal.set_encoding("UTF-8")

        # Ana pencere tan?mlan?yor
        win = Gtk.Window(Gtk.WindowType.TOPLEVEL)
        win.connect("delete-event", Gtk.main_quit)
        win.connect("draw", FuxTerminal.area_draw)

        win.set_default_size(765, 360)
        win.set_title("Fux Terminal")
        win.set_position(Gtk.WindowPosition.CENTER)
        win.set_icon_name("utilities-terminal")
        win.set_app_paintable(True)

        # Sadece VTE'nin veya sadece pencere'nin transparan olmas? yeterli de?il
        # ?kiside ayn? arkaplan rengi ve ayn? opakl?kta olmal? ki istedi?imiz
        # Transparan özellikte olsun
        win.screen = win.get_screen()
        win.visual = win.screen.get_rgba_visual()
        win.set_visual(win.visual)

        # Pencere'ye VTE ekleniyor ve gösteriliyor
        win.add(terminal)
        win.show_all()

        Gtk.main()
theme_creator.py 文件源码 项目:XFWM_theme_creator 作者: Sjc1000 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def press(self, widget, event):
        """press
        Called when the user presses a mouse button.
        Left click: Paint the currently active foreground color.
        Right Click: Remove the pixel under the mouse.
        Middle Click: Fill with the active foreground color.
        """
        if self.image is None:
            return None
        main_window = self.get_toplevel()
        var_name = main_window.var_list.active
        image_width = len(self.image[0])
        image_height = len(self.image)
        x = math.floor((event.x)/self.scale)
        y = math.floor((event.y)/self.scale)
        if x+1 > image_width or y+1 > image_height or x < 0 or y < 0:
            return None

        if event.button == 2:
            r, g, b, a = main_window.paint_color.get_rgba()
            color = [Gdk.RGBA(r, g, b), var_name]
            original = self.image[y][x]
            for yi, y in enumerate(self.image):
                for xi, x in enumerate(y):
                    if str(self.image[yi][xi]) != str(original):
                        continue
                    self.image[yi][xi] = color
            self.view.queue_draw()
            return None

        elif event.button == 1 and self.get_color:
            color = self.image[y][x]
            main_window.var_list.active = None
            main_window.paint_color.set_rgba(color[0])
            for index, item in enumerate(main_window.var_list.list):
                path = Gtk.TreePath().new_from_string(str(index))
                if item[0] == color[1]:
                    item[1] = True
                    main_window.var_list.active = item[0]
                else:
                    item[1] = False

            return None
        if event.button == 1:
            color = main_window.paint_color.get_rgba()
        elif event.button == 3:
            color = None

        if self.last is not None and self.square:
            lx, ly = self.last
            for xi in range(image_width):
                for yi in range(image_height):
                    if ((x > lx and lx <= xi <= x or x < lx and lx >= xi >= x)
                            and (y > ly and ly <= yi <= y or y < ly
                            and ly >= yi >= y)):
                        self.image[yi][xi] = [color, var_name]
        else:
            self.image[y][x] = [color, var_name]
            self.last = [x, y]
        self.view.queue_draw()
        return None
theme_creator.py 文件源码 项目:XFWM_theme_creator 作者: Sjc1000 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def load_files(self, folder):
        global files
        new_files = OrderedDict()
        image_files = sorted(os.listdir(folder))
        if 'xfwm4' in image_files:
            self.load_files(folder + '/xfwm4')
            return None
        for name in image_files:
            if name == 'themerc':
                # I might build in themerc support.
                # for now, I skip this.
                continue
            if not name.endswith('.xpm'):
                continue
            with open('{}/{}'.format(folder, name), 'r') as f:
                data = f.read().replace('\n', '')
            content = data.split('{')[1]
            content = content.strip('{};').split(',')
            chars = {}

            # Parse the width / height / number of colors
            width, height, colors, _ = content[0].strip('"').split(' ')
            width = int(width)
            height = int(height)
            for i in range(int(colors)):
                color_info = content[i+1].strip('"')
                char, color = color_info.split('c', 1)
                char = char[0]
                if 's' in color:
                    color, var = color.split('s', 1)
                else:
                    var = None
                color = color.strip()
                if color.lower() == 'none':
                    color = None
                if var is not None:
                    var = var.strip()
                if color is not None:
                    color = color.lstrip('#')
                    color = Gdk.RGBA(*(x/255 for x in bytes.fromhex(color)))
                chars[char] = [color, var]
            image = [[[None, None] for x in range(width)] for y in range(height)]
            for yi, y in enumerate(content[len(chars)+1:]):
                for xi, x in enumerate(y.strip('"')):
                    image[yi][xi] = chars[x]
            filename = name.split('.')[0]
            new_files.update({filename: {'image': image,
                         'size': [width, height]}})
        for name in names:
            if name not in image_files:
                files.update({name: {'image': [[[None, None]]], 'size': [1, 1]}})

        for name in sorted(new_files):
            files.update({name: new_files[name]})

        self.file_selecter.active = None
        return None


问题


面经


文章

微信
公众号

扫码关注公众号