Beispiel #1
0
    def __init__(self, parent=None):
        super(inputPannel, self).__init__(parent)

        # 화면 구성
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        self.device_handler = None
        self.location = None

        from src.widgets.inputWidget.protocolAssembler.protocolAssembler import protocolAssembler
        self.protocol_assembler = protocolAssembler(
            self.ui.widget_protocolAssembler)

        from src.widgets.inputWidget.protocolMangerWidget.protocolManagerWidget import protocolManager
        self.protocol_manager = protocolManager(
            self.ui.widget_protocol_manager)

        # 클래스간의 통신을 위한 설정
        self.protocol_assembler.set_handler(self.protocol_manager)
        self.protocol_manager.set_handler(self.protocol_assembler)

        # self.protocol_manager.ui.pb_save.connect(
        #     self.protocol_manager.ui.pb_save,
        #     QtCore.SIGNAL("clicked()"),
        #     self.sig_protocol_manager_save
        #     )

        self.send_thread = threadSendData(self.commSignal)
Beispiel #2
0
 def init_ui(self):
     self.app = QtWidgets.QApplication(sys.argv)
     self.window = QtWidgets.QWidget()
     self.ui = Ui_Form()
     self.ui.setupUi(self.window)
     self.window.show()
     self.setup_connections()
     self.ui.optionsLineEdit.setText(basename(self.pizza.options_file))
Beispiel #3
0
class addTab(QtGui.QWidget):
    def __init__(self, parent=None):
        super(addTab, self).__init__(parent)

        self.ui = Ui_Form()
        self.ui.setupUi(self)

    def slot_add_data_port(self):
        pass

    def slot_test(self, text):
        print text
Beispiel #4
0
class addTab(QtGui.QWidget):
    def __init__(self, parent = None):
        super(addTab, self).__init__(parent)

        self.ui = Ui_Form()
        self.ui.setupUi(self)

    def slot_add_data_port(self):
        pass

    def slot_test(self, text):
        print text
Beispiel #5
0
    def __init__(self,parent=None):
        super(MainWindow,self).__init__(parent)

        self.settings=QtCore.QSettings('./settings.ini',QtCore.QSettings.IniFormat)
        if not exists("./settings.ini"):
            self.settings.setValue("PORT",12345)
        self.settings.sync()#to create the ini file


        self.ui=Ui_Form()
        self.ui.setupUi(self)
        #read config ->userkey ->ua

        self.ui.Button_USERKEY.clicked.connect(self.on_Button_USERKEY_Clicked)
        self.ui.Button_GETKEY.clicked.connect(self.on_Button_GETKEY_Clicked)
        #self.ui.LineEdit_USERKEY.setText("86cbb0f770854622874dd3222cb6243c")
        self.worker=ThreadWorker() #Key
        self.connect(self.worker,QtCore.SIGNAL("socketerror()"),self.afterSocketError)

        
        self.userkey=self.settings.value("USERKEY")
        self.ui.LineEdit_USERKEY.setText(self.userkey.toString())
        
        self.show()
        self.port=self.settings.value("PORT").toInt()[0]
        if not 1024<self.port<65535:
            self.port=12345
            QtGui.QMessageBox.critical(self,u"错误" ,u"端口号必须在1024~65535之间\n现在强制设置为12345\n如需更改请重新设置settings.ini的PORT")
            #how to quit?
            pass 
Beispiel #6
0
    def __init__(self, parent= None):
        super(inputPannel, self).__init__(parent)

        # 화면 구성
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        self.device_handler = None
        self.location = None

        from src.widgets.inputWidget.protocolAssembler.protocolAssembler import protocolAssembler
        self.protocol_assembler = protocolAssembler(self.ui.widget_protocolAssembler)

        from src.widgets.inputWidget.protocolMangerWidget.protocolManagerWidget import protocolManager
        self.protocol_manager = protocolManager(self.ui.widget_protocol_manager)

        # 클래스간의 통신을 위한 설정
        self.protocol_assembler.set_handler(self.protocol_manager)
        self.protocol_manager.set_handler(self.protocol_assembler)

        # self.protocol_manager.ui.pb_save.connect(
        #     self.protocol_manager.ui.pb_save,
        #     QtCore.SIGNAL("clicked()"),
        #     self.sig_protocol_manager_save
        #     )

        self.send_thread = threadSendData(self.commSignal)
Beispiel #7
0
class MyCalc(QWidget):
    port = 0
    zhuangtai = 0

    def __init__(self, parent=None):
        super().__init__(parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        self.ui.pushButton.clicked.connect(self.kaishi)

    def kaishi(self):
        self.port = self.ui.lineEdit.selectedText()
        self.zhuangtai = 1
        #if self.port > 65535 or self.port < 1024:
        #pass
        #QtWidgets.QMessageBox.question(self, '警告', '退出后测试将停止,\n你确认要退出吗?',QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No)
        #self.QMessageBox.information(self,'提示','端口号应该大于1024且小于65535')
        self.ui.pushButton.setEnabled(0)
        self.ui.pushButton.setText('正在运行')
        self.ui.lineEdit.setEnabled(0)
    def __init__(self):
        super(Main, self).__init__()

        # build ui
        self.ui = Ui_Form()
        self.ui.setupUi(self)

        # connect signals
        # self.ui.pushButton.connect(self.on_button)
        self.ui.progressBar.reset()
        self.ui.pushButton.clicked.connect(self.download)

        self.ui.pushButton_2.clicked.connect(self.exitFun)
Beispiel #9
0
class MainForm(QtGui.QMainWindow):
    def __init__(self, parent=None):
        super(MainForm, self).__init__()
        self.ui = Ui_Form()
        self.ui.setupUi(self)
Beispiel #10
0
    def __init__(self, parent=None):
        super(addTab, self).__init__(parent)

        self.ui = Ui_Form()
        self.ui.setupUi(self)
Beispiel #11
0
    def __init__(self, parent=None):
        super(Ui, self).__init__(parent)
        self.pcr_yorn = False
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        self.paramSelect = []
        self.paramSelect_group = []
        self.run = Run()
        self.state = 0
        self.setAcceptDrops(True)
        #
        self.button_params_ok = self.ui.button_params_ok
        self.tabwidget_run = self.ui.tabwidget_run
        self.params_panel = self.ui.params_widget
        self.control_panel = self.ui.widget
        self.buttonauto = self.ui.Buttonautorun
        self.buttonorder = self.ui.buttonorder
        self.buttonstart = self.ui.buttonrun
        self.buttonback = self.ui.buttonback
        self.button_autoselect = self.ui.buttonautoselect
        self.button_refineall = self.ui.buttonrefineall
        self.button_clearall = self.ui.buttonclearall
        self.button_output = self.ui.buttonoutput
        self.button_fold_paramstable = self.ui.buttonfold
        self.textshow = self.ui.texteditshow
        self.textrwp = self.ui.textrwp
        self.tableprofile = self.ui.tableWidgetprofile
        self.tableatom = self.ui.tableWidgetatom
        self.tableatombiso = self.ui.tableWidgetatombiso
        self.tableins = self.ui.tableWidgetins
        self.tableother = self.ui.tableWidgetother
        self.tableocc = self.ui.tableWidgetocc
        self.tab_refine = self.ui.tabWidgettable
        self.table = []
        self.table.append(self.tableprofile)
        self.table.append(self.tableins)
        self.table.append(self.tableatom)
        self.table.append(self.tableatombiso)
        self.table.append(self.tableother)
        self.table.append(self.tableocc)
        self.buttonopen = self.ui.buttonopen
        self.window_order = Ui_order()
        self.window_output = Ui_output_Form()
        self.text_path = self.ui.text_path
        self.table_phase = self.ui.spinbox_phase.value()
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(_fromUtf8("autofp.ico")),
                       QtGui.QIcon.Normal, QtGui.QIcon.Off)
        icon.addPixmap(QtGui.QPixmap(_fromUtf8("autofp.ico")),
                       QtGui.QIcon.Normal, QtGui.QIcon.On)
        icon.addPixmap(QtGui.QPixmap(_fromUtf8("autofp.ico")),
                       QtGui.QIcon.Active, QtGui.QIcon.On)
        self.setWindowIcon(icon)

        self.ui.splitter.resize(self.size())
        self.params_fold = False
        self.show()
        self.fold_paramstable()
        #
        QtCore.QObject.connect(self.ui.pushButton_prf2origin,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.prf2origin)
        QtCore.QObject.connect(self, QtCore.SIGNAL(_fromUtf8("close()")),
                               self.stop_autofp)
        QtCore.QObject.connect(self.buttonauto,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.autorunfp)
        QtCore.QObject.connect(self.button_autoselect,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.auto_select)
        QtCore.QObject.connect(self.button_refineall,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.table_select_all)  #select all params
        QtCore.QObject.connect(self.button_clearall,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.table_clear_all)  #clear all params
        QtCore.QObject.connect(self.buttonstart,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.runfullprof)
        QtCore.QObject.connect(self.buttonback,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.back)
        QtCore.QObject.connect(self.buttonopen,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.openfile)
        QtCore.QObject.connect(self.buttonorder,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.open_order)
        QtCore.QObject.connect(self.button_output,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.outputset)
        QtCore.QObject.connect(self.button_fold_paramstable,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.fold_paramstable)
        QtCore.QObject.connect(self.button_params_ok,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.fold_paramstable)
        QtCore.QObject.connect(self.ui.spinbox_phase,
                               QtCore.SIGNAL(_fromUtf8("valueChanged(int)")),
                               self.phase_change)
        QtCore.QObject.connect(self.ui.button_stop,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.stop_autofp)
        self.txt_signal.connect(self.showMsg)
        self.autofp_done_signal.connect(self.autorunfp_result)
        self.status_signal.connect(self.showMsg)
        return
Beispiel #12
0
class Ui(QtGui.QMainWindow):
    def __init__(self, parent=None):
        super(Ui, self).__init__(parent)
        self.pcr_yorn = False
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        self.paramSelect = []
        self.paramSelect_group = []
        self.run = Run()
        self.state = 0
        self.setAcceptDrops(True)
        #
        self.button_params_ok = self.ui.button_params_ok
        self.tabwidget_run = self.ui.tabwidget_run
        self.params_panel = self.ui.params_widget
        self.control_panel = self.ui.widget
        self.buttonauto = self.ui.Buttonautorun
        self.buttonorder = self.ui.buttonorder
        self.buttonstart = self.ui.buttonrun
        self.buttonback = self.ui.buttonback
        self.button_autoselect = self.ui.buttonautoselect
        self.button_refineall = self.ui.buttonrefineall
        self.button_clearall = self.ui.buttonclearall
        self.button_output = self.ui.buttonoutput
        self.button_fold_paramstable = self.ui.buttonfold
        self.textshow = self.ui.texteditshow
        self.textrwp = self.ui.textrwp
        self.tableprofile = self.ui.tableWidgetprofile
        self.tableatom = self.ui.tableWidgetatom
        self.tableatombiso = self.ui.tableWidgetatombiso
        self.tableins = self.ui.tableWidgetins
        self.tableother = self.ui.tableWidgetother
        self.tableocc = self.ui.tableWidgetocc
        self.tab_refine = self.ui.tabWidgettable
        self.table = []
        self.table.append(self.tableprofile)
        self.table.append(self.tableins)
        self.table.append(self.tableatom)
        self.table.append(self.tableatombiso)
        self.table.append(self.tableother)
        self.table.append(self.tableocc)
        self.buttonopen = self.ui.buttonopen
        self.window_order = Ui_order()
        self.window_output = Ui_output_Form()
        self.text_path = self.ui.text_path
        self.table_phase = self.ui.spinbox_phase.value()
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(_fromUtf8("autofp.ico")),
                       QtGui.QIcon.Normal, QtGui.QIcon.Off)
        icon.addPixmap(QtGui.QPixmap(_fromUtf8("autofp.ico")),
                       QtGui.QIcon.Normal, QtGui.QIcon.On)
        icon.addPixmap(QtGui.QPixmap(_fromUtf8("autofp.ico")),
                       QtGui.QIcon.Active, QtGui.QIcon.On)
        self.setWindowIcon(icon)

        self.ui.splitter.resize(self.size())
        self.params_fold = False
        self.show()
        self.fold_paramstable()
        #
        QtCore.QObject.connect(self.ui.pushButton_prf2origin,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.prf2origin)
        QtCore.QObject.connect(self, QtCore.SIGNAL(_fromUtf8("close()")),
                               self.stop_autofp)
        QtCore.QObject.connect(self.buttonauto,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.autorunfp)
        QtCore.QObject.connect(self.button_autoselect,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.auto_select)
        QtCore.QObject.connect(self.button_refineall,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.table_select_all)  #select all params
        QtCore.QObject.connect(self.button_clearall,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.table_clear_all)  #clear all params
        QtCore.QObject.connect(self.buttonstart,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.runfullprof)
        QtCore.QObject.connect(self.buttonback,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.back)
        QtCore.QObject.connect(self.buttonopen,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.openfile)
        QtCore.QObject.connect(self.buttonorder,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.open_order)
        QtCore.QObject.connect(self.button_output,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.outputset)
        QtCore.QObject.connect(self.button_fold_paramstable,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.fold_paramstable)
        QtCore.QObject.connect(self.button_params_ok,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.fold_paramstable)
        QtCore.QObject.connect(self.ui.spinbox_phase,
                               QtCore.SIGNAL(_fromUtf8("valueChanged(int)")),
                               self.phase_change)
        QtCore.QObject.connect(self.ui.button_stop,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.stop_autofp)
        self.txt_signal.connect(self.showMsg)
        self.autofp_done_signal.connect(self.autorunfp_result)
        self.status_signal.connect(self.showMsg)
        return

    def fold_paramstable(self):
        if self.params_fold == False:
            control_geo = self.control_panel.geometry()
            self.params_panel_width = control_geo.x()
            form_geo = self.geometry()
            form_geo.setX(form_geo.x() + control_geo.x())
            self.setGeometry(form_geo)
            self.params_panel.hide()
            self.button_fold_paramstable.setText(_fromUtf8("<"))
            self.params_fold = True
        else:
            form_geo = self.geometry()
            form_geo.setX(form_geo.x() - self.params_panel_width)
            self.setGeometry(form_geo)
            self.params_panel.show()
            self.button_fold_paramstable.setText(_fromUtf8(">"))
            self.params_fold = False

    def outputset(self):
        self.window_output.show()
        return

    def prf2origin(self):
        path = self.run.codefile + ".prf"
        prf2origin.prf2origin.python.prf2origin.origin = com.origin_path
        self.write(com.origin_path + " " + path)
        prf2origin.prf2origin.python.prf2origin.prf_to_origin(path)

    def open_order(self):
        self.window_order.show()

    def auto_select(self):
        j = 0
        for i in self.paramSelect:
            qr = QCheckBox()
            qr = i
            qr.setChecked(True)
            if self.run.params.get_param_fullname(j).find("_L") != -1:
                qr.setChecked(False)
            j += 1
        self.showMsg("Autoselect ok!")
        if self.params_fold == True:
            self.fold_paramstable()

    def table_clear_all(self):
        self.table_select_all(0)

    def table_select_all(self, arg=1):
        tab = QTabWidget()
        tab = self.tab_refine
        index = tab.currentIndex()
        s = True
        table_select = QTableWidget()
        table_select = self.table[index]
        string = "select all param of table " + str(index)
        if arg == 0:
            s = False
            string = "clear all param of table " + str(index)
        for i in range(0, len(self.paramSelect_group)):
            if self.paramSelect_group[i] == index:
                self.paramSelect[i].setChecked(s)
        self.showMsg(string)

    def phase_change(self, p):
        self.table_phase = self.ui.spinbox_phase.value()
        paramSelect_backup = self.paramSelect
        param_state = []
        for i in self.paramSelect:
            param_state.append(i.isChecked())
        self.updateTable()
        for n in range(0, len(self.paramSelect)):
            self.paramSelect[n].setChecked(param_state[n])

    def insertParam(self, param_index):
        param = self.run.params.paramlist[param_index]
        table_index = self.run.params.get_param_group(param_index)
        tablep = self.table[table_index]
        qr = QtGui.QCheckBox()
        qr.setStyleSheet("QCheckBox::indicator { width:16px; height:16px; }")
        if self.run.params.get_phase(param_index) == self.table_phase:
            rowcount = tablep.rowCount()
            tablep.insertRow(rowcount)
            tablep.setCellWidget(
                rowcount, 0, QtGui.QLabel(self.run.params.alias[param_index]))
            tablep.setCellWidget(rowcount, 2,
                                 QtGui.QLabel(str(param.realvalue)))
            tablep.setCellWidget(rowcount, 3, qr)
        if param.codeWord > 0:
            qr.setChecked(True)
        self.paramSelect.append(qr)
        self.paramSelect_group.append(table_index)
        return

    def autorunfp(self):
        if self.state == 0:
            self.write("No Pcr file!")
            return -1
        if self.params_fold == False:
            self.fold_paramstable()

        self.cycle = self.ui.spinBox.value()
        com.run_set.output[
            "Cif"] = self.window_order.ui.checkBox_cif.isChecked()
        com.run_set.eps = self.window_order.ui.spinbox_eps.value() / 100.0
        com.run_set.NCY = self.window_order.ui.spinbox_ncy.value()
        self.textrwp.clear()
        self.updateFit(True)
        self.run.writepcr()

        self.showMsg("start!")
        com.autofp_running = True
        subautorun = SubAutoRun()
        subautorun.reset(self.run.pcrfilename, self.param_switch, self.run,
                         self.window_order.order, self.textshow)
        subautorun.run()

    def done_output(self):  # auto refinement over!
        rpa_raw = 0
        com.des = False
        self.write(" ")
        self.write("weight of phase [phase1, phase2, phase3 ... ]:",
                   style="ok")
        wp = com.wphase.get_w(self.run)
        self.write(str(wp), style="ok")
        self.write("AutoFP version: v_" + com.run_set.setjson["version"])
        if com.run_set.output["Cif"] == True:
            rpa_raw = self.run.fit.get("Rpa")
            self.run.fit.set("Rpa", -1)
            self.run.writepcr()
            self.run.runfp()
            self.run.fit.set("Rpa", rpa_raw)
            self.run.writepcr()

    def autorunfp_result(self, r):
        rwp = r
        self.write("end! \n Rwp=" + str(rwp), "ok")
        self.textrwp.setText(str(rwp))
        self.run.resetLoad()
        self.run.push()

        # cycles loop
        if com.autofp_running == True:
            if com.cycle >= self.cycle:
                if self.cycle > 0:
                    com.cycle = 1
                    self.updateTable()
                    self.done_output()
                if self.cycle == 0:
                    if com.des == True or com.cycle > 100:
                        com.cycle = 1
                        self.updateTable()
                        self.done_output()
                        com.des = False
                    else:
                        com.cycle = com.cycle + 1
                        self.autorunfp()
            else:
                com.cycle = com.cycle + 1
                self.autorunfp()
        else:
            self.write("autofp has been stoped by user!", style="warning")
            com.cycle = 1
            self.updateTable()
            self.done_output()

        self.showMsg(str(com.cycle) + " ok!")
        return

    def closeEvent(self, event):
        result = QtGui.QMessageBox.question(
            self, "Confirm Exit...", "Are you sure you want to exit ?",
            QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
        event.ignore()

        if result == QtGui.QMessageBox.Yes:
            self.stop_autofp()
            for p in com.plot.jobs_s:
                p.terminate()
            event.accept()

    def stop_autofp(self):
        com.autofp_running = False

    def updateFit(self, auto=False):
        self.param_switch = []
        qr = QCheckBox()
        for i in range(0, self.run.params.param_num):
            qr = self.paramSelect[i]
            self.param_switch.append(
                qr.isChecked())  #for the autorun paramorder
            print qr.isChecked(), self.run.params.get_param_fullname(i)
            if (auto == False):
                self.run.setParam(i, qr.isChecked())
            else:
                if (qr.isChecked() == False):
                    self.run.setParam(i, qr.isChecked())

    def runfullprof(self):
        self.updateFit()
        self.run.writepcr()
        self.run.runfp()
        self.textrwp.setText(str(self.run.Rwp))
        self.showMsg(str(self.run.Rwp))
        self.showMsg("run ok!")
        self.updateTable()
        return

    def openfile(self):
        selectFileNames = QtGui.QFileDialog.getOpenFileNames(
            None, _fromUtf8("Choose a file name"), ".",
            _fromUtf8("FullProf PCR File(*.pcr)"))
        if len(selectFileNames) <= 0:
            return
        print "open *.pcr: ", selectFileNames[0].toLocal8Bit()
        path = ""
        path = str(selectFileNames[0].toLocal8Bit())  #,'gbk',"ignore")
        self.open(path)

    def open(self, path):
        self.state = 1
        self.run = Run()  # get a new Run()
        self.showMsg(path + " open")
        self.run.reset(path)
        self.text_path.setText(unicode(path, "gbk", "ignore"))
        self.updateTable()
        self.pcr_yorn = True
        self.window_order.init(self.run.job)
        self.window_order.ui.combobox_job.currentIndex = self.run.job
        self.tabwidget_run.setEnabled(True)
        return

    txt_signal = QtCore.pyqtSignal(str)
    autofp_done_signal = QtCore.pyqtSignal(float)
    status_signal = QtCore.pyqtSignal(str, str)

    def write(self, s, style="normal"):
        s = com.text_style[style] + s
        self.txt_signal.emit(s)

    def flush(self):
        return 0

    def write_status(self, s, style="normal"):
        self.status_signal.emit(s, "status")

    def showMsg(self, s, strrwp=" "):
        self.textshow.append(s)
        if strrwp == "status":
            s = str(s)
            msg = s.split(':')
            self.ui.labelpar.setText(msg[1])
            self.ui.progress.setValue(int(msg[2]))

    def showRwp(self, str):
        self.textrwp.append(str)

    def back(self):
        self.showMsg("back!")
        self.run.back()
        self.showMsg("step=" + str(self.run.step_index))
        self.updateTable()
        self.textrwp.setText(str(self.run.Rwp))
        return

    def updateTable(self):
        for i in range(0, len(self.table)):
            self.table[i].setRowCount(0)
        self.showMsg("update table ok!")
        self.paramSelect = []
        self.paramSelect_group = []
        for i in range(0, self.run.params.param_num):
            self.insertParam(i)

    def dragEnterEvent(self, event):
        if event.mimeData().hasUrls:
            event.accept()
        else:
            event.ignore()

    def dropEvent(self, event):
        if event.mimeData().hasUrls:
            event.setDropAction(QtCore.Qt.CopyAction)
            event.accept()
            newText = ""
            for url in event.mimeData().urls():
                newText += str(url.toLocalFile())
            self.text_path.setText(newText)
            self.open(newText)
            self.emit(QtCore.SIGNAL("dropped"))
        else:
            event.ignore()
Beispiel #13
0
    ui.updateButton.setEnabled(True)
    ui.scanButton.setEnabled(True)

def destructor():
    app.exec_()
    if not updaterThread.isAlive() and not scanFilesThread.isAlive():
        updater.close()
    return 0

if __name__ == "__main__":
    config = configparser.ConfigParser()
    config.read('server-config.cfg')

    app = QtGui.QApplication(sys.argv)
    Form = QtGui.QWidget()
    ui = Ui_Form()
    ui.setupUi(Form)

    updater = updater(ui)
    loginResponse = updater.login(config)

    QtCore.QObject.connect(ui.updateButton, QtCore.SIGNAL("clicked()"), startUpdaterThread)
    QtCore.QObject.connect(ui.scanButton, QtCore.SIGNAL("clicked()"), startScanThread)

    Form.show()

    checkDifferThread = threading.Thread( target=checkDiffer, args=( ) )
    statusThread = threading.Thread( target=ui.labelStatus, args=( ) )
    updaterThread = threading.Thread( target=updateFiles, args=( ) )
    scanFilesThread = threading.Thread( target=scanFiles , args=( ) )
    checkDifferThread.setDaemon(True)
Beispiel #14
0
class inputPannel(QtGui.QWidget):
    commSignal = QtCore.pyqtSignal(str, int)

    START = True
    STOP = False

    def __init__(self, parent= None):
        super(inputPannel, self).__init__(parent)

        # 화면 구성
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        self.device_handler = None
        self.location = None

        from src.widgets.inputWidget.protocolAssembler.protocolAssembler import protocolAssembler
        self.protocol_assembler = protocolAssembler(self.ui.widget_protocolAssembler)

        from src.widgets.inputWidget.protocolMangerWidget.protocolManagerWidget import protocolManager
        self.protocol_manager = protocolManager(self.ui.widget_protocol_manager)

        # 클래스간의 통신을 위한 설정
        self.protocol_assembler.set_handler(self.protocol_manager)
        self.protocol_manager.set_handler(self.protocol_assembler)

        # self.protocol_manager.ui.pb_save.connect(
        #     self.protocol_manager.ui.pb_save,
        #     QtCore.SIGNAL("clicked()"),
        #     self.sig_protocol_manager_save
        #     )

        self.send_thread = threadSendData(self.commSignal)

    def set_conf(self, device_handler, location):
        self.device_handler = device_handler
        self.location = location
        self.send_thread.set_conf(None, 0, self.device_handler, location)

    def slot_send_data(self):
        interval = int(self.ui.sp_intervalTime.text())
        check_auto_send = self.ui.checkBox_autoSending.isChecked()
        if self.device_handler is None: # 통신설정이 이루어지지 않았음
            if __package__ is None:
                print 'No Handler'
            return
        if self.device_handler.isOpen() is not True:
            if __package__ is None:
                print 'device is not open now'
            return

        data_buf = self.protocol_assembler.get_assembled_data()
        self.send_thread.set_conf(data_buf, interval, self.device_handler, self.location)

        if self.send_thread.is_running() is True:
            self.ui.pb_sendButton.setText(u'전송')
            self.send_thread.stop()
        else:
            if check_auto_send is True: # 자동전송 기능 활성 검사
                self.ui.pb_sendButton.setText(u'중지')
                self.send_thread.stop()
                self.send_thread.start()
            else:
                self.send_thread.send_data() # 한번 보내기

    def stop(self):
        print 'stop'
        self.ui.pb_sendButton.setText(u'전송')
        self.send_thread.stop()
Beispiel #15
0
    def __init__(self, parent=None):
        super(protocolAssembler, self).__init__(parent)

        # 화면 구성
        self.ui = Ui_Form()
        self.ui.setupUi(self)
Beispiel #16
0
    def __init__(self, parent=None):
        super(protocolAssembler, self).__init__(parent)

        # 화면 구성
        self.ui = Ui_Form()
        self.ui.setupUi(self)
Beispiel #17
0
    def __init__(self, parent = None):
        super(addTab, self).__init__(parent)

        self.ui = Ui_Form()
        self.ui.setupUi(self)
class Main(QtGui.QMainWindow):
    def __init__(self):
        super(Main, self).__init__()

        # build ui
        self.ui = Ui_Form()
        self.ui.setupUi(self)

        # connect signals
        # self.ui.pushButton.connect(self.on_button)
        self.ui.progressBar.reset()
        self.ui.pushButton.clicked.connect(self.download)

        self.ui.pushButton_2.clicked.connect(self.exitFun)


    def download(self):
        self.ui.progressBar.reset()
        url = str(self.ui.textEdit.toPlainText())
        request = urllib2.Request(url)
        request.get_method = lambda : 'HEAD'

        response = urllib2.urlopen(request)
        response.close()
        # print response.info()
        con_length= response.headers['content-length']
        packet_size = int(con_length)/4
        part1=part2=part3=part4= ''

        threads =[]
        try:
            # t1=Thread(target=download_part,args= ("Thread-1", url,0,packet_size, part1))
            t1 = GetTitleThread("Thread-1", url,0,packet_size, part1)
            threads.append(t1)

            # t2=Thread(target=download_part,args= ("Thread-2", url,packet_size,packet_size*2, part2))
            t2 = GetTitleThread("Thread-2", url,packet_size+1,packet_size*2, part2)
            threads.append(t2)

            # t3=Thread(target=download_part,args= ("Thread-3", url, packet_size*2, packet_size * 3, part3))
            t3 = GetTitleThread("Thread-3", url, packet_size*2+1, packet_size * 3, part3)
            threads.append(t3)

            # t4=Thread(target=download_part,args= ("Thread-4", url, packet_size*3, packet_size *4, part4))
            t4 = GetTitleThread("Thread-4", url, packet_size*3+1, packet_size *4, part4)
            threads.append(t4)

            t1.start()
            t2.start()
            t3.start()
            t4.start()
        except:
            print "Error: unable to start thread"


        for t in threads:
            t.join()

        target = open(str(self.ui.textEdit_2.toPlainText()),'wb')
        data =''
        for t in threads:
            data += t.part
        target.write(data)

        target.close()

        self.ui.progressBar.setValue(100)
        print 'Button clicked!'

    def exitFun(self):
        exit(1)
Beispiel #19
0
 def __init__(self, parent=None):
     super().__init__(parent)
     self.ui = Ui_Form()
     self.ui.setupUi(self)
     self.ui.pushButton.clicked.connect(self.kaishi)
Beispiel #20
0
class PizzaApp(QObject):
    ###
    # Connections
    ###
    def setup_connections(self):
        self.ui.browseButton.clicked.connect(self.on_browse_button_clicked)
        self.ui.randomizeButton.clicked.connect(
            self.on_randomize_button_clicked)
        self.ui.optionsLineEdit.textChanged.connect(self.on_options_file_set)
        self.ui.optionsLineEdit.textChanged.connect(self.clear_all_fields)

    ###
    # Slots
    ###
    @pyqtSlot()
    def on_browse_button_clicked(self):
        fname = QtWidgets.QFileDialog.getOpenFileName(self.window,
                                                      'Select file',
                                                      'menus',
                                                      filter='*.json')
        if fname[0]:
            self.pizza.options_file = fname[0]
            self.ui.optionsLineEdit.setText(basename(self.pizza.options_file))

    @pyqtSlot('QString')
    def on_options_file_set(self, arg1):
        options = self.pizza.load_options()
        max_toppings = len(self.pizza.options['toppings'])
        self.ui.maxToppingsLineEdit.setText(str(max_toppings))
        self.ui.toppingNumSelect.setMinimum(0)
        self.ui.toppingNumSelect.setMaximum(max_toppings)
        self.ui.toppingNumSelect.setValue(3)

    @pyqtSlot()
    def on_randomize_button_clicked(self):
        self.ui.toppingsListWidget.clear()
        self.pizza.num_toppings = self.ui.toppingNumSelect.value()
        self.pizza.randomize()
        self.populate_fields()

    @pyqtSlot()
    def clear_all_fields(self):
        self.ui.crustLineEdit.clear()
        self.ui.cheeseLevelLineEdit.clear()
        self.ui.sauceLineEdit.clear()
        self.ui.sauceLevelLineEdit.clear()
        self.ui.toppingsListWidget.clear()

    ###
    # Remaining methods
    ###
    def __init__(self):
        super(PizzaApp, self).__init__()
        self.pizza = Pizza()
        self.init_ui()

    def init_ui(self):
        self.app = QtWidgets.QApplication(sys.argv)
        self.window = QtWidgets.QWidget()
        self.ui = Ui_Form()
        self.ui.setupUi(self.window)
        self.window.show()
        self.setup_connections()
        self.ui.optionsLineEdit.setText(basename(self.pizza.options_file))

    def populate_fields(self):
        self.ui.crustLineEdit.setText(self.pizza.crust)
        self.ui.cheeseLevelLineEdit.setText(self.pizza.cheese_level)
        self.ui.sauceLineEdit.setText(self.pizza.sauce)
        self.ui.sauceLevelLineEdit.setText(self.pizza.sauce_level)
        for topping in self.pizza.toppings:
            self.ui.toppingsListWidget.addItem(topping)

    def run(self):
        sys.exit(self.app.exec_())
Beispiel #21
0
 def __init__(self, parent=None):
     super(MainForm, self).__init__()
     self.ui = Ui_Form()
     self.ui.setupUi(self)
Beispiel #22
0
# -*- coding: utf-8 -*-
from PyQt5 import QtWidgets
import sys
from ui import Ui_Form

if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    root = QtWidgets.QWidget()  #创建一个根容器
    window = Ui_Form()
    window.setupUi(root)  #将自己设计的ui加载到根容器中

    root.show()
    sys.exit(app.exec())  #运行
    pass
Beispiel #23
0
class inputPannel(QtGui.QWidget):
    commSignal = QtCore.pyqtSignal(str, int)

    START = True
    STOP = False

    def __init__(self, parent=None):
        super(inputPannel, self).__init__(parent)

        # 화면 구성
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        self.device_handler = None
        self.location = None

        from src.widgets.inputWidget.protocolAssembler.protocolAssembler import protocolAssembler
        self.protocol_assembler = protocolAssembler(
            self.ui.widget_protocolAssembler)

        from src.widgets.inputWidget.protocolMangerWidget.protocolManagerWidget import protocolManager
        self.protocol_manager = protocolManager(
            self.ui.widget_protocol_manager)

        # 클래스간의 통신을 위한 설정
        self.protocol_assembler.set_handler(self.protocol_manager)
        self.protocol_manager.set_handler(self.protocol_assembler)

        # self.protocol_manager.ui.pb_save.connect(
        #     self.protocol_manager.ui.pb_save,
        #     QtCore.SIGNAL("clicked()"),
        #     self.sig_protocol_manager_save
        #     )

        self.send_thread = threadSendData(self.commSignal)

    def set_conf(self, device_handler, location):
        self.device_handler = device_handler
        self.location = location
        self.send_thread.set_conf(None, 0, self.device_handler, location)

    def slot_send_data(self):
        interval = int(self.ui.sp_intervalTime.text())
        check_auto_send = self.ui.checkBox_autoSending.isChecked()
        if self.device_handler is None:  # 통신설정이 이루어지지 않았음
            if __package__ is None:
                print 'No Handler'
            return
        if self.device_handler.isOpen() is not True:
            if __package__ is None:
                print 'device is not open now'
            return

        data_buf = self.protocol_assembler.get_assembled_data()
        self.send_thread.set_conf(data_buf, interval, self.device_handler,
                                  self.location)

        if self.send_thread.is_running() is True:
            self.ui.pb_sendButton.setText(u'전송')
            self.send_thread.stop()
        else:
            if check_auto_send is True:  # 자동전송 기능 활성 검사
                self.ui.pb_sendButton.setText(u'중지')
                self.send_thread.stop()
                self.send_thread.start()
            else:
                self.send_thread.send_data()  # 한번 보내기

    def stop(self):
        print 'stop'
        self.ui.pb_sendButton.setText(u'전송')
        self.send_thread.stop()
Beispiel #24
0
class protocolAssembler(QtGui.QWidget):
    sendSignal = QtCore.pyqtSignal(str, int)

    def __init__(self, parent=None):
        super(protocolAssembler, self).__init__(parent)

        # 화면 구성
        self.ui = Ui_Form()
        self.ui.setupUi(self)

    def set_handler(self, handler):
        """
        프로토콜 매니져의 인스턴스 레퍼런스를 받는다
        """

        pass

    def get_protocol(self):
        """
        현재 입력된 프로토콜을 Hex 값으로 리턴
        """
        protocol = {}
        # 프로토콜은 항상 HEX로만 저장 할 수 있게,
        # 입력 포맷 상태 확인
        if self.ui.cb_hex_ascii.currentIndex() == 1:
            data = str(self.ui.le_data.text().toLatin1()).encode('hex')
        else:
            data = str(self.ui.le_data.text())

        protocol.update({
            'head1': str(self.ui.le_header_1.text()),
            'head2': str(self.ui.le_header_2.text()),
            'data': data,
            'tail1': str(self.ui.le_tail_1.text()),
            'tail2': str(self.ui.le_tail_2.text()),
        })
        return protocol



    def show_protocol(self, protocol):
        """
        프로토콜을 받아서 라인에디터에 표출
        """
        pass

    def slot_hex_or_ascii(self, status):
        # Hex 또는 Ascii 콤보 박스
        data = ''
        if self.ui.cb_hex_ascii.currentIndex() == 0:
            data = str(self.ui.le_data.text().toLatin1()).encode('hex')
        else:
            try:
                data = str(self.ui.le_data.text().toLatin1()).decode('hex')
            except Exception as detail:
                print detail

        self.ui.le_data.setText(data)

    def get_assembled_data(self):
        # 프로토콜란에 입력된 데이터를 하나의 문자열로 취합
        status = self.ui.cb_hex_ascii.currentIndex()
        head1 = '' + str(self.ui.le_header_1.text()).decode('hex')
        head2 = '' + str(self.ui.le_header_2.text()).decode('hex')

        if 0 == status:         # HEX 상태일 경우
            protocol = '' + str(self.ui.le_data.text()).decode('hex')
        else:
            protocol = '' + str(self.ui.le_data.text().toLatin1())

        tail1 = '' + str(self.ui.le_tail_1.text()).decode('hex')
        tail2 = '' + str(self.ui.le_tail_2.text()).decode('hex')

        data = '' + head1 + head2 + protocol + tail1 + tail2

        if __package__ is None:
            print data

        return data

    def slot_no_item(self):
        self.ui.le_header_1.setText('')
        self.ui.le_header_2.setText('')
        self.ui.le_tail_1.setText('')
        self.ui.le_tail_2.setText('')

    def slot_cr(self):
        self.ui.le_header_1.setText('')
        self.ui.le_header_2.setText('')
        self.ui.le_tail_1.setText('')
        self.ui.le_tail_2.setText('0d')

    def slot_lf(self):
        self.ui.le_header_1.setText('')
        self.ui.le_header_2.setText('')
        self.ui.le_tail_1.setText('')
        self.ui.le_tail_2.setText('0a')

    def slot_crlf(self):
        self.ui.le_header_1.setText('')
        self.ui.le_header_2.setText('')
        self.ui.le_tail_1.setText('')
        self.ui.le_tail_2.setText('0d0a')

    def slot_stx_etx_crlf(self):
        self.ui.le_header_1.setText('02')
        self.ui.le_header_2.setText('')
        self.ui.le_tail_1.setText('03')
        self.ui.le_tail_2.setText('0d0a')
Beispiel #25
0
class MainWindow(QtGui.QWidget):
    def __init__(self,parent=None):
        super(MainWindow,self).__init__(parent)

        self.settings=QtCore.QSettings('./settings.ini',QtCore.QSettings.IniFormat)
        if not exists("./settings.ini"):
            self.settings.setValue("PORT",12345)
        self.settings.sync()#to create the ini file


        self.ui=Ui_Form()
        self.ui.setupUi(self)
        #read config ->userkey ->ua

        self.ui.Button_USERKEY.clicked.connect(self.on_Button_USERKEY_Clicked)
        self.ui.Button_GETKEY.clicked.connect(self.on_Button_GETKEY_Clicked)
        #self.ui.LineEdit_USERKEY.setText("86cbb0f770854622874dd3222cb6243c")
        self.worker=ThreadWorker() #Key
        self.connect(self.worker,QtCore.SIGNAL("socketerror()"),self.afterSocketError)

        
        self.userkey=self.settings.value("USERKEY")
        self.ui.LineEdit_USERKEY.setText(self.userkey.toString())
        
        self.show()
        self.port=self.settings.value("PORT").toInt()[0]
        if not 1024<self.port<65535:
            self.port=12345
            QtGui.QMessageBox.critical(self,u"错误" ,u"端口号必须在1024~65535之间\n现在强制设置为12345\n如需更改请重新设置settings.ini的PORT")
            #how to quit?
            pass 
        

    def on_Button_GETKEY_Clicked(self):
        self.ui.Button_GETKEY.setEnabled(False)
        self.ui.Button_USERKEY.setEnabled(False)
        self.ui.Label_INFO.setText(u"正在监听端口"+str(self.port))
        self.getuserkeyworker=GetUserKeyWorker()
        self.getuserkeyworker.port=self.port
        self.getuserkeyworker.start()
        self.connect(self.getuserkeyworker,QtCore.SIGNAL("GetUserKey(QString)"),self.afterGetUserKey)
        self.connect(self.getuserkeyworker,QtCore.SIGNAL("socketerror()"),self.afterSocketError)
        
        pass

    def on_Button_USERKEY_Clicked(self):
        if not self.ui.LineEdit_USERKEY.text().isEmpty():
            self.ui.LineEdit_USERKEY.setEnabled(False)

            self.ui.Label_INFO.setText(u"验证账号中")
            self.ui.Button_USERKEY.setEnabled(False)
            self.ui.Button_GETKEY.setEnabled(False)
            self.validateworker=ValidateWorker(self.ui.LineEdit_USERKEY.text())
            self.validateworker.start()
            self.connect(self.validateworker,QtCore.SIGNAL("validate(QStringList)"),self.afterValidate)
    
    def afterGetUserKey(self,userkey):
        self.ui.LineEdit_USERKEY.setText(userkey)
        # self.ui.Button_USERKEY.click()
        self.on_Button_USERKEY_Clicked()
        pass

    def afterValidate(self,stringList):
        self.req_cookie=str(stringList[0])
        self.set_cookie=str(stringList[1])
        print self.req_cookie
        print self.set_cookie
        
        if self.set_cookie=="" or self.req_cookie=="":
            self.ui.Label_INFO.setText(u"验证失败")
            self.ui.Button_USERKEY.setEnabled(True)
            self.ui.Button_GETKEY.setEnabled(True)
            self.ui.LineEdit_USERKEY.setEnabled(True)
        else:
            self.ui.Label_INFO.setText(u"验证完毕")
            self.settings.setValue("USERKEY",self.ui.LineEdit_USERKEY.text())
            self.worker.userkey=self.ui.LineEdit_USERKEY.text()
            self.worker.req_cookie=self.req_cookie
            self.worker.set_cookie=self.set_cookie
            self.worker.port=self.port
            self.worker.start()
            self.ui.Label_INFO.setText(u"正在监听 127.0.0.1:"+str(self.port))
            self.ui.LineEdit_USERKEY.setEnabled(True)

    def afterSocketError(self):
        QtGui.QMessageBox.warning(u"Socket连接异常,请检查网络或换一个端口")
        self.ui.Button_USERKEY.setEnabled(True)
        self.ui.Button_GETKEY.setEnabled(True)
Beispiel #26
0
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
import os
from ui import Ui_Form

# SYNC APP QT:
app = QtWidgets.QApplication(sys.argv)
# VARS:
Form = QtWidgets.QWidget()
ui = Ui_Form()
database_dir = os.curdir + '/database/'
# INIT FORM:
ui.setupUi(Form)
Form.show()


# NEW USER:
def write_user():
    name = ui.name.text()
    if name != ' ':
        with open(database_dir + 'base.txt', 'a+') as file:
            file.write(name + "\r")
        with open(database_dir + 'base.txt', 'r') as rFile:
            ui.list.setText(rFile.read())
        ui.name.clear()


# CLEAR DATABASE:
def delete_database():
    os.remove(database_dir + 'base.txt')
Beispiel #27
0
class protocolAssembler(QtGui.QWidget):
    sendSignal = QtCore.pyqtSignal(str, int)

    def __init__(self, parent=None):
        super(protocolAssembler, self).__init__(parent)

        # 화면 구성
        self.ui = Ui_Form()
        self.ui.setupUi(self)

    def set_handler(self, handler):
        """
        프로토콜 매니져의 인스턴스 레퍼런스를 받는다
        """

        pass

    def get_protocol(self):
        """
        현재 입력된 프로토콜을 Hex 값으로 리턴
        """
        protocol = {}
        # 프로토콜은 항상 HEX로만 저장 할 수 있게,
        # 입력 포맷 상태 확인
        if self.ui.cb_hex_ascii.currentIndex() == 1:
            data = str(self.ui.le_data.text().toLatin1()).encode('hex')
        else:
            data = str(self.ui.le_data.text())

        protocol.update({
            'head1': str(self.ui.le_header_1.text()),
            'head2': str(self.ui.le_header_2.text()),
            'data': data,
            'tail1': str(self.ui.le_tail_1.text()),
            'tail2': str(self.ui.le_tail_2.text()),
        })
        return protocol

    def show_protocol(self, protocol):
        """
        프로토콜을 받아서 라인에디터에 표출
        """
        pass

    def slot_hex_or_ascii(self, status):
        # Hex 또는 Ascii 콤보 박스
        data = ''
        if self.ui.cb_hex_ascii.currentIndex() == 0:
            data = str(self.ui.le_data.text().toLatin1()).encode('hex')
        else:
            try:
                data = str(self.ui.le_data.text().toLatin1()).decode('hex')
            except Exception as detail:
                print detail

        self.ui.le_data.setText(data)

    def get_assembled_data(self):
        # 프로토콜란에 입력된 데이터를 하나의 문자열로 취합
        status = self.ui.cb_hex_ascii.currentIndex()
        head1 = '' + str(self.ui.le_header_1.text()).decode('hex')
        head2 = '' + str(self.ui.le_header_2.text()).decode('hex')

        if 0 == status:  # HEX 상태일 경우
            protocol = '' + str(self.ui.le_data.text()).decode('hex')
        else:
            protocol = '' + str(self.ui.le_data.text().toLatin1())

        tail1 = '' + str(self.ui.le_tail_1.text()).decode('hex')
        tail2 = '' + str(self.ui.le_tail_2.text()).decode('hex')

        data = '' + head1 + head2 + protocol + tail1 + tail2

        if __package__ is None:
            print data

        return data

    def slot_no_item(self):
        self.ui.le_header_1.setText('')
        self.ui.le_header_2.setText('')
        self.ui.le_tail_1.setText('')
        self.ui.le_tail_2.setText('')

    def slot_cr(self):
        self.ui.le_header_1.setText('')
        self.ui.le_header_2.setText('')
        self.ui.le_tail_1.setText('')
        self.ui.le_tail_2.setText('0d')

    def slot_lf(self):
        self.ui.le_header_1.setText('')
        self.ui.le_header_2.setText('')
        self.ui.le_tail_1.setText('')
        self.ui.le_tail_2.setText('0a')

    def slot_crlf(self):
        self.ui.le_header_1.setText('')
        self.ui.le_header_2.setText('')
        self.ui.le_tail_1.setText('')
        self.ui.le_tail_2.setText('0d0a')

    def slot_stx_etx_crlf(self):
        self.ui.le_header_1.setText('02')
        self.ui.le_header_2.setText('')
        self.ui.le_tail_1.setText('03')
        self.ui.le_tail_2.setText('0d0a')