Module za_warudo.gui.widgets

Expand source code
from functools import partial
from tkinter import *
from tkinter import ttk
from ttkthemes import ThemedStyle
from tkcalendar import Calendar, DateEntry

class EntryDate(ttk.Entry):
    '''
    Entry for selecting a date
    '''

    def __init__(self, *args, **kwargs):
        if not "textvariable" in kwargs.keys(): raise ArgumentError("Must take textvariable")
        ttk.Entry.__init__(self, *args, **kwargs)
        self.bind('<FocusIn>', self.choose_date)
        self.textvariable = kwargs['textvariable']
        self.parent = args[0]

    def choose_date(self, event=None):
        '''
        A calendar appears out of nowhere
        Click on the OK button to make it
        disappear... out of nowhere
        '''

        top = Toplevel(self.parent)

        cal = Calendar(top,
                       selectmode='day',
                       cursor="hand1",
                       locale="fr_FR",
                       date_pattern="y-mm-dd")
        cal.pack()
        #cal.pack(fill="both", expand=True)
        ttk.Button(top, text="OK", command=partial(self.get_calendar_input, top, cal)).pack()

    def get_calendar_input(self, top, cal):
        self.textvariable.set(cal.selection_get())
        top.destroy()
        self.parent.focus()

class Spinbox(ttk.Entry):

    def __init__(self, master=None, **kw):

        ttk.Entry.__init__(self, master, 'ttk::spinbox', **kw)

Classes

class EntryDate (*args, **kwargs)

Entry for selecting a date

Constructs a Ttk Entry widget with the parent master.

STANDARD OPTIONS

class, cursor, style, takefocus, xscrollcommand

WIDGET-SPECIFIC OPTIONS

exportselection, invalidcommand, justify, show, state,
textvariable, validate, validatecommand, width

VALIDATION MODES

none, key, focus, focusin, focusout, all
Expand source code
class EntryDate(ttk.Entry):
    '''
    Entry for selecting a date
    '''

    def __init__(self, *args, **kwargs):
        if not "textvariable" in kwargs.keys(): raise ArgumentError("Must take textvariable")
        ttk.Entry.__init__(self, *args, **kwargs)
        self.bind('<FocusIn>', self.choose_date)
        self.textvariable = kwargs['textvariable']
        self.parent = args[0]

    def choose_date(self, event=None):
        '''
        A calendar appears out of nowhere
        Click on the OK button to make it
        disappear... out of nowhere
        '''

        top = Toplevel(self.parent)

        cal = Calendar(top,
                       selectmode='day',
                       cursor="hand1",
                       locale="fr_FR",
                       date_pattern="y-mm-dd")
        cal.pack()
        #cal.pack(fill="both", expand=True)
        ttk.Button(top, text="OK", command=partial(self.get_calendar_input, top, cal)).pack()

    def get_calendar_input(self, top, cal):
        self.textvariable.set(cal.selection_get())
        top.destroy()
        self.parent.focus()

Ancestors

  • tkinter.ttk.Entry
  • tkinter.ttk.Widget
  • tkinter.Entry
  • tkinter.Widget
  • tkinter.BaseWidget
  • tkinter.Misc
  • tkinter.Pack
  • tkinter.Place
  • tkinter.Grid
  • tkinter.XView

Methods

def choose_date(self, event=None)

A calendar appears out of nowhere Click on the OK button to make it disappear… out of nowhere

Expand source code
def choose_date(self, event=None):
    '''
    A calendar appears out of nowhere
    Click on the OK button to make it
    disappear... out of nowhere
    '''

    top = Toplevel(self.parent)

    cal = Calendar(top,
                   selectmode='day',
                   cursor="hand1",
                   locale="fr_FR",
                   date_pattern="y-mm-dd")
    cal.pack()
    #cal.pack(fill="both", expand=True)
    ttk.Button(top, text="OK", command=partial(self.get_calendar_input, top, cal)).pack()
def get_calendar_input(self, top, cal)
Expand source code
def get_calendar_input(self, top, cal):
    self.textvariable.set(cal.selection_get())
    top.destroy()
    self.parent.focus()
class Spinbox (master=None, **kw)

Ttk Entry widget displays a one-line text string and allows that string to be edited by the user.

Constructs a Ttk Entry widget with the parent master.

STANDARD OPTIONS

class, cursor, style, takefocus, xscrollcommand

WIDGET-SPECIFIC OPTIONS

exportselection, invalidcommand, justify, show, state,
textvariable, validate, validatecommand, width

VALIDATION MODES

none, key, focus, focusin, focusout, all
Expand source code
class Spinbox(ttk.Entry):

    def __init__(self, master=None, **kw):

        ttk.Entry.__init__(self, master, 'ttk::spinbox', **kw)

Ancestors

  • tkinter.ttk.Entry
  • tkinter.ttk.Widget
  • tkinter.Entry
  • tkinter.Widget
  • tkinter.BaseWidget
  • tkinter.Misc
  • tkinter.Pack
  • tkinter.Place
  • tkinter.Grid
  • tkinter.XView