Skip to content

Commit

Permalink
Improved UI
Browse files Browse the repository at this point in the history
  • Loading branch information
rohaan2614 committed Dec 19, 2023
1 parent 934c186 commit 11a04d1
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ def __init__(self):
self.test_browse_button = tk.Button(self, text="Browse", command=self.browse_test_file)
self.test_browse_button.grid(row=1, column=2, padx=10, pady=10)

self.load_train_columns_button = tk.Button(self, text="Load Columns", command=self.load_train_columns)
self.load_train_columns_button.grid(row=2, column=0, columnspan=3, pady=10)


self.column_listbox = tk.Listbox(self, selectmode=tk.MULTIPLE, exportselection=0, height=10)
self.column_listbox.grid(row=3, column=0, columnspan=3, padx=10, pady=10)

self.column_listbox.grid(row=2, column=0, columnspan=3, padx=10, pady=10)
self.select_features_button = tk.Button(self, text="Select Features", command=self.select_features)
self.select_features_button.grid(row=4, column=0, columnspan=3, pady=10)

Expand All @@ -49,6 +47,8 @@ def browse_train_file(self):
file_path = filedialog.askopenfilename(filetypes=[("CSV files", "*.csv")])
self.train_file_path = file_path
self.train_entry_var.set(file_path)
self.load_train_columns()


def browse_test_file(self):
file_path = filedialog.askopenfilename(filetypes=[("CSV files", "*.csv")])
Expand All @@ -60,21 +60,17 @@ def load_train_columns(self):
try:
df = pd.read_csv(self.train_file_path)
columns = df.columns.tolist()
self.column_listbox.delete(0, tk.END)
# Add columns to the listbox without displaying it on the GUI
for column in columns:
self.column_listbox.insert(tk.END, column)
except Exception as e:
messagebox.showerror("Error", f"Error loading columns: {e}")
messagebox.showerror("Error", f"Error loading columns: {e}")
else:
messagebox.showwarning("Warning", "Please select a training CSV file.")

def select_features(self):
selected_columns = self.column_listbox.curselection()
if not selected_columns:
messagebox.showwarning("Warning", "Please select at least one feature.")
return

self.features = [self.column_listbox.get(index) for index in selected_columns]
def select_features(self):
self.features = [self.column_listbox.get(index) for index in range(self.column_listbox.size())]

feature_selection_window = FeatureSelectionWindow(self, self.features)
self.wait_window(feature_selection_window)
Expand Down Expand Up @@ -119,10 +115,6 @@ def __init__(self, parent, features):

def confirm_selection(self):
selected_features = self.feature_listbox.curselection()
if not selected_features:
messagebox.showwarning("Warning", "Please select at least one feature.")
return

selected_target = self.target_listbox.curselection()
if not selected_target:
messagebox.showwarning("Warning", "Please select the target variable.")
Expand Down

0 comments on commit 11a04d1

Please sign in to comment.