Remove unused interface
Add all options Bugs fixed
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
class IMainWindow:
|
||||
pass
|
||||
@@ -1,11 +1,12 @@
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
from tkinter import messagebox
|
||||
from gui.IMainWindow import *
|
||||
from tkinter import filedialog
|
||||
|
||||
class MainWindow(IMainWindow):
|
||||
class MainWindow:
|
||||
def __init__(self, controller):
|
||||
self.controller = controller
|
||||
self.controller.register_window(self)
|
||||
self.root = tk.Tk()
|
||||
self.root.title("SecCon - © Louis SWINNEN 2022")
|
||||
self.root.config(bd=5)
|
||||
@@ -81,9 +82,9 @@ class MainWindow(IMainWindow):
|
||||
|
||||
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 = ttk.Button(bottom_pane, text="Refresh list", command=self.refresh_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 = ttk.Button(bottom_pane, text="Upload file", command=self.upload_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)
|
||||
@@ -120,25 +121,84 @@ class MainWindow(IMainWindow):
|
||||
self.bt_removefile.state(["!disabled"])
|
||||
|
||||
def sign_in(self):
|
||||
pass
|
||||
def sign_up(self):
|
||||
pass
|
||||
if self.check_before_signin():
|
||||
print("[MainWindow] Calling MainWindowController::on_signin()")
|
||||
self.controller.on_signin(self.host.get(), int(self.port.get()), self.login.get(), self.passw.get(), self.tls.get())
|
||||
else:
|
||||
self.show_message("All fields are mandatory!\nPort is numeric (1025-65535)", True)
|
||||
|
||||
def save_file(self):
|
||||
def sign_up(self):
|
||||
if self.check_before_signin():
|
||||
print("[MainWindow] Calling MainWindowController::on_signup()")
|
||||
self.controller.on_signup(self.host.get(), int(self.port.get()), self.login.get(), self.passw.get(), self.tls.get())
|
||||
else:
|
||||
self.show_message("All fields are mandatory!\nPort is numeric (1025-65535)", True)
|
||||
|
||||
def check_before_signin(self):
|
||||
try:
|
||||
host = self.host.get()
|
||||
port = int(self.port.get())
|
||||
login = self.login.get()
|
||||
passw = self.passw.get()
|
||||
tls = self.tls.get()
|
||||
if(not(host and host.strip())) or port <= 1024 or port >= 65536 or not (login and login.strip()) or not(passw and passw.strip()):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
def show_message(self, message, is_error):
|
||||
if is_error:
|
||||
messagebox.showerror("Error", message)
|
||||
else:
|
||||
messagebox.showinfo("Information", message)
|
||||
|
||||
def show_select_file_dialog(self):
|
||||
filepath = filedialog.askopenfilename()
|
||||
return filepath
|
||||
|
||||
def show_save_directory_dialog(self):
|
||||
filedir = filedialog.askdirectory()
|
||||
return filedir
|
||||
|
||||
def upload_file(self):
|
||||
path = self.show_select_file_dialog()
|
||||
self.controller.on_fileupload(path)
|
||||
pass
|
||||
|
||||
def get_file(self):
|
||||
pass
|
||||
current_item = self.tv_files.focus()
|
||||
selected_file = self.tv_files.item(current_item)['values']
|
||||
if selected_file is None or selected_file == '':
|
||||
self.show_message("No file selected !", True)
|
||||
else:
|
||||
path = self.show_save_directory_dialog()
|
||||
if path is None or path == '':
|
||||
self.show_message("No directory selected !", True)
|
||||
else:
|
||||
self.controller.on_filedownload(selected_file[0], path)
|
||||
|
||||
def remove_file(self):
|
||||
pass
|
||||
current_item = self.tv_files.focus()
|
||||
selected_file = self.tv_files.item(current_item)['values']
|
||||
if selected_file is None or selected_file == '':
|
||||
self.show_message("No file selected !", True)
|
||||
else:
|
||||
self.controller.on_filedelete(selected_file[0])
|
||||
|
||||
def file_list(self):
|
||||
pass
|
||||
def refresh_list(self):
|
||||
self.controller.on_refreshlist()
|
||||
|
||||
def about(self):
|
||||
pass
|
||||
|
||||
def quit(self):
|
||||
self.root.destroy()
|
||||
self.controller.on_quit()
|
||||
self.controller.on_quit()
|
||||
|
||||
def remove_all_from_treeview(self):
|
||||
self.tv_files.delete(*self.tv_files.get_children())
|
||||
|
||||
def add_file_in_treeview(self, fileinfo):
|
||||
self.tv_files.insert('', tk.END, values = fileinfo)
|
||||
Reference in New Issue
Block a user