Add GUI
This commit is contained in:
2
gui/IMainWindow.py
Normal file
2
gui/IMainWindow.py
Normal file
@@ -0,0 +1,2 @@
|
||||
class IMainWindow:
|
||||
pass
|
||||
144
gui/MainWindow.py
Normal file
144
gui/MainWindow.py
Normal file
@@ -0,0 +1,144 @@
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
from tkinter import messagebox
|
||||
from gui.IMainWindow import *
|
||||
|
||||
class MainWindow(IMainWindow):
|
||||
def __init__(self, controller):
|
||||
self.controller = controller
|
||||
self.root = tk.Tk()
|
||||
self.root.title("SecCon - © Louis SWINNEN 2022")
|
||||
self.root.config(bd=5)
|
||||
self.host = tk.StringVar()
|
||||
self.passw = tk.StringVar()
|
||||
self.login = tk.StringVar()
|
||||
self.tls = tk.BooleanVar()
|
||||
self.port = tk.IntVar()
|
||||
self.draw_window()
|
||||
|
||||
def start_main_loop(self):
|
||||
self.tf_host.focus()
|
||||
self.root.mainloop()
|
||||
|
||||
def draw_window(self):
|
||||
self.draw_top_pane()
|
||||
self.draw_center_pane()
|
||||
self.draw_footer_pane()
|
||||
self.not_connected_mode()
|
||||
|
||||
def draw_top_pane(self):
|
||||
top_pane = ttk.LabelFrame(self.root, padding=(3, 3, 12, 12), text=" Connection to FileFrontEnd ")
|
||||
top_pane.pack(fill=tk.X)
|
||||
top_pane.columnconfigure(1, weight=1)
|
||||
|
||||
ttk.Label(top_pane, text="Host:").grid(row=0, column=0, sticky=tk.E)
|
||||
self.tf_host = ttk.Entry(top_pane, textvariable=self.host)
|
||||
self.tf_host.grid(row=0, column=1, sticky=tk.EW, padx=5, pady=5)
|
||||
|
||||
ttk.Label(top_pane, text="Port:").grid(row=0, column=2, sticky=tk.E)
|
||||
self.tf_port = ttk.Entry(top_pane, textvariable=self.port)
|
||||
self.tf_port.grid(row=0, column=3, sticky=tk.EW, padx=5, pady=2)
|
||||
|
||||
ttk.Label(top_pane, text="Login:").grid(row=1, column=0, sticky=tk.E)
|
||||
self.tf_login = ttk.Entry(top_pane, textvariable=self.login)
|
||||
self.tf_login.grid(row=1,column=1, sticky=tk.EW, padx=5, pady=5)
|
||||
|
||||
ttk.Label(top_pane, text="Password:").grid(row=1, column=2, sticky=tk.E)
|
||||
self.tf_password = ttk.Entry(top_pane, show="*", textvariable=self.passw)
|
||||
self.tf_password.grid(row=1,column=3, sticky=tk.EW, padx=5, pady=2)
|
||||
|
||||
inner_frame = ttk.Frame(top_pane)
|
||||
inner_frame.grid(row=2, column=0, columnspan=4, sticky=tk.NSEW)
|
||||
inner_frame.columnconfigure(1,weight=1)
|
||||
|
||||
ttk.Label(inner_frame, text="Security:").grid(row=0, column=0, sticky=tk.E)
|
||||
self.cb_tls = ttk.Checkbutton(inner_frame, text="with SSL/TLS", variable=self.tls)
|
||||
self.cb_tls.grid(row=0, column=1, padx=5, pady=2, sticky=tk.W)
|
||||
self.bt_signup = ttk.Button(inner_frame, text="Sign up", command=self.sign_up)
|
||||
self.bt_signup.grid(row=0, column=2, padx=5, pady=2,sticky=tk.E)
|
||||
self.bt_signin = ttk.Button(inner_frame, text="Sign in", command=self.sign_in)
|
||||
self.bt_signin.grid(row=0, column=3, padx=5, pady=2, sticky=tk.E)
|
||||
|
||||
|
||||
|
||||
def draw_center_pane(self):
|
||||
title_pane = ttk.Frame(self.root, padding=(5, 0, 5, 0))
|
||||
ttk.Label(title_pane, text="My files:").grid(row=0, column=0, sticky=tk.E)
|
||||
title_pane.pack(fill=tk.X)
|
||||
center_pane = ttk.Frame(self.root, padding=(5, 0, 5, 0))
|
||||
center_pane.pack(fill=tk.BOTH, expand=True)
|
||||
center_pane.columnconfigure(1, weight=1)
|
||||
|
||||
self.scroll = ttk.Scrollbar(center_pane)
|
||||
self.tv_files = ttk.Treeview(center_pane, yscrollcommand=self.scroll.set, height=6)
|
||||
self.tv_files["columns"] = ["Filename", "Size"]
|
||||
self.tv_files["show"] = "headings"
|
||||
self.tv_files.heading("Filename", text="Filename")
|
||||
self.tv_files.heading("Size", text="Filesize")
|
||||
self.tv_files.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, pady=5)
|
||||
self.scroll.config(command=self.tv_files.yview)
|
||||
self.scroll.pack(side=tk.RIGHT, fill=tk.Y, pady=5)
|
||||
|
||||
bottom_pane = ttk.Frame(self.root, padding=(5, 0, 5, 0))
|
||||
bottom_pane.columnconfigure(1, weight=1)
|
||||
self.bt_filelist = ttk.Button(bottom_pane, text="Refresh list", command=self.file_list)
|
||||
self.bt_filelist.grid(row=0, column=0, padx=10, pady=2,sticky=tk.E)
|
||||
self.bt_savefile = ttk.Button(bottom_pane, text="Upload file", command=self.save_file)
|
||||
self.bt_savefile.grid(row=0, column=1, padx=10, pady=2,sticky=tk.E)
|
||||
self.bt_getfile = ttk.Button(bottom_pane, text="Download file", command=self.get_file)
|
||||
self.bt_getfile.grid(row=0, column=2, padx=10, pady=2,sticky=tk.E)
|
||||
self.bt_removefile = ttk.Button(bottom_pane, text="Remove file", command=self.remove_file)
|
||||
self.bt_removefile.grid(row=0, column=3, padx=10, pady=2,sticky=tk.E)
|
||||
bottom_pane.pack(fill=tk.X)
|
||||
|
||||
def draw_footer_pane(self):
|
||||
footer_pane = ttk.Frame(self.root, padding=(5,10,5,0))
|
||||
footer_pane.pack(fill=tk.X)
|
||||
footer_pane.columnconfigure(1, weight=1)
|
||||
self.bt_about = ttk.Button(footer_pane, text="About", command=self.about)
|
||||
self.bt_about.grid(row=0, column=0, pady=3, sticky=tk.E)
|
||||
self.bt_quit = ttk.Button(footer_pane, text="Quit", command=self.quit)
|
||||
self.bt_quit.grid(row=0, column=1, pady=3, sticky=tk.E)
|
||||
|
||||
def not_connected_mode(self):
|
||||
self.bt_filelist.state(["disabled"])
|
||||
self.bt_savefile.state(["disabled"])
|
||||
self.bt_getfile.state(["disabled"])
|
||||
self.bt_removefile.state(["disabled"])
|
||||
|
||||
def connected_mode(self):
|
||||
self.tf_host.state(["disabled"])
|
||||
self.tf_port.state(["disabled"])
|
||||
self.tf_login.state(["disabled"])
|
||||
self.tf_password.state(["disabled"])
|
||||
self.bt_signin.state(["disabled"])
|
||||
self.bt_signup.state(["disabled"])
|
||||
self.cb_tls.state(["disabled"])
|
||||
self.bt_filelist.state(["!disabled"])
|
||||
self.bt_savefile.state(["!disabled"])
|
||||
self.bt_getfile.state(["!disabled"])
|
||||
self.bt_removefile.state(["!disabled"])
|
||||
|
||||
def sign_in(self):
|
||||
pass
|
||||
def sign_up(self):
|
||||
pass
|
||||
|
||||
def save_file(self):
|
||||
pass
|
||||
|
||||
def get_file(self):
|
||||
pass
|
||||
|
||||
def remove_file(self):
|
||||
pass
|
||||
|
||||
def file_list(self):
|
||||
pass
|
||||
|
||||
def about(self):
|
||||
pass
|
||||
|
||||
def quit(self):
|
||||
self.root.destroy()
|
||||
self.controller.on_quit()
|
||||
Reference in New Issue
Block a user