I've hit a problem calling a function inside a class. The code fragment is:
class CharacterGenerator(GridLayout):
def printcharacter(self,my_sb,my_cr,my_scm,my_scb):
printable_stats = print_stats(my_sb)
printable_rolls = print_rolls(my_cr)
printable_scm = print_scm(my_scm)
printable_scb = print_scb(my_scb)
# self.clear_widgets()
layout=BoxLayout(orientation='vertical')
stat_box=(Label(text_size=(300, None),
text='Stats\n' + str(printable_stats)))
rolls_box=(Label(text_size=(300, None),
text='Rolls\n' + str(printable_rolls)))
scm_box=(Label(text_size=(300, None),
text='SCM\n' + str(printable_scm)))
scb_box=(Label(text_size=(300, None),
text='SCB\n' + str(printable_scb)))
layout.add_widget(stat_box)
layout.add_widget(rolls_box)
layout.add_widget(scm_box)
layout.add_widget(scb_box)
wayout = Button(text='Way Out')
layout.add_widget(wayout)
def human(self,a,b):
if b==True:
self.Status="human"
race=self.Status
statblock = human()
characteristic_rolls = rolls(statblock)
skill_category_modifiers = scm(statblock)
skill_category_bonuses = scb(statblock)
CharacterGenerator.printcharacter (self, statblock, characteristic_rolls, skill_category_modifiers, skill_category_bonuses)
It errors with:
File "./charactergenerator.kv", line 36, in <module>
on_press: root.printcharacter()
TypeError: printcharacter() missing 4 required positional arguments: 'my_sb', 'my_cr', 'my_scm', and 'my_scb'
As far as I can tell, I am sending the right parameters to the printcharacter
function. The same function and call work with printcharacter
in a separate python module.
I've tried all combinations of the calling parameters, added and removed some from the list. Without the CharacterGenerator.printcharacter
call, all I get is the message that CharacterGenerator has no object printcharacter
and I'm back to square one.
Can anyone see where I'm going wrong?