def _init_timer(self): self.frames[_('Timer')].columnconfigure(0, weight=1) # --- Fonts frame_font = ttk.Frame(self.frames[_('Timer')]) frame_font.columnconfigure(2, weight=1) ttk.Label(frame_font, text=_('Font'), style='title.TLabel').grid(row=0, column=0, sticky='w', padx=4, pady=4) # --- --- time ttk.Label(frame_font, style='subtitle.TLabel', text=_('Time')).grid(row=1, column=0, sticky='nw', padx=4, pady=8) self.timer_font_time = FontFrame(frame_font, CONFIG.get('Timer', 'font_time'), sample_text="02:17") self.timer_font_time.grid(row=1, column=1, padx=4, pady=4) ttk.Separator(frame_font, orient='horizontal').grid(row=2, columnspan=3, padx=10, pady=4, sticky='ew') # --- --- intervals ttk.Label(frame_font, style='subtitle.TLabel', text=_('Intervals')).grid(row=5, column=0, sticky='nw', padx=4, pady=8) self.timer_font_intervals = FontFrame(frame_font, CONFIG.get( 'Timer', 'font_intervals'), sample_text="02:17") self.timer_font_intervals.grid(row=5, column=1, padx=4, pady=4) # --- opacity self.timer_opacity = OpacityFrame( self.frames[_('Timer')], CONFIG.getfloat("Timer", "alpha", fallback=0.85)) # --- colors frame_color = ttk.Frame(self.frames[_('Timer')]) ttk.Label(frame_color, text=_('Colors'), style='title.TLabel').grid(row=0, column=0, sticky='w', padx=8, pady=4) self.timer_bg = ColorFrame(frame_color, CONFIG.get('Timer', 'background'), _('Background')) self.timer_bg.grid(row=0, column=1, sticky='e', padx=8, pady=4) self.timer_fg = ColorFrame(frame_color, CONFIG.get('Timer', 'foreground'), _('Foreground')) self.timer_fg.grid(row=0, column=2, sticky='e', padx=8, pady=4) # --- placement frame_font.grid(sticky='ew') ttk.Separator(self.frames[_('Timer')], orient='horizontal').grid(sticky='ew', pady=8) self.timer_opacity.grid(sticky='w', padx=4) ttk.Separator(self.frames[_('Timer')], orient='horizontal').grid(sticky='ew', pady=8) frame_color.grid(sticky='w')
def _init_tasks(self): self.frames[_('Tasks')].columnconfigure(0, weight=1) self.tasks_hide_comp = tk.BooleanVar( self, CONFIG.getboolean('Tasks', 'hide_completed')) # --- Fonts frame_font = ttk.Frame(self.frames[_('Tasks')]) frame_font.columnconfigure(2, weight=1) ttk.Label(frame_font, text=_('Font'), style='title.TLabel').grid(row=0, column=0, sticky='w', padx=4, pady=4) # --- --- title ttk.Label(frame_font, style='subtitle.TLabel', text=_('Title')).grid(row=1, column=0, sticky='nw', padx=4, pady=8) self.tasks_font_title = FontFrame(frame_font, CONFIG.get('Tasks', 'font_title'), True) self.tasks_font_title.grid(row=1, column=1, padx=4, pady=4) ttk.Separator(frame_font, orient='horizontal').grid(row=2, columnspan=3, padx=10, pady=4, sticky='ew') # --- --- text ttk.Label(frame_font, style='subtitle.TLabel', text=_('Text')).grid(row=5, column=0, sticky='nw', padx=4, pady=8) self.tasks_font = FontFrame(frame_font, CONFIG.get('Tasks', 'font')) self.tasks_font.grid(row=5, column=1, padx=4, pady=4) # --- opacity self.tasks_opacity = OpacityFrame( self.frames[_('Tasks')], CONFIG.getfloat("Tasks", "alpha", fallback=0.85)) # --- colors frame_color = ttk.Frame(self.frames[_('Tasks')]) ttk.Label(frame_color, text=_('Colors'), style='title.TLabel').grid(row=0, column=0, sticky='w', padx=8, pady=4) self.tasks_bg = ColorFrame(frame_color, CONFIG.get('Tasks', 'background'), _('Background')) self.tasks_bg.grid(row=0, column=1, sticky='e', padx=8, pady=4) self.tasks_fg = ColorFrame(frame_color, CONFIG.get('Tasks', 'foreground'), _('Foreground')) self.tasks_fg.grid(row=0, column=2, sticky='e', padx=8, pady=4) # --- placement frame_font.grid(sticky='ew') ttk.Separator(self.frames[_('Tasks')], orient='horizontal').grid(sticky='ew', pady=8) self.tasks_opacity.grid(sticky='w', padx=4) ttk.Separator(self.frames[_('Tasks')], orient='horizontal').grid(sticky='ew', pady=8) frame_color.grid(sticky='w') ttk.Separator(self.frames[_('Tasks')], orient='horizontal').grid(sticky='ew', pady=8) ttk.Checkbutton(self.frames[_('Tasks')], text=_('Hide completed tasks'), variable=self.tasks_hide_comp).grid(sticky='w', padx=4, pady=4)
def _init_calendar(self): # --- general config general = ttk.Frame(self.frames[_('Calendar')], padding=4) general.columnconfigure(1, weight=1) self.frames[_('Calendar')].add(general, text=_('General')) # --- --- opacity self.cal_opacity = OpacityFrame( general, CONFIG.getfloat('Calendar', 'alpha', fallback=0.85)) self.cal_opacity.grid(row=0, columnspan=2, sticky='w', padx=4) ttk.Separator(general, orient='horizontal').grid(row=1, columnspan=2, pady=10, sticky='ew') # --- --- font ttk.Label(general, text=_('Font'), style='title.TLabel').grid(row=2, sticky='nw', padx=4, pady=4) self.cal_font = FontFrame(general, CONFIG.get('Calendar', 'font')) self.cal_font.grid(row=2, column=1, sticky='w', padx=4, pady=4) # --- Colors frame_color = ttk.Frame(self.frames[_('Calendar')], padding=4) frame_color.columnconfigure(3, weight=1) self.frames[_('Calendar')].add(frame_color, text=_('Colors')) self.cal_colors = {} ttk.Label(frame_color, style='subtitle.TLabel', text=_('General')).grid(row=0, column=0, sticky='w') self.cal_bg = ColorFrame(frame_color, CONFIG.get('Calendar', 'background'), _('Background')) self.cal_fg = ColorFrame(frame_color, CONFIG.get('Calendar', 'foreground'), _('Foreground')) self.cal_bd = ColorFrame(frame_color, CONFIG.get('Calendar', 'bordercolor'), _('Border')) self.cal_bg.grid(row=0, column=1, sticky='e', padx=8, pady=4) self.cal_fg.grid(row=0, column=2, sticky='e', padx=8, pady=4) self.cal_bd.grid(row=1, column=1, sticky='e', padx=8, pady=4) cal_colors = { 'normal': _('Normal day'), 'weekend': _('Weekend'), 'othermonth': _('Other month day'), 'othermonthwe': _('Other month weekend'), 'select': _('Selected day'), 'headers': _('Headers'), 'tooltip': _('Tooltip') } for i, (name, label) in enumerate(cal_colors.items()): bg = ColorFrame(frame_color, CONFIG.get('Calendar', name + 'background'), _('Background')) fg = ColorFrame(frame_color, CONFIG.get('Calendar', name + 'foreground'), _('Foreground')) self.cal_colors[name + 'background'] = bg self.cal_colors[name + 'foreground'] = fg ttk.Separator(frame_color, orient='horizontal').grid(row=2 + 2 * i, columnspan=4, pady=10, sticky='ew') ttk.Label(frame_color, style='subtitle.TLabel', wraplength=110, text=label).grid(row=3 + 2 * i, column=0, sticky='w') bg.grid(row=3 + 2 * i, column=1, sticky='e', padx=8, pady=4) fg.grid(row=3 + 2 * i, column=2, sticky='e', padx=8, pady=4) # --- Categories categories = ttk.Frame(self.frames[_('Calendar')], padding=4) categories.columnconfigure(0, weight=1) categories.rowconfigure(0, weight=1) self.frames[_('Calendar')].add(categories, text=_('Event categories')) can = tk.Canvas(categories, bg=self['bg'], highlightthickness=0, width=1, relief='flat') scroll = AutoScrollbar(categories, orient='vertical', command=can.yview) can.configure(yscrollcommand=scroll.set) can.grid(row=0, column=0, sticky='ewns') scroll.grid(row=0, column=1, sticky='ns') ttk.Button(categories, image=self._im_plus, command=self.add_cat).grid(row=1, column=0, sticky='w', pady=4) self.cat_frame = ttk.Frame(can) can.create_window(0, 0, anchor='nw', window=self.cat_frame) self.cats = {} for i, cat in enumerate(CONFIG.options("Categories")): l = ttk.Label(self.cat_frame, text=cat, style='subtitle.TLabel') col = CONFIG.get('Categories', cat).split(', ') bg = ColorFrame(self.cat_frame, col[1].strip(), _('Background')) fg = ColorFrame(self.cat_frame, col[0].strip(), _('Foreground')) b = ttk.Button(self.cat_frame, image=self._im_moins, padding=2, command=lambda c=cat: self.del_cat(c)) self.cats[cat] = [l, bg, fg, b] l.grid(row=i, column=0, sticky='e', padx=4, pady=4) bg.grid(row=i, column=1, sticky='e', padx=4, pady=4) fg.grid(row=i, column=2, sticky='e', padx=4, pady=4) b.grid(row=i, column=3, sticky='e', padx=4, pady=4) self.update_idletasks() can.configure(width=self.cat_frame.winfo_reqwidth()) can.configure(scrollregion=can.bbox('all')) can.bind('<4>', lambda e: self._scroll(e, -1)) can.bind('<5>', lambda e: self._scroll(e, 1)) self.cat_frame.bind( '<Configure>', lambda e: can.configure(scrollregion=can.bbox('all')))
def _init_events(self): self.frames[_('Events')].columnconfigure(0, weight=1) # --- Fonts frame_font = ttk.Frame(self.frames[_('Events')]) frame_font.columnconfigure(2, weight=1) ttk.Label(frame_font, text=_('Font'), style='title.TLabel').grid(row=0, column=0, sticky='w', padx=4, pady=4) # --- --- title ttk.Label(frame_font, style='subtitle.TLabel', text=_('Title')).grid(row=1, column=0, sticky='ne', padx=4, pady=8) self.events_font_title = FontFrame(frame_font, CONFIG.get('Events', 'font_title'), True) self.events_font_title.grid(row=1, column=1, padx=4, pady=4) ttk.Separator(frame_font, orient='horizontal').grid(row=2, columnspan=3, padx=10, pady=4, sticky='ew') # --- --- day ttk.Label(frame_font, style='subtitle.TLabel', text=_('Day')).grid(row=3, column=0, sticky='ne', padx=4, pady=8) self.events_font_day = FontFrame(frame_font, CONFIG.get('Events', 'font_day'), True) self.events_font_day.grid(row=3, column=1, padx=4, pady=4) ttk.Separator(frame_font, orient='horizontal').grid(row=4, columnspan=3, padx=10, pady=4, sticky='ew') # --- --- text ttk.Label(frame_font, style='subtitle.TLabel', text=_('Text')).grid(row=5, column=0, sticky='ne', padx=4, pady=8) self.events_font = FontFrame(frame_font, CONFIG.get('Events', 'font')) self.events_font.grid(row=5, column=1, padx=4, pady=4) # --- opacity self.events_opacity = OpacityFrame( self.frames[_('Events')], CONFIG.getfloat("Events", "alpha", fallback=0.85)) # --- colors frame_color = ttk.Frame(self.frames[_('Events')]) ttk.Label(frame_color, text=_('Colors'), style='title.TLabel').grid(row=0, column=0, sticky='w', padx=8, pady=4) self.events_bg = ColorFrame(frame_color, CONFIG.get('Events', 'background'), _('Background')) self.events_bg.grid(row=0, column=1, sticky='e', padx=8, pady=4) self.events_fg = ColorFrame(frame_color, CONFIG.get('Events', 'foreground'), _('Foreground')) self.events_fg.grid(row=0, column=2, sticky='e', padx=8, pady=4) # --- placement frame_font.grid(sticky='ew') ttk.Separator(self.frames[_('Events')], orient='horizontal').grid(sticky='ew', pady=8) self.events_opacity.grid(sticky='w', padx=4) ttk.Separator(self.frames[_('Events')], orient='horizontal').grid(sticky='ew', pady=8) frame_color.grid(sticky='w')
def _init_reminders(self): # --- window def toggle_window(): b = 'selected' in self.reminders_window.state() state = [b * '!' + 'disabled'] label.state(state) self.reminders_timeout.state(state) self.reminders_blink.state(state) self.reminders_sound.state(state) frame_window = ttk.Frame(self.frames[_('Reminders')]) frame_window.columnconfigure(0, weight=1) self.reminders_window = ttk.Checkbutton(frame_window, text=_('Banner'), style='title.TCheckbutton', command=toggle_window) self.reminders_window.grid(sticky='w', row=0, columnspan=2, column=0, pady=4) self.reminders_window.state( ('!alternate', '!' * (not CONFIG.getboolean('Reminders', 'window')) + 'selected')) # --- --- timeout frame_timeout = ttk.Frame(frame_window) frame_timeout.grid(sticky='w', padx=(16, 4), pady=4) label = ttk.Label(frame_timeout, text=_('Timeout (min)')) label.pack(side='left') self.reminders_timeout = ttk.Entry(frame_timeout, width=5, justify='center', validate='key', validatecommand=(self._only_nb, '%P')) self.reminders_timeout.insert(0, CONFIG.get('Reminders', 'timeout')) self.reminders_timeout.pack(side='left', padx=4) # --- --- colors frame_color = ttk.Frame(frame_window) frame_color.grid(sticky='w', padx=(16, 4), pady=4) self.reminders_window_bg = ColorFrame( frame_color, CONFIG.get('Reminders', 'window_bg'), _('Background')) self.reminders_window_bg.pack(side='left', padx=(0, 4)) self.reminders_window_fg = ColorFrame( frame_color, CONFIG.get('Reminders', 'window_fg'), _('Foreground')) self.reminders_window_fg.pack(side='left', padx=(4, 0)) # --- --- opacity self.reminders_opacity = OpacityFrame(frame_window, CONFIG.getfloat('Reminders', 'window_alpha', fallback=0.75), style='TLabel') self.reminders_opacity.grid(sticky='w', padx=(16, 4), pady=4) ttk.Separator(frame_window, orient='horizontal').grid(sticky='ew', padx=(16, 10), pady=10) # --- --- blink frame_blink = ttk.Frame(frame_window) frame_blink.grid(sticky='w', padx=(16, 4), pady=4) def toggle_blink(): b = 'selected' in self.reminders_blink.state() state = [b * '!' + 'disabled'] self.reminders_window_bg_alt.state(state) self.reminders_window_fg_alt.state(state) self.reminders_blink = ttk.Checkbutton(frame_blink, text=_('Blink'), command=toggle_blink) self.reminders_blink.pack(anchor='nw') self.reminders_blink.state( ('!alternate', '!' * (not CONFIG.getboolean('Reminders', 'blink')) + 'selected')) self.reminders_window_bg_alt = ColorFrame( frame_blink, CONFIG.get('Reminders', 'window_bg_alternate'), _('Alternate Background')) self.reminders_window_bg_alt.pack(side='left', padx=(16, 4)) self.reminders_window_fg_alt = ColorFrame( frame_blink, CONFIG.get('Reminders', 'window_fg_alternate'), _('Alternate Foreground')) self.reminders_window_fg_alt.pack(side='left', padx=10) toggle_blink() ttk.Separator(frame_window, orient='horizontal').grid(sticky='ew', padx=(16, 10), pady=10) # --- --- alarm self.reminders_sound = SoundFrame(frame_window, CONFIG.get('Reminders', 'alarm'), CONFIG.get('Reminders', 'mute'), _('Alarm')) self.reminders_sound.grid(sticky='ew', padx=(16, 10), pady=4) # --- notif frame_notif = ttk.Frame(self.frames[_('Reminders')]) self.reminders_notif = ttk.Checkbutton(frame_notif, text=_('Notification'), style='title.TCheckbutton') self.reminders_notif.grid(sticky='w', pady=4) self.reminders_notif.state( ('!alternate', '!' * (not CONFIG.getboolean('Reminders', 'notification')) + 'selected')) # --- placement frame_window.pack(anchor='nw', fill='x') ttk.Separator(self.frames[_('Reminders')], orient='horizontal').pack(fill='x', pady=10) frame_notif.pack(anchor='nw')