def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) style = ttk.Style() style.theme_use("clam") style.configure("Timer.TFrame", background=COLOUR_LIGHT_BACKGROUND) style.configure("Background.TFrame", background=COLOUR_PRIMARY) style.configure( "TimerText.TLabel", background=COLOUR_LIGHT_BACKGROUND, foreground=COLOUR_DARK_TEXT, font="Courier 38" ) style.configure( "LightText.TLabel", background=COLOUR_PRIMARY, foreground=COLOUR_LIGHT_TEXT, ) style.configure( "PomodoroButton.TButton", background=COLOUR_SECONDARY, foreground=COLOUR_LIGHT_TEXT, ) style.map( "PomodoroButton.TButton", background=[("active", COLOUR_PRIMARY), ("disabled", COLOUR_LIGHT_TEXT)] ) # Main app window is a tk widget, so background is set directly self["background"] = COLOUR_PRIMARY self.title("Pomodoro Timer") self.columnconfigure(0, weight=1) self.rowconfigure(1, weight=1) self.pomodoro = tk.StringVar(value=25) self.long_break = tk.StringVar(value=15) self.short_break = tk.StringVar(value=5) self.timer_order = ["Pomodoro", "Short Break", "Pomodoro", "Short Break", "Pomodoro", "Long Break"] self.timer_schedule = deque(self.timer_order) container = ttk.Frame(self) container.grid() container.columnconfigure(0, weight=1) self.frames = {} settings_frame = Settings(container, self, lambda: self.show_frame(Timer)) timer_frame = Timer(container, self, lambda: self.show_frame(Settings)) settings_frame.grid(row=0, column=0, sticky="NESW") timer_frame.grid(row=0, column=0, sticky="NESW") self.frames[Settings] = settings_frame self.frames[Timer] = timer_frame self.show_frame(Timer)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) style = ttk.Style(self) style.theme_use('clam') self.title("Pomodoro Timer") self.columnconfigure(0, weight=1) self.rowconfigure(1, weight=1) container = ttk.Frame(self) container.grid() container.columnconfigure(0, weight=1) self.pomodoro = tk.StringVar(value=25) self.long_break = tk.StringVar(value=15) self.short_break = tk.StringVar(value=5) self.timer_order = [ 'Pomodoro', 'Short Break', 'Pomodoro', 'Short Break', 'Pomodoro', 'Long Break' ] self.timer_schedule = deque(self.timer_order) self.frames = dict() timer_frame = Timer(container, self, lambda: self.show_frame(Settings)) timer_frame.grid(row=0, column=0, sticky='NESW') settings_frame = Settings(container, self, lambda: self.show_frame(Timer)) settings_frame.grid(row=0, column=0, sticky='NESW') self.frames[Timer] = timer_frame self.frames[Settings] = settings_frame self.show_frame(Timer)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.title("Pomodoro Timer") self.columnconfigure(0, weight=1) self.rowconfigure(1, weight=1) self.pomodoro = tk.StringVar(value=25) self.long_break = tk.StringVar(value=15) self.short_break = tk.StringVar(value=5) self.timer_order = [ "Pomodoro", "Short Break", "Pomodoro", "Short Break", "Pomodoro", "Long Break" ] self.timer_schedule = deque(self.timer_order) container = ttk.Frame(self) container.grid() container.columnconfigure(0, weight=1) self.frames = {} settings_frame = Settings(container, self, lambda: self.show_frame(Timer)) timer_frame = Timer(container, self, lambda: self.show_frame(Settings)) settings_frame.grid(row=0, column=0, sticky="NESW") timer_frame.grid(row=0, column=0, sticky="NESW") self.frames[Settings] = settings_frame self.frames[Timer] = timer_frame self.show_frame(Timer)
class PomodoroTimer(tk.Tk): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) style = ttk.Style(self) style.theme_use("clam") style.configure("Timer.TFrame", background=COLOUR_LIGHT_BACKGROUND) style.configure("Background.TFrame", background=COLOUR_PRIMARY) style.configure( "TimerText.TLabel", background=COLOUR_LIGHT_TEXT, foreground=COLOUR_DARK_TEXT, font="Courier 38" ) style.configure( "LightText.TLabel", background=COLOUR_PRIMARY, foreground=COLOUR_LIGHT_TEXT, ) style.configure( "PomodoroButton.TButton", background=COLOUR_SECONDARY, foreground=COLOUR_LIGHT_TEXT ) style.configure( "PomodoroButton.TButton", background=COLOUR_SECONDARY, foreground=COLOUR_LIGHT_TEXT, ) style.map( "PomodoroButton.TButton", background=[("active", COLOUR_PRIMARY), ("disabled", COLOUR_LIGHT_TEXT)] ) self["background"] = COLOUR_PRIMARY self.title("Pomodoro Timer") self.columnconfigure(0, weight=1) self.rowconfigure(1, weight=1) self.__pomodoro = tk.StringVar(value=25) self.__long_break = tk.StringVar(value=15) self.__short_break = tk.StringVar(value=5) container = ttk.Frame(self) container.grid() container.columnconfigure(0, weight=1) self.__timer_frame = Timer(self, self.__pomodoro, self.__long_break, self.__short_break, container) self.__timer_frame.grid(row=0, sticky="NSEW") self.__settings_frame = Settings(self, self.__pomodoro, self.__long_break, self.__short_break, container) self.__settings_frame.grid(row=0, sticky="NSEW") self.__timer_frame.tkraise() def show_time_frame(self): self.__timer_frame.tkraise() def show_settings_frame(self): self.__settings_frame.tkraise()
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # ----- Aestetics ----- # create custom style style = ttk.Style(self) style.theme_use("clam") style.configure("Timer.TFrame", background=COL_LIGHT_BG) #style 1 style.configure("Background.TFrame", background=COL_PRIM) #style 2 style.configure("Timer.TFrame", background=COL_LIGHT_BG) #style 3 style.configure("TimerText.TLabel", background=COL_LIGHT_BG, foreground=COL_DARK_TXT, font="Courier 38") #style 4 style.configure("LightText.TLabel", background=COL_PRIM, foreground=COL_LIGHT_TXT) #style 5 style.configure("PomodoroButton.TButton", background=COL_SEC, foreground=COL_LIGHT_TXT) #style 6 style.map("PomodoroButton.TButton", background=[("active", COL_PRIM), ("disabled", COL_LIGHT_TXT)], bordercolor=[("active", COL_HIGHLIGHT)], borderwidth=[("active", 3)]) #style 7 # set general widget background color self["background"] = COL_PRIM # customize widget/window using tk.Tk-methods using class variables self.title("Pomodoro Timer") #set title self.columnconfigure(0, weight=1) #center content of first row self.rowconfigure(1, weight=1) # ----- create class variables ----- self.pomodoro = tk.StringVar(value=25) #used in Settings frame self.short_break = tk.StringVar(value=5) #used in Settings frame self.long_break = tk.StringVar(value=15) #used in Settings frame self.sound = tk.StringVar( value="Gong (default)") #used in Settings frame self.timer_order = [ "pomodoro", "short_break", "pomodoro", "short_break", "pomodoro", "long_break" ] #used in Timer frame self.timer_schedule = deque( self.timer_order ) #create deck to cycle through timer_order items #used in Timer frame self.label_text = { "pomodoro": "Pomodoro, get to work!!!", "short_break": "Take a short break", "long_break": "Long break! Go grab some coffee :)" } #used in Timer frame # ----- Frames ----- # save a ttk frame - object in a variable named "container" container = ttk.Frame(self) container.grid() #position the frame in the parent widget in a grid container.columnconfigure(0, weight=1) # create dictionary to keep track of frames self.frames = dict() # add timer frame that is placed within "container" self.timer_frame = Timer(container, self, lambda: self.show_frame( Settings)) #initiate Timer-class and pass self as the controller self.timer_frame.grid( row=0, column=0, sticky="NESW" ) #configure timer frame placed in the first row and first column and to fill the entire frame ("container") # add settings frame self.settings_frame = Settings(container, self, lambda: self.show_frame(Timer)) self.settings_frame.grid(row=0, column=0, sticky="NESW") # add both frames to dict self.frames[Timer] = self.timer_frame self.frames[Settings] = self.settings_frame # start with timer_frame in front self.show_frame(Timer)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) style = ttk.Style(self) style.theme_use('clam') style.configure('Timer.TFrame', background=COLOUR_LIGHT_BACKGROUND) style.configure('Background.TFrame', background=COLOUR_PRIMARY) style.configure( # style for timer element only 'TimerText.TLabel', background=COLOUR_LIGHT_BACKGROUND, foreground=COLOUR_DARK_TEXT, font='Courier 38') style.configure( # style for general elements 'LightText.TLabel', background=COLOUR_PRIMARY, foreground=COLOUR_LIGHT_TEXT) style.configure( # style the button without action 'PomodoroButton.TButton', background=COLOUR_SECONDARY, foreground=COLOUR_LIGHT_TEXT) style.map( # style the button when mouse is over it 'PomodoroButton.TButton', background=[('active', COLOUR_PRIMARY), ('disabled', COLOUR_LIGHT_TEXT)]) self[ 'background'] = COLOUR_PRIMARY # as our pomodoro class is tk sub class not ttk sub class self.title('Pomodoro Timer') self.geometry('500x320') self.resizable(False, False) self.columnconfigure(0, weight=1) self.rowconfigure(1, weight=1) # setting the value of the time of the each of the pomodoro self.pomodoro = tk.StringVar(value=25) self.long_break = tk.StringVar(value=15) self.short_break = tk.StringVar(value=5) # List containing the phases we want after completing of other phase self.timer_order = [ 'Pomodoro', 'Short Break', 'Pomodoro', 'Long Break' ] """ it puts the first phase of the timer_order sequence at the last and puts the second element from front at first... basically it makes cycles""" self.timer_schedule = deque(self.timer_order) # main frame consisting all the other sub frames container = ttk.Frame(self) container.grid() container.columnconfigure(0, weight=1) self.frames = dict() # empty dictionary to store frames # settings frame into main frame consisting of the setting widgets # lambda function calls the Timer class frame over Setting class settings_frame = Settings(container, self, lambda: self.show_frame(Timer)) settings_frame.grid(row=0, column=0, sticky='NSEW') # sub frame into the main frame, timer_frame consist of the widgets # lambda function calls the Settings class frame over Timer class timer_frame = Timer(container, self, lambda: self.show_frame(Settings)) timer_frame.grid(row=0, column=0, sticky='NSEW') # assigning frames as value to the class as key in the frames dictionary self.frames[Settings] = settings_frame self.frames[Timer] = timer_frame # calling show_frame method to show the default frame self.show_frame(Timer)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) style = ttk.Style(self) style.theme_use('clam') self['background'] = COLOR_PRIMARY style.configure('Timer.TFrame', background=COLOR_LIGHT_BACKGROUND) style.configure('Background.TFrame', background=COLOR_PRIMARY) style.configure('TimerText.TLabel', background=COLOR_LIGHT_BACKGROUND, foreground=COLOR_DART_TEXT, font='Courier 38') style.configure( 'LightText.TLabel', background=COLOR_PRIMARY, foreground=COLOR_LIGHT_TEXT, ) style.configure( 'PomodoroButton.TButton', background=COLOR_SECONDARY, foreground=COLOR_LIGHT_TEXT, ) style.map('PomodoroButton.TButton', background=[('active', COLOR_PRIMARY), ('disabled', COLOR_LIGHT_TEXT)]) self.title('Pomodoro Timer by Joanna') self.columnconfigure(0, weight=1) self.rowconfigure((0, ), weight=1) self.schedule_descriptions = [ 'Pomodoro', 'Short break', 'Pomodoro', 'Short break', 'Pomodoro', 'Long break', 'Pomodoro' ] self.schedule = deque(self.schedule_descriptions) self.pomodoro = tk.StringVar(value='25') self.short_break = tk.StringVar(value='05') self.long_break = tk.StringVar(value='15') container = ttk.Frame(self) container.grid(column=0, row=0) timer_frame = Timer(container, self, lambda: self.shift_frame(Settings)) timer_frame.grid(column=0, row=1, sticky='NEWS') settings_frame = Settings(container, self, lambda: self.shift_frame(Timer)) settings_frame.grid(column=0, row=1, sticky='NEWS') self.frames = {} self.frames[Timer] = timer_frame self.frames[Settings] = settings_frame self.shift_frame(Timer)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.geometry("340x220") self.resizable(False, False) style = ttk.Style(self) style.theme_use("clam") style.configure("Timer.TFrame", background=COLOUR_LIGHT_BACKGROUND) style.configure("Background.TFrame", background=COLOUR_PRIMARY) style.configure("TimerText.TLabel", background=COLOUR_LIGHT_BACKGROUND, foreground=COLOUR_DARK_TEXT, font="Courier 38") style.configure("SessionText.TLabel", background=COLOUR_PRIMARY, foreground=COLOUR_LIGHT_TEXT, font="TkDefaultFont 12 bold") style.configure( "LightText.TLabel", background=COLOUR_PRIMARY, foreground=COLOUR_LIGHT_TEXT, ) style.configure( "PomodoroButton.TButton", background=COLOUR_SECONDARY, foreground=COLOUR_LIGHT_TEXT, ) style.map("PomodoroButton.TButton", background=[("active", COLOUR_PRIMARY), ("disabled", COLOUR_LIGHT_TEXT)]) # Main app window is a tk widget, so background is set directly self["background"] = COLOUR_PRIMARY menuBar = tk.Menu(self) self.config(menu=menuBar) menuBar.add_command(label="Options", command=lambda: self.showFrame(Settings)) self.title("Pomodoro Timer") self.columnconfigure(0, weight=1) self.rowconfigure(1, weight=1) self.pomodoro = tk.StringVar(value=25) self.longBreak = tk.StringVar(value=25) self.shortBreak = tk.StringVar(value=5) self.timerOrder = [ "Pomodoro", "Short Break", "Pomodoro", "Short Break", "Pomodoro", "Short Break", "Pomodoro", "Long Break" ] self.timerSchedule = deque(self.timerOrder) container = ttk.Frame(self) container.grid() container.columnconfigure(0, weight=1) self.frames = dict() timerFrame = Timer(container, self, lambda: self.showFrame(Settings)) timerFrame.grid(row=0, column=0, sticky="NESW") settingsFrame = Settings(container, self, lambda: self.showFrame(Timer)) settingsFrame.grid(row=0, column=0, sticky="NESW") self.frames[Timer] = timerFrame self.frames[Settings] = settingsFrame self.showFrame(Timer)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # Set the style to 'clam'. style = ttk.Style() style.theme_use("clam") # Create some custom styles. style.configure("Background.TFrame", background=LIGHT_BACKGROUND_COLOR) style.configure("Buttons.TButton", font="Courier 10", background=DARK_BACKGROUND_COLOR, foreground=DARK_TEXT_COLOR, bordercolor="black", relief="solid") style.map("Buttons.TButton", background=[("active", ACTIVE_BUTTON), ("pressed", DARK_TEXT_COLOR)]) style.configure("Submit.TButton", background=DARK_BACKGROUND_COLOR, foreground=DARK_TEXT_COLOR, bordercolor="black", relief="solid") style.map("Submit.TButton", background=[("active", ACTIVE_BUTTON), ("pressed", DARK_TEXT_COLOR)], font=[("pressed", ("TkDefaultFont", 18))]) style.configure( "Timer.TLabel", font="TkDefaultFont 18", background=LIGHT_BACKGROUND_COLOR, foreground=DARK_TEXT_COLOR, ) style.configure( "PracticeNrSym.TLabel", font="TkDefaultFont 22", background=LIGHT_BACKGROUND_COLOR, foreground=DARK_TEXT_COLOR, ) style.configure( "SettingsText.TLabel", font="TkDefaultFont 12", background=LIGHT_BACKGROUND_COLOR, foreground=DARK_TEXT_COLOR, ) style.configure( "CorrectText.TLabel", font="TkDefaultFont 12", background=DARK_BACKGROUND_COLOR, foreground=DARK_TEXT_COLOR, ) style.configure( "Symbols.TRadiobutton", font="TkDefaultFont 8", background=LIGHT_BACKGROUND_COLOR, foreground=DARK_TEXT_COLOR, ) style.configure("TProgressbar", background='green', troughcolor=DARK_BACKGROUND_COLOR) # Set the overall fontsize to 15 instead of 10. font.nametofont("TkDefaultFont").configure(size=15) container = ttk.Frame(self) container.grid() # Set the widget's background. self["background"] = LIGHT_BACKGROUND_COLOR # Center your Frame in the middele-top self.title("Math Practice Tool") self.columnconfigure(0, weight=1) # Give the widget a default size. self.geometry("560x313") # Create the countdown. self.current_time = tk.StringVar(value="02:00") self.timer_running = False # Set the default input values for the time. self.minutes_input_value = tk.StringVar(value=2) self.seconds_input_value = tk.StringVar(value=0) # In 'chosen_symbol_index' you'll store the value of the selected Radiobutton. self.chosen_symbol_index = tk.IntVar() # Stringsvar to store the chosen symbol with '+' as default. self.chosen_symbol = tk.StringVar(value="+") # Create the 2 Stringsvars, so that a string can be inputed # and a messagebox can popuped, for the range of numbers with a default. self.input_from_value = tk.StringVar(value="1") self.input_to_value = tk.StringVar(value="101") # Create the the IntVars for the number of questions with a default. self.number_questions_input = tk.IntVar(value=10) # Create the the IntVars that tracks the number of questions answerd. self.number_questions_input_value = tk.IntVar() self.number_questions_input_value.set( self.number_questions_input.get()) # Create all needed IntVar's and StringVar's. self.first_nr_value = tk.IntVar() self.second_nr_value = tk.IntVar() # Create the StringVar that will hold the users answer input. self.input_value = tk.StringVar() # Create a var that tracks the progress bar. self.pro_bar = tk.IntVar(value=0) self.max_progressbar = tk.IntVar() # Create a variable let's know if there are no errors. self.no_errors = True self.frames = {} settings_frame = Settings(container, self, lambda: self.show_frame(Practice)) practice_frame = Practice(container, self, lambda: self.show_frame(Settings)) settings_frame.grid(row=0, column=0, sticky="NESW") practice_frame.grid(row=0, column=0, sticky="NESW") self.frames[Settings] = settings_frame self.frames[Practice] = practice_frame self.show_frame(Practice)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) style = ttk.Style() style.theme_use("clam") style.configure("Background.TFrame", background=COLOUR_PRIMARY) style.configure("CreateProject.TFrame", background=COLOUR_LIGHT_BACKGROUND) style.configure( "LightText.TLabel", background=COLOUR_PRIMARY, foreground=COLOUR_LIGHT_TEXT, ) style.configure( "LightText.TCheckbutton", background=COLOUR_PRIMARY, foreground=COLOUR_LIGHT_TEXT, ) style.map("LightText.TCheckbutton", background=[("active", COLOUR_PRIMARY), ("disabled", COLOUR_PRIMARY)]) style.configure( "Button.TButton", background=COLOUR_SECONDARY, foreground=COLOUR_LIGHT_TEXT, ) style.map("Button.TButton", background=[("active", COLOUR_PRIMARY), ("disabled", COLOUR_LIGHT_TEXT)]) style.configure("TProgressbar", background='green') # Main app window is a tk widget, so background is set directly self["background"] = COLOUR_PRIMARY self.title("Create a new Project") self.columnconfigure(0, weight=1) # Set the overall fontsize to 15 instead of 10. font.nametofont("TkDefaultFont").configure(size=14) # try to open existing settings file and create one if it does not exist data = self.get_settings() self.username = tk.StringVar(value=data["username"]) self.password = tk.StringVar(value=data["password"]) self.default_venv_name = tk.StringVar(value=data["default_venv_name"]) self.folder_path = tk.StringVar(value="C:/") self.create_venv = tk.BooleanVar() self.project_name = tk.StringVar() self.progress_int_var = tk.IntVar() container = ttk.Frame(self) container.grid() self.frames = {} settings_frame = Settings(container, self, lambda: self.show_frame(CreateProject)) project_frame = CreateProject(container, self, lambda: self.show_frame(Settings)) settings_frame.grid(row=0, column=0, sticky="NESW") project_frame.grid(row=0, column=0, sticky="NESW") self.frames[Settings] = settings_frame self.frames[CreateProject] = project_frame self.show_frame(CreateProject)