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))

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值