# Copyright (c) 2004-5 Marek Hnilica. All rights reserved. # Module that provides 'Edit time' dialog # Distributed under GPL version 2, or (at your option) later import wx from wx.lib.intctrl import * class TimeEdit(wx.Dialog): def __init__(self,parent,seconds): wx.Dialog.__init__(self,parent,-1,'Edit time') self.Closed=0 self.second_control=IntCtrl(self) self.second_control.SetLimited(1) self.second_control.SetBounds(min=0,max=59) self.second_control.SetValue(seconds%60) self.minutes_control=IntCtrl(self) self.minutes_control.SetValue(seconds/60) OkButton=wx.Button(self,wx.ID_APPLY) CancelButton=wx.Button(self,wx.ID_CANCEL) wx.EVT_BUTTON(self,wx.ID_APPLY,self.Okay) wx.EVT_BUTTON(self,wx.ID_CANCEL,self.Cancel) sizer=wx.FlexGridSizer(2,2,10,10) sizer.AddMany([ (wx.StaticText(self,-1,'Minutes:'),0,wx.ALIGN_RIGHT|wx.NORTH,10), (self.minutes_control,0,wx.ALIGN_LEFT|wx.NORTH,10), (wx.StaticText(self,-1,'Seconds:'),0,wx.ALIGN_RIGHT), (self.second_control,0,wx.ALIGN_LEFT), ]) buttonsizer=wx.BoxSizer(wx.HORIZONTAL) buttonsizer.AddMany([ (OkButton,0), (CancelButton,0) ]) BoxSizer=wx.StaticBoxSizer(wx.StaticBox(self,-1,'Set values:'),0) BoxSizer.Add(sizer) MainSizer=wx.BoxSizer(wx.VERTICAL) MainSizer.AddMany([ (BoxSizer,0,wx.ALL,20), (buttonsizer,0,wx.ALIGN_CENTER|wx.SOUTH,10) ]) MainSizer.Fit(self) self.SetAutoLayout(True) self.SetSizer(MainSizer) self.CenterOnParent() def Cancel(self,junk): self.Destroy() def Okay(self,junk): self.NewTime=self.second_control.GetValue()+self.minutes_control.GetValue()*60 self.Closed=1 self.Destroy()