def __init__(self, *args, config=None, **kwargs): super().__init__(*args, **kwargs) # Hide Tkinter root window self.withdraw() # Load config self.config = config if not self.config: self.config = Config() # On Windows, set DPI awareness if platform.system() == "Windows": self._windows_set_dpi_awareness() # Set Automagica icon icon_path = os.path.join( os.path.abspath(__file__).replace( os.path.basename(os.path.realpath(__file__)), ""), "icons", "automagica.ico", ) self.tk.call( "wm", "iconphoto", self._w, ImageTk.PhotoImage(Image.open(icon_path)), ) ICONS.generate_icons()
def draw(self): # Create bounding rectangle self.rect = self.parent.canvas.create_rectangle( self.node.x, self.node.y, self.node.x + self.w, self.node.y + self.h, tags=self.node.uid, fill=config.COLOR_1, outline=config.COLOR_0, width=0, ) # Add label text self.label_text = self.parent.canvas.create_text( self.center_x, self.center_y, text=self.text_label, tags=self.node.uid, fill=config.COLOR_0, width=self.w, font=(config.FONT, 10), ) self.uid_text = self.parent.canvas.create_text( self.node.x + self.w - 3, self.node.y + self.h - 3, text=self.node.uid, tags=self.node.uid, fill=config.COLOR_8, font=(config.FONT, 8), anchor="se", ) # Icon self.icon = self.parent.canvas.create_image( self.node.x + self.w - 10, self.node.y + 10, image=ICONS.tkinter("python.png"), tags=self.node.uid, ) # Play button self.play_button = self.parent.canvas.create_image( self.node.x + 3, self.node.y + 3, image=ICONS.tkinter("play-solid.png"), tags="play" + self.node.uid, anchor="nw", ) self.parent.canvas.tag_bind( "play" + self.node.uid, "<ButtonPress-1>", self.run_click )
def __init__(self, *args, config=None, **kwargs): super().__init__(*args, **kwargs) # Hide this parent window self.withdraw() # Load config self.config = config if not self.config: self.config = Config() # On Windows, set DPI awareness if platform.system() == "Windows": self._windows_set_dpi_awareness() ICONS.generate_icons()
def __init__(self, *args, message="", title="", **kwargs): super().__init__(*args, **kwargs) self.message = message if not title: title = _("Information") self.title = title self.configure( image=ICONS.tkinter("question-circle.png"), command=self.on_clicked, relief=tk.FLAT, bg=self.master.cget("bg"), # Take parent's background takefocus=False, # Do not include in 'TAB'-ing )
def __init__(self, canvas, activity, x, y): self.canvas = canvas if activity.get("class"): name = "{} - {}".format(activity["class"], activity["name"]) else: name = activity["name"] self.canvas.create_text( x + 25, y + 2, text=name, anchor=tk.NW, font=(config.FONT, 10), tags=activity.get("key"), ) icon_name = str(activity["icon"].split("la-")[-1]) if icon_name not in [ "html5", "trello", "salesforce", "chrome", "readme", ]: icon_name = icon_name + "-solid.png" else: icon_name = icon_name + ".png" self.icon_img = ICONS.tkinter(icon_name) self.icon = self.canvas.create_image(x, y, image=self.icon_img, anchor=tk.NW, tags=activity.get("key")) self.canvas.tag_bind( activity.get("key"), "<Double-Button-1>", lambda e: self.select_activity(activity.get("key")), )
def draw(self): # Create bounding rectangle self.rect = self.parent.canvas.create_rectangle( self.node.x, self.node.y, self.node.x + self.w, self.node.y + self.h, tags=self.node.uid, fill=config.COLOR_3, outline=config.COLOR_3, width=0, ) # Add label text self.label_text = self.parent.canvas.create_text( self.center_x, self.center_y, text=self.text_label, tags=self.node.uid, fill=config.COLOR_0, width=self.w, font=(config.FONT, 10), ) self.uid_text = self.parent.canvas.create_text( self.node.x + self.w - 3, self.node.y + self.h - 3, text=self.node.uid, tags=self.node.uid, fill=config.COLOR_8, font=(config.FONT, 8), anchor="se", ) # Icon self.icon = self.parent.canvas.create_image( self.node.x + self.w - 10, self.node.y + 10, image=ICONS.tkinter("comment-alt.png"), tags=self.node.uid, )
def draw(self): # Create bounding rectangle self.rect = self.parent.canvas.create_rectangle( self.node.x, self.node.y, self.node.x + self.w, self.node.y + self.h, tags=self.node.uid, fill=config.COLOR_1, outline=config.COLOR_0, width=0, ) # Add label text self.label_text = self.parent.canvas.create_text( self.center_x, self.center_y, text=self.text_label, tags=self.node.uid, fill=config.COLOR_0, width=self.w, font=(config.FONT, 10), ) # UID text self.uid_text = self.parent.canvas.create_text( self.node.x + self.w - 3, self.node.y + self.h - 3, text=self.node.uid, tags=self.node.uid, fill=config.COLOR_8, font=(config.FONT, 8), anchor="se", ) # Icon icon_name = str( config.ACTIVITIES[self.node.activity].get("icon").split("la-")[-1] ) if icon_name not in [ "html5", "trello", "salesforce", "chrome", "readme", ]: icon_name = icon_name + "-solid.png" else: icon_name = icon_name + ".png" self.icon = self.parent.canvas.create_image( self.node.x + self.w - 3, self.node.y + 3, image=ICONS.tkinter(icon_name), tags=self.node.uid, anchor="ne", ) # Play button self.play_button = self.parent.canvas.create_image( self.node.x + 3, self.node.y + 3, image=ICONS.tkinter("play-solid.png"), tags="play" + self.node.uid, anchor="nw", ) self.parent.canvas.tag_bind( "play" + self.node.uid, "<ButtonPress-1>", self.run_click )