[KivyCalendar] Calendar & DatePicker widgets

7,074 views
Skip to first unread message

Oleg Kozlov

unread,
Mar 6, 2015, 4:49:07 AM3/6/15
to kivy-...@googlegroups.com
Hello.

I work under small project on Kivy. App users need to be able to select date (day.month.year like 06.03.2015) from user-friendly widgets like DatePickerCtrl and CalendarCtrl from wxPython.
I designed two new Kivy widgets for my goals: CalendarWidget (like CalendarCtrl from wxPython) and DatePicker (like DateOickerCtrl from wxPython) and placed them to external python-module named KivyCalendar.

May be that will be useful for someone else.

Source code available on bitbucket.org (mit license).
Module can be installed via pypi
pip install KivyCalendar

Use as any other kivy widget (just import module first)

from kivy.app import App
from KivyCalendar import CalendarWidget

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

MyApp().run()



from kivy.app import App
from KivyCalendar import DatePicker

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

MyApp().run()

Tested only with Python 2.7.9 and Kivy 1.8.0 on Mageia 4 i586 (GNU/Linux, 32-bit).

CalendarWidget use translated with system locale (lang) days abbreviations. My system locale is ru_RU.UTF-8 and I don't tested with other langs.
[xxblx@localhost ~]$ echo $LANG
ru_RU
.UTF-8


If you found a bug, module segfaults with your lang or here some other issues, feel free to contact with me.
Also if it prefer for you can use bug-tracker.

Feedbacks are welcome.
Thanks.

Mathieu Virbel

unread,
Mar 6, 2015, 4:54:07 AM3/6/15
to kivy-...@googlegroups.com
Hi,

We tend to ask user avoiding naming their project KivyXXX, to prevent confusion. (As lot of users think because it's named kivy, it's our responbility to maintain it, or we did it.)

The Garden has been created specifically for that, and we're working on a beautiful widget listing on the website based on the current garden list. Check all the current widget available: https://github.com/kivy-garden/
Garden is managed and for the community, and we provide a tool to manage the dependencies in your app and system as well.

More informations at: http://kivy-garden.github.io/

About your widget... it's beautiful! Bravo :)

Federico Curzel

unread,
Mar 6, 2015, 7:12:21 AM3/6/15
to kivy-...@googlegroups.com
Nice!

--
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.
For more options, visit https://groups.google.com/d/optout.

Oleg Kozlov

unread,
Mar 6, 2015, 8:47:40 AM3/6/15
to kivy-...@googlegroups.com


пятница, 6 марта 2015 г., 12:54:07 UTC+3 пользователь Mathieu Virbel написал:
Hi,

We tend to ask user avoiding naming their project KivyXXX, to prevent confusion. (As lot of users think because it's named kivy, it's our responbility to maintain it, or we did it.)

The Garden has been created specifically for that, and we're working on a beautiful widget listing on the website based on the current garden list. Check all the current widget available: https://github.com/kivy-garden/
Garden is managed and for the community, and we provide a tool to manage the dependencies in your app and system as well.

More informations at: http://kivy-garden.github.io/

About your widget... it's beautiful! Bravo :)

 Sorry about module name. How it better to do now rename module or left as is (module already uploaded to pypi)?

Oleg Kozlov

unread,
Mar 7, 2015, 4:28:52 PM3/7/15
to kivy-...@googlegroups.com
Update to 0.1.1 uploaded to pypi.
Fixed: added error processing - if impossible to use system language for days abbrs and months names translation will be used english abbrs & names.

Dragos Nicu

unread,
Oct 16, 2015, 2:12:01 PM10/16/15
to Kivy users support
Hi guys.

This is probably a total noob question... but I can't figure it out how to use this widget.

Here is an example of my code:

from kivy.app import App from kivy.uix.boxlayout import BoxLayout from kivy.uix.textinput import TextInput from kivy.uix.popup import Popup from KivyCalendar import CalendarWidget from KivyCalendar import DatePicker

class SetIndex(BoxLayout):
def setDate(self, *args):
popup = Popup(title='Insert Old Date', content=CalendarWidget(), size_hint=(.9, .5)).open()

class MainApp(App):
def bulid(self):
return SetIndex()
if __name__ == '__main__':
    MainApp().run()


and the .kv file:

BoxLayout:
    orientation: "vertical"
  size_hint: 1, .4
   
  TextInput:
      id: old_date
      hint_text: "Old Date"
      on_focus: root.setDate()

Any hint on how to make this work?

Thank you!

Oleg Kozlov

unread,
Oct 17, 2015, 8:32:15 PM10/17/15
to kivy-...@googlegroups.com
Hello.

First of all, look at MainApp methods. You wrote "bulid", fix to "build" :)

What probably you trying to do?

If you want just to open CalendarWidget at app start. That easier to return directly calendar widget.

from kivy.app import App
from KivyCalendar import CalendarWidget

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

MyApp().run()


Fix for yours code look like
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.textinput import TextInput
from kivy.uix.popup import Popup
from KivyCalendar import CalendarWidget
from KivyCalendar import DatePicker

class SetIndex(BoxLayout):
   
    def __init__(self):
        super(SetIndex, self).__init__()
       
        self.init_ui()
       
    def init_ui(self):   
       
        self.cal = CalendarWidget(as_popup=True)
        self.popup = Popup(title='Insert Old Date', content=self.cal,
                           size_hint=(.9, .5))
        self.popup.open()

class MainApp(App):
    def build(self):

        return SetIndex()

if __name__ == '__main__':
    MainApp().run()

--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/Z_Vn9HyZm3c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.

John Boyd

unread,
Oct 18, 2015, 11:51:14 AM10/18/15
to Kivy users support
Very nice ! 

I know that I will be using these widgets.

Thanks.

Dragos Nicu

unread,
Oct 18, 2015, 1:08:28 PM10/18/15
to Kivy users support
Hi,

Thank you for your response!

The thing is that when I select the date, the text input field is not updated with the selected date. It just shows the hint_text. I don't know how to update the text field after I select the date.


And thank you for spotting the typo! :D

ngoone...@gmail.com

unread,
Oct 23, 2015, 12:08:44 AM10/23/15
to Kivy users support
This looks great, but when I try to use it in python3 it crashes on import with this error:-

ImportError: No module named 'calendar_ui'

Not sure if you can figure it out.

Pierre Boulanger

unread,
Jan 6, 2016, 5:25:26 AM1/6/16
to Kivy users support
Hi
I test your module but if i compile with buildozer with android, have no error and a apk.
But on my phone he's dont work...
My main 
#! usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
#-------------------------------------------------------------------------
# Name:        module1
# Purpose:
#
# Author:      Pierre
#
# Created:     30-08-2014
# Copyright:   (c) Pierre 2014
# Licence:     <your licence>
#-------------------------------------------------------------------------
from kivy.config import Config
from kivy.core.window import Window
from kivy.utils import platform
import datetime

Window.softinput_mode= 'scale'

Config.set('graphics', 'width', '600')
Config.set('graphics', 'height', '800')
Config.write()


from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.widget import Widget
from KivyCalendar import DatePicker




class Home(Screen):
    def Picker(self):
self.laDate = self.datepicker.text
self.datepicked = datetime.datetime.strptime(self.laDate, '%d.%m.%Y').strftime('%d/%m/%Y')
self.myLabel.text = str(self.datepicked)

class MyApp(App):

def build(self):
sm = ScreenManager()
sm.add_widget(Home(name='home'))
return sm

My KV
#:kivy 1.0

<home>:
myLabel: myLabel_id
datepicker: datepicker_id
BoxLayout:
orientation: 'vertical'
DatePicker:
id: datepicker_id
pHint: 0.7,0.4
size_hint: 0.4, 0.3
text_size: self.size
halign: 'center'
valign: 'middle'
Label:
id: myLabel_id
Button:
text: 'Update'
on_press: root.Picker()


And my buildozer.spec
[app]

# (str) Title of your application
title = MyApp

# (str) Package name
package.name = myapp

# (str) Package domain (needed for android/ios packaging)
package.domain = org.test

# (str) Source code where the main.py live
source.dir = .

# (list) Source files to include (let empty to include all the files)
#source.include_exts = py,png,jpg,kv,atlas

# (list) Source files to exclude (let empty to not exclude anything)
source.exclude_exts = spec

# (list) List of directory to exclude (let empty to not exclude anything)
source.exclude_dirs = tests, bin

# (list) List of exclusions using pattern matching
#source.exclude_patterns = license,images/*/*.jpg

# (str) Application versioning (method 1)
version = Beta-0.1

# (str) Application versioning (method 2)
# version.regex = __version__ = ['"](.*)['"]
# version.filename = %(source.dir)s/main.py

# (list) Application requirements
# comma seperated e.g. requirements = sqlite3,kivy
requirements = kivy

# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes
# requirements.source.kivy = ../../kivy

# (list) Garden requirements
#garden_requirements =

# (str) Presplash of the applicationru
#presplash.filename = %(source.dir)s/img/logo.png

# (str) Icon of the application
#icon.filename = %(source.dir)s/img/icon.png

# (str) Supported orientation (one of landscape, portrait or all)
orientation = portrait

# (bool) Indicate if the application should be fullscreen or not
fullscreen = 1


#
# Android specific
#

# (list) Permissions
#android.permissions = INTERNET

# (int) Android API to use
#android.api = 19

# (int) Minimum API required
#android.minapi = 9

# (int) Android SDK version to use
#android.sdk = 20

# (str) Android NDK version to use
#android.ndk = 9c

# (bool) Use --private data storage (True) or --dir public storage (False)
#android.private_storage = True

# (str) Android NDK directory (if empty, it will be automatically downloaded.)
#android.ndk_path =

# (str) Android SDK directory (if empty, it will be automatically downloaded.)
#android.sdk_path =

# (str) ANT directory (if empty, it will be automatically downloaded.)
#android.ant_path =

# (str) python-for-android git clone directory (if empty, it will be automatically cloned from github)
#android.p4a_dir =

# (list) python-for-android whitelist
#android.p4a_whitelist =

# (str) Android entry point, default is ok for Kivy-based app
#android.entrypoint = org.renpy.android.PythonActivity

# (list) List of Java .jar files to add to the libs so that pyjnius can access
# their classes. Don't add jars that you do not need, since extra jars can slow
# down the build process. Allows wildcards matching, for example:
# OUYA-ODK/libs/*.jar
#android.add_jars = foo.jar,bar.jar,path/to/more/*.jar

# (list) List of Java files to add to the android project (can be java or a
# directory containing the files)
#android.add_src =

# (str) python-for-android branch to use, if not master, useful to try
# not yet merged features.
#android.branch = master

# (str) OUYA Console category. Should be one of GAME or APP
# If you leave this blank, OUYA support will not be enabled
#android.ouya.category = GAME

# (str) Filename of OUYA Console icon. It must be a 732x412 png image.
#android.ouya.icon.filename = %(source.dir)s/data/ouya_icon.png

# (str) XML file to include as an intent filters in <activity> tag
#android.manifest.intent_filters =

# (list) Android additionnal libraries to copy into libs/armeabi
#android.add_libs_armeabi = libs/android/*.so
#android.add_libs_armeabi_v7a = libs/android-v7/*.so
#android.add_libs_x86 = libs/android-x86/*.so
#android.add_libs_mips = libs/android-mips/*.so

# (bool) Indicate whether the screen should stay on
# Don't forget to add the WAKE_LOCK permission if you set this to True
#android.wakelock = False

# (list) Android application meta-data to set (key=value format)
#android.meta_data =

# (list) Android library project to add (will be added in the
# project.properties automatically.)
#android.library_references =

#
# iOS specific
#

# (str) Name of the certificate to use for signing the debug version
# Get a list of available identities: buildozer ios list_identities
#ios.codesign.debug = "iPhone Developer: <lastname> <firstname> (<hexstring>)"

# (str) Name of the certificate to use for signing the release version
#ios.codesign.release = %(ios.codesign.debug)s


[buildozer]

# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output))
log_level = 2

# (int) Display warning if buildozer is run as root (0 = False, 1 = True)
warn_on_root = 1


#    -----------------------------------------------------------------------------
#    List as sections
#
#    You can define all the "list" as [section:key].
#    Each line will be considered as a option to the list.
#    Let's take [app] / source.exclude_patterns.
#    Instead of doing:
#
#[app]
#source.exclude_patterns = license,data/audio/*.wav,data/images/original/*
#
#    This can be translated into:
#
#[app:source.exclude_patterns]
#license
#data/audio/*.wav
#data/images/original/*
#


#    -----------------------------------------------------------------------------
#    Profiles
#
#    You can extend section / key with a profile
#    For example, you want to deploy a demo version of your application without
#    HD content. You could first change the title to add "(demo)" in the name
#    and extend the excluded directories to remove the HD content.
#
#[app@demo]
#title = My Application (demo)
#
#[app:source.exclude_patterns@demo]
#images/hd/*
#
#    Then, invoke the command line with the "demo" profile:
#
#buildozer --profile demo android debug




Le vendredi 6 mars 2015 10:49:07 UTC+1, Oleg Kozlov a écrit :
Message has been deleted

felix herbinet

unread,
Jul 25, 2019, 3:36:53 AM7/25/19
to Kivy users support
Sorry, for this late answer, to  solve that kind of issue I guess you'll just have to add `KivyCalendar` to your buildozer.spec requirements.
Furthermore when you're launching the app you can use `adb logcat` (So the full command with buildozer will be `buildozer android <debug> deploy run logcat`), and as an advice for this
kind of app you can enable Python's logcat filter in your buildozer.spec :)

felix herbinet

unread,
Jul 25, 2019, 3:45:17 AM7/25/19
to Kivy users support
Hello Oleg,
You've made a great job on this Widget !

I've made some small modifications/improvements on your Widget, and I'd like to know if it's possible to make a pull request on your repository.
I've never used  BitBucket before and I don't know why I cannot fork :/

Is anyone can fork ? Am I stupid  ;p ?

Thank you in advance for your answer :)
Reply all
Reply to author
Forward
0 new messages