我需要在wx.lib.calendar中选择一个月,而不是个别日子。 有没有办法在wxPython 3.0中做到这一点?
对于日期选择我会使用:
dlg = wx.lib.calendar.CalenDlg(self)
是否有对话框让我点击几个月而不是几天?
答案 0 :(得分:2)
你总是可以写自己的:
像这样的东西?
#!/usr/bin/env python
import wx
class MonthDialog(wx.Dialog):
def __init__(self, parent,title):
wx.Dialog.__init__(self, parent, id=-1, title=title)
self.panel = wx.Panel(self,size=(100,100))
Months = ['January','February','March','April','May','June','July','August','September','October','November','December']
self.month = ""
sizer = wx.BoxSizer(wx.HORIZONTAL)
self.Pick = wx.ComboBox(self.panel, wx.ID_ANY, choices=Months)
sizer.Add(self.Pick,0,wx.EXPAND)
self.Bind(wx.EVT_COMBOBOX, self.OnPick)
self.SetSizerAndFit(sizer)
self.Pick.SetValue(Months[0])
def OnPick(self,event):
self.EndModal(1)
self.month = self.Pick.GetValue()
if __name__ == "__main__":
app = wx.App()
dlg = MonthDialog(None, "Month")
val = dlg.ShowModal()
print "Dialog result: " + str(val)
print "Month Selected: " + str(dlg.month)