Skip to content

Commit 189bb69

Browse files
Adding some basic documentation about setting the locale of the Calendar widget. See slightlynybbled#31
1 parent 0c6a50f commit 189bb69

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

examples/user_calendar.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import tkinter
22
import tk_tools
3+
import locale
4+
5+
# use this as a flag to change the language of the
6+
# calendar using the locale, as shown below
7+
show_in_german = False
38

49

510
def callback():
@@ -10,6 +15,10 @@ def callback():
1015

1116
root = tkinter.Tk()
1217
root.title('TK Tools Calendar')
18+
19+
if show_in_german:
20+
locale.setlocale(locale.LC_ALL, 'deu_deu')
21+
1322
calendar = tk_tools.Calendar(root)
1423
calendar.pack()
1524

tk_tools/groups.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,12 @@ def _get_calendar(locale, fwday):
600600

601601
class Calendar(ttk.Frame):
602602
"""
603-
Graphical date selection widget, with callbacks.
603+
Graphical date selection widget, with callbacks. To change
604+
the language, use the ``locale`` library with the appropriate
605+
settings for the target language. For instance, to display
606+
the ``Calendar`` widget in German, you might use::
607+
608+
locale.setlocale(locale.LC_ALL, 'deu_deu')
604609
605610
:param parent: the parent frame
606611
:param callback: the callable to be executed on selection

tk_tools/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.9.5'
1+
__version__ = '0.9.6'

0 commit comments

Comments
 (0)