Changeset 84123db in flowtimer


Ignore:
Timestamp:
08/15/24 09:30:14 (9 months ago)
Author:
Enrico Schwass <ennoausberlin@…>
Branches:
guix
Children:
729b23d
Parents:
401678c
Message:

fix RecurringPhaseList.unrolled and remove progressbar attribute from Schedule

Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • flowtimer/Phase.py

    r401678c r84123db  
     1import json
     2
     3
    14class Phase:
    25
    36    """
    4 
    57    This class is a representation of a single phase inside a timer
    6 
    78    """
    89
    910    def __init__(self, title, duration):
    10 
    1111        """
    12 
    1312        creates the variables associated with that class
    1413
     
    1817        :type duration: int
    1918        :param duration: Duration in seconds
    20 
    2119        """
    2220
     
    2624        self.time_left = self.duration
    2725
     26    def to_json(self):
     27        return json.dumps({"title": self.title, "duration": self.duration})
     28        # return json.dumps(self.__dict__)
    2829
    2930    def __str__(self):
    30 
    3131        """
    32 
    3332        Human readable representation of all attributes
    3433
    3534        :return: human readable representation of all attributes
    3635        :rtype: String
    37 
    3836        """
    3937
  • flowtimer/Schedule.py

    r401678c r84123db  
     1import json
     2
     3
    14class Schedule:
    25
    36    def __init__(self, phase_list):
    4         self.progressbar = None
    57        self.currentValue = 0
    68        self.phase_list = phase_list
    79        self.current_phase = phase_list[0]
    810        self.state = "initial"
     11
     12    def to_json(self):
     13        json.dumps(self.__dict__)
    914
    1015    def start(self):
  • flowtimer/main.py

    r401678c r84123db  
    1717
    1818class TimerApp(tk.Frame):
    19    
     19
    2020    def __init__(self, parent):
    21        
     21
    2222        super().__init__(parent)
    2323        self.parent = parent
     
    2525        self.currentValue = 0
    2626        self.default_config = pd.read_csv("default_config.csv", sep=',', header=0,
    27                          names=('Titel', 'Values'), index_col=False, keep_default_na=False)
     27                                          names=('Titel', 'Values'), index_col=False,
     28                                          keep_default_na=False)
    2829        self.photo = ImageTk.PhotoImage(file='flowtimer_startbg_new.png')
    2930        self.show_config = pd.read_csv("default_config.csv", usecols=[0, 1])
     
    3637        s = ttk.Style()
    3738        s.theme_use('clam')
    38         s.configure("orange.Horizontal.TProgressbar", troughcolor='ivory3', bordercolor='black', background='CadetBlue1', lightcolor='white', darkcolor='black')
     39        s.configure("orange.Horizontal.TProgressbar", troughcolor='ivory3',
     40                    bordercolor='black', background='CadetBlue1',
     41                    lightcolor='white', darkcolor='black')
    3942
    4043        self.headline_frame = tk.Frame(self.parent, bg='white')
     
    4548        self.button_frame.pack(side='bottom', fill='both', expand=False)
    4649
    47         self.label_headline = tk.Label(self.headline_frame, text=("Hochintensive Intervallarbeit"), bg='white', fg='grey', font="serif 20")
     50        self.label_headline = tk.Label(self.headline_frame,
     51                                       text=("Hochintensive Intervallarbeit"),
     52                                       bg='white', fg='grey', font="serif 20")
    4853        self.label_headline.pack(side='left', fill='both', expand=True)
    4954
    50         self.label_config = tk.LabelFrame(self.headline_frame, text="config: ", bg='white', font="serif 12")
    51         self.label_config.pack(side='right', fill='both', expand=False, ipadx=20, padx=20, pady=10)
    52        
    53         self.config_button = tk.Button(self.headline_frame, text="change config", font="courier 14", width=20, command=self.change_config)
     55        self.label_config = tk.LabelFrame(self.headline_frame, text="config: ",
     56                                          bg='white', font="serif 12")
     57        self.label_config.pack(side='right', fill='both', expand=False,
     58                               ipadx=20, padx=20, pady=10)
     59
     60        self.config_button = tk.Button(self.headline_frame, text="change config",
     61                                       font="courier 14", width=20, command=self.change_config)
    5462        self.config_button.pack(side='right', padx=10, pady=10, expand=False)
    5563
    56         self.label_config_text = tk.Label(self.label_config, text=self.show_config, bg='white', font="serif 10", justify='right')
     64        self.label_config_text = tk.Label(self.label_config, text=self.show_config,
     65                                          bg='white', font="serif 10", justify='right')
    5766        self.label_config_text.pack()
    5867
     
    6271        self.label_sequence = tk.Label(self.center_frame)
    6372        self.label_sequence.pack(side='top', fill='both', expand=True)
    64        
    65         self.progressbar = ttk.Progressbar(self.center_frame, style="orange.Horizontal.TProgressbar", orient="horizontal",length=600, mode="determinate")
     73
     74        self.progressbar = ttk.Progressbar(self.center_frame,
     75                                           style="orange.Horizontal.TProgressbar",
     76                                           orient="horizontal", length=600, mode="determinate")
    6677        self.progressbar.pack(side='top')
    6778
    6879        self.label_duration = tk.Label(self.center_frame)
    6980        self.label_duration.pack(side='top', fill='both', expand=True)
    70        
    71         self.start_timer_button = tk.Button(self.button_frame, text="START", font="courier 14", width=20, command=self.start)
     81
     82        self.start_timer_button = tk.Button(self.button_frame, text="START",
     83                                            font="courier 14", width=20, command=self.start)
    7284        self.start_timer_button.pack(side='left', fill='both', ipady=20, expand=True)
    7385
    74         self.freeze_button = tk.Button(self.button_frame, text="PLAY/PAUSE", font="courier 14", width=20, command=self.toggle_tick)
     86        self.freeze_button = tk.Button(self.button_frame, text="PLAY/PAUSE",
     87                                       font="courier 14", width=20, command=self.toggle_tick)
    7588        self.freeze_button.pack(side='left', fill='both', ipady=20, expand=True)
    7689
    77         self.skip_button = tk.Button(self.button_frame, text=("SKIP"), font="courier 14", width=20, command=self.skip)
     90        self.skip_button = tk.Button(self.button_frame, text=("SKIP"),
     91                                     font="courier 14", width=20, command=self.skip)
    7892        self.skip_button.pack(side='left', fill='both', ipady=20, expand=True)
    7993
    80         self.quit_button = tk.Button(self.button_frame, text="QUIT", font="courier 14", width=20, command=self.quit_app)
     94        self.quit_button = tk.Button(self.button_frame, text="QUIT",
     95                                     font="courier 14", width=20, command=self.quit_app)
    8196        self.quit_button.pack(side='left', fill='both', ipady=20, expand=True)
    8297
     
    95110
    96111        if repeat_of_phases == 3:
    97             phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3)]
     112            phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3),
     113                          copy(phase_2), copy(phase_3)]
    98114
    99115        if repeat_of_phases == 4:
    100             phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3),
    101                           copy(phase_2), copy(phase_3)]
     116            phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3),
     117                          copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3)]
    102118
    103119        if repeat_of_phases == 5:
    104             phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3),
    105                           copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3)]
     120            phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3),
     121                          copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3),
     122                          copy(phase_2), copy(phase_3)]
    106123
    107124        self.repeats = repeat_of_phases
     
    110127
    111128    def tick(self):
    112        
     129
    113130        if self.schedule.is_paused():
    114131            return
     
    121138            self.label_sequence.config(text=("\n" + str(self.schedule.current_phase.title) + "..."))
    122139            self.label_duration.config(self.start_color(root))
    123             self.label_duration.config(text=("noch " + str(math.ceil(self.schedule.current_phase.time_left)) + " Min\n"))
     140            self.label_duration.config(text=("noch " +
     141                                             str(math.ceil(self.schedule.current_phase.time_left)) +
     142                                             " Min\n"))
    124143            self.schedule.start()
    125144            self.schedule.tick(1)
     
    132151                self.label_sequence.config(bg=self.random_color(self.label_sequence))
    133152                self.label_duration.config(self.random_color(root))
    134                 self.label_duration.config(text=("noch " + str(math.ceil(self.schedule.current_phase.time_left)) + " Min\n"), bg=self.random_color(self.label_duration))
     153                self.label_duration.config(text=("noch " +
     154                                                 str(math.ceil(self.schedule.current_phase.time_left))
     155                                                 + " Min\n"), bg=self.random_color(self.label_duration))
    135156                if self.schedule.tick(1/60):
    136157                    self.round_counter()
    137                    
     158
    138159            else:
    139160                self.label_sequence.configure(self.time_out_color(root))
     
    147168                self.freeze_button['state'] = 'disabled'
    148169                self.freeze_button.config(fg="ivory3")
    149    
     170
    150171    def start(self):
    151172        self.schedule.start()
     
    154175        self.start_timer_button.config(fg="ivory3")
    155176        self.config_button.pack_forget()
    156        
     177
    157178    def skip(self):
    158179        self.schedule.skip()
     
    160181        if self.schedule.state == "running":
    161182            self.round_counter()
    162    
     183
    163184    def toggle_tick(self):
    164185        if self.schedule.is_paused():
     
    177198    def quit_app(self):
    178199        self.parent.destroy()
    179    
     200
    180201    def random_color(self, widget):
    181202        if self.schedule.current_phase.title == "B-Phase":
     
    194215            self.label_duration.configure(fg="blue")
    195216
    196 
    197217    def start_color(self, widget):
    198218        self.label_sequence.configure(fg="white", font="times 72")
     
    200220        self.center_frame.configure(bg="blue")
    201221        widget.configure(bg="blue")
    202    
     222
    203223    def time_out_color(self, widget):
    204224        widget.configure(bg="red")
    205        
     225
    206226    def progress(self, currentValue):
    207227        self.progressbar["value"] = self.currentValue
     
    214234        if self.count < 3:
    215235            self.currentValue = 0
    216             self.progress(self.currentValue +1)
     236            self.progress(self.currentValue + 1)
    217237            self.progressbar.update()
    218238            self.label_config.config(text="Runde: ")
    219             self.label_config_text.config(text=("1", "/", self.repeats), fg='blue',font="Times 48")
     239            self.label_config_text.config(text=("1", "/", self.repeats),
     240                                          fg='blue', font="Times 48")
    220241        if self.count >= 3 and self.count < 5:
    221             self.label_config_text.config(text=("2", "/", self.repeats), fg='blue',font="Times 48")
     242            self.label_config_text.config(text=("2", "/", self.repeats),
     243                                          fg='blue', font="Times 48")
    222244        if self.count >= 5 and self.count < 7:
    223             self.label_config_text.config(text=("3", "/", self.repeats), fg='blue',font="Times 48")
     245            self.label_config_text.config(text=("3", "/", self.repeats),
     246                                          fg='blue', font="Times 48")
    224247        if self.count >= 7 and self.count < 9:
    225             self.label_config_text.config(text=("4", "/", self.repeats), fg='blue',font="Times 48")
     248            self.label_config_text.config(text=("4", "/", self.repeats),
     249                                          fg='blue', font="Times 48")
    226250        if self.count >= 9 and self.count < 11:
    227             self.label_config_text.config(text=("5", "/", self.repeats), fg='blue',font="Times 48")
     251            self.label_config_text.config(text=("5", "/", self.repeats),
     252                                          fg='blue', font="Times 48")
    228253
    229254    def change_config(self):
     
    235260                                                 filetypes=self.config_files)
    236261        self.user_config = pd.read_csv(self.answer, sep=',', header=0,
    237                                        names=('Titel', 'Values'), index_col=False, keep_default_na=False)
     262                                       names=('Titel', 'Values'),
     263                                       index_col=False, keep_default_na=False)
    238264        self.choosed_config = pd.read_csv(self.answer, usecols=[0, 1])
    239265        self.df = self.user_config
     
    253279
    254280        if repeat_of_phases == 3:
    255             phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3)]
     281            phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3),
     282                          copy(phase_2), copy(phase_3)]
    256283
    257284        if repeat_of_phases == 4:
    258             phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3),
     285            phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3),
     286                          copy(phase_2), copy(phase_3),
    259287                          copy(phase_2), copy(phase_3)]
    260288
    261289        if repeat_of_phases == 5:
    262             phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3),
    263                           copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3)]
     290            phase_list = [phase_1, phase_2, phase_3, copy(phase_2), copy(phase_3),
     291                          copy(phase_2), copy(phase_3), copy(phase_2), copy(phase_3),
     292                          copy(phase_2), copy(phase_3)]
    264293
    265294        self.repeats = repeat_of_phases
     
    267296        self.schedule = Schedule(phase_list)
    268297
     298
    269299root = tk.Tk()
    270 
    271 
    272300root.title("--=> flowtimer <=-- " + "  date: " + date + "  time: " + time)
    273301root.geometry("1280x860")
Note: See TracChangeset for help on using the changeset viewer.