Beispiel #1
0
    def _calcRightDateOnMove(self, side):
        """ 
		Calculate the right date when the user
		move the date on the next period
		"""

        if self._viewType == wxSCHEDULER_DAILY:
            offset = wx.DateSpan(days=1)
        elif self._viewType == wxSCHEDULER_WEEKLY:
            offset = wx.DateSpan(weeks=1)
        elif self._viewType == wxSCHEDULER_MONTHLY:
            daysAdd = self._currentDate.GetNumberOfDaysInMonth(
                self._currentDate.GetMonth())
            offset = wx.DateSpan(months=1)

        if side == wxSCHEDULER_NEXT:
            if 'phoenix' in wx.PlatformInfo:
                self._currentDate.Add(offset)
            else:
                self._currentDate.AddDS(offset)
        elif side == wxSCHEDULER_PREV:
            if 'phoenix' in wx.PlatformInfo:
                self._currentDate.Subtract(offset)
            else:
                self._currentDate.SubtractDS(offset)
Beispiel #2
0
    def _paintMonthlyHeaders(self, drawer, day, x, y, width, height):
        w, h = drawer.DrawMonthHeader(day, x, y, width, height)

        if self._style == wxSCHEDULER_HORIZONTAL:
            day.SetDay(1)
            day.SetHour(0)
            day.SetMinute(0)
            day.SetSecond(0)

            daysCount = wx.DateTime.GetNumberOfDaysInMonth(day.GetMonth())

            maxDY = 0
            for idx in xrange(daysCount):
                theDay = utils.copyDateTime(day)
                if 'phoenix' in wx.PlatformInfo:
                    theDay.Add(wx.DateSpan(days=idx))
                else:
                    theDay.AddDS(wx.DateSpan(days=idx))

                # Recherche la couleur par défaut pour le jour
                highlight = theDay.IsSameDate(wx.DateTime.Now())
                if self.joursSpeciaux != None and highlight == False:
                    couleur = self.joursSpeciaux.GetCouleur(theDay)
                    if couleur != None: highlight = couleur

                w, h = drawer.DrawSimpleDayHeader(
                    theDay, x + 1.0 * idx * width / daysCount, y + h,
                    1.0 * width / daysCount, height, highlight)
                maxDY = max(maxDY, h)

            h += maxDY

        return w, h
Beispiel #3
0
 def get_pay_incr(self):
     if self.payType == "every week":
         incr = wx.DateSpan(weeks=1)
     elif self.payType == "every 2 weeks":
         incr = wx.DateSpan(weeks=2)
     elif self.payType == "every month":
         incr = wx.DateSpan(months=1)
     else:
         incr = None
     return incr
Beispiel #4
0
def setToWeekDayInSameWeek(day, offset, startDay=1):
    """wxDateTime's    SetToWeekDayInSameWeek   appears    to   be
	buggish. When told that the  week starts on Monday, it results
	in   the  following   'week'  on   Jan,  31st,   2010:  31/01,
	25/01-30/01..."""
    # Loop backwards until we find the start day
    while True:
        if day.GetWeekDay() == startDay:
            break
        day.SubtractDS(wx.DateSpan(days=1))
    day.AddDS(wx.DateSpan(days=offset))
    return day
Beispiel #5
0
 def getWeekly(self, user, major, week, machine):
     thisWeek = self.parent.startDate.GetValue().__add__(
         wx.DateSpan(weeks=int(week))).FormatISODate().replace('-', "")
     nextWeek = self.parent.startDate.GetValue().__add__(
         wx.DateSpan(weeks=int(week) + 1)).FormatISODate().replace('-', "")
     if user.startswith("DISTINCT"):
         query = 'SELECT COUNT(DISTINCT user) FROM log WHERE major="' + major + '" and machine = "' + machine + '" AND level != "FALSE" AND level != "DEAN" and starttime between "' + thisWeek + '" and "' + nextWeek + '"'
         # query = 'SELECT COUNT(DISTINCT user) FROM log where major="'+major+'" and level="'+level+'" and machine="'+machine+'"'
     elif user.startswith("ALL"):
         query = 'SELECT COUNT(*) FROM log WHERE major="' + major + '" and machine = "' + machine + '" AND level != "FALSE" AND level != "DEAN" and starttime between "' + thisWeek + '" and "' + nextWeek + '"'
     else:
         query = 'SELECT COUNT(*) FROM log where major="' + major + '" and machine = "' + machine + '" and user="******" and starttime between "' + thisWeek + '" and "' + nextWeek + '"'
     return query
Beispiel #6
0
    def ExportMovie(self, path, duration=3):
        from stars.visualization.utils.images2gif import writeGif, writeBmps2Gif

        Y, M, D = self.start_date.year, self.start_date.month, self.start_date.day  # python.DateTime
        start_date = wx.DateTime.Today()
        start_date.Year, start_date.Month, start_date.Day = Y, M, D

        tick = self.tick
        movie_bmps = []
        for i in range(self.n):
            self.tick = i
            tmp_bmp = wx.EmptyBitmapRGBA(self.bufferWidth, self.bufferHeight,
                                         255, 255, 255, 255)
            dc = wx.MemoryDC()
            dc.SelectObject(tmp_bmp)
            self.isResizing = True
            self.DoDraw(dc)
            self.isResizing = False

            # draw lables
            if i < self.n - 1:
                end_date = wx.DateTime.Today()
                end_date.Set(start_date.Day, start_date.Month, start_date.Year)

                if self.step_by == 'Day':
                    end_date += wx.DateSpan(days=self.step)
                elif self.step_by == 'Month':
                    end_date += wx.DateSpan(months=self.step)
                elif self.step_by == 'Year':
                    end_date += wx.DateSpan(years=self.step)

                label = '(%d/%d) %s/%s/%s - %s/%s/%s (%s %s period)' % \
                      (i+1,self.n, start_date.Month,start_date.Day,start_date.Year,
                       end_date.Month,  end_date.Day,  end_date.Year,self.step, self.step_by
                       )
                start_date.Year, start_date.Day = end_date.Year, end_date.Day
                start_date.SetMonth(end_date.Month)
            else:
                label = '(%d/%d) %s/%s/%s - %s/%s/%s (%s %s period)' % \
                      (i+1,self.n, start_date.Month,start_date.Day,start_date.Year,
                       self.end_date.month,  self.end_date.day,  self.end_date.year,self.step, self.step_by
                       )

            dc.DrawText(label, 5, 5)
            #dc.Destroy()
            movie_bmps.append(tmp_bmp)
        writeBmps2Gif(path, movie_bmps, duration=duration, dither=0)
        self.tick = tick
        self.ShowMsgBox("Movie file (GIF) created successfully.",
                        mtype='CAST information',
                        micon=wx.ICON_INFORMATION)
Beispiel #7
0
	def updateMSDB(self,oaDict):
		db = MySQLdb.connect(host="db.eng.ucsd.edu",user=app.passDict['db-user'],passwd=app.passDict['db-pass'],db="makerspace")
		db.autocommit(True)
		cur = db.cursor()
		query = "DELETE FROM laser_open_hours"
		cur.execute(query)
		
		dateDict = {}
		for i in range (0,7):
			dateDict[str(i)]=[]
		dayCount = 0
		daySpan = (self.endDate - self.startDate).days
		for i in range (0, daySpan):
			newDate = self.startDate.__add__(wx.DateSpan(days=i))
			dow = str((datetime.datetime.strptime(newDate.FormatISODate(), '%Y-%m-%d')).weekday())
			if dow in dateDict:
				dateDict[dow].append(newDate.FormatISODate())
		for i in range (0,7):
			if str(i) in oaDict:
				for day in dateDict[str(i)]:
					for time in oaDict[str(i)]:
						startTime = str(datetime.datetime.strptime(time[0],'%H%M').time())
						endTime = str(datetime.datetime.strptime(time[1],'%H%M').time())
						query = 'INSERT INTO laser_open_hours (reserve_date,starttime,endtime) VALUE ("'+day+'","'+startTime+'","'+endTime+'")'
						cur.execute(query)
		db.close()	
Beispiel #8
0
def get_finish_short_date_str(task: Task):
    date_finish = py_date_to_wx_datetime(task.start_date)
    span = wx.DateSpan(0, 0, 0, int(task.get_virtual_duration()) - 1)
    date_finish.Add(span)
    date_finish_string = date_finish.Format('%B %d, %G')

    return date_finish_string
Beispiel #9
0
    def OnFor(self, event):
        f5 = self.m_datePicker1.GetValue()

        self.m_datePicker1.SetValue(f5 + wx.DateSpan(days=1))
        self.myday = self.m_datePicker1.GetValue()
        inout = self.showrecord(self.getjalali(self.myday))
        #print inout
        self.employfield(inout)
Beispiel #10
0
 def view_loaded(self):
     self.start_date_ctrl.Value = self.end_date_ctrl.Value - wx.DateSpan(months=1)
     # set check_ctrl
     check_controller = self.check_controller
     check_controller.set_custom_button_label1(u'更新数据')
     check_controller.set_custom_function1(self.inquire)
     check_controller.insert_column(0, u'用例')
     check_controller.safe_insert_rows((c, ) for c in IDATDBdatabase.case_set)
Beispiel #11
0
    def generateRoutine(self, routine):
        # Set Days based on exclude weekends parameter
        if self.exclude:
            routineDays = 5 * self.duration + self.days
        else:
            routineDays = 7 * self.duration + self.days

        # Accumulate Count to iterate over muscle groups
        muscleIndex = 0

        # Create a Workout Session for each day in a single routine
        for day in range(0, routineDays + 1):
            musclegroups = []
            # Set start date add days too for the routine
            startDate = wx.DateTime(self.calendarStart.GetValue())
            # Iterate over muscle group list and reset counter if we reach the end
            for index in range(0, self.amountOfWorkouts):
                if muscleIndex >= len(self.selectedMuscleGroups):
                    muscleIndex = 0
                musclegroups.append(self.selectedMuscleGroups[muscleIndex])
                muscleIndex += 1

            # Exclude weekends logic
            if self.exclude:
                nextDay = startDate.Add(wx.DateSpan(days=day))
                while (nextDay.GetWeekDay() == wx.DateTime.Sat
                       or nextDay.GetWeekDay() == wx.DateTime.Sun):
                    nextDay = startDate.Add(wx.DateSpan(days=1))
            else:
                nextDay = startDate.Add(wx.DateSpan(days=day))

            nextDay = nextDay.Format("%A, %D")

            # Create Session
            newSession = classes.Session(date=nextDay,
                                         workouts=self.generateWorkouts(
                                             groups=musclegroups,
                                             tracker=routine.tracker))
            routine.addSession(newSession)

        return routine
Beispiel #12
0
 def toggleCal(self, event):
     box = event.GetEventObject()
     calendar = box.GetContainingSizer().GetChildren()[1].GetWindow()
     if box.IsChecked():
         calendar.Enable()
     else:
         calendar.Disable()
     if not self.startCheckbox.IsChecked():
         self.startDateSelection = "%"
     if not self.endCheckbox.IsChecked():
         self.endDateSelection = wx.DateTime.Today().__add__(
             wx.DateSpan(days=1)).FormatISODate().replace('-', "")
Beispiel #13
0
        def onDateChar(event):
            key = event.GetKeyCode()
            incr = 0
            if key == wx.WXK_DOWN:
                incr = -1
            elif key == wx.WXK_UP:
                incr = 1
            else:
                event.Skip()

            if incr:
                dateCtrl.Value += incr * wx.DateSpan(days=1)
Beispiel #14
0
 def action(wxdte):
     # action  calcul début ou fin de mois sur les wx.DateTime
     if isinstance(wxdte, wx.DateTime):
         if fin:
             dteout = wx.DateTime.FromDMY(1, wxdte.GetMonth(),
                                          wxdte.GetYear())
             dteout += wx.DateSpan(days=-1, months=1)
         else:
             # dte début de mois
             dteout = wx.DateTime.FromDMY(1, wxdte.GetMonth(),
                                          wxdte.GetYear())
         return dteout
     return None
Beispiel #15
0
 def onAddWeeks(self, event=None, weeks=0):
     self.duration = weeks
     self.validDuration = True
     newEndDate = wx.DateTime(self.routineStartDate).Add(
         wx.DateSpan(weeks=int(self.duration)))
     self.routineEndDate = newEndDate
     self.calendarEnd.SetValue(newEndDate)
     self.endDateText.SetLabel("End Date: {}".format(
         wx.DateTime(newEndDate).Format("%A, %B %d %G")))
     self.durationText.SetLabel("Routine Duration: {} Weeks".format(
         str(self.duration)))
     self.durationText.Update()
     self.calendarEnd.Update()
Beispiel #16
0
    def MoveDate(self, months=0, years=0):
        """
        Move the current date by a given interval of months/years.

        :param int `months`: months to add (can be negative)
        :param int `years`: years to add (can be negative)
        :returns: the new date set.

        """
        cur_date = wx.DateTime.FromDMY(self.day, self.month - 1, self.year)
        new_date = cur_date + wx.DateSpan(years=years, months=months)
        self.SetDate(new_date.GetDay(),
                     new_date.GetMonth() + 1, new_date.GetYear())
        return self.GetDate()
 def __set_properties(self):
     self.SetTitle("frame")
     self.choice_time_step.SetSelection(0)
     self.choice_Hour.SetSelection(2)
     self.choice_Bands.SetSelection(0)
     self.choice_Minutes.SetSelection(0)
     self.button_UpdateImage.SetMinSize((-1, 23))
     self.choice_Tiles.SetSelection(5)
     self.datepicker_ctrl_1.SetValue(wx.DateTime.Today().Add(
         wx.DateSpan(days=-1)))
     self.isPressed = False
     self.tile_number = 20
     self.startPos = wx.Point(0, 0)
     self.endPos = self.startPos
     self.Tiles2Pixel()
     self.Bind(wx.EVT_MOTION, self.ImageCtrl_OnMouseMove)
     self.Bind(wx.EVT_LEFT_DOWN, self.ImageCtrl_OnMouseDown)
     self.Bind(wx.EVT_LEFT_UP, self.ImageCtrl_OnMouseUp)
     self.Bind(wx.EVT_PAINT, self.OnPaint)
     self.Bind(wx.EVT_SIZE, self.OnResize)
     self.setStartDate()
     self.shoreline_checker.SetValue(False)
Beispiel #18
0
    def _paintMonthlyHeaders(self, drawer, day, x, y, width, height):
        if isinstance(self, wx.ScrolledWindow):
            _, h = drawer.DrawMonthHeader(day, 0, 0,
                                          self.GetSizeTuple()[0], height)
            w = width
        else:
            w, h = drawer.DrawMonthHeader(day, x, y, width, height)

        if self._style == wxSCHEDULER_HORIZONTAL:
            day.SetDay(1)
            day.SetHour(0)
            day.SetMinute(0)
            day.SetSecond(0)

            daysCount = wx.DateTime.GetNumberOfDaysInMonth(day.GetMonth())

            maxDY = 0
            for idx in xrange(daysCount):
                theDay = utils.copyDateTime(day)
                theDay.AddDS(wx.DateSpan(days=idx))
                if theDay.IsSameDate(wx.DateTime.Now()):
                    color = self._highlightColor
                else:
                    color = None
                w, h = drawer.DrawSimpleDayHeader(
                    theDay,
                    x + 1.0 * idx * width / daysCount,
                    y + h,
                    1.0 * width / daysCount,
                    height,
                    highlight=color)
                self._headerBounds.append(
                    (x + 1.0 * (idx + 1) * width / daysCount, y + h, height))
                maxDY = max(maxDY, h)

            h += maxDY

        return w, h
Beispiel #19
0
    def draw_timeline(self):
        for tld in self.timeline_dates:
            if isinstance(tld, wx.StaticText):
                tld.Destroy()
        self.timeline_dates.clear()

        span_week = wx.DateSpan(0, 0, 1)

        if self.project is None:
            return

        start = self.project.start_date

        date_display: wx.DateTime = py_date_to_wx_datetime(start)

        y_pos = WBS_HEADER_HEIGHT - 20
        for i in range(self.number_major_vertical_grid):
            str_date = date_display.Format('%m/%d/%g')
            st = wx.StaticText(self,
                               label=str_date,
                               pos=((i * 7 * BAR_SCALE), y_pos))
            self.timeline_dates.append(st)
            date_display.Add(span_week)
Beispiel #20
0
    def _paintDaily(self, drawer, day, x, y, width, height):
        """
		Display day schedules
		"""

        minWidth = minHeight = 0

        if self._style == wxSCHEDULER_VERTICAL:
            x += LEFT_COLUMN_SIZE
            width -= LEFT_COLUMN_SIZE

        theDay = utils.copyDateTime(day)

        if self._drawHeaders:
            maxDY = 0
            for idx in xrange(self._periodCount):
                w, h = self._paintDailyHeaders(
                    drawer, theDay, x + 1.0 * width / self._periodCount * idx,
                    y, 1.0 * width / self._periodCount, height)
                maxDY = max(maxDY, h)
                if 'phoenix' in wx.PlatformInfo:
                    theDay.Add(wx.DateSpan(days=1))
                else:
                    theDay.AddDS(wx.DateSpan(days=1))
            minHeight += maxDY
            y += maxDY
            height -= maxDY
        else:
            for idx in xrange(self._periodCount):
                self._paintDailyHeaders(drawer,
                                        theDay,
                                        x +
                                        1.0 * width / self._periodCount * idx,
                                        y,
                                        1.0 * width / self._periodCount,
                                        height,
                                        includeText=False)
                if 'phoenix' in wx.PlatformInfo:
                    theDay.Add(wx.DateSpan(days=1))
                else:
                    theDay.AddDS(wx.DateSpan(days=1))

        if self._style == wxSCHEDULER_VERTICAL:
            x -= LEFT_COLUMN_SIZE
            width += LEFT_COLUMN_SIZE

        if self._style == wxSCHEDULER_VERTICAL or self._drawHeaders:
            if self._style == wxSCHEDULER_VERTICAL:
                w, h = drawer.DrawHours(x, y, width, height, self._style)
            else:
                maxDY = 0
                for idx in xrange(self._periodCount):
                    _, h = drawer.DrawHours(
                        x + 1.0 * width / self._periodCount * idx, y,
                        1.0 * width / self._periodCount, height, self._style)
                    maxDY = max(maxDY, h)
                w = 0
                h = maxDY
        else:
            w, h = 0, 0

        if self._style == wxSCHEDULER_VERTICAL:
            minWidth += w
            x += w
            width -= w
        else:
            minHeight += h
            y += h
            height -= h

        if self._style == wxSCHEDULER_HORIZONTAL:
            # Use directly paintPeriod or pagination fails
            w, h = self._paintPeriod(drawer, day, self._periodCount, x, y,
                                     width, height)
        else:
            w = 0
            maxDY = 0
            theDay = utils.copyDateTime(day)
            for idx in xrange(self._periodCount):
                dw, dh = self._paintDay(
                    drawer, theDay, x + 1.0 * width / self._periodCount * idx,
                    y, 1.0 * width / self._periodCount, height)
                w += dw
                maxDY = max(maxDY, dh)
                if 'phoenix' in wx.PlatformInfo:
                    theDay.Add(wx.DateSpan(days=1))
                else:
                    theDay.AddDS(wx.DateSpan(days=1))

        minWidth += w
        minHeight += h

        return minWidth, minHeight
    def ScheduleSize(schedule, workingHours, firstDay, dayCount):
        """
		This convenience  static method computes  the position
		and size  size of the  schedule in the  direction that
		represent time,  according to a set  of working hours.
		The workingHours  parameter is  a list of  2-tuples of
		wx.DateTime  objects   defining  intervals  which  are
		indeed worked.  startPeriod and endPeriod  delimit the
		period.
		"""

        totalSpan = 0
        scheduleSpan = 0
        position = 0

        totalTime = 0
        for startHour, endHour in workingHours:
            totalTime += copyDateTime(endHour).Subtract(
                startHour).GetMinutes() / 60.0

        for dayNumber in xrange(dayCount):
            currentDay = copyDateTime(firstDay)
            currentDay.AddDS(wx.DateSpan(days=dayNumber))

            for startHour, endHour in workingHours:
                startHourCopy = wx.DateTimeFromDMY(currentDay.GetDay(),
                                                   currentDay.GetMonth(),
                                                   currentDay.GetYear(),
                                                   startHour.GetHour(),
                                                   startHour.GetMinute(), 0)
                endHourCopy = wx.DateTimeFromDMY(currentDay.GetDay(),
                                                 currentDay.GetMonth(),
                                                 currentDay.GetYear(),
                                                 endHour.GetHour(),
                                                 endHour.GetMinute(), 0)

                totalSpan += endHourCopy.Subtract(startHourCopy).GetMinutes()

                localStart = copyDateTime(schedule.start)

                if localStart.IsLaterThan(endHourCopy):
                    position += endHourCopy.Subtract(
                        startHourCopy).GetMinutes()
                    continue

                if startHourCopy.IsLaterThan(localStart):
                    localStart = startHourCopy

                localEnd = copyDateTime(schedule.end)

                if startHourCopy.IsLaterThan(localEnd):
                    continue

                position += localStart.Subtract(startHourCopy).GetMinutes()

                if localEnd.IsLaterThan(endHourCopy):
                    localEnd = endHourCopy

                scheduleSpan += localEnd.Subtract(localStart).GetMinutes()

        return dayCount * totalTime * scheduleSpan / totalSpan, dayCount * totalTime * position / totalSpan, totalTime * dayCount
Beispiel #22
0
    def __init__(self, parent):
        wx.Frame.__init__(self,
                          parent,
                          title='Write Cap',
                          size=(CalcFormLength(), CalcFormHeight()),
                          style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER)

        wx.Frame.CenterOnScreen(self)
        panel = wx.Panel(self, -1)
        BackGroundColour = (233, 228, 214)
        panel.SetBackgroundColour(BackGroundColour)
        font16 = wx.Font(16, wx.FONTFAMILY_SWISS, wx.NORMAL, wx.NORMAL)
        font12 = wx.Font(12, wx.FONTFAMILY_SWISS, wx.NORMAL, wx.NORMAL)
        font10 = wx.Font(10, wx.FONTFAMILY_SWISS, wx.NORMAL, wx.NORMAL)

        self.StatusBar = wx.StatusBar(self, -1)
        self.StatusBar.SetFieldsCount(4)

        self.WriteFacilityText = wx.StaticText(panel,
                                               -1,
                                               u'Facility',
                                               pos=(15, 25),
                                               size=(120, 30))
        self.WriteFacilityText.SetFont(font16)

        self.WriteFacilityTextCtrl = wx.TextCtrl(panel,
                                                 -1,
                                                 '',
                                                 pos=(150, 25),
                                                 size=(175, -1))
        self.WriteFacilityTextCtrl.SetFont(font10)
        self.WriteFacilityTextCtrl.SetMaxLength(MAX_STRING_LENGTH)

        self.WriteDrText = wx.StaticText(panel,
                                         -1,
                                         u'Doctor',
                                         pos=(15, 50),
                                         size=(120, 30))
        self.WriteDrText.SetFont(font16)

        self.WriteDoctorTextCtrl = wx.TextCtrl(panel,
                                               -1,
                                               '',
                                               pos=(150, 50),
                                               size=(175, -1))
        self.WriteDoctorTextCtrl.SetFont(font10)
        self.WriteDoctorTextCtrl.SetMaxLength(MAX_STRING_LENGTH)

        # self.WriteDrChoice = wx.ComboBox(panel, -1, 'Dr. Cook', pos = (150, 50), size = (175, 25),
        # choices = [u'Dr. Bang', u'Dr Camuti', u'C. Bourgelat', u'T. Burgess', u'Dr. Ashford'],	style = wx.CB_DROPDOWN)
        # self.WriteDrChoice.SetFont(font12)

        self.WriteTreatmentText = wx.StaticText(panel,
                                                -1,
                                                u'Treatment',
                                                pos=(15, 75),
                                                size=(120, 30))
        self.WriteTreatmentText.SetFont(font16)

        self.WriteTreatmentTextCtrl = wx.TextCtrl(panel,
                                                  -1,
                                                  '',
                                                  pos=(150, 75),
                                                  size=(175, -1))
        self.WriteTreatmentTextCtrl.SetFont(font10)
        self.WriteTreatmentTextCtrl.SetMaxLength(MAX_STRING_LENGTH)

        # self.WriteMedChoice = wx.ComboBox(panel, -1, '', pos = (150, 75), size = (175, 25),
        # choices = [u'', u'Lollypop', u'Pat on the Head', u'Thorzine'],	style = wx.CB_DROPDOWN)
        #self.WriteMedChoice.SetFont(font12)

        self.WriteDoseText = wx.StaticText(panel,
                                           -1,
                                           u'Dose Freq.',
                                           pos=(15, 100),
                                           size=(120, 30))
        self.WriteDoseText.SetFont(font16)

        self.WriteDoseChoice = wx.ComboBox(
            panel,
            -1,
            '1/day',
            pos=(150, 100),
            size=(175, 25),
            choices=[
                u'1/day', u'2/day', u'3/day', u'4/day', u'1/week', u'1/month'
            ],
            style=wx.CB_DROPDOWN | wx.CB_READONLY)
        self.WriteDoseChoice.SetFont(font12)
        self.Bind(wx.EVT_COMBOBOX, self.on_DoseChange, self.WriteDoseChoice)

        self.WriteDoseCountText = wx.StaticText(panel,
                                                -1,
                                                u'Dose Count',
                                                pos=(15, 125),
                                                size=(120, 30))
        self.WriteDoseCountText.SetFont(font16)

        self.WriteDoseCount = wx.SpinCtrl(panel,
                                          -1,
                                          pos=(150, 125),
                                          size=(175, 25),
                                          initial=30,
                                          min=1,
                                          max=120)
        self.WriteDoseCount.SetFont(font12)
        self.Bind(wx.EVT_SPINCTRL, self.on_DoseChange, self.WriteDoseCount)

        self.WriteTreatmentLengthText = wx.StaticText(panel,
                                                      -1,
                                                      u'Treatment Length',
                                                      pos=(350, 110),
                                                      size=(120, 30))
        self.WriteTreatmentLengthOutText = wx.StaticText(panel,
                                                         -1,
                                                         u'30 Days',
                                                         pos=(350, 125),
                                                         size=(120, 30))

        self.WriteClientText = wx.StaticText(panel,
                                             -1,
                                             u'Client',
                                             pos=(15, 150),
                                             size=(120, 30))
        self.WriteClientText.SetFont(font16)

        self.WriteClientTextCtrl = wx.TextCtrl(panel,
                                               -1,
                                               u'',
                                               pos=(150, 150),
                                               size=(175, -1))
        self.WriteClientTextCtrl.SetFont(font10)
        self.WriteClientTextCtrl.SetMaxLength(MAX_STRING_LENGTH)

        self.WritePatientText = wx.StaticText(panel,
                                              -1,
                                              u'Patient',
                                              pos=(15, 175),
                                              size=(120, 30))
        self.WritePatientText.SetFont(font16)

        self.WritePatientTextCtrl = wx.TextCtrl(panel,
                                                -1,
                                                u'',
                                                pos=(150, 175),
                                                size=(175, -1))
        self.WritePatientTextCtrl.SetFont(font10)
        self.WritePatientTextCtrl.SetMaxLength(MAX_STRING_LENGTH)

        self.WriteClientText = wx.StaticText(panel,
                                             -1,
                                             u'Start Date',
                                             pos=(15, 200),
                                             size=(120, 30))
        self.WriteClientText.SetFont(font16)

        self.Calendar = wx.DatePickerCtrl(panel, -1, pos=(150, 200))
        self.Calendar.SetRange(wx.DateTime_Now() - wx.DateSpan(days=1),
                               wx.DateTime_Now() + wx.DateSpan(days=90))

        self.WriteStartTimeText = wx.StaticText(panel,
                                                -1,
                                                u'Start Time',
                                                pos=(15, 225),
                                                size=(120, 30))
        self.WriteStartTimeText.SetFont(font16)
        self.WriteColonText = wx.StaticText(panel,
                                            -1,
                                            u':',
                                            pos=(200, 225),
                                            size=(120, 30))
        self.WriteColonText.SetFont(font16)

        now = datetime.datetime.now()
        if now.hour == 23:
            InitHour = 0
        else:
            InitHour = now.hour + 1
        self.WriteStartHours = wx.SpinCtrl(panel,
                                           -1,
                                           pos=(150, 225),
                                           size=(50, 25),
                                           initial=InitHour,
                                           min=0,
                                           max=23)
        self.WriteStartHours.SetFont(font12)
        self.WriteStartMins = wx.SpinCtrl(panel,
                                          -1,
                                          pos=(210, 225),
                                          size=(50, 25),
                                          initial=0,
                                          min=0,
                                          max=59)
        self.WriteStartMins.SetFont(font12)

        self.WriteWriteButton = wx.Button(panel,
                                          -1,
                                          label='Write',
                                          pos=(150, 350),
                                          size=(150, 50))
        self.WriteWriteButton.SetFont(font16)
        self.Bind(wx.EVT_BUTTON, self.on_WriteWriteButton,
                  self.WriteWriteButton)

        self.WriteEraseButton = wx.Button(panel,
                                          -1,
                                          label='Erase Cap',
                                          pos=(300, 350),
                                          size=(150, 50))
        self.WriteEraseButton.SetFont(font16)
        self.Bind(wx.EVT_BUTTON, self.on_WriteEraseButton,
                  self.WriteEraseButton)

        self.WriteBackButton = wx.Button(panel,
                                         -1,
                                         label='Back',
                                         pos=(450, 350),
                                         size=(150, 50))
        self.WriteBackButton.SetFont(font16)
        self.Bind(wx.EVT_BUTTON, self.on_WriteBackButton, self.WriteBackButton)
Beispiel #23
0
    def __init__(self, *args, **kwds):
        size = (80, 80)
        # begin wxGlade: MyFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.panel_1 = wx.Panel(self, wx.ID_ANY)
        self.userBox = wx.ComboBox(self.panel_1,
                                   wx.ID_ANY,
                                   choices=["DISTINCT", "ALL"],
                                   style=wx.CB_DROPDOWN | wx.TE_PROCESS_ENTER)
        self.majorListBox = wx.CheckListBox(
            self.panel_1,
            wx.ID_ANY,
            choices=[("c"), ("a"), ("b"), ("d")],
            style=wx.LB_ALWAYS_SB | wx.LB_MULTIPLE,
            size=size)
        self.allButton_1 = wx.Button(self.panel_1, wx.ID_ANY, ("ALL"))
        self.allButton_1.cat = "MAJOR"
        self.clearButton_1 = wx.Button(self.panel_1, wx.ID_ANY, ("CLEAR"))
        self.clearButton_1.cat = "MAJOR"
        self.allButton_2 = wx.Button(self.panel_1, wx.ID_ANY, ("ALL"))
        self.allButton_2.cat = "LEVEL"
        self.clearButton_2 = wx.Button(self.panel_1, wx.ID_ANY, ("CLEAR"))
        self.clearButton_2.cat = "LEVEL"
        self.allButton_3 = wx.Button(self.panel_1, wx.ID_ANY, ("ALL"))
        self.allButton_3.cat = "MACHINE"
        self.clearButton_3 = wx.Button(self.panel_1, wx.ID_ANY, ("CLEAR"))
        self.clearButton_3.cat = "MACHINE"
        self.levelListBox = wx.CheckListBox(
            self.panel_1,
            wx.ID_ANY,
            choices=[("c"), ("a"), ("b"), ("d")],
            style=wx.LB_ALWAYS_SB | wx.LB_MULTIPLE,
            size=size)
        self.machineListBox = wx.CheckListBox(self.panel_1,
                                              wx.ID_ANY,
                                              choices=[("c"), ("a"), ("b"),
                                                       ("d")],
                                              style=wx.LB_ALWAYS_SB
                                              | wx.LB_MULTIPLE,
                                              size=size)

        self.startCheckbox = wx.CheckBox(self.panel_1, wx.ID_ANY, "")
        self.startDate = wx.GenericDatePickerCtrl(self.panel_1,
                                                  size=(120, -1),
                                                  style=wx.DP_DROPDOWN)
        # self.startDateSelection = wx.DateTime.Today().FormatISODate().replace('-',"")
        self.startDateSelection = "%"
        self.startDate.SetRange(
            wx.DateTime.Today().__add__(wx.DateSpan(years=-5)),
            wx.DateTime.Today())
        self.endCheckbox = wx.CheckBox(self.panel_1, wx.ID_ANY, "")
        self.endDate = wx.GenericDatePickerCtrl(self.panel_1,
                                                size=(120, -1),
                                                style=wx.DP_DROPDOWN)
        self.endDateSelection = wx.DateTime.Today().__add__(
            wx.DateSpan(days=1)).FormatISODate().replace('-', "")
        self.endDate.SetValue(wx.DateTime.Today().__add__(wx.DateSpan(days=1)))

        self.hourBox = wx.CheckBox(self.panel_1, wx.ID_ANY, "HOURLY DATA")
        self.weeklyBox = wx.CheckBox(self.panel_1, wx.ID_ANY, "WEEKLY DATA")
        self.timedBox = wx.CheckBox(self.panel_1, wx.ID_ANY, "TIMED DATA")
        self.runButton = wx.Button(self.panel_1, wx.ID_ANY, (" RUN "))
        self.appendBox = wx.CheckBox(self.panel_1, wx.ID_ANY, "APPEND REPORTS")
        self.exportButton = wx.Button(self.panel_1, wx.ID_ANY, ("EXPORT"))
        self.exportButton.Disable()

        self.notebook = TestNB(self.panel_1, wx.ID_ANY)
        self.hourReports = False
        self.weeklyReports = False
        self.hourList = []
        for i in range(9, 21, 1):
            self.hourList.append(str(i))
        self.user = None
        self.singleUser = False
        self.umsDB = DatabaseHandler(self)
        self.majorList = []
        self.machineList = []
        self.levelList = []
        self.reportDict = {}

        self.__set_properties()
        self.__do_layout()
        self.__set_values()
Beispiel #24
0
    def _OnPaintHeaders(self, evt):
        dc = wx.PaintDC(self._headerPanel)
        if 'phoenix' not in wx.PlatformInfo:
            dc.BeginDrawing()
        try:
            dc.SetBackground(wx.Brush(SCHEDULER_BACKGROUND_BRUSH))
            dc.SetPen(FOREGROUND_PEN)
            dc.Clear()
            dc.SetFont(wx.NORMAL_FONT)

            if self._drawerClass.use_gc:
                context = wx.GraphicsContext.Create(dc)
            else:
                context = dc

            drawer = self._drawerClass(context, self._lstDisplayedHours)

            if self._resizable:
                width, _ = self.GetVirtualSize()
            else:
                width, _ = self.CalcMinSize()

            day = utils.copyDate(self.GetDate())

            x, y = 0, 0

            # Take horizontal scrolling into account
            x0, _ = self.GetViewStart()
            xu, _ = self.GetScrollPixelsPerUnit()
            x0 *= xu
            x -= x0

            if self._viewType == wxSCHEDULER_DAILY:
                if self._style == wxSCHEDULER_VERTICAL:
                    x += LEFT_COLUMN_SIZE
                    width -= LEFT_COLUMN_SIZE
                theDay = utils.copyDateTime(day)
                maxDY = 0
                for idx in xrange(self._periodCount):
                    _, h = self._paintDailyHeaders(
                        drawer, theDay,
                        x + 1.0 * width / self._periodCount * idx, y,
                        1.0 * width / self._periodCount, 36)
                    maxDY = max(maxDY, h)
                    theDay.AddDS(wx.DateSpan(days=1))
                h = maxDY
            elif self._viewType == wxSCHEDULER_WEEKLY:
                if self._style == wxSCHEDULER_VERTICAL:
                    x += LEFT_COLUMN_SIZE
                    width -= LEFT_COLUMN_SIZE
                theDay = utils.copyDateTime(day)
                maxDY = 0
                for idx in xrange(self._periodCount):
                    h = self._paintWeeklyHeaders(
                        drawer, theDay,
                        x + 1.0 * width / self._periodCount * idx, y,
                        1.0 * width / self._periodCount, 36)
                    maxDY = max(maxDY, h)
                    theDay.AddDS(wx.DateSpan(weeks=1))
                h = maxDY
            elif self._viewType == wxSCHEDULER_MONTHLY:
                _, h = self._paintMonthlyHeaders(drawer, day, x, y, width, 36)

            minW, minH = self._headerPanel.GetMinSize()
            if minH != h:
                self._headerPanel.SetMinSize(wx.Size(-1, h))
                self._headerPanel.GetParent().Layout()
        finally:
            if 'phoenix' not in wx.PlatformInfo:
                dc.EndDrawing()
Beispiel #25
0
    def _paintMonthly(self, drawer, day, x, y, width, height):
        """
		Draw month's calendar using calendar module functions
		"""

        if self._drawHeaders:
            w, h = self._paintMonthlyHeaders(drawer, day, x, y, width, height)
        else:
            w, h = width, 0

        y += h
        height -= h

        if self._style == wxSCHEDULER_VERTICAL:
            month = calendar.monthcalendar(day.GetYear(), day.GetMonth() + 1)

            for w, monthWeek in enumerate(month):
                for d, monthDay in enumerate(monthWeek):
                    cellW, cellH = 1.0 * width / 7, 1.0 * height / len(month)

                    if monthDay == 0:
                        theDay = None
                        schedules = []
                        highlight = False
                    else:
                        theDay = day
                        theDay.SetDay(monthDay)
                        theDay.SetHour(0)
                        theDay.SetMinute(0)
                        theDay.SetSecond(0)

                        end = utils.copyDateTime(theDay)
                        if 'phoenix' in wx.PlatformInfo:
                            end.Add(wx.DateSpan(days=1))
                        else:
                            end.AddDS(wx.DateSpan(days=1))

                        schedules = self._getSchedInPeriod(
                            self._schedules, theDay, end)

                        # Recherche la couleur par défaut pour le jour
                        highlight = theDay.IsSameDate(wx.DateTime.Now())
                        if self.joursSpeciaux != None and highlight == False:
                            couleur = self.joursSpeciaux.GetCouleur(theDay)
                            if couleur != None: highlight = couleur

                        self._datetimeCoords.append(
                            (utils.copyDateTime(theDay),
                             wx.Point(d * cellW, w * cellH),
                             wx.Point(d * cellW + cellW, w * cellH + cellH)))

                    self._schedulesCoords.extend(
                        drawer.DrawSchedulesCompact(theDay, schedules,
                                                    d * cellW, w * cellH + y,
                                                    cellW, cellH, highlight))

            return (max(MONTH_CELL_SIZE_MIN.width * 7, width),
                    max(MONTH_CELL_SIZE_MIN.height * (w + 1), height))
        else:
            day.SetDay(1)
            day.SetHour(0)
            day.SetMinute(0)
            day.SetSecond(0)

            daysCount = wx.DateTime.GetNumberOfDaysInMonth(day.GetMonth())

            minHeight = h

            w, h = self._paintPeriod(drawer, day, daysCount, x, y, width,
                                     height)
            minHeight += h

            return w, minHeight
Beispiel #26
0
    def InitUI(self):

        labelfont = wx.Font(wx.NORMAL_FONT.GetPointSize(),
                            wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                            wx.FONTWEIGHT_BOLD)
        title_label = wx.StaticText(self, wx.ID_ANY, '查询条件')
        title_label.SetFont(labelfont)

        line1 = wx.StaticLine(self,
                              wx.ID_ANY,
                              size=(20, -1),
                              style=wx.LI_HORIZONTAL)

        self.inStock_cb = wx.CheckBox(self,
                                      wx.ID_ANY,
                                      "入库",
                                      style=wx.ALIGN_RIGHT)
        self.outStock_cb = wx.CheckBox(self,
                                       wx.ID_ANY,
                                       "出库",
                                       style=wx.ALIGN_RIGHT)
        self.inStock_cb.SetValue(True)
        self.outStock_cb.SetValue(True)

        goodsname_label = wx.StaticText(self, wx.ID_ANY, '物品名称:')
        date_label = wx.StaticText(self, wx.ID_ANY, '起止日期:')
        concat_label = wx.StaticText(self, wx.ID_ANY, '至')

        self.goodsname_tc = wx.TextCtrl(self, wx.ID_ANY, size=(120, -1))
        self.goodsname_tc.SetMaxLength(16)

        self.startdate = wx.adv.DatePickerCtrl(self,
                                               size=(120, -1),
                                               style=wx.adv.DP_DROPDOWN
                                               | wx.adv.DP_SHOWCENTURY)
        self.startdate.SetRange(
            wx.DateTime.Today().Subtract(wx.DateSpan(months=6)),
            wx.DateTime.Today())
        self.startdate.SetValue(wx.DateTime.Today().Subtract(
            wx.DateSpan(days=6)))

        self.endate = wx.adv.DatePickerCtrl(self,
                                            size=(120, -1),
                                            style=wx.adv.DP_DROPDOWN
                                            | wx.adv.DP_SHOWCENTURY)
        self.endate.SetRange(
            wx.DateTime.Today().Subtract(wx.DateSpan(months=6)),
            wx.DateTime.Today())

        gbSizer = wx.GridBagSizer(5, 5)
        gbSizer.Add(self.inStock_cb, (0, 0), (1, 1), wx.ALL, 5)
        gbSizer.Add(self.outStock_cb, (0, 1), (1, 1), wx.ALL, 5)
        gbSizer.Add(goodsname_label, (1, 0), (1, 1),
                    wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
        gbSizer.Add(self.goodsname_tc, (1, 1), (1, 1), wx.ALL, 5)
        gbSizer.Add(date_label, (2, 0), (1, 1),
                    wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
        gbSizer.Add(self.startdate, (2, 1), (1, 1), wx.ALL, 5)
        gbSizer.Add(concat_label, (2, 2), (1, 1), wx.ALL | wx.ALIGN_CENTER, 5)
        gbSizer.Add(self.endate, (2, 3), (1, 1), wx.ALL, 5)

        hBox_btn = wx.BoxSizer(wx.HORIZONTAL)
        hBox_btn.AddStretchSpacer()
        b = buttons.GenButton(self, -1, "查询")
        hBox_btn.Add(b, 0, wx.ALL, 5)
        self.Bind(wx.EVT_BUTTON, self.OnSearch, b)
        b = buttons.GenButton(self, -1, "导出EXCEL")
        self.Bind(wx.EVT_BUTTON, self.OnDownload, b)
        hBox_btn.Add(b, 0, wx.ALL, 5)
        hBox_btn.AddStretchSpacer()

        #grid
        self.grid = gridlib.Grid(self)
        table = StockDataTable([])
        self.grid.SetTable(table, True)
        self.grid.SetMargins(0, 0)
        self.grid.AutoSizeColumns(True)

        vBox = wx.BoxSizer(wx.VERTICAL)
        vBox.Add(title_label, 0, wx.ALL, 5)
        vBox.Add(line1, 0,
                 wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 0)
        vBox.Add(gbSizer, 0, wx.ALL, 5)
        vBox.Add(hBox_btn, 0, wx.ALL | wx.EXPAND, 5)
        vBox.Add(self.grid, 1, wx.GROW | wx.ALL, 5)

        self.SetSizer(vBox)
Beispiel #27
0
    def _paintWeekly(self, drawer, day, x, y, width, height):
        """
		Display weekly schedule
		"""

        firstDay = utils.setToWeekDayInSameWeek(day, 0, self._weekstart)
        firstDay.SetHour(0)
        firstDay.SetMinute(0)
        firstDay.SetSecond(0)

        minWidth = minHeight = 0

        if self._style == wxSCHEDULER_VERTICAL:
            x += LEFT_COLUMN_SIZE
            width -= LEFT_COLUMN_SIZE

        maxDY = 0

        if self._drawHeaders:
            theDay = utils.copyDateTime(day)
            for idx in xrange(self._periodCount):
                maxDY = max(
                    maxDY,
                    self._paintWeeklyHeaders(
                        drawer, theDay,
                        x + 1.0 * width / self._periodCount * idx, y,
                        1.0 * width / self._periodCount, height))
                if 'phoenix' in wx.PlatformInfo:
                    theDay.Add(wx.DateSpan(weeks=1))
                else:
                    theDay.AddDS(wx.DateSpan(weeks=1))

        if self._style == wxSCHEDULER_VERTICAL:
            x -= LEFT_COLUMN_SIZE
            width += LEFT_COLUMN_SIZE

        minHeight += maxDY
        y += maxDY
        height -= maxDY

        if self._style == wxSCHEDULER_VERTICAL:
            w, h = drawer.DrawHours(x, y, width, height, self._style)

            minWidth += w
            x += w
            width -= w

            day = utils.copyDateTime(firstDay)

            for idx in xrange(self._periodCount):
                for weekday in xrange(7):
                    theDay = utils.setToWeekDayInSameWeek(
                        utils.copyDateTime(day), weekday, self._weekstart)
                    self._paintDay(
                        drawer, theDay, x + (weekday + 7 * idx) * 1.0 * width /
                        7 / self._periodCount, y,
                        1.0 * width / 7 / self._periodCount, height)
                if 'phoenix' in wx.PlatformInfo:
                    day.Add(wx.DateSpan(weeks=1))
                else:
                    day.AddDS(wx.DateSpan(weeks=1))

            return max(
                WEEK_SIZE_MIN.width * self._periodCount + LEFT_COLUMN_SIZE,
                width), max(WEEK_SIZE_MIN.height, height)
        else:
            w, h = self._paintPeriod(drawer, firstDay, 7 * self._periodCount,
                                     x, y, width, height)

            minWidth += w
            minHeight += h

            return max(
                WEEK_SIZE_MIN.width * self._periodCount + LEFT_COLUMN_SIZE,
                minWidth), minHeight
Beispiel #28
0
    def _paintPeriod(self, drawer, start, daysCount, x, y, width, height):
        end = utils.copyDateTime(start)
        if 'phoenix' in wx.PlatformInfo:
            end.Add(wx.DateSpan(days=daysCount))
        else:
            end.AddDS(wx.DateSpan(days=daysCount))

        blocks = self._splitSchedules(
            self._getSchedInPeriod(self._schedules, start, end))
        offsetY = 0

        if self._showOnlyWorkHour:
            workingHours = [(self._startingHour, self._startingPauseHour),
                            (self._endingPauseHour, self._endingHour)]
        else:
            workingHours = [(self._startingHour, self._endingHour)]

        if not self.pageNumber:
            self.pageCount = 1
            self.pageLimits = [0]

            pageHeight = self.GetSize().GetHeight() - 20
            currentPageHeight = y

        for dayN in xrange(daysCount):
            theDay = utils.copyDateTime(start)
            if 'phoenix' in wx.PlatformInfo:
                theDay.Add(wx.DateSpan(days=dayN))
            else:
                theDay.AddDS(wx.DateSpan(days=dayN))

            # Recherche la couleur par défaut pour le jour
            highlight = False
            if self._viewType != wxSCHEDULER_DAILY:
                highlight = theDay.IsSameDate(wx.DateTime.Now())

            # Recherche si c'est un jour férié ou un jour de vacances
            if self.joursSpeciaux != None and self._viewType != wxSCHEDULER_DAILY and highlight == False:
                couleur = self.joursSpeciaux.GetCouleur(theDay)
                if couleur != None:
                    highlight = couleur

            drawer.DrawDayBackground(x + 1.0 * width / daysCount * dayN,
                                     y,
                                     1.0 * width / daysCount,
                                     height,
                                     highlight=highlight)

        if blocks:
            dayWidth = width / len(blocks)

            for idx, block in enumerate(blocks):
                maxDY = 0

                for schedule in block:
                    show = True
                    if self.pageNumber is not None:
                        if self._schedulesPages.get(schedule.GetId(),
                                                    None) != self.pageNumber:
                            show = False

                    if show:
                        if self._style == wxSCHEDULER_VERTICAL:
                            xx, yy, w, h = drawer.DrawScheduleVertical(
                                schedule, start, workingHours,
                                x + dayWidth * idx, y, dayWidth, height)
                        elif self._style == wxSCHEDULER_HORIZONTAL:
                            xx, yy, w, h = drawer.DrawScheduleHorizontal(
                                schedule, start, daysCount, workingHours, x,
                                y + offsetY, width, height)
                            maxDY = max(maxDY, h)

                        if self.pageNumber is None:
                            if currentPageHeight + h >= pageHeight:
                                pageNo = self.pageCount + 1
                            else:
                                pageNo = self.pageCount

                            self._schedulesPages[schedule.GetId()] = pageNo

                        self._schedulesCoords.append(
                            (schedule, wx.Point(xx,
                                                yy), wx.Point(xx + w, yy + h)))

                offsetY += maxDY

                if not self.pageNumber:
                    currentPageHeight += maxDY
                    if currentPageHeight >= pageHeight:
                        self.pageLimits.append(currentPageHeight - maxDY)
                        currentPageHeight = maxDY
                        self.pageCount += 1

        for dayN in xrange(daysCount):
            theDay = utils.copyDateTime(start)
            if 'phoenix' in wx.PlatformInfo:
                theDay.Add(wx.DateSpan(days=dayN))
            else:
                theDay.AddDS(wx.DateSpan(days=dayN))
            theDay.SetSecond(0)

            nbHours = len(self._lstDisplayedHours)

            for idx, hour in enumerate(self._lstDisplayedHours):
                theDay.SetHour(hour.GetHour())
                theDay.SetMinute(hour.GetMinute())

                if self._style == wxSCHEDULER_VERTICAL:
                    self._datetimeCoords.append(
                        (utils.copyDateTime(theDay),
                         wx.Point(x + 1.0 * width * dayN / daysCount,
                                  y + 1.0 * height * idx / nbHours),
                         wx.Point(x + 1.0 * width * (dayN + 1) / daysCount,
                                  y + 1.0 * height * (idx + 1) / nbHours)))
                else:
                    self._datetimeCoords.append(
                        (utils.copyDateTime(theDay),
                         wx.Point(
                             x + 1.0 * width * (nbHours * dayN + idx) /
                             (nbHours * daysCount), y),
                         wx.Point(
                             x + 1.0 * width * (nbHours * dayN + idx + 1) /
                             (nbHours * daysCount), y + height)))

        if self._style == wxSCHEDULER_VERTICAL:
            return max(width, DAY_SIZE_MIN.width), max(height,
                                                       DAY_SIZE_MIN.height)
        else:
            return max(width, DAY_SIZE_MIN.width), offsetY
Beispiel #29
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1, style=wx.CLIP_CHILDREN)

        # 计算日期选择控件的范围
        now = wx.DateTime.Today()
        beginDate = now.Subtract(wx.DateSpan(months=6))

        labelfont = wx.Font(wx.NORMAL_FONT.GetPointSize(),
                            wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                            wx.FONTWEIGHT_BOLD)
        bs1 = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, wx.ID_ANY, '信息登记')
        label.SetFont(labelfont)
        bs1.Add(label, 0, wx.ALL | wx.BOTTOM, 0)

        gbSizer = wx.GridBagSizer(5, 5)
        label = wx.StaticText(self, wx.ID_ANY, '名称:')
        self.tc_goodsname = wx.TextCtrl(self,
                                        wx.ID_ANY,
                                        '',
                                        style=wx.TE_READONLY)
        gbSizer.Add(label, (0, 0), (1, 1), wx.ALL | wx.ALIGN_RIGHT, 5)
        gbSizer.Add(self.tc_goodsname, (0, 1), (1, 1), wx.ALL | wx.EXPAND, 5)

        label = wx.StaticText(self, wx.ID_ANY, '物品数量:')
        self.tc_goodsNum = IntCtrl(self)
        self.tc_goodsNum.SetMin(1)
        self.tc_goodsNum.SetNoneAllowed(True)
        self.tc_goodsNum.SetValue(None)
        self.tc_goodsNum.SetMaxLength(12)
        gbSizer.Add(label, (0, 2), (1, 1), wx.ALL | wx.ALIGN_RIGHT, 5)
        gbSizer.Add(self.tc_goodsNum, (0, 3), (1, 1), wx.ALL | wx.EXPAND, 5)

        label = wx.StaticText(self, wx.ID_ANY, '类别:')
        self.tc_goodcatagory = wx.TextCtrl(self,
                                           wx.ID_ANY,
                                           '',
                                           style=wx.TE_READONLY)
        gbSizer.Add(label, (1, 0), (1, 1), wx.ALL, 5)
        gbSizer.Add(self.tc_goodcatagory, (1, 1), (1, 1), wx.ALL | wx.EXPAND,
                    5)

        label = wx.StaticText(self, wx.ID_ANY, '经办人:')
        self.tc_op = wx.TextCtrl(self, wx.ID_ANY, '')
        self.tc_op.SetMaxLength(10)
        gbSizer.Add(label, (1, 2), (1, 1), wx.ALL | wx.ALIGN_RIGHT, 5)
        gbSizer.Add(self.tc_op, (1, 3), (1, 1), wx.ALL | wx.EXPAND, 5)

        label = wx.StaticText(self, wx.ID_ANY, '规格:')
        self.tc_goodsunit = wx.TextCtrl(
            self,
            wx.ID_ANY,
            '',
        )
        self.tc_goodsunit.SetMaxLength(6)
        gbSizer.Add(label, (2, 0), (1, 1), wx.ALL | wx.ALIGN_RIGHT, 5)
        gbSizer.Add(self.tc_goodsunit, (2, 1), (1, 1), wx.ALL | wx.EXPAND, 5)

        label = wx.StaticText(self, wx.ID_ANY, '经办地点:')
        self.tc_address = wx.TextCtrl(self, wx.ID_ANY, '')
        self.tc_address.SetMaxLength(24)
        gbSizer.Add(label, (2, 2), (1, 1), wx.ALL | wx.ALIGN_RIGHT, 5)
        gbSizer.Add(self.tc_address, (2, 3), (1, 1), wx.ALL | wx.EXPAND, 5)

        label = wx.StaticText(self, wx.ID_ANY, '单价:')
        self.tc_goodsprice = wx.TextCtrl(
            self,
            wx.ID_ANY,
            '',
        )
        self.tc_goodsprice.SetMaxLength(12)
        self.tc_goodsprice.Bind(wx.EVT_CHAR, self.OnFloatChar)
        gbSizer.Add(label, (3, 0), (1, 1), wx.ALL, 5)
        gbSizer.Add(self.tc_goodsprice, (3, 1), (1, 1), wx.ALL | wx.EXPAND, 5)

        label = wx.StaticText(self, wx.ID_ANY, '登记日期:')
        self.op_date = wx.adv.DatePickerCtrl(self,
                                             size=(120, -1),
                                             style=wx.adv.DP_DROPDOWN
                                             | wx.adv.DP_SHOWCENTURY)
        #self.Bind(wx.adv.EVT_DATE_CHANGED, self.OnDateChanged, self.op_date)
        self.op_date.SetRange(beginDate, wx.DateTime.Today())
        gbSizer.Add(label, (3, 2), (1, 1), wx.ALL | wx.ALIGN_RIGHT, 5)
        gbSizer.Add(self.op_date, (3, 3), (1, 1), wx.ALL | wx.EXPAND, 5)

        gbSizer.AddGrowableCol(1)
        gbSizer.AddGrowableCol(3)

        bs2 = wx.BoxSizer(wx.HORIZONTAL)
        bs2.AddStretchSpacer(1)
        b = buttons.GenButton(self, -1, "入库")
        self.Bind(wx.EVT_BUTTON, self.OnInStock, b)
        bs2.Add(b, 0, wx.ALL, 5)
        b = buttons.GenButton(self, -1, "出库")
        self.Bind(wx.EVT_BUTTON, self.OnOutStock, b)
        bs2.Add(b, 0, wx.ALL, 5)
        b = buttons.GenButton(self, -1, "重置")
        self.Bind(wx.EVT_BUTTON, self.OnReset, b)
        bs2.Add(b, 0, wx.ALL, 5)
        bs2.AddStretchSpacer(1)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(bs1, 0, wx.ALL, 5)
        line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL)
        sizer.Add(line, 0,
                  wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 0)
        sizer.Add(gbSizer, 0, wx.ALL | wx.EXPAND, 5)
        sizer.Add(bs2, 0, wx.ALL | wx.EXPAND, 0)

        bs3 = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, wx.ID_ANY, '出入库记录')
        label.SetFont(labelfont)
        bs3.Add(label, 0, wx.ALL, 0)

        sizer.Add(bs3, 0, wx.ALL, 5)
        line1 = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL)
        sizer.Add(line1, 0,
                  wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 0)

        bs4 = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, wx.ID_ANY, '物品名称:')
        self.s_goodsname = wx.TextCtrl(self,
                                       wx.ID_ANY,
                                       size=(120, -1),
                                       style=wx.TE_PROCESS_ENTER)
        self.s_goodsname.SetMaxLength(16)
        self.Bind(wx.EVT_TEXT_ENTER, self.OnTextEnter, self.s_goodsname)

        bs4.Add(label, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL,
                5)
        bs4.Add(self.s_goodsname, 0, wx.ALL | wx.EXPAND, 5)

        label = wx.StaticText(self, wx.ID_ANY, '登记日期:')
        self.registerDate = wx.adv.DatePickerCtrl(self,
                                                  size=(120, -1),
                                                  style=wx.adv.DP_DROPDOWN
                                                  | wx.adv.DP_SHOWCENTURY)
        self.registerDate.SetRange(
            wx.DateTime.Today().Subtract(wx.DateSpan(months=6)),
            wx.DateTime.Today())
        self.Bind(wx.adv.EVT_DATE_CHANGED, self.OnDateChanged,
                  self.registerDate)

        bs4.Add(label, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL,
                5)
        bs4.Add(self.registerDate, 0, wx.ALL | wx.EXPAND, 5)
        cBtn = wx.ContextHelpButton(self)
        cBtn.SetHelpText("默认显示当天登记的记录,并且可以对记录进行删除和修改操作。")
        bs4.Add(cBtn, 0, wx.ALL | wx.EXPAND, 5)

        bs5 = wx.BoxSizer(wx.VERTICAL)
        self.list = SockListCtrl(self,
                                 -1,
                                 style=wx.LC_REPORT | wx.LC_SINGLE_SEL
                                 | wx.BORDER_NONE | wx.LC_HRULES
                                 | wx.LC_VRULES)
        self.list.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.OnRightClick)
        #self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated, self.list)
        #self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, self.list)

        bs5.Add(self.list, 1, wx.ALL | wx.EXPAND, 5)

        sizer.Add(bs4, 0, wx.ALL | wx.EXPAND, 5)
        sizer.Add(bs5, 1, wx.ALL | wx.EXPAND, 5)
        self.SetSizer(sizer)

        self.goodsId = None
        self.currentItem = None

        model.goodsDeatilModel.addListener(self.OnUpdate)
        self.queryStocksByDate()
Beispiel #30
0
 def day_inc(self, inc):
     day = self.date_picker.GetValue()
     new_day = day + wx.DateSpan(0, 0, 0, inc)
     self.date_picker.SetValue(new_day)
     self.refresh_item_list()