Python Forum
Is there a datepicker which can be used in combination with the python library urwid?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there a datepicker which can be used in combination with the python library urwid?
#1
Hello,
the module 'npyscreen' has two widgets to pick dates ('DateCombo' and 'TitleDateCombo').

I was told that the python library 'urwid' does not have a date picker, which is due to the complexity.
Unfortunately I could not find such a third-party library.

Although there are projects like 'khal', these are mostly designed as stand-alone applications and not as 'urwid' widgets.

Does anyone know such a project?
If there is no such thing, with which approaches can this lack be compensated?


'urwid.Edit' (basically a text field) has the problem that invalid data can be entered. Although a conversion to 'datetime.date' and exception handling does the trick, this is very clunky.

Here is the 'npyscreen' date picker and the associated source code:

[Image: hpkhL.png]

#! /usr/bin/env python3
# -*- coding: utf-8 -*-

import npyscreen

class DateForm(npyscreen.Form):
    def afterEditing(self):
        self.parentApp.setNextForm(None)

    def create(self):
        self.date = self.add(npyscreen.TitleDateCombo, name="Date")

class TestApplication(npyscreen.NPSAppManaged):
    def onStart(self):
        new_user = self.addForm("MAIN", DateForm, name="Read Date")

if __name__ == "__main__":
    TestApplication().run()
This question has also been posted on stackoverflow.

Best regards

AFoeee
Reply
#2
Let me see if I understand the question...

1) You're using urwid for something, which is a console library that emulates windows, sort of like curses.

2) You want a datepicker, that works with urwid, since you're using urwid.

3) I don't know what npyscreen/khal contribute to the question, since they're unrelated to urwid. Unless they're not unrelated to urwid? Was this info provided just so we had a screenshot of what you wish the hypothetical urwid widget looked like?
Reply
#3
(Sep-21-2018, 08:20 PM)AFoeee Wrote: If there is no such thing, with which approaches can this lack be compensated?
make one yourself for urwid. Once i needed a date picker for Tkinter and there isnt a default one for that. So i was going to make it, but i found one i modified online. See if you can find one that is completed or somewhat completed to modify to have base work already laid out. Then if you do finish it, i would push that to their repo. Im sure they would be happy to merge it.

Im not sure how advanced that is compared to curses. But it seems they have at least a list box at bare minimum. Ideally you would select from the text itself. You can always utilize the calendar module and then select from it.

>>> import calendar as cal
>>> c = cal.TextCalendar(cal.SUNDAY)
>>> s = c.formatmonth(2018,9)
>>> print(s)
   September 2018
Su Mo Tu We Th Fr Sa
                   1
 2  3  4  5  6  7  8
 9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30

>>>
Recommended Tutorials:
Reply
#4
Quote:Once i (I) needed a date picker for Tkinter and there isnt a default one for that

Thinking that there has to be at least one third party available, activestate was my first stop. There is this program http://code.activestate.com/recipes/5807...atepicker/ No point in reinventing when you can just modify existing code.
Reply
#5
Hello,

(Sep-21-2018, 08:50 PM)nilamo Wrote: 3) I don't know what npyscreen/khal contribute to the question, since they're unrelated to urwid. Unless they're not unrelated to urwid? Was this info provided just so we had a screenshot of what you wish the hypothetical urwid widget looked like?

I think I've read somewhere that 'khal' uses 'urwid' (could be wrong). That's why I mentioned it.
The screenshot was included because I'm looking for something visual and thought an image of it would be helpful.

Sorry, I should have made that clearer.

(Sep-21-2018, 09:29 PM)metulburr Wrote: make one yourself for urwid.

I believe that such a project is going to get quite complex and I do not know if I can handle that.
The project would probably also suffer for a long time from teething troubles , that matured projects have already overcome.

(Sep-21-2018, 10:28 PM)woooee Wrote: There is this program http://code.activestate.com/recipes/5807...atepicker/ No point in reinventing when you can just modify existing code.

Thank you, I will evaluate the code and see what I can reuse, in the case that there is no existing date picker project.

Best regards

AFoeee
Reply
#6
Hello,

since it seems that the python library urwid does not include a date picker, I wrote one.

It can be installed via pip.

For more information see above linked github wiki entry and the original question on stackoverflow.

Best regards
AFoeee
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Group List Elements according to the Input with the order of binary combination quest_ 19 6,235 Jan-28-2021, 03:36 AM
Last Post: bowlofred
  Checking if the combination of two keys is in a dictionary? mrsenorchuck 6 3,774 Dec-04-2019, 10:35 AM
Last Post: mrsenorchuck
  how to get all the possible permutation and combination of a sentence in python sodmzs 1 4,121 Jun-13-2019, 07:02 AM
Last Post: perfringo
  while + if + elif + else combination ClassicalSoul 1 2,173 Mar-27-2019, 03:54 PM
Last Post: ichabod801
  A combination of Python and MySql xgrzeniu 2 3,926 Mar-28-2018, 06:50 AM
Last Post: xgrzeniu
  PyInstaller, how to create library folder instead of library.zip file ? harun2525 2 4,740 May-06-2017, 11:29 AM
Last Post: harun2525

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020