I'm having a problem concatenating a string to a variable to create a method in my app. It goes something like this:
# coding: utf-8
import ui
w,h = ui.get_screen_size()
buttons = ''' Scan_View Show_View '''.split()
class OCRApp(ui.View):
def __init__(self):
x,y,w,h = self.bounds
self.background_color = 'orange'
self.present()
for i, button in enumerate(buttons):
button = str(button).lower()
self.add_subview(self.make_button(button,i))
def scan_view_action(self, sender):
scanview = ui.load_view('scanview.pyui')
scanview.background_color = 'red'
scanview.present()
def show_view_action(self,sender):
pass
def make_button(self,name, i):
button = ui.Button(title=name)
**the_action = name
button.action = the_action()**
button.center =w/2, (i*60)+(button.height*2)
self.add_subview(button)
return button
OCRApp()
When I create a string on the variable 'the_action' and call it on 'button.action' I get an error ' TypeError: "str" object is not callable'.
How do I go about doing this correctly?