diff --git a/source/app/main.py b/source/app/main.py index a33150c..4bdedea 100644 --- a/source/app/main.py +++ b/source/app/main.py @@ -18,44 +18,50 @@ def set_appwindow(mainWindow): # Pour afficher l'icon dans la barre des taches mainWindow.after(10, mainWindow.wm_deiconify) -color = {'lightgreen': '#EAFCEC', - 'entrycolor': '#89DA92', - 'buttontext': '#45794A', - 'gray': '#666666' - } - - -class Main(tk.Tk): +class MainWindow(tk.Tk): def __init__(self, *args, **kwargs): super().__init__() + self.COLOR = { + 'lightgreen': '#EAFCEC', + 'entrycolor': '#89DA92', + 'buttontext': '#45794A', + 'gray': '#666666' + } + # Config Window - self.geometry("851x512") - self.config(background=color["lightgreen"]) + self.geometry("679x406") + self.config(background=self.COLOR["lightgreen"]) self.wm_overrideredirect(True) self.x, self.y = None, None - self.bind('', self.mouse_down) - self.bind('', self.mouse_drag) - self.bind('', self.mouse_up) - # Design - imgs = tk.PhotoImage(file=r'../ressource/img/icon.png').subsample(20) - icons = tk.Label(self, image=imgs, background=color["lightgreen"], bd=0, foreground=color["lightgreen"]) + + Title_bar = tk.Canvas(width=679, height=47, bg=self.COLOR['entrycolor'], highlightthickness=0) + Title_bar.pack() + + Title_bar.bind('', self.mouse_down) + Title_bar.bind('', self.mouse_drag) + Title_bar.bind('', self.mouse_up) + + imgs = tk.PhotoImage(file=r'../ressource/img/icon.png').subsample(8) + icons = tk.Label(self, image=imgs, background=self.COLOR["entrycolor"], bd=0, + foreground=self.COLOR["lightgreen"]) icons.photo = imgs - icons.place(x=10, y=10) + icons.place(x=10, y=0) - title = tk.Label(self, text="GestMoney", background=color["lightgreen"], foreground=color["gray"], font=('Roboto', 24, 'bold')) - title.place(x=80, y=10) + title = tk.Label(self, text="GestMoney", background=self.COLOR["entrycolor"], foreground=self.COLOR["gray"], + font=('Roboto', 20, 'bold')) + title.place(x=60, y=2) - quit_button = tk.Button(self, text="X", bd=2, background=color["lightgreen"], - foreground=color["buttontext"], activebackground=color["lightgreen"], - activeforeground=color["buttontext"], font=('Roboto', 14, 'bold'), + quit_button = tk.Button(self, text="X", bd=2, background=self.COLOR["entrycolor"], + foreground=self.COLOR["buttontext"], activebackground=self.COLOR["entrycolor"], + activeforeground=self.COLOR["buttontext"], font=('Roboto', 14, 'bold'), command=self.destroy) - quit_button.place(x=800, y=10) + quit_button.place(x=620, y=3, width=45, height=40) # Permet de voir l'icon dans notre barre des taches self.after(10, lambda: set_appwindow(self)) @@ -68,19 +74,15 @@ def mouse_up(self, event): self.x, self.y = None, None def mouse_drag(self, event): - try: - deltax = event.x - self.x - deltay = event.y - self.y - x0 = self.winfo_x() + deltax - y0 = self.winfo_y() + deltay - self.geometry("+%s+%s" % (x0, y0)) - - except: - pass + deltax = event.x - self.x + deltay = event.y - self.y + x0 = self.winfo_x() + deltax + y0 = self.winfo_y() + deltay + self.geometry("+%s+%s" % (x0, y0)) def update(self): self.mainloop() if __name__ == "__main__": - Main().update() \ No newline at end of file + MainWindow().update()