import seaborn as sns def generate_output_and_visualizations(): selected = data_list.curselection() if selected: dataset_name = data_list.get(selected[0]) df = data_dict.get(dataset_name) if df is not None: try: # Create a new tkinter Toplevel to display the figure plot_window = tk.Toplevel(root) plot_window.title("Plot for " + dataset_name) # Create the figure fig, ax = plt.subplots(figsize=(10, 6)) # Use seaborn to create a bar plot sns.barplot(x=df.columns[0], y=df.columns[1], data=df, ax=ax) # Create a FigureCanvasTkAgg object and pass the figure canvas = FigureCanvasTkAgg(fig, master=plot_window) canvas.draw() # Pack the canvas in the plot_window canvas.get_tk_widget().pack() except Exception as e: messagebox.showerror("Error", str(e)) else: messagebox.showinfo("Error", "No data selected") else: messagebox.showinfo("Error", "No dataset selected")