你如何使按鈕打開日曆,然後選擇日期並關閉它? 到目前爲止,我管理的只是創建日曆(我不明白爲什麼它總是創建2)。但我無法弄清楚如何獲得選定的日期。我使用的Python 3 pythonwx從python獲取選定日期wx.lib.calendar
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()
編輯
加入PY3版本
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)