Modify the code here: statstext = f"{header}: True: {truecount}, False: {falsecount}" -…
- User
Modify the code here: stats_text = f"{header}: True: {true_count}, False: {false_count}" - {header} should use self.colors["text"] and the rest should use self.colors["header_info"]. Also here label=f"Total: {total_rows}", Total: should use self.colors["text"] and the rest should use self.colors["header_info"]. Only modify the font color nothing else. Python 3.12 Code: def show_stats(self): """Display stats about the boolean columns in a menu similar to datatype dialog.""" table_name = self.app.current_table_name if not table_name: messagebox.showwarning("No Table Selected", "Please select a table to view stats.") return if not self.app.current_sheet: messagebox.showwarning("No Data", "No data available to show stats.") return data = self.app.current_sheet.get_sheet_data() current_headers = self.app.current_sheet.headers() data_types = self.app.data_manager.tables_data[table_name].get("data_types", []) while len(data_types) < len(current_headers): data_types.append('string') total_rows = len(data) boolean_columns = [] for col_idx, dtype in enumerate(data_types): if dtype == 'boolean': header = current_headers[col_idx] column_data = [row[col_idx] for row in data] true_count = sum(1 for val in column_data if val is True) false_count = sum(1 for val in column_data if val is False) boolean_columns.append((header, true_count, false_count)) self.root.option_add('*Menu.disabledForeground', self.colors["text"]) self.root.option_add('*Menu.font', self.fonts["text"]) self.stats_menu = tk.Menu(self.root, tearoff=0, bg=self.colors["background"], fg=self.colors["text"], font=self.fonts["text"]) menu_x = self.root.winfo_pointerx() menu_y = self.root.winfo_pointery() self.stats_menu.add_command( label=f"Total: {total_rows}", state='disabled', foreground=self.colors["header_info"], background=self.colors["background"] ) if boolean_columns: for header, true_count, false_count in boolean_columns: stats_text = f"{header}: True: {true_count}, False: {false_count}" self.stats_menu.add_command( label=stats_text, state='disabled', foreground=self.colors["text"], background=self.colors["background"] ) else: pass self.stats_menu.post(menu_x, menu_y).
- Assistant