Reputation: 3100
I tried like this, but when I access the menu, the Preferences item is not enabled :
class Application(toga.App):
def startup(self):
# ... build UI here
self.main_window = toga.MainWindow(title=self.formal_name)
self.main_window.content = MainBox
self.main_window.show()
def preferences(self):
# Create a new window for the preferences
pref_window = toga.Window(title="Preferences")
# Create a preferences window layout
pref_box = toga.Box(style=Pack(direction=COLUMN, padding=10))
# Example preferences settings (could be text inputs, toggles, etc.)
theme_label = toga.Label("Choose Theme:", style=Pack(padding=(0, 5)))
theme_selection = toga.Selection(items=["Light", "Dark"])
notification_label = toga.Label("Enable Notifications:", style=Pack(padding=(0, 5)))
notification_toggle = toga.Switch()
# Add widgets to the box
pref_box.add(theme_label, theme_selection, notification_label, notification_toggle)
# Set the content of the preferences window
pref_window.content = pref_box
pref_window.show()
Upvotes: 0
Views: 133
Reputation: 8111
In the current version of Toga (0.4.5), you'll have to enable the menu item and attach an action to it, using the properties of the Command
object.
In the next version of Toga, the Preferences/Settings command will no longer be added by default, but there will be an API to add it yourself.
Upvotes: 0