Python gi.repository.Gtk.CssProvider() Examples
The following are 30
code examples of gi.repository.Gtk.CssProvider().
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: heading.py From kano-toolset with GNU General Public License v2.0 | 9 votes |
def __init__(self, title, description): cssProvider = Gtk.CssProvider() cssProvider.load_from_path(common_css_dir + "/heading.css") styleContext = Gtk.StyleContext() styleContext.add_provider(cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER) self.title = Gtk.Label(title) self.title_style = self.title.get_style_context() self.title_style.add_provider(cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER) self.title_style.add_class('title') self.container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10) self.container.pack_start(self.title, False, False, 0) if description != "": self.description = Gtk.Label(description) self.description.set_justify(Gtk.Justification.CENTER) self.description.set_line_wrap(True) self.description_style = self.description.get_style_context() self.description_style.add_provider(cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER) self.description_style.add_class('description') self.container.pack_start(self.description, False, False, 0)
Example #2
Source File: distractionfree.py From zim-desktop-wiki with GNU General Public License v2.0 | 6 votes |
def _new_css_provider(self): css = ''' #zim-pageview text { color: %s; background-color: %s; } widget box box scrolledwindow{ border-style: none; } box { background-color: %s; } ''' % (self.preferences['textcolor'], self.preferences['basecolor'],self.preferences['basecolor']) provider = Gtk.CssProvider() provider.load_from_data(css.encode('UTF-8')) return provider
Example #3
Source File: gtk.py From pywebview with BSD 3-Clause "New" or "Revised" License | 6 votes |
def configure_transparency(c): c.set_visual(c.get_screen().get_rgba_visual()) c.override_background_color(gtk.StateFlags.ACTIVE, Gdk.RGBA(0, 0, 0, 0)) c.override_background_color(gtk.StateFlags.BACKDROP, Gdk.RGBA(0, 0, 0, 0)) c.override_background_color(gtk.StateFlags.DIR_LTR, Gdk.RGBA(0, 0, 0, 0)) c.override_background_color(gtk.StateFlags.DIR_RTL, Gdk.RGBA(0, 0, 0, 0)) c.override_background_color(gtk.StateFlags.FOCUSED, Gdk.RGBA(0, 0, 0, 0)) c.override_background_color(gtk.StateFlags.INCONSISTENT, Gdk.RGBA(0, 0, 0, 0)) c.override_background_color(gtk.StateFlags.INSENSITIVE, Gdk.RGBA(0, 0, 0, 0)) c.override_background_color(gtk.StateFlags.NORMAL, Gdk.RGBA(0, 0, 0, 0)) c.override_background_color(gtk.StateFlags.PRELIGHT, Gdk.RGBA(0, 0, 0, 0)) c.override_background_color(gtk.StateFlags.SELECTED, Gdk.RGBA(0, 0, 0, 0)) transparentWindowStyleProvider = gtk.CssProvider() transparentWindowStyleProvider.load_from_data(b""" GtkWindow { background-color:rgba(0,0,0,0); background-image:none; }""") c.get_style_context().add_provider(transparentWindowStyleProvider, gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
Example #4
Source File: touchpad.py From hazzy with GNU General Public License v2.0 | 6 votes |
def main(): style_provider = Gtk.CssProvider() with open(os.path.join(STYLEDIR, "style.css"), 'rb') as css: css_data = css.read() style_provider.load_from_data(css_data) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION ) TouchPad(test=True) Gtk.main()
Example #5
Source File: talk_time.py From pympress with GNU General Public License v2.0 | 6 votes |
def __init__(self, label_time): self.label_time = label_time style_context = self.label_time.get_style_context() self.color_override = Gtk.CssProvider() style_context.add_provider(self.color_override, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + 1) self.label_color_default = self.load_color_from_css(style_context) label_color_ett_reached = self.load_color_from_css(style_context, "ett-reached") label_color_ett_info = self.load_color_from_css(style_context, "ett-info") label_color_ett_warn = self.load_color_from_css(style_context, "ett-warn") self.color_map = [ ( 300, self.label_color_default), ( 0, label_color_ett_reached), (-150, label_color_ett_info), (-300, label_color_ett_warn) ]
Example #6
Source File: preview.py From oomox with GNU General Public License v3.0 | 6 votes |
def get_theme_css_provider(self, theme_plugin): css_dir = theme_plugin.gtk_preview_dir css_name = "theme{}.css".format( '20' if Gtk.get_minor_version() >= 20 else '' ) css_path = os.path.join(css_dir, css_name) if not os.path.exists(css_path): css_path = os.path.join(css_dir, "theme.css") css_provider = self.css_providers.theme.get(css_path) if css_provider: return css_provider css_provider = Gtk.CssProvider() try: css_provider.load_from_path(css_path) except GLib.Error as exc: # pylint: disable=catching-non-exception print(exc) self.css_providers.theme[css_path] = css_provider return css_provider
Example #7
Source File: preview.py From oomox with GNU General Public License v3.0 | 6 votes |
def reset_gradients(self): css_provider_gradient = self.css_providers.gradient.get("reset") if not css_provider_gradient: css_provider_gradient = \ self.css_providers.gradient["reset"] = \ Gtk.CssProvider() css_provider_gradient.load_from_data(( """ * { background-image: none; } """ ).encode('ascii')) for widget in [ self.gtk_preview.button, self.gtk_preview.headerbar.button, self.gtk_preview.entry, self.gtk_preview.headerbar, ]: Gtk.StyleContext.add_provider( widget.get_style_context(), css_provider_gradient, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION )
Example #8
Source File: preview.py From oomox with GNU General Public License v3.0 | 6 votes |
def __init__(self): self.theme = {} self.gradient = {} self.border = {} self.headerbar_border = Gtk.CssProvider() self.headerbar_border.load_from_data(( """ headerbar { border: none; border-radius: 0; } """ ).encode('ascii')) self.wm_border = Gtk.CssProvider() self.caret = Gtk.CssProvider() self.reset_style = Gtk.CssProvider() self.reset_style.load_from_data(( """ * { box-shadow:none; border: none; } """ ).encode('ascii'))
Example #9
Source File: break_screen.py From SafeEyes with GNU General Public License v3.0 | 6 votes |
def __init__(self, context, on_skip, on_postpone, style_sheet_path): self.context = context self.count_labels = [] self.display = Display() self.enable_postpone = False self.enable_shortcut = False self.is_pretified = False self.keycode_shortcut_postpone = 65 self.keycode_shortcut_skip = 9 self.on_postpone = on_postpone self.on_skip = on_skip self.shortcut_disable_time = 2 self.strict_break = False self.windows = [] # Initialize the theme css_provider = Gtk.CssProvider() css_provider.load_from_path(style_sheet_path) Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
Example #10
Source File: windows.py From syncthing-gtk with GNU General Public License v2.0 | 6 votes |
def override_menu_borders(): """ Loads custom CSS to create borders around popup menus """ style_provider = Gtk.CssProvider() style_provider.load_from_data(b""" .menu { border-image: linear-gradient(to top, alpha(@borders, 0.80), alpha(@borders, 0.60) 33%, alpha(@borders, 0.50) 66%, alpha(@borders, 0.15)) 2 2 2 2/ 2px 2px 2px 2px; } .menubar .menu { border-image: linear-gradient(to top, alpha(@borders, 0.80), alpha(@borders, 0.60) 33%, alpha(@borders, 0.50) 66%, transparent 99%) 2 2 2 2/ 2px 2px 2px 2px; } """) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION )
Example #11
Source File: modules.py From gpt with GNU General Public License v3.0 | 6 votes |
def on_app_startup(self, app): # initiate custom css # css stylesheet stylesheet = os.path.join(cli.install_dir, "ui", "gtk.css") # ...encode() is needed because CssProvider expects byte type input with open(stylesheet, "r") as f: css = f.read().encode() style_provider = Gtk.CssProvider() style_provider.load_from_data(css) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION )
Example #12
Source File: application.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 6 votes |
def load_style_css(self, css_file): self.logger.debug('loading style from css file: ' + css_file) css_file = Gio.File.new_for_path(css_file) style_provider = Gtk.CssProvider() style_provider.connect('parsing-error', self.signal_css_provider_parsing_error) try: style_provider.load_from_file(css_file) except GLib.Error: # pylint: disable=catching-non-exception self.logger.error('there was an error parsing the css file, it will not be applied as a style provider') return None Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION ) return style_provider
Example #13
Source File: gtk.py From kickoff-player with GNU General Public License v3.0 | 5 votes |
def add_custom_css(style): screen = Gdk.Screen.get_default() priority = Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION provider = Gtk.CssProvider() filename = relative_path(style) if os.path.exists(filename): provider.load_from_path(filename) else: provider.load_from_data(style.encode()) Gtk.StyleContext.add_provider_for_screen(screen, provider, priority)
Example #14
Source File: application.py From Authenticator with GNU General Public License v2.0 | 5 votes |
def __setup_css(): """Setup the CSS and load it.""" uri = 'resource:///com/github/bilelmoussaoui/Authenticator/style.css' provider_file = Gio.File.new_for_uri(uri) provider = Gtk.CssProvider() screen = Gdk.Screen.get_default() context = Gtk.StyleContext() provider.load_from_file(provider_file) context.add_provider_for_screen(screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_USER) Logger.debug("Loading CSS")
Example #15
Source File: widgets.py From zim-desktop-wiki with GNU General Public License v2.0 | 5 votes |
def widget_set_css(widget, name, css): text = '#%s {%s}' % (name, css) css_provider = Gtk.CssProvider() css_provider.load_from_data(text.encode('UTF-8')) widget_style = widget.get_style_context() widget_style.add_provider(css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) widget.set_name(name)
Example #16
Source File: styled_window.py From Apostrophe with GNU General Public License v3.0 | 5 votes |
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # Set theme css css_provider_file = Gio.File.new_for_uri( "resource:///org/gnome/gitlab/somas/Apostrophe/media/css/gtk/base.css") style_provider = Gtk.CssProvider() style_provider.load_from_file(css_provider_file) Gtk.StyleContext.add_provider_for_screen( self.get_screen(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
Example #17
Source File: apply_styles.py From kano-toolset with GNU General Public License v2.0 | 5 votes |
def apply_styling_to_screen(css_file, priority="USER"): css = Gtk.CssProvider() if not os.path.exists(css_file): sys.exit(css_file + ' CSS file missing!') css.load_from_path(css_file) screen = Gdk.Screen.get_default() styleContext = Gtk.StyleContext() if priority == "FALLBACK": gtk_priority = Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK elif priority == "THEME": gtk_priority = Gtk.STYLE_PROVIDER_PRIORITY_THEME elif priority == "SETTINGS": gtk_priority = Gtk.STYLE_PROVIDER_PRIORITY_SETTINGS elif priority == "APPLICATION": gtk_priority = Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION elif priority == "USER": gtk_priority = Gtk.STYLE_PROVIDER_PRIORITY_USER styleContext.add_provider_for_screen(screen, css, gtk_priority) # Apply the styling from a CSS file to a specific widget
Example #18
Source File: apply_styles.py From kano-toolset with GNU General Public License v2.0 | 5 votes |
def apply_styling_to_widget(widget, path): if not os.path.exists(path): sys.exit('{} CSS file missing!'.format(path)) provider = Gtk.CssProvider() provider.load_from_path(path) styleContext = widget.get_style_context() styleContext.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_USER) # Apply the colour variable names to the widget (useful if you want to refer to kano_green)
Example #19
Source File: MainWindow.py From kano-apps with GNU General Public License v2.0 | 5 votes |
def __init__(self, install=None, icon_only=False, tutorial=False): ApplicationWindow.__init__(self, 'Apps', 755, 588) self._install = install self._tutorial = tutorial self._icon_only = icon_only self._last_page = 0 self.connect("show", self._app_loaded) # Destructor self.connect('delete-event', Gtk.main_quit) self.set_icon_from_file("/usr/share/kano-desktop/icons/apps.png") # Styling screen = Gdk.Screen.get_default() specific_css_provider = Gtk.CssProvider() specific_css_provider.load_from_path(Media.media_dir() + 'css/style.css') specific_style_context = Gtk.StyleContext() specific_style_context.add_provider_for_screen( screen, specific_css_provider, Gtk.STYLE_PROVIDER_PRIORITY_USER ) style = self.get_style_context() style.add_class('main_window') # Setup widgets self.set_decorated(True) self._top_bar = TopBar(_("Apps"), self._win_width, False) self._top_bar.set_close_callback(Gtk.main_quit) self.set_titlebar(self._top_bar) self._contents = Contents(self) self.set_main_widget(self._contents) self.show_apps_view()
Example #20
Source File: gtk_ui.py From oversteer with GNU General Public License v3.0 | 5 votes |
def __init__(self, gui): self.gui = gui style_provider = Gtk.CssProvider() style_provider.load_from_path(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'main.css')) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION ) self._set_builder_objects() self._set_markers() cell_renderer = Gtk.CellRendererText() self.device_combobox.pack_start(cell_renderer, True) self.device_combobox.add_attribute(cell_renderer, 'text', 1) self.device_combobox.set_id_column(0) cell_renderer = Gtk.CellRendererText() self.profile_combobox.pack_start(cell_renderer, True) self.profile_combobox.add_attribute(cell_renderer, 'text', 1) self.profile_combobox.set_id_column(0) cell_renderer = Gtk.CellRendererText() self.emulation_mode_combobox.pack_start(cell_renderer, True) self.emulation_mode_combobox.add_attribute(cell_renderer, 'text', 1) self.emulation_mode_combobox.set_id_column(0) self.set_wheel_range_overlay('never') self.builder.connect_signals(self) self.window.show_all()
Example #21
Source File: mainwindow.py From lplayer with MIT License | 5 votes |
def load_css(self): style_provider = Gtk.CssProvider() style_provider.load_from_data(CSS.encode()) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
Example #22
Source File: LearnInfoBar.py From pychess with GNU General Public License v3.0 | 5 votes |
def add_provider(widget): screen = widget.get_screen() style = widget.get_style_context() provider = Gtk.CssProvider() provider.load_from_data(css.encode('utf-8')) style.add_provider_for_screen(screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
Example #23
Source File: annotationPanel.py From pychess with GNU General Public License v3.0 | 5 votes |
def add_provider(widget): screen = widget.get_screen() style = widget.get_style_context() provider = Gtk.CssProvider() provider.load_from_data(css.encode('utf-8')) style.add_provider_for_screen(screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_USER) # -- Documentation
Example #24
Source File: statusbar.py From vimiv with MIT License | 5 votes |
def _error_false(self): """Strip one error and update the statusbar if no more errors remain.""" # Remove any timers that remove the error message if self._timer_id: GLib.source_remove(self._timer_id) self._timer_id = 0 # Strip one error self._errors = False # Reset css from error_message css_provider = Gtk.CssProvider() css_str = "#OverLay { border-top: solid 0px; }" css_provider.load_from_data(css_str.encode()) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
Example #25
Source File: statusbar.py From vimiv with MIT License | 5 votes |
def message(self, message, style="error", timeout=5): """Push a message to the statusbar. Args: message: Message to push. style: One of error, warning and info. timeout: Time until the message shall be removed by update info. """ if self._app.debug: self._app["log"].write_message(style, message) self._errors = True styles = {"error": "#CC0000", "warning": "#FA9E21", "info": "#6699FF"} message = "<b><span foreground='" + styles[style] + "'>" + \ style.upper() + ": </span></b>" + message self._timer_id = GLib.timeout_add(timeout * 1000, self.update_info) # Show if is was hidden if not settings["display_bar"].get_value(): settings.override("display_bar", "true") self._was_hidden = True self._left_label.set_markup(message) # CSS to style bar according to message css_provider = Gtk.CssProvider() css_str = "#OverLay { border-top: solid 2px " + styles[style] + ";}" css_provider.load_from_data(css_str.encode()) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
Example #26
Source File: app.py From vimiv with MIT License | 5 votes |
def _create_window_structure(self): """Generate the structure of all the widgets and add it to the window. There is a large Gtk.Grid() to organize the widgets packed into a Gtk.Overlay(). The commandline is added as overlay. """ main_grid = Gtk.Grid() main_grid.attach(self["library"].grid, 0, 0, 1, 1) main_grid.attach(self["main_window"], 1, 0, 1, 1) main_grid.attach(self["manipulate"], 0, 1, 2, 1) main_grid.attach(self["statusbar"].separator, 0, 2, 2, 1) overlay_grid = Gtk.Grid() overlay_grid.attach(self["statusbar"], 0, 0, 1, 1) overlay_grid.attach(self["completions"].info, 0, 1, 1, 1) overlay_grid.attach(self["commandline"], 0, 2, 1, 1) overlay_grid.set_valign(Gtk.Align.END) # Make it nice using CSS overlay_grid.set_name("OverLay") style = Gtk.Window().get_style_context() bg = style.get_background_color(Gtk.StateType.NORMAL) color_str = "#OverLay { background: " + bg.to_string() + "; }" command_provider = Gtk.CssProvider() command_css = color_str.encode() command_provider.load_from_data(command_css) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), command_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) # Overlay contains grid mainly and adds commandline as floating overlay = Gtk.Overlay() overlay.add(main_grid) overlay.add_overlay(overlay_grid) self["window"].add(overlay)
Example #27
Source File: application.py From Audio-Cutter with GNU General Public License v3.0 | 5 votes |
def _setup_css(self): """Setup the CSS.""" resource = 'resource:////com/github/bilelmoussaoui/AudioCutter/style.css' css_file = Gio.File.new_for_uri(resource) cssProvider = Gtk.CssProvider() screen = Gdk.Screen.get_default() styleContext = Gtk.StyleContext() cssProvider.load_from_file(css_file) styleContext.add_provider_for_screen(screen, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER) Logger.debug("Loading css file {}".format(css_file))
Example #28
Source File: application.py From gtg with GNU General Public License v3.0 | 5 votes |
def init_style(self): """Load the application's CSS file.""" screen = Gdk.Screen.get_default() provider = Gtk.CssProvider() add_provider = Gtk.StyleContext.add_provider_for_screen css_path = os.path.join(CSS_DIR, 'style.css') provider.load_from_path(css_path) add_provider(screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
Example #29
Source File: themes.py From addons-source with GNU General Public License v2.0 | 5 votes |
def scroll_changed(self, obj): ''' Scrollbar changed ''' value = obj.get_active() config.set('interface.fixed-scrollbar', str(value)) self.gtksettings.set_property('gtk-primary-button-warps-slider', not value) if hasattr(MyPrefs, 'provider'): Gtk.StyleContext.remove_provider_for_screen( Screen.get_default(), MyPrefs.provider) if value: MyPrefs.provider = Gtk.CssProvider() css = ('* { -GtkScrollbar-has-backward-stepper: 1; ' '-GtkScrollbar-has-forward-stepper: 1; }') MyPrefs.provider.load_from_data(css.encode('utf8')) Gtk.StyleContext.add_provider_for_screen( Screen.get_default(), MyPrefs.provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) try: if value: txt = subprocess.check_output('setx GTK_OVERLAY_SCROLLING 0', shell=True) else: txt = subprocess.check_output( 'reg delete HKCU\Environment /v GTK_OVERLAY_SCROLLING /f', shell=True) except subprocess.CalledProcessError: print("Cannot set environment variable GTK_OVERLAY_SCROLLING")
Example #30
Source File: gtk.py From kickoff-player with GNU General Public License v3.0 | 5 votes |
def add_widget_custom_css(widget, style): priority = Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION provider = Gtk.CssProvider() context = widget.get_style_context() filename = relative_path(style) if os.path.exists(filename): provider.load_from_path(filename) else: provider.load_from_data(style.encode()) context.add_provider(provider, priority)