インストールしといてね
pip install -U wxPython
サンプルコード
import wx import wx.adv class MyDialog(wx.Dialog): def __init__(self, parent): super().__init__(parent, title="設定ダイアログ") panel = wx.Panel(self) self.start_date = wx.TextCtrl(panel) start_button = wx.Button(panel, label="カレンダー") start_button.Bind(wx.EVT_BUTTON, self.on_start_calendar_clicked) sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.start_date, 0, wx.ALL, 5) sizer.Add(start_button, 0, wx.ALL, 5) panel.SetSizer(sizer) sizer.Fit(self) def on_start_calendar_clicked(self, event): dlg = wx.Dialog(self, title="カレンダーダイアログ") cal_ctrl = wx.adv.CalendarCtrl(dlg) ok_button = wx.Button(dlg, wx.ID_OK) cancel_button = wx.Button(dlg, wx.ID_CANCEL) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(cal_ctrl, 0, wx.ALL, 5) sizer.Add(ok_button, 0, wx.ALL, 5) sizer.Add(cancel_button, 0, wx.ALL, 5) dlg.SetSizerAndFit(sizer) if dlg.ShowModal() == wx.ID_OK: date = cal_ctrl.GetDate() self.start_date.SetValue(date.Format("%Y-%m-%d")) dlg.Destroy() # アプリケーションの起動 app = wx.App() dialog = MyDialog(None) dialog.ShowModal() app.MainLoop()