Hier ist ein relevanter Code:
Code: Select all
def update_time_box(app_self, time_str):
if not app_self.is_calculated_time_added:
## lines of code ##
app_self.cook_button = toga.Button(text="Cocinar", on_press=set_alarm_wrapper(app_self, time_in_seconds))
## some more lines of code ##
def set_alarm(app_self, time_in_seconds):
context = toga.App.app._impl.native
if context is None:
print("El contexto es None")
return
current_time_millis = int(time.time() * 1000)
trigger_time = current_time_millis + (time_in_seconds * 1000)
total_minutes = (trigger_time // (1000 * 60)) % (24 * 60)
alarm_hour_24 = total_minutes // 60
alarm_minute = total_minutes % 60
alarm_intent = Intent(AlarmClock.ACTION_SET_ALARM)
## THESE EXTRAS WON'T WORK ##
alarm_intent.putExtra(AlarmClock.EXTRA_HOUR, alarm_hour_24)
alarm_intent.putExtra(AlarmClock.EXTRA_MINUTES, alarm_minute)
alarm_intent.putExtra(AlarmClock.EXTRA_MESSAGE, "a cocinar!")
## ##
context.startActivity(alarm_intent)
def set_alarm_wrapper(app_self, time_in_seconds):
def wrapped_function(widget):
set_alarm(app_self, time_in_seconds)
return wrapped_function