Datepickerctrlgeneric

@Chris_Keo
I’ll probably be accused of blowing my own trumpet here, but you could give my minidatepicker a whirl, with the caveat, that I don’t think it has been tested on Windows.
You can find the latest version using this link:

Here I stole the code from @RichardT (sorry Richard) and replaced the date widget.
On Linux it behaves itself. :slight_smile:

import wx
#import wx.adv
import minidatepicker as MDP

class MyFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.SetSize((400, 200))
        self.SetTitle("MiniDatePicker")
        self.main_panel = wx.Panel(self, wx.ID_ANY)
        main_sizer = wx.BoxSizer(wx.VERTICAL)
        format = (lambda dt: (f'{dt.Format("%A %d-%m-%Y")}'))
        #self.datepicker_ctrl = wx.adv.DatePickerCtrlGeneric(self.main_panel, wx.ID_ANY)
        self.datepicker_ctrl = MDP.MiniDatePicker(self.main_panel, -1, formatter=format)

        main_sizer.Add(self.datepicker_ctrl, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.TOP, 16)
        self.text_ctrl = wx.TextCtrl(self.main_panel, wx.ID_ANY, "")
        main_sizer.Add(self.text_ctrl, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.TOP, 16)
        bottom_sizer = wx.BoxSizer(wx.HORIZONTAL)
        main_sizer.Add(bottom_sizer, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.BOTTOM | wx.TOP, 16)
        self.button_1 = wx.Button(self.main_panel, wx.ID_ANY, "button_1")
        bottom_sizer.Add(self.button_1, 0, wx.RIGHT, 32)
        self.button_2 = wx.Button(self.main_panel, wx.ID_ANY, "button_2")
        bottom_sizer.Add(self.button_2, 0, 0, 0)
        self.main_panel.SetSizer(main_sizer)
        self.Layout()
        #self.Bind(wx.adv.EVT_DATE_CHANGED, self.OnDateChanged, self.datepicker_ctrl)
        self.Bind(MDP.EVT_DATE_CHANGED, self.OnDateChanged, self.datepicker_ctrl)

    def OnDateChanged(self, event):
        print(event.GetDate())


class MyApp(wx.App):
    def OnInit(self):
        self.frame = MyFrame(None, wx.ID_ANY, "")
        self.SetTopWindow(self.frame)
        self.frame.Show()
        return True


if __name__ == "__main__":
    app = MyApp(0)
    app.MainLoop()

1 Like