-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6763d14
commit f8dec68
Showing
6 changed files
with
61 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class BaseTheme: | ||
colors = None | ||
|
||
def get_colorful(self): | ||
import colorful as cf | ||
|
||
cf.update_palette(self.colors) | ||
return cf | ||
|
||
def __init__(self): | ||
self.backgroud = self.colors["backgroud"] | ||
self.text = self.colors["text"] | ||
|
||
self.font_size = 19 | ||
self.font = "SF Pro" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from python_search.apps.theme.theme import D2Theme, DesertTheme, NewLight | ||
|
||
|
||
import datetime | ||
import os | ||
|
||
|
||
class ThemeSelector: | ||
""" | ||
A class that selects theme. | ||
If the user has a theme file in their home directory, it will use that theme. | ||
Otherwise, it will use the NewLight theme during the day and the Desert theme at night. | ||
Methods: | ||
get_theme(): Returns the theme to use based on the current time. | ||
""" | ||
|
||
_HOUR_FROM = 8 | ||
_HOUR_TO = 15 | ||
|
||
def get_theme(self) -> str: | ||
""" | ||
Returns the theme to use based on the current time. | ||
Returns: | ||
str: The selected theme. | ||
""" | ||
import os | ||
|
||
home = os.environ["HOME"] | ||
if os.path.exists(home + "/.python_search/theme"): | ||
theme = open(home + "/.python_search/theme").read().strip() | ||
if theme == "Desert": | ||
return DesertTheme() | ||
elif theme == "D2": | ||
return D2Theme() | ||
|
||
now = datetime.datetime.now() | ||
if now.hour >= self._HOUR_FROM and now.hour <= self._HOUR_TO: | ||
return NewLight() | ||
else: | ||
return DesertTheme() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters