import tkinter as tk from tkinter import ttk class ButtonFrame(ttk.Frame): """Frame for holding the main action buttons.""" def __init__(self, parent, process_command, quit_command, **kwargs): """ Initialize the Button Frame. Args: parent: The parent widget. process_command: Callback function for the Process button. # theme_command: Callback function for the Toggle Theme button. quit_command: Callback function for the Quit button. **kwargs: Additional arguments for ttk.Frame. """ super().__init__(parent, padding=10, **kwargs) self._process_command = process_command # self._theme_command = theme_command self._quit_command = quit_command self._create_widgets() def _create_widgets(self): """Create the buttons.""" self.process_button = ttk.Button(self, text="Process SVG", command=self._process_command) self.process_button.pack(side=tk.LEFT, padx=5) # self.theme_button = ttk.Button(self, text="Toggle Theme", command=self._theme_command) # self.theme_button.pack(side=tk.LEFT, padx=5) self.quit_button = ttk.Button(self, text="Quit", command=self._quit_command) self.quit_button.pack(side=tk.RIGHT, padx=5) # Changed back to tk.RIGHT def add_center_mode_checkbox(self, variable): """Adds the checkbox for selecting path center calculation mode.""" self.center_mode_checkbox = ttk.Checkbutton( self, text="Use Centroid for Paths", variable=variable, onvalue='centroid', offvalue='bbox' ) # Pack it to the left, after the Process button self.center_mode_checkbox.pack(side=tk.LEFT, padx=10) def set_process_button_state(self, state): """Enable or disable the Process button.""" self.process_button.config(state=state) # Example usage if __name__ == '__main__': root = tk.Tk() root.title("Button Frame Test") root.geometry("400x100") style = ttk.Style() style.theme_use('clam') def mock_process(): print("Process button clicked") def mock_quit(): print("Quit button clicked") root.quit() button_frame = ButtonFrame( root, process_command=mock_process, quit_command=mock_quit ) button_frame.pack(pady=20) # Example of disabling/enabling the process button ttk.Button(root, text="Disable Process", command=lambda: button_frame.set_process_button_state(tk.DISABLED)).pack(side=tk.LEFT, padx=10) ttk.Button(root, text="Enable Process", command=lambda: button_frame.set_process_button_state(tk.NORMAL)).pack(side=tk.LEFT, padx=10) root.mainloop()