co-mingle kivy and kivyMD widgets

105 views
Skip to first unread message

markR

unread,
Mar 8, 2022, 8:51:14 PM3/8/22
to Kivy users support
Just Confirming that since the main class has to inherit from either App if using kivy widgets or MDApp if using kivyMD widgets; there is no way to have an application with kivy widgets and try to add a kivyMD widget??
The background here is i have a application where everything was built with kivy widgets in python. I need a datepicker and thought i could import kivyMD and use MDDatePicker. I get the following error:
[python]
 App object must be inherited from `kivymd.app.MDApp`
[/python]

Any other good options for a datepicker that could be used with kivy?

Elliot Garbus

unread,
Mar 9, 2022, 11:19:08 AM3/9/22
to kivy-...@googlegroups.com

You can mix widgets.  Have you main app class inherit from MDApp instead of App.

The datepicker and time picker are still under development, if you are doing anything serious, test them thoroughly.  I have seen bugs in the time picker.

 

Here is date picker for kivy:

https://bitbucket.org/xxblx/kivycalendar/src/master/

 

I helped another user that was modifying this data picker for another calendar. 

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/d90e710f-b00d-4121-ab16-5fc00d1fb7a6n%40googlegroups.com.

 

markR

unread,
Mar 9, 2022, 8:24:10 PM3/9/22
to Kivy users support
Thank You.
I downloaded KivyCalendar into my environment and confirmed it dwells in the site-packages. I get the following error:
[python]
Exception has occurred: ModuleNotFoundError

No module named 'calendar_ui'
[/python]

I did research the KivyCalendar  fixes for python3 but did not really understand what they meant. Can you steer me in a direction to resolve? I do know calendar_ui.py exits in KivyCalendar/_pyCach_

Elliot Garbus

unread,
Mar 9, 2022, 9:09:13 PM3/9/22
to kivy-...@googlegroups.com

When I did the work with the other guy, I just downloaded the source files into my project directory.  I did not do a pip install.  If all else fails -do that.

 

Looking at the source directory, I found the examples below.  See if they work.

 

CalendarWidget example

from kivy.app import App

from KivyCalendar import CalendarWidget

class MyApp(App):

def build(self):

return CalendarWidget()

MyApp().run()

DatePicker example

from kivy.app import App

from KivyCalendar import DatePicker

class MyApp(App):

def build(self):

return DatePicker()

MyApp().run()

markR

unread,
Mar 9, 2022, 10:07:06 PM3/9/22
to Kivy users support
I tried running the examples as well with same error.
By source files do you mean the : _init_.py, calendar_data.py, and calendar_ui.py files? I am not sure I know how to ask the correct question here or how to get them to work once i get the correct file downloaded. Any general guidance appreciated.
Thank you

Elliot Garbus

unread,
Mar 9, 2022, 11:46:33 PM3/9/22
to kivy-...@googlegroups.com
Download the calendar_ui.py and the calendar_data.py files to your project directory. 

Import the widgets from calendar_ui, look at the source code. 

Sent from my iPhone

On Mar 9, 2022, at 8:07 PM, markR <markandla...@gmail.com> wrote:



markR

unread,
Mar 10, 2022, 8:17:06 PM3/10/22
to Kivy users support
Thank you.
Downloaded into project directory both files mentioned above.
Changed import statement "from KivyCalendar import DatePicker" to "from calendar_ui import DatePicker"-honestly I am guessing here but assume after it looks in the lib/
python/site-packages/,  it looks in the same directory?
The error has changed to:
[python]
Exception has occurred: ImportError

cannot import name 'TimeEncoding' from 'calendar' (/usr/lib/python3.8/calendar.py)
File "/home/mark/Python_Environments/env3/kmd/calendar_data.py", line 13, in <module> from calendar import TimeEncoding, month_name, day_abbr, Calendar, monthrange File "/home/mark/Python_Environments/env3/kmd/calendar_ui.py", line 24, in <module> import calendar_data as cal_data File "/home/mark/Python_Environments/env3/kmd/Bovine25.py", line 39, in <module> from calendar_ui import DatePicker
[/python]

This is coming from Calendar_data.py,
line 13- "from calendar import TimeEncoding, month_name, day_abbr, Calendar, monthrange". Seems like it is still looking in the library.
Thoughts?

Elliot Garbus

unread,
Mar 10, 2022, 9:45:29 PM3/10/22
to kivy-...@googlegroups.com

On line 24 of calander_ui.py replace:

from . import calendar_data as cal_data

with:

import calendar_data as cal_data

markR

unread,
Mar 11, 2022, 9:07:05 AM3/11/22
to Kivy users support
After above change I now get:
[python]
No module named 'calendar_data'
File "/home/mark/Python_Environments/env3/kmd/KivyCalendar/calendar_ui.py", line 24, in <module> import calendar_data as cal_data File "/home/mark/Python_Environments/env3/kmd/KivyCalendar/__init__.py", line 4, in <module> from KivyCalendar.calendar_ui import DatePicker, CalendarWidget File "/home/mark/Python_Environments/env3/kmd/Bovine25.py", line 38, in <module> from KivyCalendar.calendar_ui import DatePicker
[/python]

I removed KivyCalendar file  from site-packages folder where pip installed it after i copied KivyCalendar file to the environment directory i am working in.

What other areas would you look at?

Elliot Garbus

unread,
Mar 11, 2022, 9:41:21 AM3/11/22
to kivy-...@googlegroups.com

I downloaded the 2 calendar_*.py files.

I created a main.py

I made the edit to the import as described in caledar_ui.py, and It works.

I have attached the 3 files in a zip file.

caltest.zip

markR

unread,
Mar 11, 2022, 9:25:50 PM3/11/22
to Kivy users support
Thank you.
I loaded your three files in a directory and ran them fine.
The only difference is I noticed your  calendar_data.py included
"import locale as _locale" where mine did not. Would this have contributed to any of my issues?
Armed with these working files I will attempt to implement into my app.
I do appreciate the extra explanations to help me understand.

Elliot Garbus

unread,
Mar 11, 2022, 10:42:35 PM3/11/22
to kivy-...@googlegroups.com
If that line was missing it would cause a problem. I did not add or edit that line. 

Sent from my iPhone

On Mar 11, 2022, at 7:25 PM, markR <markandla...@gmail.com> wrote:



markR

unread,
Mar 12, 2022, 6:00:28 PM3/12/22
to Kivy users support
Incorporated into my App and works GREAT. Thanks.
Just replaced the TextInputs I was using for date entry with the imported DatePicker(textInput).
Modified code to show date as needed and display calendar only when left mouse click.

Elliot Garbus

unread,
Mar 12, 2022, 7:15:26 PM3/12/22
to kivy-...@googlegroups.com
Congratulations!

Sent from my iPhone

On Mar 12, 2022, at 4:00 PM, markR <markandla...@gmail.com> wrote:


Reply all
Reply to author
Forward
0 new messages