def __set_foreground_width(self, *args): self.event_generate("<<ForegroundWidthChange>>") if __name__ == "__main__": if sys.stdout.isatty(): def on_foreground_change(dock): print("foreground", dock.foreground) def on_background_change(dock): print("background", dock.background) application = tk.Tk() application.title("Colors") dock = Dock(application, None) dock.pack(fill=tk.BOTH, expand=True) # Since tkinter doesn't support the event.data field we must access # the data ourselves dock.bind("<<ForegroundChange>>", lambda *args: on_foreground_change(dock)) dock.bind("<<BackgroundChange>>", lambda *args: on_background_change(dock)) dock.bind("<Escape>", lambda *args: application.quit()) application.bind("<Escape>", lambda *args: application.quit()) application.mainloop() else: print("Loaded OK")