Ejemplo n.º 1
0
 def __init__(self, parent):
     xrcCRelogioFrame.__init__(self, parent)
     #load application icon
     iconFile = "../res/date.ico"
     icon = wx.Icon(iconFile, wx.BITMAP_TYPE_ICO)
     self.SetIcon(icon)
     self.SetSize((460,350))
     self.RelogioTrayBar = CTrayBar(self)
     self.RelogioTrayBar.Iconize(False)
     self.Bind(wx.EVT_ICONIZE, self.OnIconize)
     self.Bind(wx.EVT_CLOSE, self.OnUserClose)
     
     self.Hide()
     
     self.SetMinSize((460,350))
     
     #load data base
     self.cPontoDB = CPontoDB()
     self.cPontoDB.LoadDB()
     #self.cPontoDB.Print()
     
     #self.ColoredGauge = CColoredGauge(self.GaugePanel, self.OnGaugeGetToday)
     self.ColoredGauge = CColoredGauge(self, self.OnGaugeGetToday)
     
     self.wxFrameBoxSizer = self.GetSizer()
     self.wxFrameBoxSizer.Add(self.ColoredGauge, 1, wx.EXPAND|wx.ALL)
     
     self.ColoredGauge.RefreshMark()
     
     #MilestoneBox = wx.StaticBox(self, -1, "Milestones")
     #MilestoneBox.SetBackgroundColour(wx.LIGHT_GREY)
     #MilestoneBox.SetBackgroundStyle(wx.BG_STYLE_COLOUR)
     #bsizer = wx.StaticBoxSizer(MilestoneBox, wx.VERTICAL)        
     
     self.MilestonePanel = CMilestonePanel(self, self.OnGaugeGetToday)
     self.MilestonePanel.RefreshMark()
     
     #t = wx.StaticText(self, -1, "Controls placed \"inside\" the box are really its siblings")
     #bsizer.Add(self.MilestonePanel, 1, wx.EXPAND|wx.ALL, 0)
     self.wxFrameBoxSizer.Add(self.MilestonePanel, 1, wx.EXPAND|wx.ALL)
Ejemplo n.º 2
0
class CCRelogioFrame(xrcCRelogioFrame):
    def __init__(self, parent):
        xrcCRelogioFrame.__init__(self, parent)
        #load application icon
        iconFile = "../res/date.ico"
        icon = wx.Icon(iconFile, wx.BITMAP_TYPE_ICO)
        self.SetIcon(icon)
        self.SetSize((460,350))
        self.RelogioTrayBar = CTrayBar(self)
        self.RelogioTrayBar.Iconize(False)
        self.Bind(wx.EVT_ICONIZE, self.OnIconize)
        self.Bind(wx.EVT_CLOSE, self.OnUserClose)
        
        self.Hide()
        
        self.SetMinSize((460,350))
        
        #load data base
        self.cPontoDB = CPontoDB()
        self.cPontoDB.LoadDB()
        #self.cPontoDB.Print()
        
        #self.ColoredGauge = CColoredGauge(self.GaugePanel, self.OnGaugeGetToday)
        self.ColoredGauge = CColoredGauge(self, self.OnGaugeGetToday)
        
        self.wxFrameBoxSizer = self.GetSizer()
        self.wxFrameBoxSizer.Add(self.ColoredGauge, 1, wx.EXPAND|wx.ALL)
        
        self.ColoredGauge.RefreshMark()
        
        #MilestoneBox = wx.StaticBox(self, -1, "Milestones")
        #MilestoneBox.SetBackgroundColour(wx.LIGHT_GREY)
        #MilestoneBox.SetBackgroundStyle(wx.BG_STYLE_COLOUR)
        #bsizer = wx.StaticBoxSizer(MilestoneBox, wx.VERTICAL)        
        
        self.MilestonePanel = CMilestonePanel(self, self.OnGaugeGetToday)
        self.MilestonePanel.RefreshMark()
        
        #t = wx.StaticText(self, -1, "Controls placed \"inside\" the box are really its siblings")
        #bsizer.Add(self.MilestonePanel, 1, wx.EXPAND|wx.ALL, 0)
        self.wxFrameBoxSizer.Add(self.MilestonePanel, 1, wx.EXPAND|wx.ALL)
        
    def OnGaugeGetToday(self):
        return self.cPontoDB.GetToday()    
        
    def OnUserClose(self, event):
        if not event.CanVeto():
            print '[CCRelogioFrame.OnUserIconize] - Destroy: ',self.Destroy()
            #event.Skip()
            #self.Close(True)
            wx.GetApp().ExitMainLoop()
        else:    
            print '[CCRelogioFrame.OnUserIconize] - Iconize'
            self.RelogioTrayBar.Iconize(False)
            self.Hide()
            event.Veto()
                    
    def OnIconize(self, event):
        print '[CCRelogioFrame.OnIconize]', event.Iconized()
        if event.Iconized():
            self.RelogioTrayBar.Iconize(False)
            self.Hide()
        else:
            self.UpdateInterface()
            #self.SetSize(event.GetSize())
            #self.Refresh()
    def OnButton_ClearAllMarks(self, evt):
        self.ColoredGauge.DeleteAllBookMarks() 
        self.cPontoDB.ClearToday()       
    def OnButton_AddMarkBtn(self, evt):
        print '[CCRelogioFrame.OnButton_AddMarkBtn] - ShowDialog'
        dialog = CDialogMark(self)
        returncode = dialog.ShowModal()
        print '[CCRelogioFrame.OnButton_AddMarkBtn] - return: ',returncode
        if returncode >= 0:
            mark = dialog.GetMark()
            old_mark = self.cPontoDB.has_mark_anywhere(mark[3],mark[2],mark[0],mark[1])
            if old_mark != None:
                dlg = wx.MessageDialog(self, 'Do you want to replace this mark?',
                                       'Ponto',
                                       wx.YES_NO | wx.ICON_QUESTION
                                       #wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_INFORMATION
                                       )
                if( dlg.ShowModal() == wx.ID_YES):
                    print '[OnButton_AddMarkBtn] replace mark: ',mark
                    self.cPontoDB.DeleteMark(old_mark)
                    self.cPontoDB.TimeMark(mark[3],mark[2],mark[0],mark[1])
                    #self.cPontoDB.Print()  
                    self.ColoredGauge.RefreshMark()  
                    self.MilestonePanel.RefreshMark()                  
                dlg.Destroy()                
            else:    
                print '[OnButton_AddMarkBtn] mark: ',mark
                self.cPontoDB.TimeMark(mark[3],mark[2],mark[0],mark[1])
                #self.cPontoDB.Print()  
                self.ColoredGauge.RefreshMark() 
                self.MilestonePanel.RefreshMark()   
                
    def OnButton_ExitBtn(self, evt):               
        print '[CCRelogioFrame.OnButton_ExitBtn] - Destroy'
        #self.Destroy()
        #wx.GetApp().ExitMainLoop()
        self.Close(True)
    def OnButton_CReportButton(self, evt):
        self.cReportFrame = CReport(None,self.cPontoDB)
        self.cReportFrame.Show(True)
    def UpdateInterface(self):
        #self.SetSize(self.GetSize())
        self.MilestonePanel.RefreshMark() 
        self.MilestonePanel.Refresh()
        self.ColoredGauge.RefreshMark()
        self.Refresh()
    def OnMaximize(self, evt):
        print '[CCRelogioFrame.OnMaximize]',evt   
    def OnButton_AboutButton(self, evt):
        info = wx.AboutDialogInfo()
        info.Name = LABELING.APP_LONG_NAME
        info.Version = LABELING.VERSION
        info.Copyright = LABELING.COPYRIGHT
        info.Description = wordwrap(
        LABELING.ABOUT_DESCRIPTION
        ,650, wx.ClientDC(self))
        info.WebSite = (LABELING.COMPANY_WEBSITE, LABELING.COMPANY_NAME)
        info.Developers = [ LABELING.DEVELOPER_MAIN,
                            LABELING.DEVELOPER_MAIN_CONT ]
        wx.AboutBox(info)
    def OnButton_COnedayReportButton(self, evt):
        target_day = time.localtime()
        print "OnButton_COnedayReportButton: ",target_day
        #target_day = time.strptime(self.GetItemText(self.currentItem),"%d/%m/%Y")
        self.cReportFrame = COneDayReport(None,self.cPontoDB,datetime(target_day.tm_year,target_day.tm_mon,target_day.tm_mday,target_day.tm_hour,target_day.tm_min,target_day.tm_sec))
        self.cReportFrame.Show(True)