-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuBarPopUpWindow.py
More file actions
71 lines (48 loc) · 2.4 KB
/
MenuBarPopUpWindow.py
File metadata and controls
71 lines (48 loc) · 2.4 KB
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
from Functions import read_json
import tkinter as tk
from tkinter import ttk
from PlaceHolderEntry import *
import Functions
from Globals import *
class ConfigPopUpWindow():
def __init__(self, master, title:str):
self.popup = tk.Toplevel(master)
self.popup.title(title)
self.popup.iconbitmap(ICON_PATH)
self.popup.geometry(f"250x180+{master.winfo_x()+10}+{master.winfo_y()+10}")
self.popup.resizable(0,0)
self.config_file = Functions.read_json(CONFIG_FILE_PATH)
""" Activity Time """
self.activity_time_frame = ttk.Frame(self.popup)
self.activity_time_frame.pack()
self.activity_time_text = ttk.Label(self.activity_time_frame, text="Activity Time")
self.activity_time_text.pack()
self.activity_time_entry = PlaceHolderEntry(self.activity_time_frame, self.config_file["APP"]["minute"])
self.activity_time_entry.pack()
""" Break Time """
self.break_time_frame = ttk.Frame(self.popup)
self.break_time_frame.pack()
self.break_time_text = ttk.Label(self.break_time_frame, text="Break Time")
self.break_time_text.pack()
self.break_time_entry = PlaceHolderEntry(self.break_time_frame, self.config_file["APP"]["break"])
self.break_time_entry.pack()
""" Auto Break """
self.auto_break_frame = ttk.Frame(self.popup)
self.auto_break_frame.pack()
self.auto_break_text = ttk.Label(self.auto_break_frame, text="Auto Break")
self.auto_break_text.pack()
self.auto_break_combobox = ttk.Combobox(self.auto_break_frame, values=(True, False), state="readonly")
self.auto_break_combobox.current(0 if self.config_file["APP"]["auto_break"] else 1)
self.auto_break_combobox.pack()
""" Button Part """
self.apply_button = ttk.Button(self.popup, text="Apply", command=self.config_update)
self.apply_button.pack()
self.button = ttk.Button(self.popup, text="Close", command=self.close)
self.button.pack()
def config_update(self):
self.config_file["APP"]["minute"] = self.activity_time_entry.get()
self.config_file["APP"]["break"] = self.break_time_entry.get()
self.config_file["APP"]["auto_break"] = "True" == self.auto_break_combobox.get()
Functions.update_json(CONFIG_FILE_PATH, self.config_file)
def close(self):
self.popup.destroy()