Exemplo n.º 1
0
class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        self.setWindowTitle("Volume Evaluation")
        self.setFixedSize(600, 400)
        self.Volume_Evaluation()
        self.dial()

    def dial(self):
        self.widget = QDial(self)
        self.widget.setGeometry(100, 100, 150, 200)  # x,y,w,h
        self.widget.setRange(0, 100)
        self.widget.setSingleStep(1)  # set keyboard input to 1 step
        self.widget.setSliderPosition(0)  # set pos to 0
        self.widget.valueChanged.connect(self.value_changed)

    def Volume_Evaluation(self):
        self.text_label = QLabel("Move Dial to Evaluate", self)
        self.text_label.setGeometry(260, 150, 320, 100)  # x,y,w,h
        self.text_label.setFont(QFont('Arial', 15))

    def value_changed(self, i):
        if i == 0: self.text_label.setText(f"Current value[{i}]: Muted")
        if i > 0: self.text_label.setText(f"Current value[{i}]: Very Low")
        if i >= 20: self.text_label.setText(f"Current value[{i}]: Low")
        if i >= 45: self.text_label.setText(f"Current value[{i}]: Medium")
        if i >= 80: self.text_label.setText(f"Current value[{i}]: High")
        if i == 100: self.text_label.setText(f"Current value[{i}]: Max")
        print(i)
Exemplo n.º 2
0
    def initUI(self):
        lcd = QLCDNumber(self)
        dial = QDial(self)

        self.setGeometry(300, 300, 350, 250)
        self.setWindowTitle("拨号")

        lcd.setGeometry(100, 50, 150, 60)
        dial.setGeometry(120, 120, 100, 100)

        dial.valueChanged.connect(lcd.display)

        self.show()
Exemplo n.º 3
0
    def initUi(self):
        lcd = QLCDNumber(self)
        dial = QDial(self)

        # 屏幕位置及大小
        self.setGeometry(500, 100, 350, 250)
        self.setWindowTitle('学点编程吧')

        lcd.setGeometry(100, 50, 150, 60)
        dial.setGeometry(120, 120, 100, 100)

        dial.valueChanged.connect(lcd.display)

        self.show()
Exemplo n.º 4
0
 def initUi(self):
     lcd = QLCDNumber(self)
     lcd2 = QLCDNumber(self)
     dial = QDial(self)
     slider = QSlider(self)
     self.setGeometry(300, 300, 700, 250)
     self.setWindowTitle('学点编程吧')
     lcd.setGeometry(100, 50, 150, 60)
     lcd2.setGeometry(400, 50, 150, 60)
     dial.setGeometry(120, 120, 100, 100)
     slider.setGeometry(420, 120, 100, 100)
     dial.valueChanged.connect(lcd.display)
     slider.valueChanged.connect(lcd2.display)
     self.show()
    def initUi(self):
        #QDial对象发送信号。 QLCDNumber接收信号的。 槽是对信号作出反应的方法
        lcd = QLCDNumber(self)
        dial = QDial(self)

        self.setGeometry(300, 300, 350, 250)
        self.setWindowTitle('学点编程吧')

        lcd.setGeometry(100, 50, 150, 60)
        dial.setGeometry(120, 120, 100, 100)

        # 将QDial这个小部件的一个valueChanged信号连接到lcd数字的显示槽。
        dial.valueChanged.connect(lcd.display)

        self.show()
Exemplo n.º 6
0
    def initUi(self):
        #lcd是什么玩意,lcd数字显示槽
        lcd = QLCDNumber(self)
        #用了对话框了
        dial = QDial(self)

        self.setGeometry(300, 300, 350, 250)
        self.setWindowTitle('学点编程吧')

        lcd.setGeometry(100, 50, 150, 60)
        dial.setGeometry(120, 120, 100, 100)

        #出现了!事件
        #将QDial这个小部件的一个valueChanged信号连接到lcd数字的显示槽
        #dial对象发送信号,lcd接受信号,槽是对信号做出的反应
        dial.valueChanged.connect(lcd.display)

        self.show()
Exemplo n.º 7
0
    def addDial(self, title, x, y, w, h, labelX, minimum, maximum, key):

        label = QLabel(self.window)
        label.setText(title)
        label.setGeometry(labelX, y + h, w, 20)

        dial = QDial(self.window)
        dial.setGeometry(x, y, w, h)
        dial.setMinimum(minimum)
        dial.setMaximum(maximum)
        dial.valueChanged.connect(lambda: self.updateDial(dial))

        valueLabel = QLabel(self.window)
        valueLabel.setText(str(dial.value()))
        valueLabel.setGeometry(
            dial.geometry().x() + int(dial.geometry().width() / 2) - 5, y - 35,
            w, h)

        self.dialList.append([key, dial, label, valueLabel])
Exemplo n.º 8
0
class Example(QWidget):
    def __init__(self):
        super().__init__()
        # 创建 QLCDNumber、QDial、slider
        self.lcd = QLCDNumber(self)
        self.dial = QDial(self)
        self.slider = QSlider(self)
        # 设定各个部件属性
        self.initUI()

    def initUI(self):
        # 设置窗口
        self.setWindowTitle("信号、槽")
        self.setGeometry(300, 300, 300, 200)
        # 设置 QLCDNumber、QDial
        self.lcd.setGeometry(115, 50, 70, 40)
        self.dial.setGeometry(80, 120, 70, 70)
        self.slider.setGeometry(190, 120, 20, 70)
        # 事件绑定
        self.dial.valueChanged.connect(self.lcd.display)
        self.slider.valueChanged.connect(self.lcd.display)
        # 窗口显示
        self.show()
Exemplo n.º 9
0
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_()
Exemplo n.º 10
0
class dial_4vent(QWidget):
    style ='''
    QDial
    {
        background-color: rgb(255,255,255);
        font: 15px Menlo;
        color: rgb(0, 0, 131);
        /*text-align: left;*/
    }
    QLabel {
        /*border: 1px solid white;*/
        border-radius: 5px;
        background-color:  rgb(172, 236, 217);
        font: 15px Verdana, sans-serif;
        color:  rgb(0, 0, 131);
        text-align: center;
    }
    '''
    def __init__(self, title, min, max, **kwargs):
        super().__init__()
        self.title = title
        self.min   = min;self.max = max; self.moved_cbs = []
        self.layout = QGridLayout()
        self.label0 = QLabel(self)
        self.label  = QLabel(self)
        self.dial   = QDial()
        self.bar    = _Bar(["#5e4fa2", "#3288bd", "#66c2a5", "#abdda4",
                            "#e6f598", "#ffffbf", "#fee08b", "#fdae61",
                            "#f46d43", "#d53e4f", "#9e0142"])
        #_Bar(20) for pink ["#49006a", "#7a0177", "#ae017e", "#dd3497", "#f768a1", "#fa9fb5", "#fcc5c0", "#fde0dd", "#fff7f3"]
        self.label0.setStyleSheet(self.style)
        self.dial.setStyleSheet(self.style)
        self.label.setStyleSheet(self.style)
        self.dial.setMinimum(self.min)
        self.dial.setMaximum(self.max)
        self.dial.setValue(self.max)
        self.dial.setNotchesVisible(True)
        self.dial.valueChanged.connect(self.slider_moved)
        self.dial.setWrapping(False)
        self.dial.setGeometry(QtCore.QRect(25,25,100,100))
        self.layout.addWidget(self.label0, 0, 0, 1, 1)
        self.layout.addWidget(self.dial,1,0,1,1)
        self.layout.addWidget(self.bar,1,1,1,1)
        self.layout.addWidget(self.label,2,0, 1, 1)
        self.setLayout(self.layout)
        self.label0.setText(self.title)
        self.label.setStyleSheet("font-family: Impact, Charcoal, sans-serif");
        self.label.setText(str(self.dial.value()))
        #self.dial.installEventFilter(self) ## disables person using mouse
        self.show()
        ## Bar related initalization
        self.add_slider_moved(self.bar._trigger_refresh)
        # Take NO feedback from click events on the meter.
        self.bar.installEventFilter(self)

    def __getattr__(self, name):
        if name in self.__dict__:
            return self[name]
        return getattr(self.dial, name)

    def eventFilter(self, source, event):
        if (source is self.dial and isinstance(event, (
            QtGui.QMouseEvent, QtGui.QWheelEvent, QtGui.QKeyEvent))):
            return True
        return QtGui.QWidget.eventFilter(self, source, event)

    def slider_moved(self):
        self.label.setText(str(self.dial.value()))
        for fn in self.moved_cbs:
            fn()
    def add_slider_moved(self, func):
        self.moved_cbs.append(func)

    def setColor(self, color):
        self.bar.steps = [color] * self.bar.n_steps
        self.bar.update()

    def setColors(self, colors):
        self.bar.n_steps = len(colors)
        self.bar.steps = colors
        self.bar.update()

    def setBarPadding(self, i):
        self.bar._padding = int(i)
        self.bar.update()

    def setBarSolidPercent(self, f):
        self.bar.bar_solid_percent = float(f)
        self.bar.update()

    def setBackgroundColor(self, color):
        self.bar._background_color = QtGui.QColor(color)
        self.bar.update()
Exemplo n.º 11
0
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)