PlanHelper.docx
《PlanHelper.docx》由会员分享,可在线阅读,更多相关《PlanHelper.docx(55页珍藏版)》请在冰豆网上搜索。
![PlanHelper.docx](https://file1.bdocx.com/fileroot1/2023-7/15/7e34e586-6d35-4e17-9278-4f2ab6007b52/7e34e586-6d35-4e17-9278-4f2ab6007b521.gif)
PlanHelper
importwx
importos,sys
importrandom,time
importthreading
#单利
classSingleton(object):
def__new__(cls,*args,**kwargs):
ifnothasattr(cls,'_instance'):
orig=super(UserPanel,cls)
cls.__instance=orig.__new__(cls,*args,**kwargs)
returncls.__instance
#首页内部面板
classUserPanel(wx.Panel,Singleton):
def__init__(self,parent,act):
super(UserPanel,self).__init__(parent,pos=(0,0),size=(575,490),
style=wx.BORDER_SUNKEN|wx.CLIP_CHILDREN)
#显示所计划#
classPanel0(UserPanel,Singleton):
def__init__(self,parent,act):
super(Panel0,self).__init__(parent,act)
self.act=act
lblTitleFont=wx.Font(25,wx.DEFAULT,wx.NORMAL,wx.NORMAL,False)
lblFont=wx.Font(17,wx.DEFAULT,wx.NORMAL,wx.NORMAL,False)
lblTitle=wx.StaticText(self,-1,"显示所有计划",(180,30))
lblTitle.SetFont(lblTitleFont)
btnShow=wx.Button(self,-1,"刷新",(420,30))
btnShow.SetFont(lblFont)
lblPlan=wx.StaticText(self,-1,"计划",(255,80))
lblPlan.SetFont(lblFont)
self.txtPlan=wx.TextCtrl(self,-1,"",(1,110),(570,150),wx.TE_MULTILINE|wx.TE_READONLY)
lblHabit=wx.StaticText(self,-1,"习惯",(255,270))
lblHabit.SetFont(lblFont)
self.txtHabit=wx.TextCtrl(self,-1,"",(1,300),(570,150),wx.TE_MULTILINE|wx.TE_READONLY)
self.Bind(wx.EVT_BUTTON,self.BtnClick,btnShow)
defBtnClick(self,e):
self.txtPlan.SetValue("")
self.txtHabit.SetValue("")
planCount=0
habitCount=0
try:
path="C:
\\PlanHelper\\"+self.act+"\\"#获取路径
except:
pass
#显示计划
try:
PlanRead=open(path+"plan\\execute.txt",'r',encoding="utf-8")#读取计划
planLines=PlanRead.readlines()#读取
forlineinplanLines:
planCount=planCount+1
line=eval(line)
self.txtPlan.AppendText(str(planCount)+"\n")
txtPlan=str("创建时间为:
"+line['创建时间']+"\n计划名称:
"+line['计划名称']+\
"\n执行天数:
"+line['自定义天数']+"\t休息天数:
"+line['休息天数']+\
"\n首次打卡时间为:
"+line['首次打卡时间']+"\n是否打卡:
"+str(line['是否打卡'])+\
"\n打卡时间:
"+line['打卡时间'])+"\n\n"
self.txtPlan.AppendText(txtPlan)
except:
pass
#显示习惯
try:
HabitRead=open(path+"habit\\execute.txt",'r',encoding="utf-8")#读取习惯
habitLines=HabitRead.readlines()#读取
forlineinhabitLines:
habitCount=habitCount+1
line=eval(line)
self.txtHabit.AppendText(str(habitCount)+"\n")
ifline['每日每周']=='每日':
txtHabit=str("创建时间为:
"+line['创建时间']+"\n习惯名称:
"+line['习惯名称']+\
"\n在什么时候:
"+line['在一天什么时候']+"\n打卡时间:
"+line['每日每周']+\
"\n打卡次数:
"+line['打卡次数']+"\n是否打卡:
"+str(line['是否打卡'])+\
"\n激励自己的话:
"+line['激励自己的话']+"\n打卡时间:
"+line['打卡时间'])+"\n\n"
elifline['每日每周']=='每周':
txtHabit=str("创建时间为:
"+line['创建时间']+"\n习惯名称:
"+line['习惯名称']+\
"\n在一天什么时候执行:
"+line['在一天什么时候']+"\n打卡时间:
"+line['每日每周']+\
"\n打卡次数:
"+line['打卡次数']+"\t在一周什么时候执行:
"+line['在一周什么时候']+\
"\n是否打卡:
"+str(line['是否打卡'])+"\n激励自己的话:
"+line['激励自己的话']+\
"\n打卡时间:
"+line['打卡时间'])+"\n\n"
self.txtHabit.AppendText(txtHabit)
except:
pass
#显示计划信息#
classPanel1(UserPanel,Singleton):
def__init__(self,parent,act):
self.act=act
self.planCount=0#计划个数
super(Panel1,self).__init__(parent,act)
lblTitleFont=wx.Font(25,wx.DEFAULT,wx.NORMAL,wx.NORMAL,False)
lblFont=wx.Font(17,wx.DEFAULT,wx.NORMAL,wx.NORMAL,False)
lblTitle=wx.StaticText(self,-1,"显示计划信息",(200,30))
lblTitle.SetFont(lblTitleFont)
btnShow=wx.Button(self,-1,"刷新",(420,30))
btnShow.SetFont(lblFont)
try:
self.path="C:
\\PlanHelper\\"+self.act+"\\plan\\"#获取路径
self.list=[]
except:
pass
PlanBatRead=open(self.path+"execute.txt",'r',encoding="utf-8")#读取计划
planBatLines=PlanBatRead.readlines()#读取
forlineinplanBatLines:
self.planCount=self.planCount+1#计划个数
count=self.planCount
line=eval(line)
self.list.append(str(str(count)+"--创建时间:
"+line['创建时间']+"====计划名称:
"+line['计划名称']+"====是否打卡:
"+str(line['是否打卡'])))
self.listBox=wx.ListBox(self,-1,(1,100),(570,380),self.list,wx.LB_SINGLE)
self.Bind(wx.EVT_BUTTON,self.BtnClick,btnShow)
defBtnClick(self,e):
try:
list1=[]
self.planCount=0#计划个数
self.listBox.Clear()
PlanBatRead=open(self.path+"execute.txt",'r',encoding="utf-8")#读取计划
planBatLines=PlanBatRead.readlines()#读取
forlineinplanBatLines:
self.planCount=self.planCount+1#计划个数
count=self.planCount
line=eval(line)
list1.append(str(str(count)+"--创建时间:
"+line['创建时间']+"====计划名称:
"+line['计划名称']+"====是否打卡:
"+str(line['是否打卡'])))
self.listBox.Set(list1)#重新设置列表框
except:
pass
#显示习惯信息#
classPanel2(UserPanel,Singleton):
def__init__(self,parent,act):
super(Panel2,self).__init__(parent,act)
self.act=act
self.habitCount=0
lblTitleFont=wx.Font(25,wx.DEFAULT,wx.NORMAL,wx.NORMAL,False)
lblFont=wx.Font(17,wx.DEFAULT,wx.NORMAL,wx.NORMAL,False)
lblTitle=wx.StaticText(self,-1,"显示习惯信息",(180,30))
lblTitle.SetFont(lblTitleFont)
btnShow=wx.Button(self,-1,"刷新",(420,30))
btnShow.SetFont(lblFont)
try:
self.path="C:
\\PlanHelper\\"+self.act+"\\habit\\"#获取路径
self.list=[]
except:
pass
try:
HabitBatRead=open(self.path+"execute.txt",'r',encoding="utf-8")#读取习惯
habitBatLines=HabitBatRead.readlines()#读取
forlineinhabitBatLines:
self.habitCount=self.habitCount+1#加
count=self.habitCount
line=eval(line)
self.list.append(str(str(count)+"--创建时间"+line['创建时间']+"====习惯名称:
"+line['习惯名称']+"====是否打卡:
"+str(line['是否打卡'])))
self.listBox=wx.ListBox(self,-1,(1,100),(570,380),self.list,wx.LB_SINGLE)
except:
pass
self.Bind(wx.EVT_BUTTON,self.BtnClick,btnShow)
defBtnClick(self,e):
self.habitCount=0#习惯个数
list1=[]
self.listBox.Clear()
HabitBatRead=open(self.path+"execute.txt",'r',encoding="utf-8")#读取计划
habitBatLines=HabitBatRead.readlines()#读取
forlineinhabitBatLines:
self.habitCount=self.habitCount+1#加
count=self.habitCount
line=eval(line)
list1.append(str(str(count)+"--创建时间:
"+line['创建时间']+"====习惯名称:
"+line['习惯名称']+"====是否打卡:
"+str(line['是否打卡'])))
self.listBox.Set(list1)
#计划打卡未实现打卡
classPanel3(UserPanel,Singleton):
def__init__(self,parent,act):
super(Panel3,self).__init__(parent,act)
self.act=act
self.planCount=0#计划个数
self.getNowTime=str(time.strftime("%Y-%m-%d",time.localtime(time.time())))#获取当前时间
lblTitleFont=wx.Font(25,wx.DEFAULT,wx.NORMAL,wx.NORMAL,False)
lblFont=wx.Font(17,wx.DEFAULT,wx.NORMAL,wx.NORMAL,False)
lblTitle=wx.StaticText(self,-1,"计划打卡",(200,30))
lblTitle.SetFont(lblTitleFont)
#btnShow=wx.Button(self,-1,"刷新",(420,30))
#btnShow.SetFont(lblFont)
try:
self.path="C:
\\PlanHelper\\"+self.act+"\\plan\\"#获取路径
self.list=[]
except:
pass
PlanBatRead=open(self.path+"finish.txt",'r',encoding="utf-8")#读取计划
self.planBatLines=PlanBatRead.readlines()#读取
forlineinself.planBatLines:
self.planCount=self.planCount+1#计划个数
count=self.planCount
line=eval(line)
self.list.append(str(str(count)+"--计划名称:
"+line['计划名称']+"=====是否打卡:
"+str(line['是否打卡'])))
self.listBox=wx.ListBox(self,-1,(1,100),(570,380),self.list,wx.LB_SINGLE)
self.Bind(wx.EVT_LISTBOX_DCLICK,self.ListClick,self.listBox)
#self.Bind(wx.EVT_BUTTON,self.BtnClick,btnShow)
#defBtnClick(self,e):
#try:
#self.planCount=0
#try:
#self.path="C:
\\PlanHelper\\"+self.act+"\\plan\\"#获取路径
#self.list=[]
#except:
#pass
#
#PlanBatRead=open(self.path+"finish.txt",'r',encoding="utf-8")#读取计划
#self.planBatLines=PlanBatRead.readlines()#读取
#forlineinself.planBatLines:
#self.planCount=self.planCount+1#计划个数
#count=self.planCount
#line=eval(line)
#self.list.append(str(str(count)+"--计划名称:
"+line['计划名称']+"=====是否打卡:
"+str(line['是否打卡'])))
#self.listBox=wx.ListBox(self,-1,(1,100),(570,380),self.list,wx.LB_SINGLE)
#self.Bind(wx.EVT_LISTBOX_DCLICK,self.ListClick,self.listBox)
#except:
pass
#未实现
defListClick(self,e):
#try:
self.planCount=0#计划个数
clickCount=str(int(self.listBox.GetSelection())+1)#获取当前点击按钮的编号
PlanBatRead=open(self.path+"finish.txt",'r',encoding="utf-8")
planBatLines=PlanBatRead.readlines()
listPlanBatLines=list(planBatLines)
forlineinplanBatLines:
line=eval(line)
self.planCount=self.planCount+1#计划个数
count=str(self.planCount)
ifclickCount==count:
#判断是否点击的是同一个按钮
mdg=wx.MessageDialog(self,"是否打卡?
","打卡",wx.YES_NO)
ifmdg.ShowModal()==wx.ID_YES:
#如果打卡
list1=list(line.values())
iflist1[6]!
=self.getNowTime:
#如果打卡时间!
=当前时间,就打卡
listL=[]
line['是否打卡']=True#设置
line['打卡时间']=self.getNowTime#设置
PlanBatFinishWrite=open(self.path+"finish.txt",'a+',encoding="utf-8")#写入计划
PlanBatFinishWrite.write(str(line)+"\n")#重新写入
PlanBatFinishRead=open(self.path+"finish.txt",'r',encoding="utf-8")#读取计划
PlanReadLines=PlanBatFinishRead.readlines()#读取
listL.append(str(str(count)+"--计划名称:
"+line['计划名称']+"=====是否打卡:
"+str(line['是否打卡'])))
self.listBox.InsertItems(listL,int(clickCount))#插入
self.listBox.Delete(int(clickCount)-1)
#except:
pass
#习惯打卡未实现打卡
classPanel4(UserPanel,Singleton):
def__init__(self,parent,act):
super(Panel4,self).__init__(parent,act)
self.act=act
self.habitCount=0#习惯个数
self.getNowTime=time.strftime("%Y-%m-%d",time.localtime(time.time()))#获取当前时间
lblTitleFont=wx.Font(25,wx.DEFAULT,wx.NORMAL,wx.NORMAL,False)
lblFont=wx.Font(17,wx.DEFAULT,wx.NORMAL,wx.NORMAL,False)
lblTitle=wx.StaticText(self,-1,"习惯打卡",(200,30))
lblTitle.SetFont(lblTitleFont)
#btnShow=wx.Button(self,-1,"刷新",(420,30))
#btnShow.SetFont(lblFont)
try:
self.path="C:
\\PlanHelper\\"+self.act+"\\habit\\"#获取路径
self.list=[]
except:
pass
try:
HabitBatRead=open(self.path+"finish.txt",'r',encoding="utf-8")#读取习惯
habitBatLines=HabitBatRead.readlines()#读取
forlineinhabit