-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
86 lines (70 loc) · 3.21 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import json
import dearpygui.dearpygui as dpg
import configs
from tools import Tools
from pomodoro_settings import PomodoroSettings
from os.path import exists
# sets up the dearpygui
def create_windows():
dpg.create_context()
dpg.create_viewport(title=configs.VIEWPORT_TITLE,
width=configs.VIEWPORT_WIDTH,
height=configs.VIEWPORT_HEIGHT)
dpg.setup_dearpygui()
dpg.set_global_font_scale(configs.DPG_FONT_SCALE)
# creating fonts
create_dpg_fonts()
# creating themes
create_dpg_themes()
# create default user_data.json if not existent
if not exists(configs.USERDATA_FILEPATH):
Tools.create_default_user_data()
# load json data
user_data_file = open(configs.USERDATA_FILEPATH)
user_data = json.load(user_data_file)
user_data_file.close()
# load pomodoro settings window
PomodoroSettings(dpg, user_data)
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
def create_dpg_fonts():
with dpg.font_registry():
dpg.add_font(configs.DEFAULT_FONT_PATH, 20, tag=configs.DEFAULT_FONT_ID)
dpg.add_font(configs.TIMER_FONT_PATH, 60, tag=configs.TIMER_FONT_ID)
# implement the default font
dpg.bind_font(configs.DEFAULT_FONT_ID)
def create_dpg_themes():
# default theme
with dpg.theme(tag=configs.DEFAULT_THEME_ID):
with dpg.theme_component(dpg.mvAll):
dpg.add_theme_color(dpg.mvThemeCol_WindowBg, (196, 45, 45),
category=dpg.mvThemeCat_Core)
dpg.add_theme_color(dpg.mvThemeCol_ChildBg, (196, 45, 45),
category=dpg.mvThemeCat_Core)
dpg.add_theme_color(dpg.mvThemeCol_TitleBgActive, (38, 177, 181),
category=dpg.mvThemeCat_Core)
dpg.add_theme_style(dpg.mvStyleVar_WindowPadding, 20, 0,
category=dpg.mvThemeCat_Core)
dpg.add_theme_color(dpg.mvThemeCol_Button, (65, 157, 161),
category=dpg.mvThemeCat_Core)
dpg.add_theme_color(dpg.mvThemeCol_ScrollbarGrab, (65, 157, 161),
category=dpg.mvThemeCat_Core)
dpg.add_theme_style(dpg.mvStyleVar_ChildBorderSize, 0)
dpg.add_theme_style(dpg.mvStyleVar_FrameRounding, 6)
# popup theme
with dpg.theme(tag=configs.POPUP_THEME_ID):
with dpg.theme_component(dpg.mvAll):
dpg.add_theme_color(dpg.mvThemeCol_PopupBg, (196, 45, 45),
category=dpg.mvThemeCat_Core)
dpg.add_theme_color(dpg.mvThemeCol_TitleBgActive, (38, 177, 181),
category=dpg.mvThemeCat_Core)
dpg.add_theme_style(dpg.mvStyleVar_WindowPadding, 20, 0,
category=dpg.mvThemeCat_Core)
dpg.add_theme_color(dpg.mvThemeCol_Button, (65, 157, 161),
category=dpg.mvThemeCat_Core)
dpg.add_theme_color(dpg.mvThemeCol_ScrollbarGrab, (65, 157, 161),
category=dpg.mvThemeCat_Core)
dpg.add_theme_style(dpg.mvStyleVar_FrameRounding, 6)
if __name__ == '__main__':
create_windows()