skip to Main Content
import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import Gridlayout
from kivy.uix.textinput import TextInput


class MyGrid(GridLayout):
    def __init__(self, **kwargs):
        super(MyGrid, self).__init__(**kwargs)
        self.cols = 2
        self.add_widget(Label(text="Name: "))
        self.name = TextInput(multiline=False)
        self.add_widget(self.name)
        



class MyApp(App):
    def build(self):
        return MyGrid()

if __name__ == "__main__":
    MyApp().run()

After running this I am getting the result this:

>>> 
= RESTART: C:UsersskkarDesktopadiPython FilesTelgram BotPythonApp for Telegram BotAdot Telegrm Bot App.py
[INFO   ] [Logger      ] Record log in C:Usersskkar.kivylogskivy_21-04-07_13.txt
[INFO   ] [deps        ] Successfully imported "kivy_deps.gstreamer" 0.3.2
[INFO   ] [deps        ] Successfully imported "kivy_deps.angle" 0.3.0
[INFO   ] [deps        ] Successfully imported "kivy_deps.glew" 0.3.0
[INFO   ] [deps        ] Successfully imported "kivy_deps.sdl2" 0.3.1
[INFO   ] [Kivy        ] v2.0.0
[INFO   ] [Kivy        ] Installed at "C:UsersskkarAppDataLocalProgramsPythonPython39libsite-packageskivy__init__.py"
[INFO   ] [Python      ] v3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)]
[INFO   ] [Python      ] Interpreter at "C:UsersskkarAppDataLocalProgramsPythonPython39pythonw.exe"
[INFO   ] [Factory     ] 186 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
 Traceback (most recent call last):
   File "C:UsersskkarDesktopadiPython FilesTelgram BotPythonApp for Telegram BotAdot Telegrm Bot App.py", line 4, in <module>`
     from kivy.uix.gridlayout import Gridlayout
 ImportError: cannot import name 'Gridlayout' from 'kivy.uix.gridlayout' (C:UsersskkarAppDataLocalProgramsPythonPython39libsite-packageskivyuixgridlayout.py)

Why am I getting this?
When ever I run it I get this only. And nothing else.

Please tell and help me with my code!

Regards
K1NG_C0D3R_AD0T

2

Answers


  1. You can see in the error message that it cannot import "Gridlayout" because the actual name is "GridLayout". I think this will fix your issue.

    Use this:

    from kivy.uix.gridlayout import GridLayout
    
    Login or Signup to reply.
  2. Use GridLayout, with a capital L

    from kivy.uix.gridlayout import GridLayout
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search