def __init__(self, master, controller, py, idx, data, *args, **kwargs): tk.Frame.__init__(self, master, width=360, height=72, *args, *kwargs) self.icon = ImageTk.PhotoImage( Image.open("folder_icon.png").resize((44, 48))) self.data = data self.dummy = tk.Label(master, image=self.icon).place(anchor=tk.NW, x=16, y=12 + py) self.controller = controller abc = tk.Label(master, text=data.get("title"), font=FONT16(), bg=BG, fg=FONT_COLOR) abc.place(anchor=tk.NW, x=81, y=20 + py) def delete_folder(): del db.data["note"][idx] db.save_data() controller.show("folder_list") text = TextProperties(fill="white", text="x", anchor="c", font="Consolas 20") self.delete = CircularButton(self, 22, BAD_COLOR, BAD_COLOR, delete_folder, text) self.delete.place(anchor=tk.NW, x=WIDTH - 48, y=12) self.config(bg=BG) abc.bind("<ButtonRelease-1>", self._on_release) self.bind("<ButtonRelease-1>", self._on_release)
def add_userbtn(self): text = TextProperties(fill="white", text="+", anchor="c", font="Consolas 20") self.add_user = CircularButton( self, 28, config.COLOR, config.COLOR, lambda: self.controller.show("create_user"), text) self.add_user.place(anchor=tk.NW, x=286, y=HEIGHT - 56 - 81)
def __init__(self, *args, **kwargs): tk.Frame.__init__(self, *args, **kwargs) tk.Label(self, text="asdfasdfasdfa").pack() text = TextProperties(fill="white", text="+", anchor="c", font="Consolas 20") def test(): print("asdfasdf") CircularButton(self, 50, "#009789", "#009789", command=test, text=text).pack()
def add_userbtn(self): text = TextProperties( fill="black", text="+", anchor="c", font="Consolas 20" ) self.add_user = CircularButton( self, 28, config.COLOR, config.COLOR, self.CreateFolder, text) self.add_user.place( anchor=tk.NW, x=286, y=HEIGHT-56-81 )
def __init__(self, master, controller, py, idx, data, *args, **kwargs): tk.Frame.__init__(self, master, width=360, height=72, *args, *kwargs) self.data = data[idx] self.controller = controller abc = tk.Label(master, text=f"{self.data['title']}", font=FONT16(), bg=BG, fg=FONT_COLOR) abc.place(anchor=tk.NW, x=81, y=16 + py) lbl = tk.Label(master, text=f"{self.data['date']}", font=FONT12(), bg=BG, fg=FONT_COLOR) lbl.place(anchor=tk.NW, x=81, y=38 + py) self.config(bg=BG) def delete_note(): print(type(data)) del data[idx] db.save_data() self.controller.show("notes_frame", no_update=True) text = TextProperties(fill="white", text="x", anchor="c", font="Consolas 20") self.delete = CircularButton(self, 22, BAD_COLOR, BAD_COLOR, delete_note, text) self.delete.place(anchor=tk.NW, x=WIDTH - 48, y=12) lbl.bind("<ButtonRelease-1>", self._on_release) abc.bind("<ButtonRelease-1>", self._on_release) self.bind("<ButtonRelease-1>", self._on_release)
def _on_press(self, event): self.configure(relief="sunken") def _on_release(self, event): self.configure(relief="raised") if self.command is not None: self.command() if __name__ == "__main__": def test(): print("button working") text = TextProperties(fill="white", text="+", anchor="c", font="Consolas 20") window = tk.Tk() btn = CircularButton(window, 30, "#009789", "#009789", command=test, text=text) btn.pack() window.mainloop()