Example #1
0
class StatisticFrame(Frame):
    def __init__(self):
        Frame.__init__(self)
        self.pack()

        # Db
        db = Db()

        # Datetime now
        now = datetime.now()

        # Station selectbox
        stationOptions = {}
        for station in db.getStations():
            stationOptions[station.name] = station.id
        self.stationSelect = Select(self, 'Station:', stationOptions)
        self.stationSelect.setEvent(self.updateStatistic)

        # Type selectbox
        self.statisticTypeSelect = Select(self, 'Type:', {
            'Day': 'D',
            'Month': 'm',
            'Year': 'Y'
        })
        self.statisticTypeSelect.setEvent(self.updateStatistic)
        self.statisticTypeSelect.setValue('Day')

        # Date from calendar (7 Days before now)
        self.dateFromSelect = DateEntry(self,
                                        selectmode='day',
                                        date_pattern='dd.mm.y')
        self.dateFromSelect.set_date((now - timedelta(days=7)))
        self.dateFromSelect.bind("<<DateEntrySelected>>", self.updateStatistic)
        self.dateFromSelect.pack()

        # Date to calendar
        self.dateToSelect = DateEntry(self,
                                      selectmode='day',
                                      date_pattern='dd.mm.y')
        self.dateToSelect.set_date(now)
        self.dateToSelect.bind("<<DateEntrySelected>>", self.updateStatistic)
        self.dateToSelect.pack()

        # Statistic
        self.statistic = StatisticPrint(self, self.stationSelect.get(),
                                        self.dateFromSelect.get_date(),
                                        self.dateToSelect.get_date(),
                                        self.statisticTypeSelect.get())

    def updateStatistic(self, *args):
        self.statistic.set(self.stationSelect.get(),
                           self.dateFromSelect.get_date(),
                           self.dateToSelect.get_date(),
                           self.statisticTypeSelect.get())
Example #2
0
    def __init__(self):
        Frame.__init__(self)
        self.pack()

        # Db
        db = Db()

        now = datetime.now()

        # Station selectbox
        stationOptions = {}
        for station in db.getStations():
            stationOptions[station.name] = station.id
        self.stationSelect = Select(self, 'Station:', stationOptions)
        self.stationSelect.setEvent(self.updateStatistic)

        # Type selectbox
        self.statisticTypeSelect = Select(self, 'Type:', {
            'Day': 'day',
            'Month': 'month',
            'Year': 'year'
        })
        self.statisticTypeSelect.setEvent(self.updateStatistic)

        # Date from calendar
        self.dateFromSelect = DateEntry(self,
                                        selectmode='day',
                                        date_pattern='dd.mm.y')
        self.dateFromSelect.set_date(self.firstDayOfMonth(now))
        self.dateFromSelect.bind("<<DateEntrySelected>>", self.updateStatistic)
        self.dateFromSelect.pack()

        # Date to calendar
        self.dateToSelect = DateEntry(self,
                                      selectmode='day',
                                      date_pattern='dd.mm.y')
        self.dateToSelect.set_date(self.lastDayOfMonth(now))
        self.dateToSelect.bind("<<DateEntrySelected>>", self.updateStatistic)
        self.dateToSelect.pack()

        # Update statistic
        self.updateStatistic()
Example #3
0
class StatisticFrame(Frame):
    def __init__(self):
        Frame.__init__(self)
        self.pack()

        # Db
        db = Db()

        now = datetime.now()

        # Station selectbox
        stationOptions = {}
        for station in db.getStations():
            stationOptions[station.name] = station.id
        self.stationSelect = Select(self, 'Station:', stationOptions)
        self.stationSelect.setEvent(self.updateStatistic)

        # Type selectbox
        self.statisticTypeSelect = Select(self, 'Type:', {
            'Day': 'day',
            'Month': 'month',
            'Year': 'year'
        })
        self.statisticTypeSelect.setEvent(self.updateStatistic)

        # Date from calendar
        self.dateFromSelect = DateEntry(self,
                                        selectmode='day',
                                        date_pattern='dd.mm.y')
        self.dateFromSelect.set_date(self.firstDayOfMonth(now))
        self.dateFromSelect.bind("<<DateEntrySelected>>", self.updateStatistic)
        self.dateFromSelect.pack()

        # Date to calendar
        self.dateToSelect = DateEntry(self,
                                      selectmode='day',
                                      date_pattern='dd.mm.y')
        self.dateToSelect.set_date(self.lastDayOfMonth(now))
        self.dateToSelect.bind("<<DateEntrySelected>>", self.updateStatistic)
        self.dateToSelect.pack()

        # Update statistic
        self.updateStatistic()

    def updateStatistic(self, *args):
        StatisticPrint(self, self.stationSelect.get(),
                       self.dateFromSelect.get_date(),
                       self.dateToSelect.get_date(),
                       self.statisticTypeSelect.get())

    def firstDayOfMonth(self, d):
        return d.replace(day=1, hour=0, minute=0, second=0, microsecond=0)

    def lastDayOfMonth(self, d):
        if d.month == 12:
            return d.replace(day=31)
        return d.replace(month=d.month + 1, day=1) - timedelta(days=1)
Example #4
0
    def __init__(self, master):
        Frame.__init__(self, master)
        self.pack()

        self.wsw = SerialWrite()

        self.eyes = Eyes()
        self.head = Head()
        self.neck = Neck()
        self.arms = Arms()
        self.motor = Motor()
        self.happy = Happy()

        self.reset()

        self.servoSelect = Select(
            self, 'SERVO:', {
                '0': '0',
                '1': '1',
                '2': '2',
                '3': '3',
                '4': '4',
                '5': '5',
                '6': '6',
                '7': '7',
                '8': '8',
                '9': '9',
                '10': '10',
                '11': '11',
                '12': '12',
                '13': '13',
                '14': '14'
            })
        self.servoSelect.setValue('0')

        self.servoInt = TextField(self, 'Go To')
        self.servoInt.setValue(300)

        self.servoSpeed = TextField(self, 'Speed')
        self.servoSpeed.setValue(1)

        self.submit = Button(self, text="Submit", command=self.sendForm)
        self.submit.pack()

        frameArmR = Frame(self)
        frameArmR.pack(side=BOTTOM, padx=10, pady=10)

        self.btArUp = Button(frameArmR,
                             text="Arm right UP",
                             command=lambda: self.arms.rightUp())
        self.btArUp.pack(side=LEFT)

        self.btArC = Button(frameArmR,
                            text="Arm right Center",
                            command=lambda: self.arms.rightCenter())
        self.btArC.pack(side=LEFT)

        self.btArDown = Button(frameArmR,
                               text="Arm right Down",
                               command=lambda: self.arms.rightDown())
        self.btArDown.pack(side=LEFT)

        frameArmL = Frame(self)
        frameArmL.pack(side=BOTTOM, padx=10, pady=10)

        self.btAlUp = Button(frameArmL,
                             text="Arm left UP",
                             command=lambda: self.arms.leftUp())
        self.btAlUp.pack(side=LEFT)

        self.btAlC = Button(frameArmL,
                            text="Arm left Center",
                            command=lambda: self.arms.leftCenter())
        self.btAlC.pack(side=LEFT)

        self.btAlDown = Button(frameArmL,
                               text="Arm left Down",
                               command=lambda: self.arms.leftDown())
        self.btAlDown.pack(side=LEFT)

        frameNeck = Frame(self)
        frameNeck.pack(side=BOTTOM, padx=10, pady=10)

        self.btNup = Button(frameNeck,
                            text="Neck UP",
                            command=lambda: self.neck.up(4))
        self.btNup.pack(side=LEFT)

        self.btNd = Button(frameNeck,
                           text="Neck Center",
                           command=lambda: self.neck.center(4))
        self.btNd.pack(side=LEFT)

        self.btNdown = Button(frameNeck,
                              text="Neck Down",
                              command=lambda: self.neck.down(4))
        self.btNdown.pack(side=LEFT)

        frameShow = Frame(self)
        frameShow.pack(side=BOTTOM, padx=10, pady=10)

        self.btNshowUp = Button(frameShow,
                                text="Show Up",
                                command=lambda: self.neck.showUp(3))
        self.btNshowUp.pack(side=LEFT)

        self.btNshowDown = Button(frameShow,
                                  text="Show Down",
                                  command=lambda: self.neck.showDown(3))
        self.btNshowDown.pack(side=LEFT)

        frameHead = Frame(self)
        frameHead.pack(side=BOTTOM, padx=10, pady=10)

        self.btHleft = Button(frameHead,
                              text="Head Left",
                              command=lambda: self.head.left(4))
        self.btHleft.pack(side=LEFT)

        self.btHdefault = Button(frameHead,
                                 text="Head Center",
                                 command=lambda: self.head.center(4))
        self.btHdefault.pack(side=LEFT)

        self.btHright = Button(frameHead,
                               text="Head Right",
                               command=lambda: self.head.right(4))
        self.btHright.pack(side=LEFT)

        frameEyes = Frame(self)
        frameEyes.pack(side=BOTTOM, padx=10, pady=10)

        self.btEleft = Button(frameEyes,
                              text="Eyes Left",
                              command=lambda: self.eyes.left(4))
        self.btEleft.pack(side=LEFT)

        self.btEdefault = Button(frameEyes,
                                 text="Eyes Center",
                                 command=lambda: self.eyes.center(4))
        self.btEdefault.pack(side=LEFT)

        self.btEright = Button(frameEyes,
                               text="Eyes Right",
                               command=lambda: self.eyes.right(4))
        self.btEright.pack(side=LEFT)

        self.btEright = Button(frameEyes,
                               text="Eyes Down",
                               command=lambda: self.eyes.down(4))
        self.btEright.pack(side=LEFT)

        self.btEright = Button(frameEyes,
                               text="Eyes Up",
                               command=lambda: self.eyes.up(4))
        self.btEright.pack(side=LEFT)

        frameMotor = Frame(self)
        frameMotor.pack(side=BOTTOM, padx=10, pady=10)

        self.defaultMotorSpeed = 120
        self.btMleft = Button(
            frameMotor,
            text="Motor Left",
            command=lambda: self.motor.left(self.defaultMotorSpeed, 2))
        self.btMleft.pack(side=LEFT)

        self.btMdefault = Button(
            frameMotor,
            text="Motor Straight",
            command=lambda: self.motor.straight(self.defaultMotorSpeed, self.
                                                defaultMotorSpeed, 2))
        self.btMdefault.pack(side=LEFT)

        self.btMdefault = Button(
            frameMotor,
            text="Motor Back",
            command=lambda: self.motor.back(self.defaultMotorSpeed, self.
                                            defaultMotorSpeed, 2))
        self.btMdefault.pack(side=LEFT)

        self.btMright = Button(
            frameMotor,
            text="Motor Right",
            command=lambda: self.motor.right(self.defaultMotorSpeed, 2))
        self.btMright.pack(side=LEFT)

        frameEmotion = Frame(self)
        frameEmotion.pack(side=BOTTOM, padx=10, pady=10)

        self.btHappyShake = Button(frameEmotion,
                                   text="Happy Shake",
                                   command=lambda: self.happy.shake())
        self.btHappyShake.pack(side=LEFT)

        frameReset = Frame(self)
        frameReset.pack(side=BOTTOM, padx=10, pady=10)

        self.btReset = Button(frameReset,
                              text="Reset",
                              command=lambda: self.reset())
        self.btReset.pack(side=LEFT)