If anyone can help me I would appreciate it. I am trying to initialize a kivy
screen into another kivy
screen which is something I struggle with, I've tried different methods to initialize it and I keep receiving error codes. I think I have something to do with the way my GUI
is set up but I'm not sure. My latest error code is this:
TypeError: __init__() takes 1 positional argument but 2 were given
I have been trying different methods to initialize the ProjectListScreen
in the ApplyPage. can someone please help identify exactly what I'm doing wrong I'll appreciate it. Below is my code:
class ProjectListScreen(Screen):
project_list = ObjectProperty(None)
def __init__(self, **kwargs):
super(ProjectListScreen, self).__init__(**kwargs)
self.thelocalId = None
self.placementtext = None
projectlistscreen = ProjectListScreen()
class ApplyPage(Screen):
def __init__(self, **kwargs):
super(ApplyPage, self).__init__(**kwargs)
self.projectlistscreen = projectlistscreen
self.yes = Button(text="Yes", font_size = 20, font_name= "fonts/Qanelas-Heavy.otf", background_color = (0.082, 0.549, 0.984, 1.0), background_normal= '', pos_hint = {"x":0.1,"y":0.05}, size_hint= [0.2, 0.1])
self.add_widget(self.yes)
self.no = Button(text="No", font_size= 20, font_name= "fonts/Qanelas-Heavy.otf", background_color = (0.082, 0.549, 0.984, 1.0), background_normal= '', pos_hint = {"x":0.7, "y":0.05}, size_hint= [0.2, 0.1])
self.add_widget(self.no)
def on_enter(self, *args):
print(self.projectlistscreen.placementtext)
class MyApp(App):
refresh_token_file = "refresh_token.txt"
members_list = "members_list.txt"
def build(self):
self.refresh_token_file = self.user_data_dir + self.refresh_token_file
self.thefirebase = MyFireBase()
self.projectlistscreen = ProjectListScreen()
self.apply = ApplyPage(self.projectlistscreen)
return sm
sm = Builder.load_file("kivy.kv")
if __name__ == "__main__":
MyApp().run()
Below is my full traceback
Traceback (most recent call last):
File "/Users/temitayoadefemi/PycharmProjects/test5/mainfile.py", line 871, in
MyApp().run()
File "/Users/temitayoadefemi/PycharmProjects/test5/venv/lib/python3.7/site-packages/kivy/app.py", line 800, in run
root = self.build()
File "/Users/temitayoadefemi/PycharmProjects/test5/mainfile.py", line 860, in build
self.apply = ApplyPage(self.projectlistscreen)
TypeError: init() takes 1 positional argument but 2 were given
self
, but rather about the difference between*args
and**kwargs
– phoenixo