Untitled conversation
- User
[WARNING] [Config ] Older configuration version detected (0 instead of 27) [WARNING] [Config ] Upgrading configuration in progress. [DEBUG ] [Config ] Upgrading from 0 to 1 [INFO ] [Logger ] Record log in C:\Users\L14.kivy\logs\kivy_24-04-21_0.txt [INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.3.3 [INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.3.1 [INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.6.0 [INFO ] [Kivy ] v2.2.1 [INFO ] [Kivy ] Installed at "C:\Users\L14\AppData\Local\Programs\Python\Python310\lib\site-packages\kivy_init_.py" [INFO ] [Python ] v3.10.9 (tags/v3.10.9:1dd9be6, Dec 6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)] [INFO ] [Python ] Interpreter at "C:\Users\L14\AppData\Local\Programs\Python\Python310\python.exe" [INFO ] [Logger ] Purge log fired. Processing... [INFO ] [Logger ] Purge finished! [INFO ] [Factory ] 190 symbols loaded [INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored) [INFO ] [Window ] Provider: sdl2 [INFO ] [GL ] Using the "OpenGL" graphics system [INFO ] [GL ] GLEW initialization succeeded [INFO ] [GL ] Backend used [INFO ] [GL ] OpenGL version <b'4.6.0 Compatibility Profile Context 23.11.1.231017'> [INFO ] [GL ] OpenGL vendor <b'ATI Technologies Inc.'> [INFO ] [GL ] OpenGL renderer <b'AMD Radeon (TM) Graphics'> [INFO ] [GL ] OpenGL parsed version: 4, 6 [INFO ] [GL ] Shading version <b'4.60'> [INFO ] [GL ] Texture max size <16384> [INFO ] [GL ] Texture max units <32> [INFO ] [Window ] auto add sdl2 input provider [INFO ] [Window ] virtual keyboard not allowed, single mode, not docked [INFO ] [Text ] Provider: sdl2 [INFO ] [GL ] NPOT texture support is available [INFO ] [Base ] Start application main loop [INFO ] [Base ] Leaving application in progress... Traceback (most recent call last): File "kivy\properties.pyx", line 961, in kivy.properties.ObservableDict.getattr KeyError: 'input_height'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "c:\Users\L14\Documents\Projets\Healthy\Healthy_BMI.py", line 88, in HealthyBMIAppli().run() File "C:\Users\L14\AppData\Local\Programs\Python\Python310\lib\site-packages\kivy\app.py", line 956, in run runTouchApp() File "C:\Users\L14\AppData\Local\Programs\Python\Python310\lib\site-packages\kivy\base.py", line 574, in runTouchApp EventLoop.mainloop() File "C:\Users\L14\AppData\Local\Programs\Python\Python310\lib\site-packages\kivy\base.py", line 339, in mainloop self.idle() File "C:\Users\L14\AppData\Local\Programs\Python\Python310\lib\site-packages\kivy\base.py", line 383, in idle self.dispatch_input() File "C:\Users\L14\AppData\Local\Programs\Python\Python310\lib\site-packages\kivy\base.py", line 334, in dispatch_input post_dispatch_input(*pop(0)) File "C:\Users\L14\AppData\Local\Programs\Python\Python310\lib\site-packages\kivy\base.py", line 263, in post_dispatch_input listener.dispatch('on_motion', etype, me) File "kivy_event.pyx", line 731, in kivy..py", line 1691, in on_motion self.dispatch('on_touch_down', me) File "kivy_event.pyx", line 731, in kivy..py", line 1708, in on_touch_down if w.dispatch('on_touch_down', touch): File "kivy_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch File "C:\Users\L14\AppData\Local\Programs\Python\Python310\lib\site-packages\kivy\uix\screenmanager.py", line 1210, in on_touch_down return super(ScreenManager, self).on_touch_down(touch) File "C:\Users\L14\AppData\Local\Programs\Python\Python310\lib\site-packages\kivy\uix\widget.py", line 589, in on_touch_down if child.dispatch('on_touch_down', touch): File "kivy_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch File "C:\Users\L14\AppData\Local\Programs\Python\Python310\lib\site-packages\kivy\uix\relativelayout.py", line 306, in on_touch_down ret = super(RelativeLayout, self).on_touch_down(touch) File "C:\Users\L14\AppData\Local\Programs\Python\Python310\lib\site-packages\kivy\uix\widget.py", line 589, in on_touch_down if child.dispatch('on_touch_down', touch): File "kivy_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch File "C:\Users\L14\AppData\Local\Programs\Python\Python310\lib\site-packages\kivy\uix\widget.py", line 589, in on_touch_down if child.dispatch('on_touch_down', touch): File "kivy_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch File "C:\Users\L14\AppData\Local\Programs\Python\Python310\lib\site-packages\kivy\uix\behaviors\button.py", line 151, in on_touch_down self.dispatch('on_press') File "kivy_event.pyx", line 727, in kivy._event.EventDispatcher.dispatch File "kivy_event.pyx", line 1307, in kivy._event.EventObservers.dispatch File "kivy_event.pyx", line 1231, in kivy._event.EventObservers._dispatch File "c:\Users\L14\Documents\Projets\Healthy\Healthy_BMI.py", line 56, in on_calculate_button_press height = float(self.ids.input_height.text) File "kivy\properties.pyx", line 964, in kivy.properties.ObservableDict. AttributeError: 'super' object has no attribute ''. Did you mean: ''?
- Assistant
The error you're encountering is related to accessing an attribute in your Kivy application that doesn't seem to exist. Specifically, the error is occurring when trying to access
input_heightfromself.ids. This issue may arise for a few reasons, such as: - User
- Assistant
from kivy.app import App from kivy.uix.textinput import TextInput from kivy.uix.boxlayout import BoxLayout from kivy.uix.label import Label from kivy.uix.button import Button from kivy.uix.popup import Popup from kivy.graphics import Color from kivy.uix.screenmanager import ScreenManager, Screen class LoginScreen(Screen): pass # Simplified for clarity class MainScreen(Screen): def __init__(self, **kwargs): super(MainScreen, self).__init__(**kwargs) layout = BoxLayout(orientation='vertical') self.add_widget(layout) label = Label(text='Enter your height and weight to calculate your BMI', font_size=20, color=[0.5, 0.8, 0.2, 1], halign='center', valign='middle') layout.add_widget(label) self.input_height = TextInput(id='input_height', multiline=False, hint_text='Height (in cm)') # Added id self.input_weight = TextInput(id='input_weight', multiline=False, hint_text='Weight (in kg)') # Added id calculate_button = Button(text='Calculate BMI', font_size=20) calculate_button.bind(on_press=self.on_calculate_button_press) layout.add_widget(self.input_height) layout.add_widget(self.input_weight) layout.add_widget(calculate_button) def on_calculate_button_press(self, instance): height = float(self.input_height.text) # Correctly accessing the TextInput weight = float(self.input_weight.text) # Correctly accessing the TextInput bmi = weight / (height / 100) ** 2 # Corrected the BMI formula popup = Popup(title='Your BMI', content=Label(text=f'Your BMI is {bmi:.2f}'), size_hint=(None, None), size=(400, 200)) popup.open() class HealthyBMIAppliApp(App): def build(self): sm = ScreenManager() sm.add_widget(LoginScreen(name='login')) sm.add_widget(MainScreen(name='main')) return sm if __name__ == '__main__': HealthyBMIAppliApp().run() # Corrected the App class name to match the defined class
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.