Python gi.repository.Gtk 模块,STYLE_PROVIDER_PRIORITY_APPLICATION 实例源码

我们从Python开源项目中,提取了以下22个代码示例,用于说明如何使用gi.repository.Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION

项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def start_app(datadir):
    global splash_win
    if not options.no_splash:
        solfege.splash_win = splash_win = SplashWin()
        time.sleep(0.1)
        Gdk.flush()
        while Gtk.events_pending():
            Gtk.main_iteration()

    else:
        solfege.splash_win = splash_win = None
    style_provider = Gtk.CssProvider()
    with open("solfege.css", "r") as f:
        css = f.read()
    try:
        style_provider.load_from_data(css)
    except GObject.GError, e:
        print e
        pass
    Gtk.StyleContext.add_provider_for_screen(
        Gdk.Screen.get_default(), style_provider,
        Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
    GObject.timeout_add(1, start_gui, datadir)
    Gtk.main()
项目:pedro    作者:saandial    | 项目源码 | 文件源码
def gtk_style():
        css = b"""

#button {
    color: #ffffff;
    background: #e80606;
}
#servo {
    color: #ffffff;
    background: #d80606;
}

        """
        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
        )
项目:pedro    作者:saandial    | 项目源码 | 文件源码
def gtk_style():
        css = b"""

#button {
    color: #ffffff;
    background: #e80606;
}
#servo {
    color: #ffffff;
    background: #d80606;
}

        """
        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
        )
项目:apart-gtk    作者:alexheretic    | 项目源码 | 文件源码
def main():
    win = Window()
    # allow keyboard interrupt / nodemon to end program cleanly
    for sig in [signal.SIGINT, signal.SIGTERM, signal.SIGUSR2]:
        signal.signal(sig, lambda _s, _f: win.on_delete())

    style_provider = Gtk.CssProvider()
    style_provider.load_from_path(os.path.dirname(os.path.realpath(__file__)) + "/apart.css")
    Gtk.StyleContext.add_provider_for_screen(
        Gdk.Screen.get_default(),
        style_provider,
        Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
    )

    win.show_all()
    Gtk.main()
项目:gpt    作者:encarsia    | 项目源码 | 文件源码
def __init__(self):
        self.builder = Gtk.Builder()
        self.builder.set_translation_domain(cli.appname)

        #load tlcalculator and subordinated window glade files
        self.builder.add_from_file(cli.gladefile[0])
        self.builder.add_from_file(cli.gladefile[1])

        #initiate custom css
        #...encode() is needed because CssProvider expects byte type input

        with open(cli.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
        )
项目:MTTT    作者:roxana-lafuente    | 项目源码 | 文件源码
def gtk_change_visuals(self, light_option="unchanged", theme="unchanged"):
        if Gtk.MAJOR_VERSION >= 3 and Gtk.MINOR_VERSION >= 14:
            css_filename = "gtk"
            filename = ""
            if theme == "metro" or theme == "paper":
                self.gtk_theme = theme
            if light_option == "gtk" or light_option == "gtk-dark":
                self.lightsOption = light_option
            filename = 'gui/' + self.gtk_theme + '/'+ self.lightsOption + '.css'
            css = open(filename, 'r')

            style_provider = Gtk.CssProvider()
            css_data = css.read()
            css.close()

            style_provider.load_from_data(css_data)

            Gtk.StyleContext.add_provider_for_screen(
                Gdk.Screen.get_default(),
                style_provider,
                Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
            )
项目:SafeEyes    作者:slgobinath    | 项目源码 | 文件源码
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)
项目:budgie-extras    作者:UbuntuBudgie    | 项目源码 | 文件源码
def color_button(self, button, hexcol):
        provider = self.set_css(hexcol)
        color_cont = button.get_style_context()
        color_cont.add_class("colorbutton")
        Gtk.StyleContext.add_provider(
            color_cont,
            provider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION,
        )
项目:budgie-extras    作者:UbuntuBudgie    | 项目源码 | 文件源码
def color_button(self, button, hexcol):
        provider = self.set_css(hexcol)
        color_cont = button.get_style_context()
        color_cont.add_class("colorbutton")
        Gtk.StyleContext.add_provider(
            color_cont,
            provider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION,
        )
项目:mcg    作者:coderkun    | 项目源码 | 文件源码
def _load_css(self):
        styleProvider = Gtk.CssProvider()
        styleProvider.load_from_resource(self._get_resource_path('gtk.css'))
        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(),
            styleProvider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
        )
项目:gedit-scroll-past    作者:hardpixel    | 项目源码 | 文件源码
def do_activate(self):
    self._style_provider = Gtk.CssProvider()
    self._current_screen = Gdk.Screen.get_default()

    css = b""".gedit-view { padding-bottom: 400px }"""
    self._style_provider.load_from_data(css)

    Gtk.StyleContext.add_provider_for_screen(
      self._current_screen,
      self._style_provider,
      Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
    )
项目:input-paste    作者:RPing    | 项目源码 | 文件源码
def __init__(self):
        # create a new window
        window = Gtk.Window()
        window.set_position(Gtk.WindowPosition.CENTER)
        window.set_name('window')
        window.set_title("Input Helper")
        window.set_decorated(False)

        window.set_default_size(300, 40)
        window.connect("destroy", self.destroy)

        self.entry = Gtk.Entry()
        self.entry.set_name('entry')
        self.entry.connect("key_press_event", self.on_key_press)

        self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)

        style_provider = Gtk.CssProvider()
        base_dir = os.path.abspath(os.path.dirname(__file__))
        css_path = os.path.join(base_dir, 'input_paste.css')
        style_provider.load_from_file(Gio.File.new_for_path(css_path))
        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(),
            style_provider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
        )

        window.add(self.entry)
        window.show_all()
项目:revolt    作者:aperezdc    | 项目源码 | 文件源码
def __on_startup(self, app):
        gtk_settings = Gtk.Settings.get_default()
        gtk_settings.set_property("gtk-dialogs-use-header",
                                  self.settings.get_boolean("use-header-bar"))
        css_provider = Gtk.CssProvider()
        css_provider.load_from_resource(self.get_resource_base_path() + "/gtk/custom.css")
        Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), css_provider,
                                                 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
        self.statusicon = StatusIcon(self)
        self.__action("quit", lambda *arg: self.quit())
        self.__action("about", self.__on_app_about)
        self.__action("preferences", self.__on_app_preferences)
        self.__action("riot-settings", self.__on__riot_settings)
项目:ACYLS    作者:worron    | 项目源码 | 文件源码
def load_gtk_css(file_):
    """Set custom CSS for Gtk theme"""
    style_provider = Gtk.CssProvider()
    style_provider.load_from_path(file_)

    Gtk.StyleContext.add_provider_for_screen(
        Gdk.Screen.get_default(),
        style_provider,
        Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
    )
项目:KTV    作者:RainMark    | 项目源码 | 文件源码
def font_update(self):
        shell = 'm4 -DFONT_FAMILY=%s -DFONT_SIZE=%s resources/glade/template.css > resources/glade/.style.css' % (self.font, self.font_size)
        os.system(shell)
        self.style_provider.load_from_path('resources/glade/.style.css')
        Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(),
                                                 self.style_provider,
                                                 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def _load_custom_css(self):
        css_filepath = pathlib.Path(__file__).parent.joinpath("gui_style.css")
        with css_filepath.open("rb") as css_file:
            css_data = css_file.read()

        style_provider = Gtk.CssProvider()
        style_provider.load_from_data(css_data)

        Gtk.StyleContext.add_provider_for_screen(
                Gdk.Screen.get_default(), style_provider,
                Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
        )
项目:lightdm-settings    作者:linuxmint    | 项目源码 | 文件源码
def __init__(self, title):
        Gtk.Frame.__init__(self)
        self.set_shadow_type(Gtk.ShadowType.IN)
        frame_style = self.get_style_context()
        frame_style.add_class("view")
        self.size_group = Gtk.SizeGroup()
        self.size_group.set_mode(Gtk.SizeGroupMode.VERTICAL)

        self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.add(self.box)

        toolbar = Gtk.Toolbar.new()
        toolbar_context = toolbar.get_style_context()
        Gtk.StyleContext.add_class(Gtk.Widget.get_style_context(toolbar), "cs-header")

        label = Gtk.Label.new()
        label.set_markup("<b>%s</b>" % title)
        title_holder = Gtk.ToolItem()
        title_holder.add(label)
        toolbar.add(title_holder)
        self.box.add(toolbar)

        toolbar_separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
        self.box.add(toolbar_separator)
        separator_context = toolbar_separator.get_style_context()
        frame_color = frame_style.get_border_color(Gtk.StateFlags.NORMAL).to_string()
        # css_provider = Gtk.CssProvider()
        # css_provider.load_from_data(".separator { -GtkWidget-wide-separators: 0; \
        #                                            color: %s;                    \
        #                                         }" % frame_color)
        # separator_context.add_provider(css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

        self.list_box = Gtk.ListBox()
        self.list_box.set_selection_mode(Gtk.SelectionMode.NONE)
        self.list_box.set_header_func(list_header_func, None)
        self.box.add(self.list_box)
项目:kickoff-player    作者:jonian    | 项目源码 | 文件源码
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)
项目:kickoff-player    作者:jonian    | 项目源码 | 文件源码
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)
项目:mate-menu    作者:ubuntu-mate    | 项目源码 | 文件源码
def SetupMateMenuBorder(self):
        style = self.window.get_style_context()
        styleProvider = Gtk.CssProvider()
        styleProvider.load_from_data(".background { border-width: %dpt; }" % self.borderwidth)
        style.add_provider(styleProvider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

        self.border.set_margin_top(self.borderwidth)
        self.border.set_margin_bottom(self.borderwidth)
        self.border.set_margin_start(self.borderwidth)
        self.border.set_margin_end(self.borderwidth)
项目:MokaPlayer    作者:vedard    | 项目源码 | 文件源码
def __init__(self, appconfig, userconfig, player):
        super().__init__(title="MokaPlayer", default_width=1366, default_height=768)

        self.logger = logging.getLogger('MainWindow')
        self.appconfig = appconfig
        self.userconfig = userconfig
        self.player = player
        self.current_playlist = SongsPlaylist()
        self.set_icon_from_file(self.ICON_FILE)
        self.has_flowbox_album_loaded = False
        self.has_flowbox_artist_loaded = False
        self.is_fullscreen = False

        style_provider = Gtk.CssProvider()
        style_provider.load_from_path(self.CSS_FILE)
        Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

        if self.userconfig['gtk']['darktheme']:
            settings = Gtk.Settings.get_default()
            settings.set_property("gtk-application-prefer-dark-theme", True)

        self.connect("destroy", self.on_window_destroy)
        self.connect("key-press-event", self.on_window_key_press)
        self.connect("window-state-event", self.on_window_state_event)

        self.builder = Gtk.Builder()
        self.builder.add_from_file(self.GLADE_FILE)
        self.__get_object()
        self.__init_sort_radio()
        self.__init_gridview_columns()
        self.__init_sidebar()
        self.__init_txt_goto()
        self.__init_cmb_visualiser()

        self.builder.connect_signals(self)
        self.player.state_changed.subscribe(self.on_player_state_changed)
        self.player.audio_changed.subscribe(self.on_audio_changed)
        self.player.volume_changed.subscribe(self.on_volume_changed)

        self.__set_current_song_info()
        self.on_volume_changed()

        self.__show_current_playlist()

        GObject.timeout_add(750, self.on_tick, None)
        self.logger.info('Window loaded')

        if not self.player.library.is_musics_folder_valid():
            self.__ask_for_music_folder()
项目:pytimetrack    作者:fhackerz    | 项目源码 | 文件源码
def do_startup(self):
        mark_time("in app startup")

        self.check_schema()
        self.create_data_directory()

        Gtk.Application.do_startup(self)

        mark_time("basic app startup done")

        css = Gtk.CssProvider()
        css.load_from_path(CSS_FILE)
        screen = Gdk.Screen.get_default()
        Gtk.StyleContext.add_provider_for_screen(
            screen, css, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
        mark_time("CSS loaded")

        builder = Gtk.Builder.new_from_file(MENUS_UI_FILE)
        self.set_app_menu(builder.get_object('app_menu'))
        mark_time("menus loaded")

        self.actions = self.Actions(self)

        if not hasattr(self, 'set_accels_for_action'):
            self.set_accels_for_action = self.fallback_set_accels

        self.set_accels_for_action("win.detail-level::chronological", ["<Alt>1"])
        self.set_accels_for_action("win.detail-level::grouped", ["<Alt>2"])
        self.set_accels_for_action("win.detail-level::summary", ["<Alt>3"])
        self.set_accels_for_action("win.time-range::day", ["<Alt>4"])
        self.set_accels_for_action("win.time-range::week", ["<Alt>5"])
        self.set_accels_for_action("win.time-range::month", ["<Alt>6"])
        self.set_accels_for_action("win.show-task-pane", ["F9"])
        self.set_accels_for_action("win.show-menu", ["F10"])
        self.set_accels_for_action("win.show-search-bar", ["<Primary>F"])
        self.set_accels_for_action("win.go-back", ["<Alt>Left"])
        self.set_accels_for_action("win.go-forward", ["<Alt>Right"])
        self.set_accels_for_action("win.go-home", ["<Alt>Home"])
        self.set_accels_for_action("app.edit-log", ["<Primary>E"])
        self.set_accels_for_action("app.edit-tasks", ["<Primary>T"])
        self.set_accels_for_action("app.help", ["F1"])
        self.set_accels_for_action("app.preferences", ["<Primary>P"])
        self.set_accels_for_action("app.quit", ["<Primary>Q"])
        self.set_accels_for_action("win.report", ["<Primary>D"])
        self.set_accels_for_action("win.cancel-report", ["Escape"])
        self.set_accels_for_action("win.send-report", ["<Primary>Return"])

        mark_time("app startup done")