wxpython 用calendarctrl制作日历以及显示当前日期在statictext上

calendar的日期显示


    def beginEvent(self,event):
        dlgb = wx.Dialog(None, id = -1 ,title='Calendar',size=(300,200))
        self.datepick = wx.adv.CalendarCtrl(self.pnl,-1,pos=(600,100)) 
        self.datepick.Bind(wx.adv.EVT_CALENDAR, self.OnActionb) 

    def OnActionb(self,event):
        inp_date = self.datepick.GetDate() 
        beginyear = inp_date.GetYear()
        beginmonth = inp_date.GetMonth()+1
        beginday = inp_date.GetDay()
                
        font = wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.BOLD, True) 
        
        self.dateby = wx.StaticText(self.pnl,-1,pos = (150, 40))
        self.dateby.SetFont(font)
        self.dateby.SetLabel(str(beginyear))
        self.dateby.SetForegroundColour((255,0,255))
        self.dateby.SetBackgroundColour((0,0,0))
        self.datebm = wx.StaticText(self.pnl,-1,pos = (250, 40))
        self.datebm.SetFont(font)
        self.datebm.SetLabel(str(beginmonth))
        self.datebm.SetForegroundColour((255,0,255))
        self.datebm.SetBackgroundColour((0,0,0))
        self.datebd = wx.StaticText(self.pnl,-1,pos = (330, 40))
        self.datebd.SetFont(font)
        self.datebd.SetLabel(str(beginday))
        self.datebd.SetForegroundColour((255,0,255))
        self.datebd.SetBackgroundColour((0,0,0))

猜你喜欢

转载自blog.csdn.net/u010847579/article/details/85322872