def setEnabled(self, enabled): if self.isEnabled() == enabled: return QDial.setEnabled(self, enabled) self.fPixmap.load(":/bitmaps/dial_%s%s.png" % (self.fPixmapNum, "" if enabled else "d")) self.updateSizes() self.update()
class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(1871, 1200) self.centralwidget = QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.transformsGroupBox = QGroupBox(self.centralwidget) self.transformsGroupBox.setGeometry(QRect(1500, 170, 240, 500)) self.transformsGroupBox.setMaximumSize(QSize(240, 600)) font = QFont() font.setFamily("MS Shell Dlg 2") font.setPointSize(10) font.setBold(True) font.setWeight(75) self.transformsGroupBox.setFont(font) self.transformsGroupBox.setToolTip("") self.transformsGroupBox.setWhatsThis("") self.transformsGroupBox.setObjectName("transformsGroupBox") self.edgesButton = QPushButton(self.transformsGroupBox) self.edgesButton.setGeometry(QRect(110, 180, 120, 30)) self.edgesButton.setObjectName("edgesButton") self.brightnessButton = QPushButton(self.transformsGroupBox) self.brightnessButton.setGeometry(QRect(110, 20, 120, 30)) font = QFont() font.setPointSize(8) self.brightnessButton.setFont(font) self.brightnessButton.setObjectName("brightnessButton") self.getSizeButton = QPushButton(self.transformsGroupBox) self.getSizeButton.setGeometry(QRect(0, 470, 75, 23)) self.getSizeButton.setObjectName("getSizeButton") self.paramsGroupBox = QGroupBox(self.transformsGroupBox) self.paramsGroupBox.setGeometry(QRect(10, 29, 91, 321)) font = QFont() font.setPointSize(8) self.paramsGroupBox.setFont(font) self.paramsGroupBox.setObjectName("paramsGroupBox") self.leftSlider = QSlider(self.paramsGroupBox) self.leftSlider.setGeometry(QRect(10, 50, 20, 240)) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.leftSlider.sizePolicy().hasHeightForWidth()) self.leftSlider.setSizePolicy(sizePolicy) self.leftSlider.setOrientation(Qt.Vertical) self.leftSlider.setTickPosition(QSlider.TicksAbove) self.leftSlider.setObjectName("leftSlider") self.rightSlider = QSlider(self.paramsGroupBox) self.rightSlider.setGeometry(QRect(50, 50, 20, 240)) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.rightSlider.sizePolicy().hasHeightForWidth()) self.rightSlider.setSizePolicy(sizePolicy) self.rightSlider.setOrientation(Qt.Vertical) self.rightSlider.setTickPosition(QSlider.TicksAbove) self.rightSlider.setObjectName("rightSlider") self.leftLabel = QLabel(self.paramsGroupBox) self.leftLabel.setGeometry(QRect(10, 20, 20, 15)) self.leftLabel.setTextFormat(Qt.PlainText) self.leftLabel.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter) self.leftLabel.setObjectName("leftLabel") self.rightLabel = QLabel(self.paramsGroupBox) self.rightLabel.setGeometry(QRect(50, 20, 20, 15)) self.rightLabel.setTextFormat(Qt.PlainText) self.rightLabel.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter) self.rightLabel.setObjectName("rightLabel") self.adaptiveThresholdButton = QPushButton(self.transformsGroupBox) self.adaptiveThresholdButton.setGeometry(QRect(110, 140, 120, 30)) font = QFont() font.setPointSize(8) self.adaptiveThresholdButton.setFont(font) self.adaptiveThresholdButton.setObjectName("adaptiveThresholdButton") self.gray2colSelButton = QPushButton(self.transformsGroupBox) self.gray2colSelButton.setGeometry(QRect(110, 100, 120, 30)) font = QFont() font.setPointSize(8) self.gray2colSelButton.setFont(font) self.gray2colSelButton.setObjectName("gray2colSelButton") self.gray2colAllButton = QPushButton(self.transformsGroupBox) self.gray2colAllButton.setGeometry(QRect(110, 60, 120, 30)) font = QFont() font.setPointSize(8) self.gray2colAllButton.setFont(font) self.gray2colAllButton.setObjectName("gray2colAllButton") self.fftButton = QPushButton(self.transformsGroupBox) self.fftButton.setGeometry(QRect(110, 220, 120, 30)) self.fftButton.setObjectName("fftButton") self.dftButton = QPushButton(self.transformsGroupBox) self.dftButton.setGeometry(QRect(110, 260, 120, 30)) self.dftButton.setObjectName("dftButton") self.gaborButton = QPushButton(self.transformsGroupBox) self.gaborButton.setGeometry(QRect(110, 300, 120, 30)) self.gaborButton.setObjectName("gaborButton") self.differenceButton = QPushButton(self.transformsGroupBox) self.differenceButton.setGeometry(QRect(110, 340, 120, 30)) self.differenceButton.setObjectName("differenceButton") self.RGB2GrayButton = QPushButton(self.transformsGroupBox) self.RGB2GrayButton.setGeometry(QRect(110, 380, 120, 30)) self.RGB2GrayButton.setObjectName("RGB2GrayButton") self.invertedCheckBox = QCheckBox(self.transformsGroupBox) self.invertedCheckBox.setGeometry(QRect(110, 430, 121, 17)) self.invertedCheckBox.setObjectName("invertedCheckBox") self.angleDial = QDial(self.transformsGroupBox) self.angleDial.setGeometry(QRect(20, 360, 81, 64)) self.angleDial.setMinimum(1) self.angleDial.setMaximum(4) self.angleDial.setPageStep(1) self.angleDial.setSliderPosition(1) self.angleDial.setWrapping(False) self.angleDial.setNotchesVisible(True) self.angleDial.setObjectName("angleDial") self.groupButtonsBox = QGroupBox(self.centralwidget) self.groupButtonsBox.setGeometry(QRect(1500, 730, 241, 141)) self.groupButtonsBox.setMaximumSize(QSize(250, 600)) font = QFont() font.setPointSize(10) font.setBold(True) font.setWeight(75) self.groupButtonsBox.setFont(font) self.groupButtonsBox.setObjectName("groupButtonsBox") self.addImgButton = QPushButton(self.groupButtonsBox) self.addImgButton.setGeometry(QRect(50, 20, 150, 30)) palette = QPalette() brush = QBrush(QColor(180, 146, 66)) brush.setStyle(Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Button, brush) brush = QBrush(QColor(180, 146, 66)) brush.setStyle(Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.Button, brush) brush = QBrush(QColor(180, 146, 66)) brush.setStyle(Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.Button, brush) self.addImgButton.setPalette(palette) font = QFont() font.setPointSize(10) font.setBold(True) font.setWeight(75) self.addImgButton.setFont(font) self.addImgButton.setObjectName("addImgButton") self.saveSceneImgButton = QPushButton(self.groupButtonsBox) self.saveSceneImgButton.setGeometry(QRect(50, 60, 150, 30)) font = QFont() font.setPointSize(10) font.setBold(True) font.setWeight(75) self.saveSceneImgButton.setFont(font) self.saveSceneImgButton.setObjectName("saveSceneImgButton") self.saveImgButton = QPushButton(self.groupButtonsBox) self.saveImgButton.setGeometry(QRect(50, 100, 150, 30)) font = QFont() font.setPointSize(9) font.setBold(True) font.setWeight(75) self.saveImgButton.setFont(font) self.saveImgButton.setObjectName("saveImgButton") self.graphicsView = QGraphicsView(self.centralwidget) self.graphicsView.setGeometry(QRect(10, 15, 1471, 900)) self.graphicsView.setMaximumSize(QSize(4000, 3000)) self.graphicsView.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.graphicsView.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.graphicsView.setSizeAdjustPolicy(QAbstractScrollArea.AdjustToContents) self.graphicsView.setObjectName("graphicsView") self.scene = TransformScene() self.graphicsView.setScene(self.scene) self.scaleEditLabel = QLabel(self.centralwidget) self.scaleEditLabel.setGeometry(QRect(1500, 100, 47, 13)) font = QFont() font.setPointSize(10) font.setBold(True) font.setWeight(75) self.scaleEditLabel.setFont(font) self.scaleEditLabel.setObjectName("scaleEditLabel") self.scaleBox = QDoubleSpinBox(self.centralwidget) self.scaleBox.setGeometry(QRect(1550, 100, 62, 22)) font = QFont() font.setBold(True) font.setWeight(75) self.scaleBox.setFont(font) self.scaleBox.setMinimum(0.1) self.scaleBox.setMaximum(10.0) self.scaleBox.setSingleStep(0.1) self.scaleBox.setProperty("value", 0.5) self.scaleBox.setObjectName("scaleBox") self.infoLabel = QLabel(self.centralwidget) self.infoLabel.setGeometry(QRect(1499, 130, 230, 20)) self.infoLabel.setFrameShape(QFrame.WinPanel) self.infoLabel.setText("") self.infoLabel.setAlignment(Qt.AlignCenter) self.infoLabel.setObjectName("infoLabel") self.infoLabel_2 = QLabel(self.centralwidget) self.infoLabel_2.setGeometry(QRect(1500, 20, 230, 20)) font = QFont() font.setBold(True) font.setItalic(True) font.setWeight(75) self.infoLabel_2.setFont(font) self.infoLabel_2.setFrameShape(QFrame.WinPanel) self.infoLabel_2.setText("") self.infoLabel_2.setAlignment(Qt.AlignCenter) self.infoLabel_2.setObjectName("infoLabel_2") self.infoLabel_3 = QLabel(self.centralwidget) self.infoLabel_3.setGeometry(QRect(1500, 60, 230, 20)) font = QFont() font.setBold(True) font.setItalic(True) font.setWeight(75) self.infoLabel_3.setFont(font) self.infoLabel_3.setFrameShape(QFrame.Box) self.infoLabel_3.setText("") self.infoLabel_3.setAlignment(Qt.AlignCenter) self.infoLabel_3.setObjectName("infoLabel_3") self.clearImgButton = QPushButton(self.centralwidget) self.clearImgButton.setGeometry(QRect(1550, 690, 150, 30)) font = QFont() font.setPointSize(10) font.setBold(True) font.setWeight(75) self.clearImgButton.setFont(font) self.clearImgButton.setObjectName("clearImgButton") MainWindow.setCentralWidget(self.centralwidget) self.menubar = QMenuBar(MainWindow) self.menubar.setGeometry(QRect(0, 0, 1871, 21)) self.menubar.setObjectName("menubar") self.menuHelp = QMenu(self.menubar) self.menuHelp.setObjectName("menuHelp") MainWindow.setMenuBar(self.menubar) self.statusbar = QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.actionExit = QAction(MainWindow) self.actionExit.setObjectName("actionExit") self.actionHelp = QAction(MainWindow) self.actionHelp.setObjectName("actionHelp") self.actionAbout = QAction(MainWindow) self.actionAbout.setObjectName("actionAbout") self.actionDefault_Values = QAction(MainWindow) self.actionDefault_Values.setObjectName("actionDefault_Values") self.menuHelp.addAction(self.actionHelp) self.menuHelp.addAction(self.actionAbout) self.menuHelp.addSeparator() self.menuHelp.addAction(self.actionDefault_Values) self.menubar.addAction(self.menuHelp.menuAction()) self.retranslateUi(MainWindow) QMetaObject.connectSlotsByName(MainWindow) self.scene.file_signal.connect(on_file_signal) self.scene.info_signal.connect(on_info_signal) self.scene.sliders_reset_signal.connect(on_sliders_reset_signal) def retranslateUi(self, MainWindow): _translate = QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "Green Monkey")) self.transformsGroupBox.setTitle(_translate("MainWindow", "Transformations")) self.edgesButton.setText(_translate("MainWindow", "Edges, Sobel")) self.brightnessButton.setToolTip(_translate("MainWindow", "You can change brightness with left slider and blur with rigt one.")) self.brightnessButton.setWhatsThis(_translate("MainWindow", "You can change brightness with left slider and blur with rigt one.")) self.brightnessButton.setText(_translate("MainWindow", "Brightness and Blur")) self.getSizeButton.setText(_translate("MainWindow", "get Size")) self.paramsGroupBox.setTitle(_translate("MainWindow", "Parameters")) self.leftSlider.setToolTip(_translate("MainWindow", "Adaptive Threshold\n" "blockSize – Size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, and so on.")) self.leftSlider.setWhatsThis(_translate("MainWindow", "Adaptive Threshold\n" "blockSize – Size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, and so on.")) self.rightSlider.setToolTip(_translate("MainWindow", "Adaptive Threshold\n" "C – Constant subtracted from the mean or weighted mean (see the details below). Normally, it is positive but may be zero or negative as well.")) self.rightSlider.setWhatsThis(_translate("MainWindow", "Adaptive Threshold\n" "C – Constant subtracted from the mean or weighted mean (see the details below). Normally, it is positive but may be zero or negative as well.")) self.leftLabel.setText(_translate("MainWindow", "0")) self.rightLabel.setText(_translate("MainWindow", "0")) self.adaptiveThresholdButton.setText(_translate("MainWindow", "Adaptive Threshold")) self.gray2colSelButton.setToolTip(_translate("MainWindow", "Gray scale 0..255 to color with selected method only.\n" "Image is converted to gray and finally to color.")) self.gray2colSelButton.setWhatsThis(_translate("MainWindow", "Gray scale 0..255 to color with selected method only.\n" "Image is converted to gray and and finally to color.")) self.gray2colSelButton.setText(_translate("MainWindow", "Gray2Color Sel.")) self.gray2colAllButton.setToolTip(_translate("MainWindow", "Gray scale 0..255 to color for all available methods.\n" "Image resized as per scale window and then is converted to gray and finally to color.")) self.gray2colAllButton.setWhatsThis(_translate("MainWindow", "Gray scale 0..255 to color for all available methods.\n" "Image resized as per scale window and then is converted to gray and finally to color.")) self.gray2colAllButton.setText(_translate("MainWindow", "Gray2Color All")) self.fftButton.setText(_translate("MainWindow", "FFT")) self.dftButton.setText(_translate("MainWindow", "DFT")) self.gaborButton.setToolTip(_translate("MainWindow", "Applies Gabor Filter")) self.gaborButton.setWhatsThis(_translate("MainWindow", "Applies Gabor Filter")) self.gaborButton.setText(_translate("MainWindow", "Gabor Filter")) self.differenceButton.setText(_translate("MainWindow", "Difference")) self.RGB2GrayButton.setText(_translate("MainWindow", "RGB to Gray")) self.invertedCheckBox.setText(_translate("MainWindow", "Inverted Image")) self.angleDial.setToolTip(_translate("MainWindow", "GABOR Filter - angle 1..4 ~ 1*np.pi/angle")) self.angleDial.setWhatsThis(_translate("MainWindow", "GABOR Filter - angle 1..4 ~ 1*np.pi/angle")) self.groupButtonsBox.setTitle(_translate("MainWindow", "Images")) self.addImgButton.setText(_translate("MainWindow", "Add Image(s)")) self.addImgButton.setShortcut(_translate("MainWindow", "Ctrl+A")) self.saveSceneImgButton.setText(_translate("MainWindow", "Save Scene as Image")) self.saveImgButton.setText(_translate("MainWindow", "Save Selected as Image")) self.scaleEditLabel.setText(_translate("MainWindow", "Scale:")) self.clearImgButton.setText(_translate("MainWindow", "Clear Image(s)")) self.menuHelp.setTitle(_translate("MainWindow", "Help")) self.actionExit.setText(_translate("MainWindow", "Exit")) self.actionHelp.setText(_translate("MainWindow", "Help")) self.actionAbout.setText(_translate("MainWindow", "About")) self.actionDefault_Values.setText(_translate("MainWindow", "Default Values")) self.actionHelp.setShortcut('F1') self.actionHelp.setStatusTip('Help') self.actionHelp.triggered.connect(self.showHelp) self.actionAbout.setStatusTip('About') self.actionAbout.triggered.connect(self.showAbout) self.actionDefault_Values.setStatusTip('Default folders and other values') self.actionDefault_Values.triggered.connect(self.updateINI) self.addImgButton.clicked.connect(partial(self.scene.addImg)) self.clearImgButton.clicked.connect(self.scene.dialogClearScene) self.saveSceneImgButton.clicked.connect(partial(self.scene.saveScene)) self.saveImgButton.clicked.connect(partial(self.scene.saveImg)) self.scaleBox.valueChanged.connect(self.onScaleBoxValueChanged) self.getSizeButton.clicked.connect(self.showSceneSize) self.brightnessButton.clicked.connect(self.startBrightnessAndBlur) self.gray2colAllButton.clicked.connect(self.startGray2colAllButton) self.gray2colSelButton.clicked.connect(self.startGray2colSelButton) self.adaptiveThresholdButton.clicked.connect(self.startAdaptiveThreshold) self.edgesButton.clicked.connect(self.startSobelXY) self.fftButton.clicked.connect(self.startFFT) self.dftButton.clicked.connect(self.startDFT) self.gaborButton.clicked.connect(self.startGabor) self.differenceButton.clicked.connect(self.startDifference) self.RGB2GrayButton.clicked.connect(self.starRGB2Gray) self.leftSlider.valueChanged['int'].connect(self. leftSliderChanged) self.rightSlider.valueChanged['int'].connect(self.rightSliderChanged) self.angleDial.valueChanged['int'].connect(self.angleDialChanged) def setStart(self): self.graphicsView.setAlignment(Qt.AlignLeft|Qt.AlignTop) self.scene.setSceneRect(0, 0, 0, 0) self.scene.imgScale = self.scaleBox.value() self.clearSliders() self.infoLabel.setText("") self.scene.cv2Images = {} self.transformsGroupBox.setEnabled(False) self.transformsGroupBox.setEnabled(False) self.invertedCheckBox.setChecked(False) def clearSliders(self): self.infoLabel_2.setText('') self.infoLabel_3.setText('') self.scene.currentTransform = 0 self.leftSlider.setEnabled(False) self.leftSlider.setToolTip("") self.leftSlider.setWhatsThis("") self.leftSlider.setMaximum(99) self.leftSlider.setMinimum(0) self.leftSlider.setTickInterval(10) self.leftSlider.setSingleStep(1) self.leftSlider.setTickPosition(11) self.rightSlider.setEnabled(False) self.rightSlider.setToolTip("") self.rightSlider.setWhatsThis("") self.rightSlider.setMaximum(99) self.rightSlider.setMinimum(0) self.rightSlider.setTickInterval(10) self.rightSlider.setSingleStep(1) self.rightSlider.setTickPosition(0) self.paramsGroupBox.setFlat(False) self.paramsGroupBox.setStyleSheet('QGroupBox * {color: black; font-weight: normal;}') self.angleDial.setEnabled(False) self.angleDial.setToolTip(" ") self.angleDial.setWhatsThis("") def invertCheckBoxEvent(self, checked): self.scene.inverted = checked def showSceneSize(self): x = self.scene.sceneRect().width() y = self.scene.sceneRect().height() self.infoLabel.setText(f'size: {x}x{y}, {self.scene.findSceneArea()}') def onScaleBoxValueChanged(self, val): self.scene.imgScale = val def startBrightnessAndBlur(self): self.scene.currentTransform = 1 self.infoLabel_2.setText('Adaptive Threshold') self.scene.currentBrightnessValue = 0 self.scene.currentBlurValue = 0 self.scene.transform1() self.infoLabel_2.setText('Brightness and Blur') self.scene.currentTransform = 1 self.leftSlider.setEnabled(True) self.rightSlider.setEnabled(True) self.leftSlider.setToolTip("Change Brightness -> 0 .. 99") self.leftSlider.setWhatsThis("Change Brightness -> 0 .. 99") self.rightSlider.setToolTip("Change Blur -> 0 .. 99") self.rightSlider.setWhatsThis("Change Blur -> 0 .. 99") self.leftSlider.setMaximum(99) self.leftSlider.setMinimum(0) self.leftSlider.setTickInterval(10) self.leftSlider.setSingleStep(1) self.leftSlider.setTickPosition(11) self.rightSlider.setMaximum(99) self.rightSlider.setMinimum(0) self.rightSlider.setTickInterval(10) self.rightSlider.setSingleStep(1) self.rightSlider.setTickPosition(0) self.paramsGroupBox.setFlat(True) self.paramsGroupBox.setStyleSheet('QGroupBox * {color: red; font-weight: bold;}') def startGray2colAllButton(self): self.infoLabel_2.setText('Gray to Color All Methods') self.scene.currentTransform = 2 self.scene.transform2(1, 1) def startGray2colSelButton(self): self.scene.currentTransform = 3 self.infoLabel_2.setText(' Gray to Color') self.scene.transform2(0, 1) def startSobelXY(self): self.scene.currentTransform = 4 self.infoLabel_2.setText('Edge Detection') self.scene.transform4() def startFFT(self): self.scene.currentTransform = 7 self.infoLabel_2.setText('FFT') self.scene.transform7() def startDFT(self): self.scene.currentTransform = 6 self.infoLabel_2.setText('DFT') self.scene.transform6() def startDenoising(self): self.scene.currentTransform = 8 self.infoLabel_2.setText('Denoising') self.scene.transform8() def startDifference(self): self.scene.currentTransform = 9 self.infoLabel_2.setText('Difference') self.scene.transform9() def starRGB2Gray(self): self.scene.currentTransform = 10 #txt = self.infoLabel_2.text() self.infoLabel_2.setText('RGB to Gray') self.scene.transform10() def startAdaptiveThreshold(self): self.scene.currentTransform = 5 self.infoLabel_2.setText('Adaptive Threshold') self.scene.currentBlockSizeValue = 11 self.scene.currentCValue = 5 self.scene.transform5() self.leftSlider.setEnabled(True) self.rightSlider.setEnabled(True) self.leftSlider.setToolTip("Adaptive Threshold\n" "blockSize – Size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, and so on.") self.leftSlider.setWhatsThis("Adaptive Threshold\n" "blockSize – Size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, and so on.") self.rightSlider.setToolTip("Adaptive Threshold\n" "C – Constant subtracted from the mean or weighted mean (see the details below). Normally, it is positive but may be zero or negative as well.") self.rightSlider.setWhatsThis("Adaptive Threshold\n" "C – Constant subtracted from the mean or weighted mean (see the details below). Normally, it is positive but may be zero or negative as well.") self.leftSlider.setMaximum(16) self.leftSlider.setMinimum(1) self.leftSlider.setTickInterval(1) self.leftSlider.setSingleStep(1) self.leftSlider.setTickPosition(11) self.rightSlider.setMaximum(20) self.rightSlider.setMinimum(-5) self.rightSlider.setTickInterval(1) self.rightSlider.setSingleStep(1) self.rightSlider.setTickPosition(5) self.paramsGroupBox.setFlat(True) self.paramsGroupBox.setStyleSheet('QGroupBox * {color: red; font-weight: bold;}') def startGabor(self): self.scene.currentTransform = 8 self.infoLabel_2.setText('Gabor Filter') self.scene.currentKernelSizeValue = 10 self.scene.currentSigmaValue = 10 self.scene.thetaCurrentValue self.scene.transform8() self.angleDial.setEnabled(True) self.leftSlider.setEnabled(True) self.rightSlider.setEnabled(True) self.leftSlider.setToolTip("Gabor Filter\n" "kernelSize – Size of a kernel 1..50") self.leftSlider.setWhatsThis("Gabor Filter\n" "kernelSize – Size of a kernel") self.rightSlider.setToolTip("Gabor Filter\n" "Standard Deviation – 1..30") self.rightSlider.setWhatsThis("Gabor Filter\n" "Standard Deviation – 1..30") self.angleDial.setToolTip("GABOR Filter - angle 1..4 ~ 1*np.pi/angle") self.angleDial.setWhatsThis("GABOR Filter - angle 1..4 ~ 1*np.pi/angle") self.leftSlider.setMaximum(50) self.leftSlider.setMinimum(1) self.leftSlider.setTickInterval(5) self.leftSlider.setSingleStep(5) self.leftSlider.setTickPosition(10) self.rightSlider.setMaximum(30) self.rightSlider.setMinimum(1) self.rightSlider.setTickInterval(5) self.rightSlider.setSingleStep(5) self.rightSlider.setTickPosition(10) self.paramsGroupBox.setFlat(True) self.paramsGroupBox.setStyleSheet('QGroupBox * {color: red; font-weight: bold;}') def leftSliderChanged(self, value): self.leftLabel.setText(str(value)) if self.scene.currentTransform == 1: self.scene.currentBrightnessValue = value elif self.scene.currentTransform == 5: if value % 2 == 1:return self.scene.currentBlockSizeValue = value elif self.scene.currentTransform == 8: self.scene.currentKernelSizeValue = value else: pass self.update() def rightSliderChanged(self, value): self.rightLabel.setText(str(value)) if self.scene.currentTransform == 1: self.scene.currentBlurValue = value elif self.scene.currentTransform == 5: self.scene.currentCValue = value elif self.scene.currentTransform == 8: self.scene.currentSigmaValue = value else: pass self.update() def angleDialChanged(self, value): if self.scene.currentTransform == 8: self.scene.thetaCurrentValue = value self.update() def update(self): if self.scene.currentTransform == 1: if len(self.scene.selectedItems()) > 0: self.scene.transform1() elif self.scene.currentTransform == 5: self.infoLabel_2.setText(f'Adaptive Threshold {self.scene.currentBlockSizeValue} {self.scene.currentCValue}') if len(self.scene.selectedItems()) > 0: self.scene.transform5() elif self.scene.currentTransform == 8: if len(self.scene.selectedItems()) > 0: self.scene.transform8() else: ... def updateINI(self): Dialog = QDialog() ui = Ui_INI_Dialog() ui.setupUi(Dialog) Dialog.show() Dialog.exec_() self.readINI() def readINI(self): self.scene.source_dir = '' self.scene.result_dir = '' self.scene.color_map = '' self.scene.scale = '' if os.path.exists("elilik.ini"): f = open("elilik.ini", "r") Lines = f.readlines() # Strips the newline character for line in Lines: l = line.strip() if "source_dir : " in l: self.scene.source_dir = l.replace("source_dir : ","").strip() elif "result_dir : " in l: self.scene.result_dir = l.replace("result_dir : ","").strip() elif "color_map : " in l: s = l.replace("color_map : ","").strip() self.scene.color_map = s.split() elif "scale : " in l: self.scene.scale = l.replace("scale : ","").strip() else: ... def showHelp(self): help = showText(os.getcwd()+"/help.html") help.exec_() def showAbout(self): about = showText(os.getcwd()+"/about.html") about.resize(280,250) about.exec_()
class ChromAbWidget(QWidget): def __init__(self, parent=None): super(ChromAbWidget, self).__init__(parent) self.maxD = 0.01 self.deadZ = 5 self.isShapeRadial = True self.isFalloffExp = True self.direction = 100 self.interpolate = False self.numThreads = 4 self.shapeInfo = QLabel("Shape and Direction:", self) self.shapeChoice = QButtonGroup(self) self.shapeBtn1 = QRadioButton("Radial") self.shapeBtn2 = QRadioButton("Linear") self.shapeChoice.addButton(self.shapeBtn1) self.shapeChoice.addButton(self.shapeBtn2) self.shapeBtn1.setChecked(True) self.shapeBtn1.pressed.connect(self.changeShape1) self.shapeBtn2.pressed.connect(self.changeShape2) self.theDial = QDial() self.theDial.setMinimum(0) self.theDial.setMaximum(359) self.theDial.setValue(100) self.theDial.setWrapping(True) self.theDial.setEnabled(False) self.theDial.valueChanged.connect(self.updateDial) self.maxInfo = QLabel("Max Displacement: 1%", self) self.maxDisplace = QSlider(Qt.Horizontal, self) self.maxDisplace.setRange(1, 500) self.maxDisplace.setValue(10) self.maxDisplace.valueChanged.connect(self.updateMax) self.falloffInfo = QLabel("Falloff:", self) self.falloffChoice = QButtonGroup(self) self.foBtn1 = QRadioButton("Exponential") self.foBtn2 = QRadioButton("Linear") self.falloffChoice.addButton(self.foBtn1) self.falloffChoice.addButton(self.foBtn2) self.foBtn1.setChecked(True) self.foBtn1.pressed.connect(self.changeFalloff1) self.foBtn2.pressed.connect(self.changeFalloff2) self.deadInfo = QLabel("Deadzone: 5%", self) self.deadzone = QSlider(Qt.Horizontal, self) self.deadzone.setRange(0, 100) self.deadzone.setValue(5) self.deadzone.valueChanged.connect(self.updateDead) self.biFilter = QCheckBox( "Bilinear Interpolation (slow, but smooths colors)", self) self.biFilter.stateChanged.connect(self.updateInterp) self.threadInfo = QLabel( "Number of Worker Threads (FOR ADVANCED USERS): 4", self) self.workThreads = QSlider(Qt.Horizontal, self) self.workThreads.setRange(1, 64) self.workThreads.setValue(4) self.workThreads.valueChanged.connect(self.updateThread) vbox = QVBoxLayout() vbox.addWidget(self.shapeInfo) vbox.addWidget(self.shapeBtn1) vbox.addWidget(self.shapeBtn2) vbox.addWidget(self.theDial) vbox.addWidget(self.maxInfo) vbox.addWidget(self.maxDisplace) vbox.addWidget(self.falloffInfo) vbox.addWidget(self.foBtn1) vbox.addWidget(self.foBtn2) vbox.addWidget(self.deadInfo) vbox.addWidget(self.deadzone) vbox.addWidget(self.biFilter) vbox.addWidget(self.threadInfo) vbox.addWidget(self.workThreads) self.setLayout(vbox) self.show() # Update labels and members def updateMax(self, value): self.maxInfo.setText("Max Displacement: " + str(value / 10) + "%") self.maxD = value / 1000 def updateDead(self, value): self.deadInfo.setText("Deadzone: " + str(value) + "%") self.deadZ = value def changeShape1(self): self.isShapeRadial = True # Change UI so only valid options can be changed self.theDial.setEnabled(False) self.theDial.repaint() self.foBtn1.setEnabled(True) self.foBtn1.repaint() self.foBtn2.setEnabled(True) self.foBtn2.repaint() self.deadzone.setEnabled(True) self.deadzone.repaint() def changeShape2(self): self.isShapeRadial = False # Change UI so only valid options can be changed self.theDial.setEnabled(True) self.theDial.repaint() self.foBtn1.setEnabled(False) self.foBtn1.repaint() self.foBtn2.setEnabled(False) self.foBtn2.repaint() self.deadzone.setEnabled(False) self.deadzone.repaint() def changeFalloff1(self): self.isFalloffExp = True def changeFalloff2(self): self.isFalloffExp = False def updateDial(self, value): self.direction = value def updateInterp(self, state): if state == Qt.Checked: self.interpolate = True else: self.interpolate = False def updateThread(self, value): self.threadInfo.setText( "Number of Worker Threads (FOR ADVANCED USERS): " + str(value)) self.numThreads = value # Required for main window to call into def getWindowName(self): return "Chromatic Aberration" def saveSettings(self, settings): settings.setValue("CA_maxD", self.maxD * 1000) settings.setValue("CA_deadZ", self.deadZ) if self.isShapeRadial: shape = 1 else: shape = 0 settings.setValue("CA_isShapeRadial", shape) if self.isFalloffExp: falloff = 1 else: falloff = 0 settings.setValue("CA_isFalloffExp", falloff) settings.setValue("CA_direction", self.direction) if self.interpolate: interp = 1 else: interp = 0 settings.setValue("CA_interpolate", interp) settings.setValue("CA_numThreads", self.numThreads) def readSettings(self, settings): self.updateMax(int(settings.value("CA_maxD", 10))) self.updateDead(int(settings.value("CA_deadZ", 5))) shapeRadial = int(settings.value("CA_isShapeRadial", 1)) if shapeRadial == 1: self.isShapeRadial = True else: self.isShapeRadial = False falloffExp = int(settings.value("CA_isFalloffExp", 1)) if falloffExp == 1: self.isFalloffExp = True else: self.isFalloffExp = False self.direction = int(settings.value("CA_direction", 100)) interp = int(settings.value("CA_interpolate", 0)) if interp == 1: self.interpolate = True else: self.interpolate = False self.updateThread(int(settings.value("CA_numThreads", 4))) # Update interactable UI elements self.theDial.setValue(self.direction) self.shapeBtn1.setChecked(self.isShapeRadial) self.shapeBtn2.setChecked(not self.isShapeRadial) self.maxDisplace.setValue(int(self.maxD * 1000)) self.foBtn1.setChecked(self.isFalloffExp) self.foBtn2.setChecked(not self.isFalloffExp) self.deadzone.setValue(self.deadZ) self.biFilter.setChecked(self.interpolate) self.workThreads.setValue(self.numThreads) if self.isShapeRadial: self.changeShape1() else: self.changeShape2() def getBlendMode(self): return "normal" # Call into C library to process the image def applyFilter(self, imgData, imgSize): newData = create_string_buffer(imgSize[0] * imgSize[1] * 4) dll = GetSharedLibrary() imgCoords = Coords(imgSize[0], imgSize[1]) # python makes it hard to get a pointer to existing buffers for some reason cimgData = c_char * len(imgData) threadPool = [] interp = 0 if self.interpolate: interp = 1 if self.isShapeRadial: falloff = 0 if self.isFalloffExp: falloff = 1 filterSettings = RadialFilterData(int(self.maxD * imgSize[0]), self.deadZ, falloff, interp) else: filterSettings = LinearFilterData(int(self.maxD * imgSize[0]), self.direction, interp) idx = 0 for i in range(self.numThreads): numPixels = (imgSize[0] * imgSize[1]) // self.numThreads if i == self.numThreads - 1: numPixels = (imgSize[0] * imgSize[1] ) - idx # Give the last thread the remainder if self.isShapeRadial: workerThread = Thread(target=dll.VFXRadialAberration, args=( idx, numPixels, filterSettings, imgCoords, cimgData.from_buffer(imgData), byref(newData), )) else: workerThread = Thread(target=dll.VFXLinearAberration, args=( idx, numPixels, filterSettings, imgCoords, cimgData.from_buffer(imgData), byref(newData), )) threadPool.append(workerThread) threadPool[i].start() idx += numPixels # Join threads to finish # If a crash happens, it would freeze here. User can still cancel though for i in range(self.numThreads): threadPool[i].join() return bytes(newData) def postFilter(self, app, doc, node): pass
class window(QtWidgets.QMainWindow): def __init__(self): super(window,self).__init__() self.currentlocal=0 self.data=None self.checker=0 self.lastcolored=0 self.photo = QLabel(self) self.port=0 self.pixmap = QPixmap('photo.png') self.pixmap = self.pixmap.scaled(600, 300, QtCore.Qt.KeepAspectRatio) self.photo.setPixmap(self.pixmap) self.labelgif=QLabel(self) self.labelgif.setStyleSheet("QLabel { background-color : white;}"); self.labelgif.setGeometry(100,50,500,430) self.movie = QtGui.QMovie('data.gif', QtCore.QByteArray(),self.labelgif) self.movie.setSpeed(100) self.labelgif.setMovie(self.movie) self.movie.start() self.labelgif.setVisible(False) self.labelyazi=QLabel(self) self.labelgif1=QLabel(self) self.labelgif1.setStyleSheet("QLabel { background-color : white;}") self.labelyazi.setText('G'+"\u00F6"+"zl"+"\u0259"+"yin..") font1=QtGui.QFont('Times',17) self.labelyazi.setFont(font1) self.labelyazi.setVisible(False) self.labelyazi.setGeometry(350,150,150,60) self.labelgif1.setGeometry(150,100,489,289) self.movie1 = QtGui.QMovie('wait.gif', QtCore.QByteArray(),self.labelgif1) self.movie1.setSpeed(100) self.labelgif1.setMovie(self.movie1) self.movie1.start() self.labelgif1.setVisible(False) self.setWindowTitle("Diplom i\u015Fi v1") self.setWindowIcon(QtGui.QIcon('pyicon.png')) self.button = QPushButton('PyQt5 button', self)#button yaradildi self.listw=QListWidget(self)#listWidget yaradildi self.button1=QPushButton(self) self.buttonlocal=QPushButton(self) self.buttonlocal.setText('Qo\u015F') self.button1.setText("Temperaturu"+" " +"\u00F6"+"l"+"\u00E7") self.dial=QDial(self) self.lcd=QLCDNumber(self) self.label=QLabel(self) self.labelrefresh=QLabel(self) self.obj=[] self.listCOM=QListWidget(self) self.spin=QSpinBox(self) self.radiosan=QRadioButton(self) self.radiosan.setText("Saniy"+"\u0259") self.radiodeq=QRadioButton(self) self.radiodeq.setText("D"+"\u0259"+"qiq"+"\u0259") self.starting() self.initUI() def initUI(self): self.setFixedSize(700,500) self.dial.setNotchesVisible(True) self.labelrefresh.setText('Yenil\u0259m\u0259k \u00FC\u00E7\u00FCn F5 d\u00FCym\u0259sini s\u0131x\u0131n ') self.labelrefresh.setStyleSheet("QLabel{background-color: yellow; }") font=QtGui.QFont('Times',10,QtGui.QFont.Bold) self.labelrefresh.setFont(font) self.lcd.setVisible(False) self.photo.setVisible(False) self.photo.raise_() self.labelgif.raise_() self.labelgif1.raise_() self.labelyazi.raise_() self.spin.setRange(1,60) self.dial.setRange(1,60) self.button.setText("\u015E"+"\u0259"+"b\u0259k\u0259ni yoxla") self.button1.setEnabled(False) self.button.setEnabled(False) self.spin.setEnabled(False) self.dial.setEnabled(False) self.radiosan.setEnabled(False) self.radiodeq.setEnabled(False) self.label.setText('Qo\u015Fulmu'+'\u015F cihaz yoxdur') self.label.setStyleSheet("QLabel { background-color : #e20000; color : black; }"); newfont = QtGui.QFont('Times',11) self.label.setFont(newfont) #geometries self.setGeometry(40,50,700,500) self.button.setGeometry(20,40,120,50) self.listw.setGeometry(380,160,300,200) self.button1.setGeometry(575,40,120,50) self.dial.setGeometry(40,400,75,70) self.spin.setGeometry(150,425,50,25) self.radiosan.setGeometry(150,400,75,25) self.radiodeq.setGeometry(150,380,75,25) self.lcd.setGeometry(300,40,100,50) self.buttonlocal.setGeometry(150,40,125,50) self.label.setGeometry(520,440,155,30) self.listCOM.setGeometry(20,160,300,200) self.labelrefresh.setGeometry(20,100,220,30) self.photo.setGeometry(50,100,600,300) #events self.buttonlocal.clicked.connect(self.checklocal) self.button.clicked.connect(self.thread1) self.button.clicked.connect(self.threadnetwork) self.dial.valueChanged.connect(self.spin.setValue) self.spin.valueChanged.connect(self.dial.setValue) self.listCOM.doubleClicked.connect(self.showdialog) self.listw.doubleClicked.connect(self.showdialogremote) self.button1.clicked.connect(self.thread) # communication self.radiodeq.clicked.connect(self.spinvalue) self.radiosan.clicked.connect(self.dialvalue) self.button1.clicked.connect(self.threadback) def threadback(self): if self.radiodeq.isChecked() or self.radiosan.isChecked(): self.thread1=threading.Thread(target=self.send) self.thread1.start() else: pass def loading(self): m=loading() def send(self): try: self.currentlocal.open() remotestr=self.listw.currentItem().text() li=remotestr.split("-") xbee_network=self.currentlocal.get_network() remote=xbee_network.get_device_by_64(XBee64BitAddress.from_hex_string(li[0])) arr_64=self.currentlocal.get_64bit_addr() NEW_TIMEOUT_FOR_SYNC_OPERATIONS = 1 self.currentlocal.set_sync_ops_timeout(NEW_TIMEOUT_FOR_SYNC_OPERATIONS) if self.radiosan.isChecked(): self.currentlocal.send_data(remote,str(arr_64)+"-"+str(self.spin.value())) else: self.currentlocal.send_data(remote,str(arr_64)+"-"+str(self.spin.value()*60)) self.labelgif1.setVisible(False) self.labelgif1.setVisible(True) self.labelyazi.setVisible(True) while(True): self.data=self.currentlocal.read_data() if(self.data!=None): self.data=self.data.data.decode() self.labelgif1.setVisible(False) self.labelyazi.setVisible(False) break self.currentlocal.close() data_list=self.data.split(',') self.labelgif.setVisible(True) objects = [] performance=[] for i in range(1,len(data_list)): objects.append(i) for i in range(len(data_list)-1): li=data_list[i] li=li.split('-') performance.append(li[1]) y_pos = np.arange(len(objects)) objects=tuple(objects) plt.figure("Qrafik") plt.xticks(y_pos, objects) plt.ylabel('Temperatur') plt.xlabel('Zaman') plt.plot(y_pos,performance) self.labelgif.setVisible(False) plt.show() self.data=None except: print('salam') self.currentlocal.close() def showdialog(self): try: li=self.listCOM.currentItem().text().split('-') local=XBeeDevice(li[2],9600) local.open() arr_64=local.get_64bit_addr() arr_16=local.get_16bit_addr() arr_node=local.get_node_id() arr_pro=local.get_protocol() arr_hard=local.get_hardware_version() local.close() dlg=dialog(arr_64,arr_16,arr_node,arr_pro,arr_hard) except: pass #exception def showdialogremote(self): li=self.listw.currentItem().text().split('-') if self.checker !=0: self.lastcolored.setBackground(QtGui.QColor(255,255,255)) self.lastcolored=self.listw.currentItem() self.listw.currentItem().setBackground(QtGui.QColor(239, 255, 25)) try: self.currentlocal.open() xbee_network=self.currentlocal.get_network() remote=xbee_network.get_device_by_64(XBee64BitAddress.from_hex_string(li[0])) arr_64=remote.get_64bit_addr() arr_16=remote.get_16bit_addr() arr_node=remote.get_node_id() arr_pro=remote.get_protocol() arr_hard=remote.get_hardware_version() self.currentlocal.close() dlg=dialog(arr_64,arr_16,arr_node,arr_pro,arr_hard) self.checker=1 except: pass # exception def spinvalue(self): self.dial.setRange(1,60) self.spin.setRange(1,60) self.dial.setValue(1) def dialvalue(self): self.dial.setRange(4,60) self.spin.setRange(4,60) self.dial.setValue(4) def keyPressEvent(self, event): key = event.key() if key == QtCore.Qt.Key_F5: self.threadrefresh() def checklocal(self): try: if (self.currentlocal !=0): for i in range(0,self.listCOM.count()): self.listCOM.item(i).setBackground(QtGui.QColor(255, 255, 255)) self.listCOM.currentItem().setBackground(QtGui.QColor(97, 255, 66)) li=self.listCOM.currentItem().text().split('-') self.currentlocal = XBeeDevice(li[2], 9600) self.port=li[2] self.currentCOM=self.listCOM.currentItem().text() self.currentlocal.open() self.currentlocal.close() self.listw.clear() self.button1.setEnabled(True) self.button.setEnabled(True) self.spin.setEnabled(True) self.dial.setEnabled(True) self.radiosan.setEnabled(True) self.radiodeq.setEnabled(True) if platform.system()=='Linux': self.label.setGeometry(500,440,180,30) self.label.setText('Qo\u015Fulmu'+'\u015F port: '+str(li[2])) self.checker=0 self.label.setStyleSheet("QLabel { background-color : #22ce00; color : white; }") except: QMessageBox.about(self, 'Yanl\u0131\u015F', 'Lokal cihaz\u0131n portu do\u011Fru deyil') def refresh(self): self.listCOM.clear() index=0 if platform.system()=='Windows': for i in range(0,257): try: local_xbee = XBeeDevice('COM'+str(i), 9600) local_xbee.open() addr64=local_xbee.get_64bit_addr() noid=local_xbee.get_node_id() local_xbee.close() self.listCOM.addItem(str(addr64)+"-"+str(noid)+"-"+'COM'+str(i)) if(self.port=='COM'+str(i)): self.listCOM.item(index).setBackground(QtGui.QColor(97, 255, 66)) index+=1 except: pass elif platform.system()=='Linux': for i in range(257): try: local_xbee = XBeeDevice('/dev/ttyUSB'+str(i), 9600) local_xbee.open() addr64=local_xbee.get_64bit_addr() noid=local_xbee.get_node_id() local_xbee.close() self.listCOM.addItem(str(addr64)+"-"+str(noid)+"-"+'/dev/ttyUSB'+str(i)) if(self.port=='/dev/ttyUSB'+str(i)): self.listCOM.item(index).setBackground(QtGui.QColor(97, 255, 66)) index+=1 except: pass self.checker=0 def thread(self): if self.radiodeq.isChecked() or self.radiosan.isChecked(): self.thread=threading.Thread(target=self.timing) self.thread.start() else: QMessageBox.about(self, 'Yanl\u0131\u015F', 'Zaman vahidini se\u00E7in') def thread1(self): if self.radiodeq.isChecked() or self.radiosan.isChecked(): self.thread1=threading.Thread(target=self.scan) self.thread1.start() else: QMessageBox.about(self, 'Yanl\u0131\u015F', 'Zaman vahidini se\u00E7in') def threadnetwork(self): if self.radiodeq.isChecked() or self.radiosan.isChecked(): self.thread1=threading.Thread(target=self.network) self.thread1.start() else: pass def network(self): try: self.button1.setEnabled(False) self.buttonlocal.setEnabled(False) self.button.setEnabled(False) self.button1.setEnabled(False) self.spin.setEnabled(False) self.dial.setEnabled(False) self.radiosan.setEnabled(False) self.radiodeq.setEnabled(False) self.listw.clear() self.currentlocal.open() xbee_network=self.currentlocal.get_network() xbee_network.clear() listdev=[] def callback_device_discovered(remote): listdev.append(str(remote)) if self.radiosan.isChecked(): if(self.spin.value()>25): defe=int((self.spin.value())/25) qaliqsan=(self.spin.value())%25 for i in range(0,defe): xbee_network.set_discovery_timeout(22) xbee_network.add_device_discovered_callback(callback_device_discovered) xbee_network.start_discovery_process() while xbee_network.is_discovery_running(): QtCore.QThread.msleep(100) if(qaliqsan<4): add=q=4-qaliqsan xbee_network.set_discovery_timeout(qaliqsan+add) xbee_network.add_device_discovered_callback(callback_device_discovered) xbee_network.start_discovery_process() while xbee_network.is_discovery_running(): QtCore.QThread.msleep(100) else: xbee_network.set_discovery_timeout(qaliqsan) xbee_network.add_device_discovered_callback(callback_device_discovered) xbee_network.start_discovery_process() while xbee_network.is_discovery_running(): QtCore.QThread.msleep(100) self.currentlocal.close() else: xbee_network.set_discovery_timeout(self.spin.value()) xbee_network.add_device_discovered_callback(callback_device_discovered) xbee_network.start_discovery_process() while xbee_network.is_discovery_running(): QtCore.QThread.msleep(100) self.currentlocal.close() self.photo.setVisible(True) listdev=list(set(listdev)) for i in range(0,len(listdev)): self.listw.addItem(listdev[i]) QtCore.QThread.msleep(1000) self.photo.setEnabled(True) self.buttonlocal.setEnabled(True) self.button1.setEnabled(True) self.button.setEnabled(True) self.spin.setEnabled(True) self.dial.setEnabled(True) self.radiosan.setEnabled(True) self.radiodeq.setEnabled(True) self.photo.setVisible(False) if self.radiodeq.isChecked(): defe=int((self.spin.value()*60)/25) qaliqsan=(self.spin.value()*60)%25 for i in range(0,defe): xbee_network.set_discovery_timeout(22) # 24 seconds + saniye elave. xbee_network.add_device_discovered_callback(callback_device_discovered) xbee_network.start_discovery_process() while xbee_network.is_discovery_running(): QtCore.QThread.msleep(100) xbee_network.set_discovery_timeout(qaliqsan) # qaliq saniye. xbee_network.add_device_discovered_callback(callback_device_discovered) xbee_network.start_discovery_process() while xbee_network.is_discovery_running(): QtCore.QThread.msleep(100) self.currentlocal.close() else: xbee_network.set_discovery_timeout(self.spin.value()) # qaliq saniye xbee_network.add_device_discovered_callback(callback_device_discovered) xbee_network.start_discovery_process() while xbee_network.is_discovery_running(): QtCore.QThread.msleep(100) self.currentlocal.close() self.photo.setVisible(True) listdev=list(set(listdev)) for i in range(0,len(listdev)): self.listw.addItem(listdev[i]) QtCore.QThread.msleep(2000) self.buttonlocal.setEnabled(True) self.button1.setEnabled(True) self.button.setEnabled(True) self.spin.setEnabled(True) self.dial.setEnabled(True) self.radiosan.setEnabled(True) self.radiodeq.setEnabled(True) self.photo.setVisible(False) except: self.currentlocal.close() def threadrefresh(self): t=threading.Thread(target=self.refresh) t.start() #UI has been finished def timing(self): QtCore.QThread.msleep(1000) self.button1.setEnabled(False) if(self.radiodeq.isChecked()): self.lcd.setVisible(True) j=self.spin.value()*60 k=self.spin.value() if(k<10): self.lcd.display("0{}:00".format(k)) QtCore.QThread.msleep(1000) else: self.lcd.display("{}:00".format(k)) QtCore.QThread.msleep(1000) j-=1 k-=1 while(j>-1): if(k<10): if(j%60<10): if(j%60 is 0): self.lcd.display("0{}:0{}".format(k,j%60)) k-=1 j-=1 QtCore.QThread.msleep(1000) continue self.lcd.display("0{}:0{}".format(k,j%60)) app.processEvents() QtCore.QThread.msleep(1000) j-=1 else: self.lcd.display("0{}:{}".format(k,j%60)) QtCore.QThread.msleep(1000) j-=1 else: if(j%60 is 0): self.lcd.display("0{}:0{}".format(k,j%60)) k-=1 j-=1 QtCore.QThread.msleep(1000) continue if(j%60<10): self.lcd.display("{}:0{}".format(k,j%60)) QtCore.QThread.msleep(1000) j-=1 else: self.lcd.display("{}:{}".format(k,j%60)) QtCore.QThread.msleep(1000) j-=1 self.lcd.setVisible(False) self.button1.setEnabled(True) elif (self.radiosan.isChecked()): self.lcd.setVisible(True) timing=self.spin.value() for i in range(timing,-1,-1): if(i<10): self.lcd.display("00:0{}".format(i)) QtCore.QThread.msleep(1000) else: self.lcd.display("00:{}".format(i)) QtCore.QThread.msleep(1000) self.lcd.setVisible(False) self.button1.setEnabled(True) def starting(self): splash=QtWidgets.QSplashScreen(QtGui.QPixmap('splash.jpg'),QtCore.Qt.WindowStaysOnTopHint) splash.show() for i in range(0,257): app.processEvents() if (i is 50): splash.showMessage("<h1><font color=#608fdb>Proqram başladılır!</font></h1>", QtCore.Qt.AlignTop) QtCore.QThread.msleep(1000) try: if (platform.system() == 'Windows'): local_xbee = XBeeDevice('COM'+str(i), 9600) local_xbee.open() addr64=local_xbee.get_64bit_addr() noid=local_xbee.get_node_id() local_xbee.close() self.listCOM.addItem(str(addr64)+"-"+str(noid)+"-"+'COM'+str(i)) elif (platform.system() == 'Linux'): local_xbee = XBeeDevice('/dev/ttyUSB'+str(i), 9600) local_xbee.open() addr64=local_xbee.get_64bit_addr() noid=local_xbee.get_node_id() local_xbee.close() self.listCOM.addItem(str(addr64)+"-"+str(noid)+"-"+'/dev/ttyUSB'+str(i)) except: pass splash.close() def createlistw(self): self.listw.clear() for i in range(0,9): self.obj.append(i) self.obj[i]=elements() self.obj[i].t=[10,20,30,40,2,3,4,5,6] self.obj[i].s=[5,6,7,8,9,1,2,3,4,5,88] self.listw.addItem(str(self.obj[i].t[i])) def scan(self): self.button.setEnabled(False) if(self.radiodeq.isChecked()): self.lcd.setVisible(True) j=self.spin.value()*60 k=self.spin.value() if(k<10): self.lcd.display("0{}:00".format(k)) QtCore.QThread.msleep(1000) else: self.lcd.display("{}:00".format(k)) QtCore.QThread.msleep(1000) j-=1 k-=1 while(j>-1): if(k<10): if(j%60<10): if(j%60 is 0): self.lcd.display("0{}:0{}".format(k,j%60)) k-=1 j-=1 QtCore.QThread.msleep(1000) continue self.lcd.display("0{}:0{}".format(k,j%60)) app.processEvents() QtCore.QThread.msleep(1000) j-=1 else: self.lcd.display("0{}:{}".format(k,j%60)) QtCore.QThread.msleep(1000) j-=1 else: if(j%60 is 0): self.lcd.display("0{}:0{}".format(k,j%60)) k-=1 j-=1 QtCore.QThread.msleep(1000) continue if(j%60<10): self.lcd.display("{}:0{}".format(k,j%60)) QtCore.QThread.msleep(1000) j-=1 else: self.lcd.display("{}:{}".format(k,j%60)) QtCore.QThread.msleep(1000) j-=1 self.lcd.setVisible(False) self.button.setEnabled(True) elif (self.radiosan.isChecked()): self.lcd.setVisible(True) timing=self.spin.value() for i in range(timing,-1,-1): if(i<10): self.lcd.display("00:0{}".format(i)) QtCore.QThread.msleep(1000) else: self.lcd.display("00:{}".format(i)) QtCore.QThread.msleep(1000) self.lcd.setVisible(False) self.button.setEnabled(True)