本文整理汇总了Python中gi.repository.Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION属性的典型用法代码示例。如果您正苦于以下问题:Python Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION属性的具体用法?Python Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION怎么用?Python Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_app_startup
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STYLE_PROVIDER_PRIORITY_APPLICATION [as 别名]
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
)
示例2: load_style_css
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STYLE_PROVIDER_PRIORITY_APPLICATION [as 别名]
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
示例3: override_menu_borders
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STYLE_PROVIDER_PRIORITY_APPLICATION [as 别名]
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
)
示例4: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STYLE_PROVIDER_PRIORITY_APPLICATION [as 别名]
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)
示例5: update_preview_carets
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STYLE_PROVIDER_PRIORITY_APPLICATION [as 别名]
def update_preview_carets(self, colorscheme):
self.css_providers.caret.load_from_data((
(Gtk.get_minor_version() >= 20 and """
* {{
caret-color: #{primary_caret_color};
-gtk-secondary-caret-color: #{secondary_caret_color};
-GtkWidget-cursor-aspect-ratio: {caret_aspect_ratio};
}}
""" or """
* {{
-GtkWidget-cursor-color: #{primary_caret_color};
-GtkWidget-secondary-cursor-color: #{secondary_caret_color};
-GtkWidget-cursor-aspect-ratio: {caret_aspect_ratio};
}}
""").format(
primary_caret_color=colorscheme['CARET1_FG'],
secondary_caret_color=colorscheme['CARET2_FG'],
caret_aspect_ratio=colorscheme['CARET_SIZE']
)
).encode('ascii'))
Gtk.StyleContext.add_provider(
self.gtk_preview.entry.get_style_context(),
self.css_providers.caret,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
)
示例6: reset_gradients
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STYLE_PROVIDER_PRIORITY_APPLICATION [as 别名]
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
)
示例7: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STYLE_PROVIDER_PRIORITY_APPLICATION [as 别名]
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)
]
示例8: main
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STYLE_PROVIDER_PRIORITY_APPLICATION [as 别名]
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()
示例9: configure_transparency
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STYLE_PROVIDER_PRIORITY_APPLICATION [as 别名]
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)
示例10: on_fullscreen_changed
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STYLE_PROVIDER_PRIORITY_APPLICATION [as 别名]
def on_fullscreen_changed(self, window):
self.window.toggle_menubar(True) # always do this first to allow recovery
screen = Gdk.Screen.get_default()
if window.isfullscreen:
self._show_panes = bool(window.get_visible_panes())
window.toggle_panes(False)
self.save_bar_state()
self.set_bar_state_fullscreen()
self.insert_maxwidth()
for widget in self._pathbar_widgets():
widget.hide()
self._css_provider = self._new_css_provider()
Gtk.StyleContext.add_provider_for_screen(screen, self._css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
else:
Gtk.StyleContext.remove_provider_for_screen(screen, self._css_provider)
self.remove_maxwidth()
window.toggle_panes(self._show_panes)
self.restore_bar_state()
for widget in self._pathbar_widgets():
widget.show()
window.pageview.grab_focus()
示例11: apply_styling_to_screen
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STYLE_PROVIDER_PRIORITY_APPLICATION [as 别名]
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
示例12: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STYLE_PROVIDER_PRIORITY_APPLICATION [as 别名]
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()
示例13: add_widget_custom_css
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STYLE_PROVIDER_PRIORITY_APPLICATION [as 别名]
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)
示例14: add_custom_css
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STYLE_PROVIDER_PRIORITY_APPLICATION [as 别名]
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)
示例15: scroll_changed
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STYLE_PROVIDER_PRIORITY_APPLICATION [as 别名]
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")