Skip to content

Commit

Permalink
css styling support
Browse files Browse the repository at this point in the history
  • Loading branch information
shadeyg56 committed Feb 4, 2023
1 parent 136b449 commit cd51ea3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 12 additions & 2 deletions auto_cpufreq/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

gi.require_version("Gtk", "3.0")

from gi.repository import Gtk
from gi.repository import GLib
from gi.repository import Gtk, GLib, Gdk, Gio

import os

from objects import RadioButtonView, SystemStatsLabel, CPUFreqStatsLabel, CurrentGovernorBox

CSS_FILE = "styles.css"

HBOX_PADDING = 20

class MyWindow(Gtk.Window):
Expand All @@ -17,6 +18,8 @@ def __init__(self):
self.set_default_size(640, 480)
self.set_border_width(10)

self.load_css()

settings = Gtk.Settings.get_default()
# Theme
theme = os.environ.get("GTK_THEME")
Expand All @@ -42,6 +45,13 @@ def __init__(self):

GLib.timeout_add_seconds(2, self.refresh)

def load_css(self):
screen = Gdk.Screen.get_default()
self.gtk_provider = Gtk.CssProvider()
self.gtk_context = Gtk.StyleContext()
self.gtk_context.add_provider_for_screen(screen, self.gtk_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
self.gtk_provider.load_from_file(Gio.File.new_for_path(CSS_FILE))

def refresh(self):
self.systemstats.refresh()
self.currentgovernor.refresh()
Expand Down
4 changes: 4 additions & 0 deletions auto_cpufreq/gui/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
label{
font-family: Noto Sans;
font-size: 15px;
}

0 comments on commit cd51ea3

Please sign in to comment.