How do you make button which open calendar then selects date and closes it? So far I managed just create calendars (I don't get why it always creates 2). But I couldn't figure out how to get selected date. I'm using pythonwx on Python 3.
class MyCalendar(wx.Frame):
def __init__(self, *args, **kargs):
wx.Frame.__init__(self, *args, **kargs)
self.cal = CalendarCtrl(self, 10, wx.DateTime.Now())
self.timer = wx.Timer(self)
if __name__ == '__main__':
app = wx.App()
frame = MyCalendar(None)
frame.Show()
app.MainLoop()
EDIT
adding py3 version
from wx.adv import CalendarCtrl, GenericCalendarCtrl, CalendarDateAttr
class MyCalendar(wx.Frame):
def __init__(self, *args, **kargs):
wx.Frame.__init__(self, *args, **kargs)
self.cal = CalendarCtrl(self, 10, wx.DateTime.Now())
self.cal.Bind(wx.adv.EVT_CALENDAR, self.OnDate)
def OnDate(self,event):
print (self.cal.GetDate())
wx.Window.Close(self)
import wx
import wx.adv
class MyCalendar(wx.Frame):
def __init__(self, *args, **kargs):
wx.Frame.__init__(self, *args, **kargs)
self.cal = wx.adv.CalendarCtrl(self, 10, wx.DateTime.Now())
self.cal.Bind(wx.adv.EVT_CALENDAR, self.OnDate)
def OnDate(self,event):
print(self.cal.GetDate())
if __name__ == '__main__':
app = wx.App()
frame = MyCalendar(None)
frame.Show()
app.MainLoop()
Now double click on a date.
I'll leave you to research creating a frame/panel and putting a button on it, to activate the calendar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With