示例#1
0
文件: ask_date.py 项目: wiz21b/koi
    def __init__(self, info_text, no_date_allowed = True):
        super(DatePick, self).__init__()

        self.accepted_date = None

        layout = QVBoxLayout()

        title = _("Pick a date")
        self.setWindowTitle(title)
        layout.addWidget(TitleWidget(title, self))

        self.info_label =QLabel(info_text)
        self.qw = QCalendarWidget()

        self.info_label.setWordWrap(True)
        self.info_label.setMaximumWidth(self.qw.minimumWidth())
        layout.addWidget( self.info_label)
        layout.addWidget( self.qw)
        self.qw.activated.connect(self.date_chosen)

        self.buttons = QDialogButtonBox()

        if no_date_allowed:
            self.buttons.addButton( QPushButton("No date"), QDialogButtonBox.ButtonRole.AcceptRole)

        self.buttons.addButton( QDialogButtonBox.StandardButton.Cancel)
        self.buttons.addButton( QDialogButtonBox.Ok)

        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)

        layout.addWidget(self.buttons)
        layout.addStretch()
        self.setLayout(layout)
示例#2
0
    def paintCell(self, painter, rect, date):

        QCalendarWidget.paintCell(self, painter, rect, date)
        filelist = glob.glob('journal_[0-9]*')
        datelist = []
        for i in filelist:
            l = tuple(i[i.index('_') + 1:].split('_'))
            datelist.append(QDate(int(l[2]), int(l[1]), int(l[0])))
        if date in datelist:
            painter.fillRect(rect, self.color)
示例#3
0
class Schedule(QWizardPage):
    def __init__(self, parent):
        super(Schedule, self).__init__(parent)

        self.setTitle("Scheduling")
        self.setSubTitle("Specify the next evaluation date.")

        self.calendar = QCalendarWidget(self)
        self.calendar.setMinimumDate(QDate.currentDate())

        QVBoxLayout(self).addWidget(self.calendar)
示例#4
0
    def _initGUI(self):
        self.layout = QVBoxLayout()
        self.form = QFormLayout()

        self.name = QLineEdit()
        self.surname = QLineEdit()

        self.birthdate = QCalendarWidget()
        self.birthdate.setGridVisible(True)
        self.birthdate.setMinimumDate(QDate(1850, 1, 1))
        self.birthdate.setMaximumDate(QDate.currentDate())

        self.male = QRadioButton("Male")
        self.male.setChecked(True)
        self.female = QRadioButton("Female")

        self.height = QDoubleSpinBox()
        self.height.setMaximum(250)
        self.height.setMinimum(50)
        self.height.setValue(165)
        self.height.setSuffix(" cm")

        self.mass = QDoubleSpinBox()
        self.mass.setMaximum(300)
        self.mass.setMinimum(20)
        self.mass.setValue(60)
        self.mass.setSuffix(" Kg")

        btnLayout = QVBoxLayout()

        self.form.addRow("Name", self.name)
        self.form.addRow("Surname", self.surname)
        self.form.addRow("Birth date", self.birthdate)

        sexLayout = QHBoxLayout()
        sexLayout.addWidget(self.male)
        sexLayout.addWidget(self.female)
        self.form.addRow("Sex", sexLayout)

        self.form.addRow("Height", self.height)
        self.form.addRow("Mass", self.mass)

        self.layout.addLayout(self.form)
        self.layout.addLayout(btnLayout)
        self.setLayout(self.layout)
示例#5
0
    def createGUI(self):
        self.series = QSpinBox()
        self.series.setMinimum(1)

        self.repetitions = QSpinBox()
        self.repetitions.setMaximum(512)

        self.avgHeartRateToggle = QCheckBox()
        self.avgHeartRateToggle.toggled.connect(self._toggleHeartRateSpinBox)

        self.avgHeartRate = QSpinBox()
        self.avgHeartRate.setMinimum(30)
        self.avgHeartRate.setMaximum(250)
        self.avgHeartRate.setValue(120)
        self.avgHeartRate.setDisabled(True)

        self.dateSelector_widget = QCalendarWidget()
        self.dateSelector_widget.setMaximumDate(QDate.currentDate())

        self.addButton = QPushButton("Add pushup")
        self.addButton.setMaximumWidth(90)
        self.addButton.clicked.connect(self._createPushup)

        self.cancelButton = QPushButton("Cancel")
        self.cancelButton.setMaximumWidth(90)
        self.cancelButton.clicked.connect(self.reject)

        self.pushupForm.addRow("Series", self.series)
        self.pushupForm.addRow("Repetitions", self.repetitions)
        self.pushupForm.addRow("Store average heart rate ? ",
                               self.avgHeartRateToggle)
        self.pushupForm.addRow("Average Heart Rate", self.avgHeartRate)
        self.pushupForm.addRow("Exercise Date", self.dateSelector_widget)

        btnsLayout = QVBoxLayout()
        btnsLayout.addWidget(self.addButton)
        btnsLayout.addWidget(self.cancelButton)
        btnsLayout.setAlignment(Qt.AlignRight)

        layoutWrapper = QVBoxLayout()
        layoutWrapper.addLayout(self.pushupForm)
        layoutWrapper.addLayout(btnsLayout)

        self.setLayout(layoutWrapper)
示例#6
0
文件: ask_date.py 项目: wiz21b/koi
class DatePick(QDialog):

    def accept(self, *args, **kwargs):
        return super(DatePick,self).accept()

    def reject(self, *args, **kwargs):
        return super(DatePick,self).reject()

    @Slot(date)
    def date_chosen(self, chosen_date):
        self.accepted_date = date( chosen_date.year(), chosen_date.month(), chosen_date.day())
        self.accept()

    def resizeEvent(self, *args, **kwargs):
        self.info_label.setMaximumWidth( self.qw.width())

    def __init__(self, info_text, no_date_allowed = True):
        super(DatePick, self).__init__()

        self.accepted_date = None

        layout = QVBoxLayout()

        title = _("Pick a date")
        self.setWindowTitle(title)
        layout.addWidget(TitleWidget(title, self))

        self.info_label =QLabel(info_text)
        self.qw = QCalendarWidget()

        self.info_label.setWordWrap(True)
        self.info_label.setMaximumWidth(self.qw.minimumWidth())
        layout.addWidget( self.info_label)
        layout.addWidget( self.qw)
        self.qw.activated.connect(self.date_chosen)

        self.buttons = QDialogButtonBox()

        if no_date_allowed:
            self.buttons.addButton( QPushButton("No date"), QDialogButtonBox.ButtonRole.AcceptRole)

        self.buttons.addButton( QDialogButtonBox.StandardButton.Cancel)
        self.buttons.addButton( QDialogButtonBox.Ok)

        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)

        layout.addWidget(self.buttons)
        layout.addStretch()
        self.setLayout(layout)
示例#7
0
 def _initGUI(self):
     self.layout = QVBoxLayout()
     self.form = QFormLayout()
     
     self.name = QLineEdit()
     self.surname = QLineEdit()
     
     self.birthdate = QCalendarWidget()
     self.birthdate.setGridVisible(True)
     self.birthdate.setMinimumDate(QDate(1850,1,1))
     self.birthdate.setMaximumDate(QDate.currentDate())
     
     self.male = QRadioButton("Male")
     self.male.setChecked(True)
     self.female = QRadioButton("Female")
     
     self.height = QDoubleSpinBox()
     self.height.setMaximum(250)
     self.height.setMinimum(50)
     self.height.setValue(165)
     self.height.setSuffix(" cm")
     
     self.mass = QDoubleSpinBox()
     self.mass.setMaximum(300)
     self.mass.setMinimum(20)
     self.mass.setValue(60)
     self.mass.setSuffix(" Kg")
     
     btnLayout = QVBoxLayout()
     
     self.form.addRow("Name", self.name)
     self.form.addRow("Surname", self.surname)
     self.form.addRow("Birth date",self.birthdate)
     
     sexLayout = QHBoxLayout()
     sexLayout.addWidget(self.male)
     sexLayout.addWidget(self.female)
     self.form.addRow("Sex", sexLayout)
     
     self.form.addRow("Height", self.height)
     self.form.addRow("Mass", self.mass)
             
     self.layout.addLayout(self.form)
     self.layout.addLayout(btnLayout)
     self.setLayout(self.layout)
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self._dateEdit = QDateEdit()

        self._dateEdit.setDisplayFormat("dd/MM/yyyy")
        self._bttn = QPushButton("")
        self._bttn.setObjectName("MenuBttn")

        menu = QMenu(self._bttn)
        cal = QCalendarWidget()
        action = QWidgetAction(self._bttn)
        action.setDefaultWidget(cal)
        menu.addAction(action)
        self._bttn.setMenu(menu)
        cal.clicked[QtCore.QDate].connect(self._dateEdit.setDate)

        self.setupUI()
示例#9
0
 def createGUI(self):
     self.series = QSpinBox()
     self.series.setMinimum(1)
     
     self.repetitions = QSpinBox()
     self.repetitions.setMaximum(512)
     
     self.avgHeartRateToggle = QCheckBox()
     self.avgHeartRateToggle.toggled.connect(self._toggleHeartRateSpinBox)
     
     self.avgHeartRate = QSpinBox()
     self.avgHeartRate.setMinimum(30)
     self.avgHeartRate.setMaximum(250)
     self.avgHeartRate.setValue(120)
     self.avgHeartRate.setDisabled(True)
     
     self.dateSelector_widget = QCalendarWidget()
     self.dateSelector_widget.setMaximumDate(QDate.currentDate())
     
     self.addButton = QPushButton("Add pushup")
     self.addButton.setMaximumWidth(90)
     self.addButton.clicked.connect(self._createPushup)
     
     self.cancelButton = QPushButton("Cancel")
     self.cancelButton.setMaximumWidth(90)
     self.cancelButton.clicked.connect(self.reject)
     
     self.pushupForm.addRow("Series", self.series)
     self.pushupForm.addRow("Repetitions", self.repetitions)
     self.pushupForm.addRow("Store average heart rate ? ", self.avgHeartRateToggle)
     self.pushupForm.addRow("Average Heart Rate", self.avgHeartRate)
     self.pushupForm.addRow("Exercise Date", self.dateSelector_widget)
     
     btnsLayout = QVBoxLayout()
     btnsLayout.addWidget(self.addButton)
     btnsLayout.addWidget(self.cancelButton)        
     btnsLayout.setAlignment(Qt.AlignRight)
     
     layoutWrapper = QVBoxLayout()
     layoutWrapper.addLayout(self.pushupForm)
     layoutWrapper.addLayout(btnsLayout)
     
     self.setLayout(layoutWrapper)        
示例#10
0
class ProfileFormWidget(QWidget):
    '''
    classdocs
    '''
    def __init__(self):
        '''
        Constructor
        '''
        QWidget.__init__(self)
        self._initGUI()

    def _initGUI(self):
        self.layout = QVBoxLayout()
        self.form = QFormLayout()

        self.name = QLineEdit()
        self.surname = QLineEdit()

        self.birthdate = QCalendarWidget()
        self.birthdate.setGridVisible(True)
        self.birthdate.setMinimumDate(QDate(1850, 1, 1))
        self.birthdate.setMaximumDate(QDate.currentDate())

        self.male = QRadioButton("Male")
        self.male.setChecked(True)
        self.female = QRadioButton("Female")

        self.height = QDoubleSpinBox()
        self.height.setMaximum(250)
        self.height.setMinimum(50)
        self.height.setValue(165)
        self.height.setSuffix(" cm")

        self.mass = QDoubleSpinBox()
        self.mass.setMaximum(300)
        self.mass.setMinimum(20)
        self.mass.setValue(60)
        self.mass.setSuffix(" Kg")

        btnLayout = QVBoxLayout()

        self.form.addRow("Name", self.name)
        self.form.addRow("Surname", self.surname)
        self.form.addRow("Birth date", self.birthdate)

        sexLayout = QHBoxLayout()
        sexLayout.addWidget(self.male)
        sexLayout.addWidget(self.female)
        self.form.addRow("Sex", sexLayout)

        self.form.addRow("Height", self.height)
        self.form.addRow("Mass", self.mass)

        self.layout.addLayout(self.form)
        self.layout.addLayout(btnLayout)
        self.setLayout(self.layout)

    def getLayout(self):
        return self.layout

    def getWidget(self):
        widget = QWidget()
        widget.setLayout(self.layout)

        return widget

    def setProfile(self, athlete):
        self.name.setText(athlete._name)
        self.surname.setText(athlete._surname)
        self.birthdate.setSelectedDate(athlete._birthDate)

        if athlete._sex == "Male":
            self.male.setChecked(True)
        else:
            self.female.setChecked(True)

        self.height.setValue(athlete._height)
        self.mass.setValue(athlete._mass)

    def getProfile(self):
        qDate = self.birthdate.selectedDate()
        birthDate = self.qDate_to_date(qDate)

        athleteProfile = Athlete(self.name.text(), self.surname.text(),
                                 self._getSex(), birthDate,
                                 self.height.value(), self.mass.value())
        return athleteProfile

    def qDate_to_date(self, qDate):
        return date(qDate.year(), qDate.month(), qDate.day())

    def _getSex(self):
        if (self.male.isChecked()):
            return "Male"
        elif (self.female.isChecked()):
            return "Female"
        else:
            print "Error: No sex selected"
            return False
示例#11
0
class ProfileFormWidget(QWidget):
    '''
    classdocs
    '''
    
    def __init__(self):
        '''
        Constructor
        '''
        QWidget.__init__(self)
        self._initGUI()
        
    def _initGUI(self):
        self.layout = QVBoxLayout()
        self.form = QFormLayout()
        
        self.name = QLineEdit()
        self.surname = QLineEdit()
        
        self.birthdate = QCalendarWidget()
        self.birthdate.setGridVisible(True)
        self.birthdate.setMinimumDate(QDate(1850,1,1))
        self.birthdate.setMaximumDate(QDate.currentDate())
        
        self.male = QRadioButton("Male")
        self.male.setChecked(True)
        self.female = QRadioButton("Female")
        
        self.height = QDoubleSpinBox()
        self.height.setMaximum(250)
        self.height.setMinimum(50)
        self.height.setValue(165)
        self.height.setSuffix(" cm")
        
        self.mass = QDoubleSpinBox()
        self.mass.setMaximum(300)
        self.mass.setMinimum(20)
        self.mass.setValue(60)
        self.mass.setSuffix(" Kg")
        
        btnLayout = QVBoxLayout()
        
        self.form.addRow("Name", self.name)
        self.form.addRow("Surname", self.surname)
        self.form.addRow("Birth date",self.birthdate)
        
        sexLayout = QHBoxLayout()
        sexLayout.addWidget(self.male)
        sexLayout.addWidget(self.female)
        self.form.addRow("Sex", sexLayout)
        
        self.form.addRow("Height", self.height)
        self.form.addRow("Mass", self.mass)
                
        self.layout.addLayout(self.form)
        self.layout.addLayout(btnLayout)
        self.setLayout(self.layout)
        
    def getLayout(self):
        return self.layout
    
    def getWidget(self):
        widget = QWidget()
        widget.setLayout(self.layout)
    
        return widget
    
    def setProfile(self, athlete):
        self.name.setText(athlete._name)
        self.surname.setText(athlete._surname)
        self.birthdate.setSelectedDate(athlete._birthDate)
        
        if athlete._sex=="Male":
            self.male.setChecked(True)
        else:
            self.female.setChecked(True)
            
        self.height.setValue(athlete._height)
        self.mass.setValue(athlete._mass)
                
    def getProfile(self):        
        qDate = self.birthdate.selectedDate()
        birthDate = self.qDate_to_date(qDate)
        
        athleteProfile = Athlete(self.name.text(),
                                 self.surname.text(),
                                 self._getSex(),
                                 birthDate,
                                 self.height.value(),
                                 self.mass.value())
        return athleteProfile 
    
    def qDate_to_date(self, qDate):        
        return date(qDate.year(), qDate.month(),qDate.day())
     
    def _getSex(self):
        if (self.male.isChecked()):
            return "Male"
        elif (self.female.isChecked()):
            return "Female"
        else :
            print "Error: No sex selected"
            return False
示例#12
0
    def __init__(self, *args):

        QCalendarWidget.__init__(self, *args)
        self.color = QColor(self.palette().color(QPalette.Highlight))
        self.color.setAlpha(64)
        self.selectionChanged.connect(self.updateCells)
示例#13
0
class PushupForm(QDialog):
    '''
    classdocs
    '''
    pushupCreated = Signal(Pushup_Model)
    
    def __init__(self, athlete):
        '''
        Constructor
        '''
        QDialog.__init__(self)
        
        self.setWindowTitle("Pushup form")
        self.athlete = athlete
        self.pushupForm = QFormLayout()
        self.createGUI()
        
    def createGUI(self):
        self.series = QSpinBox()
        self.series.setMinimum(1)
        
        self.repetitions = QSpinBox()
        self.repetitions.setMaximum(512)
        
        self.avgHeartRateToggle = QCheckBox()
        self.avgHeartRateToggle.toggled.connect(self._toggleHeartRateSpinBox)
        
        self.avgHeartRate = QSpinBox()
        self.avgHeartRate.setMinimum(30)
        self.avgHeartRate.setMaximum(250)
        self.avgHeartRate.setValue(120)
        self.avgHeartRate.setDisabled(True)
        
        self.dateSelector_widget = QCalendarWidget()
        self.dateSelector_widget.setMaximumDate(QDate.currentDate())
        
        self.addButton = QPushButton("Add pushup")
        self.addButton.setMaximumWidth(90)
        self.addButton.clicked.connect(self._createPushup)
        
        self.cancelButton = QPushButton("Cancel")
        self.cancelButton.setMaximumWidth(90)
        self.cancelButton.clicked.connect(self.reject)
        
        self.pushupForm.addRow("Series", self.series)
        self.pushupForm.addRow("Repetitions", self.repetitions)
        self.pushupForm.addRow("Store average heart rate ? ", self.avgHeartRateToggle)
        self.pushupForm.addRow("Average Heart Rate", self.avgHeartRate)
        self.pushupForm.addRow("Exercise Date", self.dateSelector_widget)
        
        btnsLayout = QVBoxLayout()
        btnsLayout.addWidget(self.addButton)
        btnsLayout.addWidget(self.cancelButton)        
        btnsLayout.setAlignment(Qt.AlignRight)
        
        layoutWrapper = QVBoxLayout()
        layoutWrapper.addLayout(self.pushupForm)
        layoutWrapper.addLayout(btnsLayout)
        
        self.setLayout(layoutWrapper)        
        
    def _createPushup(self):        
        exerciseDate = self.dateSelector_widget.selectedDate()
        exerciseDate = self.qDate_to_date(exerciseDate)
        
        if self.avgHeartRateToggle.isChecked():
            heartRate = self.avgHeartRate.value()
        else:
            heartRate = None
            
        pushup = Pushup_Model(self.athlete._name, 
                              exerciseDate, 
                              heartRate, 
                              self.series.value(),
                              self.repetitions.value())

        self.pushupCreated.emit(pushup)
        self.accept()       
    
    def _toggleHeartRateSpinBox(self):
        if self.avgHeartRateToggle.isChecked():
            self.avgHeartRate.setDisabled(False)
        else:
            self.avgHeartRate.setDisabled(True)
        
    def qDate_to_date(self, qDate):        
        return date(qDate.year(), qDate.month(),qDate.day())
        
示例#14
0
class PushupForm(QDialog):
    '''
    classdocs
    '''
    pushupCreated = Signal(Pushup_Model)

    def __init__(self, athlete):
        '''
        Constructor
        '''
        QDialog.__init__(self)

        self.setWindowTitle("Pushup form")
        self.athlete = athlete
        self.pushupForm = QFormLayout()
        self.createGUI()

    def createGUI(self):
        self.series = QSpinBox()
        self.series.setMinimum(1)

        self.repetitions = QSpinBox()
        self.repetitions.setMaximum(512)

        self.avgHeartRateToggle = QCheckBox()
        self.avgHeartRateToggle.toggled.connect(self._toggleHeartRateSpinBox)

        self.avgHeartRate = QSpinBox()
        self.avgHeartRate.setMinimum(30)
        self.avgHeartRate.setMaximum(250)
        self.avgHeartRate.setValue(120)
        self.avgHeartRate.setDisabled(True)

        self.dateSelector_widget = QCalendarWidget()
        self.dateSelector_widget.setMaximumDate(QDate.currentDate())

        self.addButton = QPushButton("Add pushup")
        self.addButton.setMaximumWidth(90)
        self.addButton.clicked.connect(self._createPushup)

        self.cancelButton = QPushButton("Cancel")
        self.cancelButton.setMaximumWidth(90)
        self.cancelButton.clicked.connect(self.reject)

        self.pushupForm.addRow("Series", self.series)
        self.pushupForm.addRow("Repetitions", self.repetitions)
        self.pushupForm.addRow("Store average heart rate ? ",
                               self.avgHeartRateToggle)
        self.pushupForm.addRow("Average Heart Rate", self.avgHeartRate)
        self.pushupForm.addRow("Exercise Date", self.dateSelector_widget)

        btnsLayout = QVBoxLayout()
        btnsLayout.addWidget(self.addButton)
        btnsLayout.addWidget(self.cancelButton)
        btnsLayout.setAlignment(Qt.AlignRight)

        layoutWrapper = QVBoxLayout()
        layoutWrapper.addLayout(self.pushupForm)
        layoutWrapper.addLayout(btnsLayout)

        self.setLayout(layoutWrapper)

    def _createPushup(self):
        exerciseDate = self.dateSelector_widget.selectedDate()
        exerciseDate = self.qDate_to_date(exerciseDate)

        if self.avgHeartRateToggle.isChecked():
            heartRate = self.avgHeartRate.value()
        else:
            heartRate = None

        pushup = Pushup_Model(self.athlete._name, exerciseDate, heartRate,
                              self.series.value(), self.repetitions.value())

        self.pushupCreated.emit(pushup)
        self.accept()

    def _toggleHeartRateSpinBox(self):
        if self.avgHeartRateToggle.isChecked():
            self.avgHeartRate.setDisabled(False)
        else:
            self.avgHeartRate.setDisabled(True)

    def qDate_to_date(self, qDate):
        return date(qDate.year(), qDate.month(), qDate.day())