Esempio n. 1
0
    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)
Esempio n. 2
0
    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)
Esempio n. 3
0
    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)
Esempio n. 4
0
    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()
Esempio n. 5
0
    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)
Esempio n. 6
0
    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)
Esempio n. 7
0
    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)
Esempio n. 8
0
    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)