Skip to content

Commit

Permalink
Ajout titlebar
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxenceR26 committed Feb 16, 2022
1 parent 39af804 commit b36217c
Showing 1 changed file with 35 additions and 33 deletions.
68 changes: 35 additions & 33 deletions source/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('<ButtonPress-1>', self.mouse_down)
self.bind('<B1-Motion>', self.mouse_drag)
self.bind('<ButtonRelease-1>', 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('<ButtonPress-1>', self.mouse_down)
Title_bar.bind('<B1-Motion>', self.mouse_drag)
Title_bar.bind('<ButtonRelease-1>', 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))
Expand All @@ -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()
MainWindow().update()

0 comments on commit b36217c

Please sign in to comment.