Ejemplo n.º 1
0
    def load_recipe_steps(self, recipeStepsTable, steps):
        """Takes two arguments. One being the table and the second being the
        rows you'd like to add. It does not clear the table and simply adds the
        rows on the bottom if there are exiting rows."""
        # Create spreadsheet choices
        fanSpeedChoices = [str(x) for x in range(1, 10)]
        targetTempChoices = ["Cooling"] + [str(x) for x in range(150, 551, 10)]

        # loop through recipe and load each step
        for row in range(len(steps)):
            recipeStepsTable.insertRow(recipeStepsTable.rowCount())
            # Temperature Value
            sectionTempWidget = customqtwidgets.ComboBoxNoWheel()
            sectionTempWidget.setObjectName("recipeEditCombo")
            sectionTempWidget.addItems(targetTempChoices)
            sectionTempWidget.insertSeparator(1)

            if 'targetTemp' in steps[row]:
                sectionTemp = steps[row]["targetTemp"]
                # Accommodate for temperature not fitting in 10 increment list
                if str(steps[row]["targetTemp"]) in targetTempChoices:
                    sectionTempWidget.setCurrentIndex(
                        targetTempChoices.index(str(steps[row]["targetTemp"]))
                        + 1)
                else:
                    roundedNumber = steps[row]["targetTemp"] - (
                        steps[row]["targetTemp"] % 10)
                    sectionTempWidget.insertItem(
                        targetTempChoices.index(str(roundedNumber)) + 2,
                        str(steps[row]["targetTemp"]))
                    sectionTempWidget.setCurrentIndex(
                        targetTempChoices.index(str(roundedNumber)) + 2)

            elif 'cooling' in steps[row]:
                sectionTemp = "Cooling"
                sectionTempWidget.setCurrentIndex(
                    targetTempChoices.index("Cooling"))

            # Time Value
            sectionTimeWidget = customqtwidgets.TimeEditNoWheel()
            sectionTimeWidget.setObjectName("recipeEditTime")
            sectionTimeWidget.setAttribute(QtCore.Qt.WA_MacShowFocusRect, 0)
            sectionTimeWidget.setDisplayFormat("mm:ss")
            # Set QTimeEdit to the right time from recipe
            sectionTimeStr = time.strftime(
                "%M:%S", time.gmtime(steps[row]["sectionTime"]))
            sectionTime = QtCore.QTime().fromString(sectionTimeStr, "mm:ss")
            sectionTimeWidget.setTime(sectionTime)

            # Fan Speed Value
            sectionFanSpeedWidget = customqtwidgets.ComboBoxNoWheel()
            sectionFanSpeedWidget.setObjectName("recipeEditCombo")

            sectionFanSpeedWidget.addItems(fanSpeedChoices)
            sectionFanSpeedWidget.setCurrentIndex(
                fanSpeedChoices.index(str(steps[row]["fanSpeed"])))

            # Modify Row field
            upArrow = QtWidgets.QPushButton()
            upArrow.setObjectName("upArrow")
            #upArrow.setIcon(QtGui.QIcon('static/images/upSmall.png'))
            upArrow.setIcon(
                QtGui.QIcon(
                    utils.get_resource_filename('static/images/upSmall.png')))
            upArrow.clicked.connect(
                functools.partial(self.move_recipe_step_up, row))
            downArrow = QtWidgets.QPushButton()
            downArrow.setObjectName("downArrow")
            #downArrow.setIcon(QtGui.QIcon('static/images/downSmall.png'))
            downArrow.setIcon(
                QtGui.QIcon(
                    utils.get_resource_filename(
                        'static/images/downSmall.png')))
            downArrow.clicked.connect(
                functools.partial(self.move_recipe_step_down, row))
            deleteRow = QtWidgets.QPushButton()
            # deleteRow.setIcon(QtGui.QIcon('static/images/delete.png'))
            deleteRow.setIcon(
                QtGui.QIcon(
                    utils.get_resource_filename('static/images/delete.png')))
            deleteRow.setObjectName("deleteRow")
            deleteRow.clicked.connect(
                functools.partial(self.delete_recipe_step, row))
            insertRow = QtWidgets.QPushButton()
            # insertRow.setIcon(QtGui.QIcon('static/images/plus.png'))
            insertRow.setIcon(
                QtGui.QIcon(
                    utils.get_resource_filename('static/images/plus.png')))
            insertRow.setObjectName("insertRow")
            insertRow.clicked.connect(
                functools.partial(self.insert_recipe_step, row))

            # Create a grid layout to add all the widgets to
            modifyRowWidgetLayout = QtWidgets.QHBoxLayout()
            modifyRowWidgetLayout.setSpacing(0)
            modifyRowWidgetLayout.setContentsMargins(0, 0, 0, 0)
            modifyRowWidgetLayout.addWidget(upArrow)
            modifyRowWidgetLayout.addWidget(downArrow)
            modifyRowWidgetLayout.addWidget(deleteRow)
            modifyRowWidgetLayout.addWidget(insertRow)

            # Assign Layout to a QWidget to add to a single column
            modifyRowWidget = QtWidgets.QWidget()
            modifyRowWidget.setObjectName("buttonTable")
            modifyRowWidget.setLayout(modifyRowWidgetLayout)

            # Add widgets
            recipeStepsTable.setCellWidget(row, 0, sectionTempWidget)
            recipeStepsTable.setCellWidget(row, 1, sectionFanSpeedWidget)
            recipeStepsTable.setCellWidget(row, 2, sectionTimeWidget)
            recipeStepsTable.setCellWidget(row, 3, modifyRowWidget)
Ejemplo n.º 2
0
    def create_slider_panel(self):
        sliderPanel = QtWidgets.QGridLayout()
        sliderPanel.setColumnStretch(0, 3)

        # Create temperature slider label.
        tempSliderLabel = QtWidgets.QLabel("TARGET TEMP")
        sliderPanel.addWidget(tempSliderLabel, 0, 0)

        # Create temperature slider.
        self.tempSlider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
        self.tempSlider.setRange(150, 550)
        self.tempSlider.valueChanged.connect(self.update_target_temp_slider)
        sliderPanel.addWidget(self.tempSlider, 1, 0)

        # Create temperature spin box.
        self.tempSpinBox = QtWidgets.QSpinBox()
        self.tempSpinBox.setObjectName("miniSpinBox")
        self.tempSpinBox.setButtonSymbols(2)      # Remove arrows.
        self.tempSpinBox.setAlignment(QtCore.Qt.AlignCenter)
        self.tempSpinBox.setRange(150, 550)
        self.tempSpinBox.valueChanged.connect(self.update_target_temp_spin_box)
        self.tempSpinBox.setAttribute(QtCore.Qt.WA_MacShowFocusRect, 0)
        sliderPanel.addWidget(self.tempSpinBox, 1, 1)

        # Update temperature data.
        self.update_target_temp()

        # Create timer slider label.
        timeSliderLabel = QtWidgets.QLabel("SECTION TIME")
        sliderPanel.addWidget(timeSliderLabel, 2, 0)

        # Create timer slider.
        self.sectTimeSlider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
        self.sectTimeSlider.setRange(0, 900)
        self.sectTimeSlider.valueChanged.connect(self.update_sect_time_slider)
        sliderPanel.addWidget(self.sectTimeSlider, 3, 0)

        # Create mini timer spin box.
        self.sectTimeSpinBox = customqtwidgets.TimeEditNoWheel()
        self.sectTimeSpinBox.setObjectName("miniSpinBox")
        self.sectTimeSpinBox.setButtonSymbols(2)      # Remove arrows.
        self.sectTimeSpinBox.setAlignment(QtCore.Qt.AlignCenter)
        self.sectTimeSpinBox.setAttribute(QtCore.Qt.WA_MacShowFocusRect, 0)
        self.sectTimeSpinBox.setDisplayFormat("mm:ss")
        self.sectTimeSpinBox.timeChanged.connect(self.update_sect_time_spin_box)
        sliderPanel.addWidget(self.sectTimeSpinBox, 3, 1)

        # Create fan speed slider.
        fanSliderLabel = QtWidgets.QLabel("FAN SPEED")
        sliderPanel.addWidget(fanSliderLabel, 4, 0)

        # Create fan speed slider.
        self.fanSlider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
        self.fanSlider.setRange(1, 9)
        self.fanSlider.valueChanged.connect(self.update_fan_speed_slider)
        sliderPanel.addWidget(self.fanSlider, 5, 0)

        # Create mini fan spin box
        self.fanSpeedSpinBox = QtWidgets.QSpinBox()
        self.fanSpeedSpinBox.setObjectName("miniSpinBox")
        self.fanSpeedSpinBox.setButtonSymbols(2)      # Remove arrows.
        self.fanSpeedSpinBox.setRange(1, 9)
        self.fanSpeedSpinBox.setAttribute(QtCore.Qt.WA_MacShowFocusRect, 0)
        self.fanSpeedSpinBox.setAlignment(QtCore.Qt.AlignCenter)
        self.fanSpeedSpinBox.valueChanged.connect(self.update_fan_spin_box)
        sliderPanel.addWidget(self.fanSpeedSpinBox, 5, 1)

        return sliderPanel