Skip to content

Commit

Permalink
I fixed the BusKillOptionItem()!!!!!!
Browse files Browse the repository at this point in the history
This commit creates a on_manager() function, which is called by Kivy whenever the Kivy Property for the object named "manager" gets a new value.

 * https://stackoverflow.com/questions/78177697/how-to-access-kivy-properties-from-within-its-self-on-init/78177807#78177807
 * https://kivy.org/doc/stable/api-kivy.properties.html#observe-using-on-propname

This finally allows us (well, actually the RecycleView) to setup the instances of BusKillOptionItem() while still having access to the manager, main screen, and dialog objects that were originally passed to it as positional arguments, but are now Kivy Properites.
  • Loading branch information
maltfield committed Mar 18, 2024
1 parent 503cf2a commit 2d2264a
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/buskill_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,20 +505,11 @@ def fileBugReport( self ):
class BusKillOptionItem(FloatLayout):

title = StringProperty('')
print( "title:|" +str(title)+ "|" )
#self.desc = kwargs['desc']
desc = StringProperty('')
#self.confirmation = kwargs['confirmation']
confirmation = StringProperty('')
#self.icon = kwargs['icon']
icon = StringProperty('')
print( "icon:|" +str(icon)+ "|" )
#self.icon = StringProperty('')
#self.value = kwargs['value']
value = StringProperty('')
#self.parent_option = kwargs['parent_option']
parent_option = ObjectProperty()
#self.manager = kwargs['manager']
manager = ObjectProperty()

#def __init__(self, title, value, desc, confirmation, icon, parent_option, manager, **kwargs):
Expand Down Expand Up @@ -546,14 +537,17 @@ def __init__(self, **kwargs):
# #self.manager = kwargs['manager']
# manager = ObjectProperty()

super(BusKillOptionItem, self).__init__(**kwargs)

def on_manager(self, instance, value):
self.manager = value

# the "main" screen
# self.main_screen = self.manager.get_screen('main')
self.main_screen = self.manager.get_screen('main')

# we steal (reuse) the instance field referencing the "modal dialog" from
# the "main" screen
# self.dialog = self.main_screen.dialog

super(BusKillOptionItem, self).__init__(**kwargs)
self.dialog = self.main_screen.dialog

# this is called when the user clicks on this OptionItem (eg choosing the
# 'soft-shutdown' trigger)
Expand Down

0 comments on commit 2d2264a

Please sign in to comment.