class App(tk.Tk): def __init__(self, *args, **kwargs): super(App, self).__init__(*args, **kwargs) self.i = 0 self.o = 0 self.__flush_id = 0 self.preferences = Preferences(on_load=self.configure) # always on top self.wm_attributes("-topmost", 1) # transparency self.attributes("-alpha", 0.85) self.title("Teststep") self.iconbitmap("icons\\accept.ico") status_frame = ttk.Frame(self) status_frame.pack(side=tk.BOTTOM, fill=tk.X) ttk.Sizegrip(status_frame).pack(side=tk.RIGHT) measureSystem = tk.StringVar() def changed(): print('OHO!', measureSystem.get()) check = ttk.Checkbutton(status_frame, text='Always on top', command=changed, variable=measureSystem, onvalue='metric', offvalue='imperial') check.pack(side=tk.RIGHT) progress_bar = ProgressBar(status_frame, values=[0.93, 0.75], height=5) progress_bar.pack(side=tk.BOTTOM, expand=True, fill=tk.BOTH) frame_buttons = tk.Frame(self, pady=3) button_passed = tk.Button(frame_buttons, text="Passed", height=1, command=self.click) button_passed.pack(expand=True, fill=tk.X, side=tk.LEFT, padx=3) button_failed = tk.Button(frame_buttons, text="Failed", width=12, height=1, command=self.click) button_failed.pack(expand=True, fill=tk.X, side=tk.LEFT, padx=3) button_blocked = tk.Button(frame_buttons, text="Blocked", width=12, height=1, command=self.click) button_blocked.pack(expand=True, fill=tk.X, side=tk.LEFT, padx=3) frame_buttons.pack(side=tk.BOTTOM, expand=True, fill=tk.X) self.task_comment = tk.PanedWindow(self, orient=tk.VERTICAL, sashpad=3, sashwidth=3, sashrelief=tk.RAISED) self.task_comment.pack(expand=True, fill=tk.BOTH, pady=3) self.task = ScrolledText(self.task_comment, 'Task', width=80, font=("Calibri", 14), wrap=tk.NONE) self.task_comment.add(self.task.frame, stretch='always') add_text_example(self.task) comment = ScrolledText(self, 'Comment', width=80, height=5, font=("Calibri", 14), wrap=tk.NONE) self.task_comment.add(comment.frame, stretch='always') self.bind("<Configure>", self.on_configure) self.task.frame.bind("<Configure>", self.on_configure) def test(self): self.preferences.flush() print('call', self.i) self.i += 1 def configure(self, preferences): logger.debug("New configuration %d", self.o) self.o += 1 def on_configure(self, event): self.after_cancel(self.__flush_id) if event.widget is self: self.preferences['position'] = {'x': event.x, 'y': event.y} self.preferences['size'] = {'w': event.width, 'h': event.height} elif event.widget is self.task.frame: __, self.preferences['sash_position'] = self.task_comment.sash_coord(0) self.after_cancel(self.__flush_id) self.__flush_id = self.after_idle(self.test) def destroy(self): logger.debug('Destroy window') super(App, self).destroy() self.preferences.stop() def click(self): icons = [os.path.join('icons', f) for f in os.listdir('icons') if f.endswith('.ico')] print("you clicked") self.iconbitmap(random.choice(icons))