def test_format_period_method(self): time_period = TimePeriod(self.time_type, wx.DateTimeFromDMY(1, 7, 2010, 13, 44), wx.DateTimeFromDMY(2, 7, 2010, 13, 30)) self.assertEquals( u"01 %s 2010 13:44 to 02 %s 2010 13:30" % (_("Aug"), _("Aug")), self.time_type.format_period(time_period))
def testGetValueWhenTimeIsHiddenShouldReturnDateWithoutTime(self): self.time_picker.IsShown.return_value = False self.time_picker.get_time.return_value = wx.DateTimeFromHMS(14, 30) self.date_picker.get_date.return_value = wx.DateTimeFromDMY( 31, 7, 2010, 0, 0) self.assertEquals(wx.DateTimeFromDMY(31, 7, 2010, 0, 0), self.controller.get_value())
def edit_data_peserta(self, event): if self.m_dataViewListCtrl3.GetSelectedRow() != -1: self.data = self.m_dataViewListCtrl3.GetValue( self.m_dataViewListCtrl3.GetSelectedRow(), 1) self.bio = self.data_peserta.query_select_data_peserta(self.data) self.day, self.month, self.year = self.bio[2].split("/") self.day2, self.month2, self.year2 = self.bio[5].split("/") self.date = wx.DateTimeFromDMY(int(self.day), int(self.month) - 1, int(self.year)) self.date2 = wx.DateTimeFromDMY(int(self.day2), int(self.month2) - 1, int(self.year2)) self.biodata = EditBiodata(self) self.biodata.Show() # self.data =[] # for i in range(9): # self.data.append(self.m_dataViewListCtrl3.GetValue(self.m_dataViewListCtrl3.GetSelectedRow(),i)) # print(self.data) # self.data_peserta.(self.data) # self.Close() pass
def test_time_string_method(self): time1 = wx.DateTimeFromDMY(20, 11, 0, 0, 0) time2 = wx.DateTimeFromDMY(20, 11, 1, 0, 0) delta = time2 - time1 self.assertEqual(365, delta.GetDays()) self.assertEqual(u"0000-12-20", time1.FormatISODate()) self.assertEqual(-1, time1.ConvertYearToBC(time1.GetYear()))
def test_format_overlapping_events(self): time_period1 = TimePeriod(self.time_type, wx.DateTimeFromDMY(1, 7, 2010, 13, 44), wx.DateTimeFromDMY(2, 7, 2010, 13, 30)) time_period2 = TimePeriod(self.time_type, wx.DateTimeFromDMY(1, 7, 2010, 13, 44), wx.DateTimeFromDMY(2, 7, 2010, 13, 30)) delta = time_period2.start_time - time_period1.end_time self.assertEquals("0", self.time_type.format_delta(delta))
def dateTimePy2Wx(date): if isinstance(date, datetime.date): retVal = wx.DateTimeFromDMY(date.day, date.month - 1, date.year) elif isinstance(date, datetime.datetime): retVal = wx.DateTimeFromDMY(date.day, date.month - 1, date.year, date.hour, date.minute, date.second, date.microsecond) else: retVal = date return retVal
def test_datetimesort(): d1 = wx.DateTimeFromDMY(12, 6, 2007) assert d1.GetDay() == 12 assert d1.GetYear() == 2007 d2 = wx.DateTimeFromDMY(15, 7, 2008) d3 = wx.DateTimeFromDMY(11, 6, 2007) dates = [d1, d2, d3] dates.sort() assert dates == [d3, d1, d2], repr(dates)
def OnKeyDown(self, event): if not self.hasFocus: event.Skip() return key_code = event.KeyCode() if key_code == wx.WXK_TAB: forward = not event.ShiftDown() ne = wx.NavigationKeyEvent() ne.SetDirection(forward) ne.SetCurrentFocus(self) ne.SetEventObject(self) self.GetParent().GetEventHandler().ProcessEvent(ne) event.Skip() return delta = None if key_code == wx.WXK_UP: delta = -7 elif key_code == wx.WXK_DOWN: delta = 7 elif key_code == wx.WXK_LEFT: delta = -1 elif key_code == wx.WXK_RIGHT: delta = 1 elif key_code == wx.WXK_HOME: curDate = wx.DateTimeFromDMY(int(self.cal_days[self.sel_key]), self.month - 1, self.year) newDate = wx.DateTime_Now() ts = newDate - curDate delta = ts.GetDays() if delta <> None: curDate = wx.DateTimeFromDMY(int(self.cal_days[self.sel_key]), self.month - 1, self.year) timeSpan = wx.TimeSpan_Days(delta) newDate = curDate + timeSpan if curDate.GetMonth() == newDate.GetMonth(): self.set_day = newDate.GetDay() key = self.sel_key + delta self.SelectDay(key) else: self.month = newDate.GetMonth() + 1 self.year = newDate.GetYear() self.set_day = newDate.GetDay() self.sel_key = None self.DoDrawing(wx.ClientDC(self)) event.Skip()
def setDates(self): dateAfter = self.recordService.get_series_points()[0][2] dateBefore = self.recordService.get_series_points()[-1][2] formattedDateAfter = wx.DateTimeFromDMY( int(dateAfter.day) - 1, int(dateAfter.month), int(dateAfter.year), 0, 0, 0) formattedDateBefore = wx.DateTimeFromDMY( int(dateBefore.day) + 1, int(dateBefore.month), int(dateBefore.year), 0, 0, 0) self.dpAfter.SetRange(formattedDateAfter, formattedDateBefore) self.dpBefore.SetRange(formattedDateAfter, formattedDateBefore) self.dpAfter.SetValue(formattedDateAfter) self.dpBefore.SetValue(formattedDateBefore)
def Load_Cycle(name='cycle', passwd='123', file='cycle'): p, f_name = get_f_name(file) if os.path.isfile(f_name): m = hashlib.md5() m.update(passwd) rt = rotor.newrotor(m.digest()) f = open(f_name, "rb") tmp = f.read() if tmp[:len("UserName="******"UserName="******"===") + len("===") tmp = tmp[n:] #remove username tmp = rt.decrypt(tmp) f.close() if tmp[0:5] != 'Cycle': # print 'Password is invalid' return False else: tmp = tmp[5:] #remove control word 'Cycle' objLoad = cPickle.loads(tmp) set_color_default() for type, d in objLoad: # print "Load: ", type, d if type == 'period': cal_year.cycle.period = int(d) elif type == 'by_average': cal_year.cycle.by_average = int(d) elif type == 'disp': cal_year.cycle.disp = int(d) elif type == 'first_week_day': cal_year.cycle.first_week_day = int(d) elif type == 'begin': dt = wx.DateTimeFromDMY(d[0], d[1], d[2]) cal_year.cycle.begin.append(dt) elif type == 'last': dt = wx.DateTimeFromDMY(d[0], d[1], d[2]) cal_year.cycle.last.append(dt) elif type == 'tablet': dt = wx.DateTimeFromDMY(d[0], d[1], d[2]) cal_year.cycle.tablet.append(dt) elif type == 'note': cal_year.cycle.note = d.copy() elif type == 'colour': # d=['item', (r,g,b)] c = wx.Colour(d[1][0], d[1][1], d[1][2]) if cal_year.cycle.colour_set.has_key(d[0]): cal_year.cycle.colour_set[d[0]] = c else: cal_yaar.cycle.colour_set.update({d[0]: c}) # print "Load OK" return True
def getEventInfo(self, event): # In order to edit if not self.eventsOLV.GetSelectedObject(): dlg = wx.MessageDialog(None, "Click on a row in order to edit event.", 'Error Message.', wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() else: self.rowData = self.eventsOLV.GetSelectedObject() rowObj = self.eventsOLV.GetSelectedObject() self.edit_event_panel.event_id.SetValue(str(rowObj['event_id'])) self.edit_event_panel.event_name.SetValue(rowObj['event_name']) self.edit_event_panel.event_desc.SetValue(rowObj['event_desc']) # get wxPython datetime format day = rowObj['event_date'].day month = rowObj['event_date'].month year = rowObj['event_date'].year # -1 because the month counts from 0, whereas people count January as month #1. dateFormatted = wx.DateTimeFromDMY(day, month - 1, year) self.edit_event_panel.event_date.SetValue(dateFormatted) self.edit_event_panel.Show()
def __init__(self): super(afTestcaseFilter, self).__init__() self.version = [] self.changedfrom = wx.DateTimeFromDMY(1, 1, 2000) self.changedto = wx.Now() self.changedby = None self.changedbylist = []
def _pydate2wxdate(date): import datetime assert isinstance(date, (datetime.datetime, datetime.date)) tt = date.timetuple() dmy = (tt[2], tt[1] - 1, tt[0]) return wx.DateTimeFromDMY(*dmy)
def pydate2wxdate(date): """Function to convert datetime.datetime to wx.datetime format """ assert isinstance(date, (datetime.datetime, datetime.date)) tt = date.timetuple() dmy = (tt[2], tt[1] - 1, tt[0]) return wx.DateTimeFromDMY(*dmy)
def AddChangeSearchWidget(self, box): stext = wx.StaticText(self, -1, _('Changed between')) self.changedate_from = wx.DatePickerCtrl( self, dt=wx.DateTimeFromDMY(1, 0, 2000), size=wx.DefaultSize, style=wx.DP_DROPDOWN | wx.DP_SHOWCENTURY) box.Add(stext, 0, wx.ALIGN_CENTER) box.Add(self.changedate_from, 0, wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT, 5) stext = wx.StaticText(self, -1, _('and')) self.changedate_to = wx.DatePickerCtrl(self, size=wx.DefaultSize, style=wx.DP_DROPDOWN | wx.DP_SHOWCENTURY) box.Add(stext, 0, wx.ALIGN_CENTER) box.Add(self.changedate_to, 0, wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT, 5) stext = wx.StaticText(self, -1, _('by')) self.combo_changedby = wx.ComboBox(self, -1, choices=[], style=wx.CB_DROPDOWN | wx.CB_READONLY) box.Add(stext, 0, wx.ALIGN_CENTER) box.Add(self.combo_changedby, 0, wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT, 5)
def __init__(self, parent, cache, markType, date=None, logText='', encoded=False): ''' Initialises the View Travel Bugs Frame Arguments parent: The parent window for the dialog. cache: The cache object to display the travel bugs from. ''' pre = wx.PreDialog() self.res = Xrc.XmlResource( os.path.join(geocacher.getBasePath(), 'xrc', 'foundCache.xrc')) self.res.LoadOnDialog(pre, parent, 'FoundCacheDialog') self.PostCreate(pre) self.SetTitle(_('Mark cache ') + cache + _(' as ') + markType) self.date = Xrc.XRCCTRL(self, 'datePick') self.logText = Xrc.XRCCTRL(self, 'logText') self.encodeLog = Xrc.XRCCTRL(self, 'encodeLogCb') if date != None: self.date.SetValue( wx.DateTimeFromDMY(date.day, date.month - 1, date.year)) if logText == None: logText = '' self.logText.SetValue(logText) self.encodeLog.SetValue(encoded)
def cancelAddStudent(self, event): self.reg_no.SetValue("") self.first_name.SetValue("") self.last_name.SetValue("") self.surname.SetValue("") self.address.SetValue("") self.kin_names.SetValue("") self.kin_phone.SetValue("") self.birth_cert_no.SetValue("") self.kcpe_marks.SetValue("") td = datetime.today() # get wxPython datetime format day = td.day month = td.month year = td.year # -1 because the month counts from 0, whereas people count January as month #1. tdFormatted = wx.DateTimeFromDMY(day, month - 1, year) self.dob.SetValue(tdFormatted) self.class_id.SetSelection(-1) self.gender.SetSelection(-1)
def cancelAddTeacher(self, event): self.first_name.SetValue("") self.last_name.SetValue("") self.surname.SetValue("") self.email.SetValue("") self.phone.SetValue("") self.address.SetValue("") self.national_id.SetValue("") self.tsc_no.SetValue("") self.username.SetValue("") self.password.SetValue("") self.conf_password.SetValue("") self.gender.SetSelection(-1) self.subject.SetSelection(-1) self.subject2.SetSelection(-1) td = datetime.today() # get wxPython datetime format day = td.day month = td.month year = td.year # -1 because the month counts from 0, whereas people count January as month #1. tdFormatted = wx.DateTimeFromDMY(day, month - 1, year) self.dob.SetValue(tdFormatted)
def goToPatient(self, panel, user): self.updatePanel(panel) patientJson = patientPath + jsonFileName self.loadHistoryList("All") if os.path.exists(patientJson): jsonFile = open(patientJson, "r") userData = json.load(jsonFile) jsonFile.close() date = wx.DateTimeFromDMY(userData['dobDay'], userData['dobMonth'], userData['dobYear']) self.patientPanel.fnameTextCtrl.SetValue(userData['firstName']) self.patientPanel.lnameTextCtrl.SetValue(userData['lastName']) self.patientPanel.dobDatePicker.SetValue(date) self.patientPanel.genderChoice.SetSelection(userData['gender']) self.patientPanel.patientIdTextCtrl.SetValue(userData['patientID']) self.patientPanel.notesTextCtrl.SetValue(userData['notes']) self.loadSims() self.loadHistorySimChoices() else: wx.MessageBox('Could not load user', 'Problem', wx.OK | wx.ICON_INFORMATION)
def getTeacherInfo(self, event): if not self.dataOlv.GetSelectedObject(): dlg = wx.MessageDialog(None, "Click on a row in order to edit teacher.", 'Error Message.', wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() else: rowObj = self.dataOlv.GetSelectedObject() self.user_id.SetValue(str(rowObj['user_id'])) self.first_name.SetValue(rowObj['first_name']) self.last_name.SetValue(rowObj['last_name']) self.surname.SetValue(rowObj['surname']) self.email.SetValue(rowObj['email']) self.username.SetValue(rowObj['username']) rowObj['dob'] = datetime.strptime(str(rowObj['dob']), "%Y-%m-%d").date() # get wxPython datetime format day = rowObj['dob'].day month = rowObj['dob'].month year = rowObj['dob'].year # -1 because the month counts from 0, whereas people count January as month #1. dateFormatted = wx.DateTimeFromDMY(day, month - 1, year) self.dob.SetValue(dateFormatted) self.gender.SetValue(rowObj['gender']) self.subject.SetValue(rowObj['subject1']) if rowObj['subject2'] != "--": self.subject2.SetValue(rowObj['subject2'])
def __init__(self, parent, id, component, logType=0, evalSpace=None, bCounter=False, progressDlg=None): """ Конструктор базового класса пользовательских компонентов. @type parent: C{wx.Window} @param parent: Указатель на родительское окно. @type id: C{int} @param id: Идентификатор окна. @type component: C{dictionary} @param component: Словарь описания компонента. @type logType: C{int} @param logType: Тип лога (0 - консоль, 1- файл, 2- окно лога). @param evalSpace: Пространство имен, необходимых для вычисления внешних выражений. @type evalSpace: C{dictionary} @type bCounter: C{bool} @param bCounter: Признак отображения в ProgressBar-е. Иногда это не нужно - для создания объектов полученных по ссылки. Т. к. они не учтены при подсчете общего количества объектов. @type progressDlg: C{wx.ProgressDialog} @param progressDlg: Указатель на идикатор создания формы. """ component = util.icSpcDefStruct(self.component_spc, component) icwidget.icWidget.__init__(self, parent, id, component, logType, evalSpace) # По спецификации создаем соответствующие атрибуты (кроме служебных атрибутов) lst_keys = [x for x in component.keys() if x.find('__') != 0] for key in lst_keys: setattr(self, key, component[key]) # !!! Конструктор наследуемого класса !!! # Необходимо вставить реальные параметры конструкора. # На этапе генерации их не всегда можно определить. if self.value: value = self.value.replace(':', '.').replace('/', '.').replace('\\', '.') day, month, year = [int(s) for s in value.split('.')] tm = wx.DateTimeFromDMY(day, month, year) else: tm = wx.DefaultDateTime wx.DatePickerCtrl.__init__(self, parent, dt=tm, pos=self.position, size=self.size, style=self.style) # --- Регистрация обработчиков событий self.Bind(wx.EVT_DATE_CHANGED, self.OnDateChanged) self.BindICEvt()
def copyDate(value): """ Simple method for copy the date (Y,M,D). """ if 'phoenix' in wx.PlatformInfo: date = wx.DateTime.FromDMY(value.GetDay(), value.GetMonth(), value.GetYear()) else : date = wx.DateTimeFromDMY(value.GetDay(), value.GetMonth(), value.GetYear()) return date
def SetValue(self, date): if date is None: date = wx.DefaultDateTime if isinstance(date, (datetime.datetime, datetime.date)): tt = date.timetuple() dmy = (tt[2], tt[1] - 1, tt[0]) date = wx.DateTimeFromDMY(*dmy) wx.GenericDatePickerCtrl.SetValue(self, date)
def Popup(self, year, month, day, event): d = wx.DateTimeFromDMY(day, month - 1, year) self.control.SetDate(d) btn = event.GetEventObject() pos = btn.ClientToScreen((0, 0)) sz = btn.GetSize() self.Move((pos[0], pos[1] + sz.height)) self.ShowModal()
def as_wx_date(py_date): """ Convert an iso date string to a wxDateTime. """ day = py_date.day month = py_date.month - 1 # wx peculiarity! year = py_date.year return wx.DateTimeFromDMY(day, month, year)
def _pydate2wxdate(self,date): """ Module function: convert from Python Date to wx.Date type """ tt = date.timetuple() dmy = (tt[2], tt[1]-1, tt[0]) return wx.DateTimeFromDMY(*dmy)
def update(self): self.Freeze() try: self.description = self.task.subject() started = self.task.startDateTime() if started == date.DateTime(): self.start = wx.DateTimeFromDMY(1, 1, 0) # Huh else: self.start = wx.DateTimeFromDMY(started.day, started.month - 1, started.year, started.hour, started.minute, started.second) ended = self.task.dueDateTime() if ended == date.DateTime(): self.end = wx.DateTimeFromDMY(1, 1, 9999) else: self.end = wx.DateTimeFromDMY(ended.day, ended.month - 1, ended.year, ended.hour, ended.minute, ended.second) if self.task.completed(): self.done = True self.color = wx.Color( *(self.task.backgroundColor() or (255, 255, 255))) self.foreground = wx.Color( *(self.task.foregroundColor(True) or (0, 0, 0))) self.font = self.task.font() icons = [self.iconProvider(self.task, False)] if self.task.attachments(): icons.append('paperclip_icon') if self.task.notes(): icons.append('note_icon') self.icons = icons if self.task.percentageComplete(True): # If 0, just let the default None value so the progress bar isn't drawn # at all self.complete = 1.0 * self.task.percentageComplete(True) / 100 finally: self.Thaw()
def Draw_Year(self): Val.frame.SetTitle(cycle.name+" - "+str(self.year)) for m in range(12): t=wx.DateTimeFromDMY(1, m, self.year) self.month[m].EnableMonthChange(True) self.month[m].SetDate(t) self.month[m].EnableMonthChange(False) self.month[m].Refresh()
def __init__(self, parent): wx.Panel.__init__(self, parent=parent) self.parent = parent self.topSizer = wx.BoxSizer(wx.VERTICAL) self.buttonSizer = wx.BoxSizer(wx.VERTICAL) self.sizer1 = wx.BoxSizer(wx.HORIZONTAL) self.sizer2 = wx.BoxSizer(wx.HORIZONTAL) self.sizer3 = wx.BoxSizer(wx.HORIZONTAL) self.sizer4 = wx.BoxSizer(wx.HORIZONTAL) self.sizer5 = wx.BoxSizer(wx.HORIZONTAL) txt1 = wx.StaticText(self, label="Chart type:") chart_choices = [ 'Spread vs duration', 'Historical range', 'Historical performance', 'Benchmark bonds vs. EMBI', 'SSA bonds vs. Africa index', 'SSA bonds vs. EMBI', 'CEE bonds vs. EMBI', 'CIS bonds vs. EMBI', 'Africa spread vs. rating', 'EMBI spread vs. rating', 'CEE spread vs. rating', 'CIS spread vs. rating' ] self.combo1 = wx.ComboBox(self, wx.ID_ANY, 'Spread vs duration', style=wx.CB_DROPDOWN, choices=chart_choices) txt2 = wx.StaticText(self, label="Data:") self.combo2 = wx.ComboBox(self, wx.ID_ANY, list(BONDCHARTS.columns)[0], style=wx.CB_DROPDOWN, choices=list(BONDCHARTS.columns)) txt3 = wx.StaticText(self, label="Start date for historical charts:") self.startcalendar = wx.DatePickerCtrl( self, wx.ID_ANY, wx.DateTimeFromDMY(31, 11, datetime.datetime.now().year - 1)) self.btn = wx.Button(self, label="Draw") self.btn.Bind(wx.EVT_BUTTON, self.onDrawChart) self.txt4 = wx.StaticText(self, label="Ready") self.sizer1.Add(txt1, 1, wx.ALL, 2) self.sizer1.Add(self.combo1, 1, wx.ALL, 2) self.sizer2.Add(txt2, 1, wx.ALL, 2) self.sizer2.Add(self.combo2, 1, wx.ALL, 2) self.sizer3.Add(txt3, 1, wx.ALL, 2) self.sizer3.Add(self.startcalendar, 1, wx.ALL, 2) self.sizer4.Add(self.btn, 1, wx.ALL, 2) self.sizer5.Add(self.txt4, 1, wx.ALL, 2) self.buttonSizer.Add(self.sizer1, 0, wx.ALL | wx.EXPAND, 2) self.buttonSizer.Add(self.sizer2, 0, wx.ALL | wx.EXPAND, 2) self.buttonSizer.Add(self.sizer3, 0, wx.ALL | wx.EXPAND, 2) self.buttonSizer.Add(self.sizer4, 0, wx.ALL | wx.EXPAND, 2) self.buttonSizer.Add(self.sizer5, 0, wx.ALL | wx.EXPAND, 2) self.topSizer.Add(self.buttonSizer, 0, wx.ALL | wx.EXPAND, 2) self.SetSizer(self.topSizer) self.Layout() self.embiZscores = None self.africaZscores = None self.africaEMBIZscores = None self.ceeZscores = None pass
def pydate2wxdate(date): assert isinstance(date, (datetime.datetime, datetime.date)) tt = date.timetuple() dmy = (tt[2], tt[1] - 1, tt[0]) wxt = wx.DateTimeFromDMY(*dmy) wxt.SetHour(date.hour) wxt.SetMinute(date.minute) wxt.SetSecond(date.second) return wxt