RhetTbull / guitk

Python GUI Toolkit for Tk (guitk): simplify the layout and construction of tkinter graphical user interfaces in python using a declarative syntax.
MIT License
18 stars 1 forks source link

Add Generic element #9

Closed RhetTbull closed 1 year ago

RhetTbull commented 3 years ago

class Generic(Element) would allow wrapping of any Tk compatible widget.

class Generic(Element):
    def __init__(self, element, *args, **kwargs):
        pass

    def create_element(self):
         self.element = element(parent, *args, **kwargs)

For example:


from tkcalendar import Calendar
import guitk
import datetime

class TestCalendar(Window):
    today = datetime.date.today()
    mindate = datetime.date(year=2018, month=1, day=21)
    maxdate = today + datetime.timedelta(days=5)

    layout = [[ttk.Generic(Calendar,  font="Arial 14", selectmode='day', locale='en_US',
                   mindate=mindate, maxdate=maxdate, disabledforeground='red',
                   cursor="hand1", year=2018, month=2, day=5)]]
RhetTbull commented 1 year ago

Could Widget() be used for this?

RhetTbull commented 1 year ago

Implemented with Widget()