2020-12-14 07:02:08 +01:00
|
|
|
import tkinter as tk
|
2020-12-14 13:24:23 +01:00
|
|
|
|
2021-01-07 18:35:51 +01:00
|
|
|
from constants import LOGIN_VIEW_NAME
|
|
|
|
from views.login_view import LoginView
|
|
|
|
from views.main_view import MainView
|
|
|
|
from views.register_view import RegisterView
|
2020-12-14 07:02:08 +01:00
|
|
|
|
2020-12-21 14:23:52 +01:00
|
|
|
|
2020-12-14 07:02:08 +01:00
|
|
|
class SmartPicasso(tk.Tk):
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
tk.Tk.__init__(self, *args, **kwargs)
|
|
|
|
container = tk.Frame(self)
|
|
|
|
self.title('SmartPicasso')
|
|
|
|
self.geometry('610x460')
|
|
|
|
|
2020-12-14 13:24:23 +01:00
|
|
|
container.pack(side="top", fill="both", expand=True)
|
2020-12-14 07:02:08 +01:00
|
|
|
|
|
|
|
container.grid_rowconfigure(0, weight=1)
|
|
|
|
container.grid_columnconfigure(0, weight=1)
|
|
|
|
|
|
|
|
self.frames = {}
|
|
|
|
|
2020-12-14 13:24:23 +01:00
|
|
|
for F in (LoginView, MainView, RegisterView):
|
2020-12-14 07:02:08 +01:00
|
|
|
frame = F(container, self)
|
|
|
|
|
2021-01-07 18:35:51 +01:00
|
|
|
self.frames[F.get_view_name()] = frame
|
2020-12-14 07:02:08 +01:00
|
|
|
|
|
|
|
frame.grid(row=0, column=0, sticky="nsew")
|
|
|
|
|
2021-01-07 18:35:51 +01:00
|
|
|
self.show_frame(LOGIN_VIEW_NAME)
|
2020-12-14 07:02:08 +01:00
|
|
|
|
2020-12-14 13:24:23 +01:00
|
|
|
def show_frame(self, view, token=None):
|
|
|
|
frame = self.frames[view]
|
2020-12-14 07:02:08 +01:00
|
|
|
frame.tkraise()
|
|
|
|
|
2020-12-14 13:24:23 +01:00
|
|
|
if token:
|
|
|
|
frame.token = token
|
|
|
|
|
|
|
|
|
2020-12-14 07:02:08 +01:00
|
|
|
app = SmartPicasso()
|
2020-12-14 13:24:23 +01:00
|
|
|
app.mainloop()
|