from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.textinput import TextInput
class MainApp(App):
def build(self):
main_layout = BoxLayout(orientation="vertical", padding=10, spacing=10)
self.solution = TextInput(multiline=False, readonly=False, haling="right", front_size=55, input_filter="float")
main_layout.add_widget(self.solution)
buttons = [
["7", "8", "9", "/"]
["4", "5", "6", "*"]
["1", "2", "3", "-"]
[".", "0", "C", "+"]
]
for row in buttons:
h_layout = BoxLayout()
for label in row:
button = Button(text=label, pos_hint={"center_x": 0.5, "center_y": 0.5})
h_layout.add_widget(button)
main_layout.add_widget(h_layout)
return main_layout
if __name__ == '__main__':
MainApp().run()
Traceback (most recent call last):
File "C:/Users/Administrator/PycharmProjects/project1/main.py", line 27, in <module>
MainApp().run()
File "C:\Users\Administrator\PycharmProjects\project1\venv\lib\site-packages\kivy\app.py", line 949, in run
self._run_prepare()
File "C:\Users\Administrator\PycharmProjects\project1\venv\lib\site-packages\kivy\app.py", line 919, in _run_prepare
root = self.build()
File "C:/Users/Administrator/PycharmProjects/project1/main.py", line 10, in build
self.solution = TextInput(multiline=False, readonly=False, haling="right", front_size=55, input_filter="float")
File "C:\Users\Administrator\PycharmProjects\project1\venv\lib\site-packages\kivy\uix\textinput.py", line 528, in __init__
super(TextInput, self).__init__(**kwargs)
File "C:\Users\Administrator\PycharmProjects\project1\venv\lib\site-packages\kivy\uix\behaviors\focus.py", line 367, in __init__
super(FocusBehavior, self).__init__(**kwargs)
File "C:\Users\Administrator\PycharmProjects\project1\venv\lib\site-packages\kivy\uix\widget.py", line 350, in __init__
super(Widget, self).__init__(**kwargs)
File "kivy\_event.pyx", line 245, in kivy._event.EventDispatcher.__init__
TypeError: object.__init__() takes exactly one argument (the instance to initialize)
Process finished with exit code 1