예제 #1
0
파일: timer.py 프로젝트: sim1234/Odtwarzacz
class TimePicker(wx.Dialog):
    def __init__(self, parent, pos = (0,0), size = (200,110)):
        wx.Dialog.__init__(self, parent, wx.ID_ANY, "Korekta czasu", pos, size)

        #self.SetBackgroundColour((230,255,230))
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        
        Sizer1 = wx.BoxSizer(wx.VERTICAL)

        self.c = wx.StaticText(self, -1, u"Podaj aktualną godzinę:")
        Sizer1.Add(self.c, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 3)

        self.tc = TimeCtrl(self, -1, fmt24hr = True)
        Sizer1.Add(self.tc, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 3)
        self.tc.SetValue(wx.DateTime.Now())

        self.ok = wx.Button(self, -1, "OK")
        self.ok.Bind(wx.EVT_BUTTON, self.OnConfirm)
        Sizer1.Add(self.ok, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 3)

        self.t = Timer(self.OnUpdate, 1000)
        
        self.SetSizer(Sizer1)
        self.Layout()

    def OnClose(self, e):
        self.t.stop()
        self.EndModal(1)
        e.Skip()
        
    def OnConfirm(self, e):
        self.t.stop()
        self.EndModal(1)
        e.Skip()

    def OnUpdate(self):
        value = self.tc.GetValue(as_wxTimeSpan = 1)#as_wxDateTime, as_mxDateTime, as_wxTimeSpan, as_mxDateTimeDelta
        value += wx.TimeSpan(0, 0, 1, 0)
        sel = self.tc.GetSelection()
        self.tc.ChangeValue(value)
        self.tc.SetSelection(sel[0], sel[1])

    def GetLag(self):
        now = wx.DateTime.Now()
        t = now - now.GetDateOnly()
        return self.tc.GetValue(as_wxTimeSpan = 1) - t
예제 #2
0
파일: timer.py 프로젝트: sim1234/Odtwarzacz
    def __init__(self, parent, pos = (0,0), size = (200,110)):
        wx.Dialog.__init__(self, parent, wx.ID_ANY, "Korekta czasu", pos, size)

        #self.SetBackgroundColour((230,255,230))
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        
        Sizer1 = wx.BoxSizer(wx.VERTICAL)

        self.c = wx.StaticText(self, -1, u"Podaj aktualną godzinę:")
        Sizer1.Add(self.c, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 3)

        self.tc = TimeCtrl(self, -1, fmt24hr = True)
        Sizer1.Add(self.tc, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 3)
        self.tc.SetValue(wx.DateTime.Now())

        self.ok = wx.Button(self, -1, "OK")
        self.ok.Bind(wx.EVT_BUTTON, self.OnConfirm)
        Sizer1.Add(self.ok, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 3)

        self.t = Timer(self.OnUpdate, 1000)
        
        self.SetSizer(Sizer1)
        self.Layout()