Make uix widgets accessible with "from kivy.uix import Button..."
See original GitHub issueIt seems almost trivial, but would it be possible to make some of the more commonly used/base widgets accessible in the kivy/uix/__init__.py
module?
This would mean instead of needing to do the following:
from kivy.uix.button import Button
from kivy.uix.label import Label
...
from kivy.uix.scatter import Scatter
You only need to do the following:
from kivy.uix import Label, Button, ... , Scatter
The reason for this request is mainly to help tidy up the imports a little and means it isn’t necessary to write a 30 almost identical lines when wanting to import 30 different widgets.
As far as I can tell, you would just need to import the desired classes into the kivy/uix/__init__.py
module and adjust the __all__
variable like so:
# kivy/uix/__init__.py
from kivy.uix.button import Button
from kivy.uix.label import Label
...
from kivy.uix.scatter import Scatter
__all__ = ['Button', 'Label', ..., 'Scatter']
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Widgets — Kivy 2.1.0 documentation
A Widget is the base building block of GUI interfaces in Kivy. It provides a Canvas that can be used to draw on...
Read more >Kivy: Get widgets ids and accessing widgets by unique property
The id works like a python dict key id:Widget but only if ... from kivy.uix.label import Label from kivy.uix.button import Button kv ...
Read more >Python | Layouts in layouts (Multiple Layouts) in Kivy
Basic Approach to create multiple layouts in one file: 1) import ... from kivy.uix.button import Button ... It takes the available space and....
Read more >List - KivyMD 1.1.1 documentation
from kivy.lang import Builder from kivymd.app import MDApp from ... from kivy.uix.button import Button >>> root = Widget() >>> button = Button() > ......
Read more >Kivy Menagerie. A reference collection of Kivy widgets…
from kivy.uix.button import Button from kivy.uix.slider import Sliderclass manyWidgetsApp(App): def build(self): layout = GridLayout(cols=2)
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Worth mentioning that Factory provides easy import if you need it;
I’m referring to the reason not to have this type of import - if all the widgets are imported by
__init__.py
it imposes a minor perfomance penalty whenever you import any widget, since all of their files are loaded. This penalty would be quite small though, I don’t know if it’s important (though on Android these things can be relevant even if negligible on the desktop).