コード例 #1
0
    def b_port_clicked(self):
        global listviewA
        listviewA = QListView(self)
        listviewA.setStyleSheet("font: 20px;  background-color: rgb(255,255,255);");
        listviewA.resize(220,80)
        listviewA.move(20,200)
        slm=QStringListModel()

        self.qList=serial_ports()
        slm.setStringList(self.qList)
        listviewA.setModel(slm)
        listviewA.clicked.connect(self.listviewA_clicked)
        listviewA.show()  #self.show()
コード例 #2
0
    def initWindow(self, hlabel):
        history_list = hlabel
        list_view = QListView(self)  # 리스트뷰 생성
        model = QStandardItemModel()  # 리스트 뷰에 들어갈 모델 생성

        for h in history_list:
            model.appendRow(QStandardItem(h))  # 모델에 한 줄 씩 추가

        list_view.setModel(model)  # 리스트 뷰에 모델 얹기
        list_view.resize(500, 500)

        self.setWindowTitle(self.title)  # 창 제목 세팅
        self.setGeometry(500, 250, 500, 500)
        self.show()
コード例 #3
0
    def run(self):
        QStandardItemModel
        items = []
        for i in range(1, 50):
            items.append("Application %d" % i)

        list = QListView(self)
        model = QStandardItemModel(list)
        for i in items:
            row = QStandardItem(i)
            row.setCheckable(True)
            model.appendRow(row)

        list.setWindowTitle('Example List')
        list.resize(200, 150)
        list.setModel(model)

        layout = QVBoxLayout()
        layout.addWidget(list)
        self.setLayout(layout)
        self.setGeometry(300, 300, 300, 200)
        self.setWindowTitle('Tooltips')
        self.show()
コード例 #4
0
    def initUI(self):
        
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        #a_combobox = QWidgets.QComboBox()
        comboA = QtWidgets.QComboBox(self)
        comboB = QtWidgets.QComboBox(self)
        #comboA.setGeometry(QtCore.QRect(400, 180, 200, 50))
        comboA.setGeometry(400, 210, 150, 80)
        comboB.setGeometry(20, 300, 220, 40)
        layoutA = QtWidgets.QVBoxLayout(comboA)
        layoutB = QtWidgets.QVBoxLayout(comboB)

        comboA.setStyleSheet("font: 20px; border-style: outset; border-width:1px ; border-color: rbg(128,128,128); color:rgb(0,0,255); background-color: rgb(255,255,255);");
        comboB.setStyleSheet("font: 20px; border-style: outset; border-width:1px ; border-color: rbg(128,128,128); color:rgb(255,0,0); background-color: rgb(255,255,255);");
        comboA.addItem("選擇連線硬體")
        comboA.addItem("Arduino")
        comboA.addItem("Circuit")
        comboA.addItem("ESP-8266")
        comboA.addItem("Picoboard")
        comboA.addItem("Raspberry Pi")
        comboB.addItem("選擇燒錄硬體")
        comboB.addItem("Arduino Uno")
        comboB.addItem("ESP-8266")
        comboB.addItem("Circuit")
        ##預設值
        comboA.setCurrentIndex(0)
         
        print (comboA.currentText())
        #self.comboA.move(400,200)
        #a_combobox.addItem(1,"TWO")
        #ui->ComboBox->insertItem(0,"ONE")
        #ui->ComboBox->insertItem(1,"SEC")
        #comboA.setGeometry(QtCore.QRect(70, 30, 131, 25))
        comboA.activated.connect(self.comboA_selectionchange)
        layoutA.addWidget(comboA)
        layoutB.addWidget(comboB)

        #label
        l_A = QLabel("連接硬體功能",self)
        l_A.setAlignment(QtCore.Qt.AlignCenter)
        l_A.resize(150,35)
        l_A.setStyleSheet("font: 20px; border-style: outset; border-width:1px ; border-color: rbg(128,128,128); text-align:center; color:rgb(255,0,255); background-color: rgb(255,255,255);");
        l_A.move(400,300)
        l_B = QLabel('',self)
        l_B.setPixmap(self.pixmap)
        l_B.resize(300,160)
        l_B.move(350,10)

        chk_B =QPushButton('燒錄韌體',self)
        chk_B.move(250,300)
        ##chk_B.setAlignment(QtCore.Qt.AlignCenter) ##//*置中*/
        chk_B.resize(120,35)
        chk_B.setStyleSheet("font: 20px; text-align:center; border-style: outset; border-width:1px ; border-color: rbg(128,128,128); color:rgb(255,0,255); background-color: rgb(255,255,255);");
        chk_B.setToolTip("先選擇設備port再選要燒入的硬體")
        # 當 button1 這個物件發出訊號時( 被按了) 到 button1_clicked 這個槽執行
        chk_B.clicked.connect(self.chk_B_clicked)

        l_D =QLabel('開始創作',self)
        l_D.setAlignment(QtCore.Qt.AlignLeft)
        l_D.resize(120,35)
        l_D.setStyleSheet("font: 16px; border-style: outset; border-width:0px ; border-color: rbg(128,128,128); color:rgb(174, 182, 191); ");
        l_D.move(600,175)

        l_E =QLabel('選擇硬體',self)
        l_E.setAlignment(QtCore.Qt.AlignLeft)
        l_E.resize(120,35)
        l_E.setStyleSheet("font: 16px; border-style: outset; border-width:0px ; border-color: rbg(128,128,128); color:rgb(174, 182, 191); ");
        l_E.move(400,175)

        l_F =QLabel('確認硬體',self)
        l_F.setAlignment(QtCore.Qt.AlignLeft)
        l_F.resize(120,35)
        l_F.setStyleSheet("font: 16px; border-style: outset; border-width:0px ; border-color: rbg(128,128,128); color:rgb(174, 182, 191); ");
        l_F.move(20,175)


        b_port = QPushButton("連接埠",self)
        b_port.resize(120,35)
        b_port.setStyleSheet("font: 20px; text-align:center; color:rgb(255,0,255); background-color: rgb(255,255,255);");
        b_port.setToolTip("偵測設備port")
        b_port.move(250,200)
        b_port.clicked.connect(self.b_port_clicked)

        
        #l_B = QLabel("設備port",self)
        #l_B.move(164,10)
        #https://blog.csdn.net/jia666666/article/details/81624550
        listviewA = QListView(self)
        listviewA.setStyleSheet("font: 20px;  background-color: rgb(255,255,255);");
        listviewA.resize(220,80)
        listviewA.move(20,200)
        slm=QStringListModel()

        ##port
        self.qList=serial_ports()
        ##listviewA.qList=['aaaa','bbbb','cccc']
        slm.setStringList(self.qList)
        listviewA.setModel(slm)
        listviewA.clicked.connect(self.listviewA_clicked)

        #再 widget windows 內創建一個 Button 物件
        b_arduino = QPushButton("Arduino", self)
        b_arduino.setStyleSheet("font: bold 18px; background-color: rgb(255,0,0);");
        b_arduino.move(20,32)  # 移動位置
        ##"""方法setToolTip在用戶滑鼠在按鈕上顯示訊息"""
        b_arduino.setToolTip("連線硬體arduino 執行s3a")
        # 當 button1 這個物件發出訊號時( 被按了) 到 button1_clicked 這個槽執行
        b_arduino.clicked.connect(self.b_arduino_clicked)

        b_circuit = QPushButton("Circuit",self)
        b_circuit.setStyleSheet("font: bold 18px; background-color: rgb(76,200,68);");
        b_circuit.setToolTip("連線硬體circuit 執行s3c")
        b_circuit.move(20,64)
        b_circuit.clicked.connect(self.b_circuit_clicked)

        b_esp8266 = QPushButton("ESP-8266",self)
        b_esp8266.setStyleSheet("font: bold 18px; background-color: rgb(66,77,197);");
        b_esp8266.setToolTip("連線硬體ESP-8266 執行s3e")
        b_esp8266.move(20,96)
        b_esp8266.clicked.connect(self.b_esp8266_clicked)

        b_picoboard = QPushButton("Picoboard",self)
        b_picoboard.setStyleSheet("font: bold 18px; background-color: rgb(141,64,192);");
        b_picoboard.setToolTip("連線硬體Picoboard 執行s3p")
        b_picoboard.move(20,128)
        b_picoboard.clicked.connect(self.b_picoboard_clicked)
        
        b_raspberrypi = QPushButton("Raspberry Pi",self)
        b_raspberrypi.setStyleSheet("font: bold 18px; background-color: rgb(255,143,43);");
        b_raspberrypi.setToolTip("連線硬體raspberrypi 執行s3r")
        b_raspberrypi.move(20,160)
        b_raspberrypi.clicked.connect(self.b_raspberrypi_clicked)

        b_uno = QPushButton("uno燒韌體",self)
        b_uno.setStyleSheet("font: bold 16px;");
        b_uno.setToolTip("燒入arduino uno韌體(需要arduino ide)FirmataExpress.ino.hex")
        b_uno.move(20,192)
        b_uno.clicked.connect(self.b_uno_clicked)

        b_cpx = QPushButton("circuit燒韌體",self)
        b_cpx.setStyleSheet("font: bold 16px;");
        b_cpx.setToolTip("燒入circuit韌體FirmataCPx.uf2")
        b_cpx.move(20,230)
        b_cpx.clicked.connect(self.b_cpx_clicked)

        b_class = QPushButton("OSEP課程資源",self)
        b_class.setStyleSheet("font: 20px;text-align:center; color:rgb(255,255,255); background-color: rgb(233,0,125);");
        b_class.setToolTip("瀏覽器開啟OSEP課程資源")
        b_class.resize(150,35)
        b_class.move(600,210)
        b_class.clicked.connect(self.b_class_clicked)

        b_url = QPushButton("OSEP線上操作",self)
        b_url.setStyleSheet("font: 20px;text-align:center; color:rgb(255,255,255); background-color: rgb(233,0,125);");
        b_url.setToolTip("瀏覽器開啟OSEP線上操作網站")
        b_url.resize(150,35)
        b_url.move(600,255)
        b_url.clicked.connect(self.b_url_clicked)

        b_offline = QPushButton("OSEP離線操作",self)
        b_offline.resize(150,35)
        b_offline.setStyleSheet("font: 20px;text-align:center; color:rgb(128,128,128); background-color: rgb(255,255,255);");
        b_offline.setToolTip("OSEP離線操作")
        b_offline.move(600,300)
        b_offline.clicked.connect(self.b_offline_clicked)

        b_clear = QPushButton("重置OSEP",self)
        b_clear.setToolTip("clear python.exe")
        b_clear.resize(150,35)
        b_clear.setStyleSheet("font: 20px;text-align:center; color:rgb(128,128,128); background-color: rgb(255,255,255);");
        b_clear.move(600,65)
        b_clear.clicked.connect(self.b_clear_clicked)

        b_about = QPushButton("關於OSEP",self)
        b_about.setToolTip("關於OSEP")
        b_about.resize(150,35)
        b_about.setStyleSheet("font: 20px; color: rgb(128,128,128);  text-align::center; background-color: rgb(255,255,255);");
        b_about.move(600,20)
        b_about.clicked.connect(self.b_about_clicked)
        
        b_b_esp8266 = QPushButton("esp8266燒韌體",self)
        b_b_esp8266.setStyleSheet("font: bold 16px;");
        b_b_esp8266.setToolTip("esp8266燒入韌體,設定wifi")
        b_b_esp8266.move(20,265)
        b_b_esp8266.clicked.connect(self.b_b_esp8266_clicked)

        self.show()
コード例 #5
0
class FileManager(QWidget, _HalWidgetBase):
    def __init__(self, parent=None):
        super(FileManager, self).__init__(parent)
        self.title = 'PyQt5 file system view - pythonspot.com'
        self.left = 10
        self.top = 10
        self.width = 640
        self.height = 480
        self.default_path = (os.path.join(os.path.expanduser('~'),
                                          'labvcnc/nc_files/examples'))
        self.user_path = (os.path.join('/media'))
        self.currentPath = None
        self.initUI()

    def initUI(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        self.model = QFileSystemModel()
        self.model.setRootPath(QDir.currentPath())
        self.model.setFilter(QDir.AllDirs | QDir.NoDot | QDir.Files)
        self.model.setNameFilterDisables(False)
        self.model.setNameFilters(["*.ngc", '*.py'])

        self.list = QListView()
        self.list.setModel(self.model)
        self.updateDirectoryView(self.default_path)
        self.list.setWindowTitle("Dir View")
        self.list.resize(640, 480)
        self.list.clicked[QModelIndex].connect(self.clicked)
        self.list.activated.connect(self.load)
        self.list.setAlternatingRowColors(True)

        self.cb = QComboBox()
        self.cb.currentTextChanged.connect(self.filterChanged)
        self.cb.addItems(sorted({'*.ngc', '*.py', '*'}))
        #self.cb.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))

        self.button = QPushButton()
        self.button.setText('Media')
        self.button.setSizePolicy(
            QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
        self.button.setToolTip('Jump to Media directory')
        self.button.clicked.connect(self.onMediaClicked)

        self.button2 = QPushButton()
        self.button2.setText('User')
        self.button2.setSizePolicy(
            QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
        self.button2.setToolTip('Jump to labvcnc directory')
        self.button2.clicked.connect(self.onUserClicked)

        hbox = QHBoxLayout()
        hbox.addWidget(self.button)
        hbox.addWidget(self.button2)
        hbox.addWidget(self.cb)

        windowLayout = QVBoxLayout()
        windowLayout.addWidget(self.list)
        windowLayout.addLayout(hbox)
        self.setLayout(windowLayout)
        self.show()

    def updateDirectoryView(self, path):
        self.list.setRootIndex(self.model.setRootPath(path))

    def filterChanged(self, text):
        self.model.setNameFilters([text])

    def clicked(self, index):
        # the signal passes the index of the clicked item
        dir_path = self.model.filePath(index)
        if self.model.fileInfo(index).isFile():
            self.currentPath = dir_path
            return
        root_index = self.model.setRootPath(dir_path)
        self.list.setRootIndex(root_index)

    def onMediaClicked(self):
        self.updateDirectoryView(self.user_path)

    def onUserClicked(self):
        self.updateDirectoryView(self.default_path)

    def select_row(self, style):
        style = style.lower()
        selectionModel = self.list.selectionModel()
        row = selectionModel.currentIndex().row()
        self.rows = self.model.rowCount(self.list.rootIndex())

        if style == 'last':
            row = self.rows
        elif style == 'up':
            if row > 0:
                row -= 1
            else:
                row = 0
        elif style == 'down':
            if row < self.rows:
                row += 1
            else:
                row = self.rows
        else:
            return
        top = self.model.index(row, 0, self.list.rootIndex())
        selectionModel.setCurrentIndex(
            top, QItemSelectionModel.Select | QItemSelectionModel.Rows)
        selection = QItemSelection(top, top)
        selectionModel.clearSelection()
        selectionModel.select(selection, QItemSelectionModel.Select)

    def _hal_init(self):
        if self.PREFS_:
            last_path = self.PREFS_.getpref('last_file_path',
                                            self.default_path, str,
                                            'BOOK_KEEPING')
            self.updateDirectoryView(last_path)
            LOG.debug("lAST FILE PATH: {}".format(last_path))
        else:
            LOG.debug("lAST FILE PATH: {}".format(self.default_path))
            self.updateDirectoryView(self.default_path)

    # get current selection and update the path
    # then if the path is good load it into labvcnc
    # record it in the preference file if available
    def load(self):
        row = self.list.selectionModel().currentIndex()
        self.clicked(row)

        fname = self.currentPath
        if fname is None:
            return
        if fname:
            if self.PREFS_:
                self.PREFS_.putpref('last_file_path', fname, str,
                                    'BOOK_KEEPING')
            ACTION.OPEN_PROGRAM(fname)
            STATUS.emit('update-machine-log', 'Loaded: ' + fname, 'TIME')

    def up(self):
        self.select_row('up')

    def down(self):
        self.select_row('down')
コード例 #6
0
import sys
from PyQt5.QtWidgets import QApplication, QListView
from myModel import MyModel
from itemDelegate import MyItemDelegate

if __name__ == '__main__':

    app = QApplication(sys.argv)
    w = QListView()
    w.setItemDelegate(MyItemDelegate())
    model = MyModel()
    w.setModel(model)
    w.resize(500, 300)
    w.move(300, 300)
    w.setWindowTitle('Simple')
    w.show()
    sys.exit(app.exec_())
コード例 #7
0
ファイル: file_manager.py プロジェクト: zym1rm/linuxcnc
class FileManager(QWidget, _HalWidgetBase):
    def __init__(self, parent=None):
        super(FileManager, self).__init__(parent)
        self.title = 'Qtvcp File System View'
        self.left = 10
        self.top = 10
        self.width = 640
        self.height = 480
        self._last = 0

        if INFO.PROGRAM_PREFIX is not None:
            self.user_path = os.path.expanduser(INFO.PROGRAM_PREFIX)
        else:
            self.user_path = (os.path.join(os.path.expanduser('~'),
                                           'linuxcnc/nc_files'))
        user = os.path.split(os.path.expanduser('~'))[-1]
        self.media_path = (os.path.join('/media', user))
        temp = [('User', self.user_path), ('Media', self.media_path)]
        self._jumpList = OrderedDict(temp)
        self.currentPath = None
        self.currentFolder = None
        self.PREFS_ = None
        self.initUI()

    def initUI(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        pasteBox = QHBoxLayout()
        self.textLine = QLineEdit()
        self.textLine.setToolTip('Current Director/selected File')
        self.pasteButton = QToolButton()
        self.pasteButton.setEnabled(False)
        self.pasteButton.setText('Paste')
        self.pasteButton.setToolTip(
            'Copy file from copy path to current directory/file')
        self.pasteButton.clicked.connect(self.paste)
        self.pasteButton.hide()
        pasteBox.addWidget(self.textLine)
        pasteBox.addWidget(self.pasteButton)

        self.copyBox = QFrame()
        hbox = QHBoxLayout()
        hbox.setContentsMargins(0, 0, 0, 0)
        self.copyLine = QLineEdit()
        self.copyLine.setToolTip('File path to copy from, when pasting')
        self.copyButton = QToolButton()
        self.copyButton.setText('Copy')
        self.copyButton.setToolTip('Record current file as copy path')
        self.copyButton.clicked.connect(self.recordCopyPath)
        hbox.addWidget(self.copyButton)
        hbox.addWidget(self.copyLine)
        self.copyBox.setLayout(hbox)
        self.copyBox.hide()

        self.model = QFileSystemModel()
        self.model.setRootPath(QDir.currentPath())
        self.model.setFilter(QDir.AllDirs | QDir.NoDot | QDir.Files)
        self.model.setNameFilterDisables(False)
        self.model.rootPathChanged.connect(self.folderChanged)

        self.list = QListView()
        self.list.setModel(self.model)
        self.list.resize(640, 480)
        self.list.clicked[QModelIndex].connect(self.listClicked)
        self.list.activated.connect(self._getPathActivated)
        self.list.setAlternatingRowColors(True)
        self.list.hide()

        self.table = QTableView()
        self.table.setModel(self.model)
        self.table.resize(640, 480)
        self.table.clicked[QModelIndex].connect(self.listClicked)
        self.table.activated.connect(self._getPathActivated)
        self.table.setAlternatingRowColors(True)

        header = self.table.horizontalHeader()
        header.setSectionResizeMode(0, QHeaderView.Stretch)
        header.setSectionResizeMode(1, QHeaderView.ResizeToContents)
        header.setSectionResizeMode(3, QHeaderView.ResizeToContents)
        header.swapSections(1, 3)
        header.setSortIndicator(1, Qt.AscendingOrder)

        self.table.setSortingEnabled(True)
        self.table.setColumnHidden(2, True)  # type
        self.table.verticalHeader().setVisible(False)  # row count header

        self.cb = QComboBox()
        self.cb.currentIndexChanged.connect(self.filterChanged)
        self.fillCombobox(INFO.PROGRAM_FILTERS_EXTENSIONS)
        self.cb.setMinimumHeight(30)
        self.cb.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,
                                          QSizePolicy.Fixed))

        self.button2 = QToolButton()
        self.button2.setText('User')
        self.button2.setSizePolicy(
            QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
        self.button2.setMinimumSize(60, 30)
        self.button2.setToolTip(
            'Jump to User directory.\nLong press for Options.')
        self.button2.clicked.connect(self.onJumpClicked)

        self.button3 = QToolButton()
        self.button3.setText('Add Jump')
        self.button3.setSizePolicy(
            QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
        self.button3.setMinimumSize(60, 30)
        self.button3.setToolTip('Add current directory to jump button list')
        self.button3.clicked.connect(self.onActionClicked)

        self.settingMenu = QMenu(self)
        self.button2.setMenu(self.settingMenu)

        hbox = QHBoxLayout()
        hbox.addWidget(self.button2)
        hbox.addWidget(self.button3)
        hbox.insertStretch(2, stretch=0)
        hbox.addWidget(self.cb)

        windowLayout = QVBoxLayout()
        windowLayout.addLayout(pasteBox)
        windowLayout.addWidget(self.copyBox)
        windowLayout.addWidget(self.list)
        windowLayout.addWidget(self.table)
        windowLayout.addLayout(hbox)
        self.setLayout(windowLayout)
        self.show()

    def _hal_init(self):
        if self.PREFS_:
            last_path = self.PREFS_.getpref('last_loaded_directory',
                                            self.user_path, str,
                                            'BOOK_KEEPING')
            LOG.debug("lAST FILE PATH: {}".format(last_path))
            if not last_path == '':
                self.updateDirectoryView(last_path)
            else:
                self.updateDirectoryView(self.user_path)

            # get all the saved jumplist paths
            temp = self.PREFS_.getall('FILEMANAGER_JUMPLIST')
            self._jumpList.update(temp)

        else:
            LOG.debug("lAST FILE PATH: {}".format(self.user_path))
            self.updateDirectoryView(self.user_path)

        # install jump paths into toolbutton menu
        for i in self._jumpList:
            self.addAction(i)

        # set recorded columns sort settings
        self.SETTINGS_.beginGroup("FileManager-{}".format(self.objectName()))
        sect = self.SETTINGS_.value('sortIndicatorSection', type=int)
        order = self.SETTINGS_.value('sortIndicatorOrder', type=int)
        self.SETTINGS_.endGroup()
        if not None in (sect, order):
            self.table.horizontalHeader().setSortIndicator(sect, order)

    # when qtvcp closes this gets called
    # record jump list paths
    def _hal_cleanup(self):
        if self.PREFS_:
            for i, key in enumerate(self._jumpList):
                if i in (0, 1):
                    continue
                self.PREFS_.putpref(key, self._jumpList.get(key), str,
                                    'FILEMANAGER_JUMPLIST')

        # record sorted columns
        h = self.table.horizontalHeader()
        self.SETTINGS_.beginGroup("FileManager-{}".format(self.objectName()))
        self.SETTINGS_.setValue('sortIndicatorSection',
                                h.sortIndicatorSection())
        self.SETTINGS_.setValue('sortIndicatorOrder', h.sortIndicatorOrder())
        self.SETTINGS_.endGroup()

    #########################
    # callbacks
    #########################

    # add shown text and hidden filter data from the INI
    def fillCombobox(self, data):
        for i in data:
            self.cb.addItem(i[0], i[1])

    def folderChanged(self, data):
        data = os.path.normpath(data)
        self.currentFolder = data
        self.textLine.setText(data)

    def updateDirectoryView(self, path, quiet=False):
        if os.path.exists(path):
            self.list.setRootIndex(self.model.setRootPath(path))
            self.table.setRootIndex(self.model.setRootPath(path))
        else:
            LOG.debug(
                "Set directory view error - no such path {}".format(path))
            if not quiet:
                STATUS.emit(
                    'error', LOW_ERROR,
                    "File Manager error - No such path: {}".format(path))

    # retrieve selected filter (it's held as QT.userData)
    def filterChanged(self, index):
        userdata = self.cb.itemData(index)
        self.model.setNameFilters(userdata)

    def listClicked(self, index):
        # the signal passes the index of the clicked item
        dir_path = os.path.normpath(self.model.filePath(index))
        if self.model.fileInfo(index).isFile():
            self.currentPath = dir_path
            self.textLine.setText(self.currentPath)
            return
        root_index = self.model.setRootPath(dir_path)
        self.list.setRootIndex(root_index)
        self.table.setRootIndex(root_index)

    def onUserClicked(self):
        self.showUserDir()

    def onMediaClicked(self):
        self.showMediaDir()

    # jump directly to a saved path shown on the button
    def onJumpClicked(self):
        data = self.button2.text()
        if data.upper() == 'MEDIA':
            self.showMediaDir()
        elif data.upper() == 'USER':
            self.showUserDir()
        else:
            temp = self._jumpList.get(data)
            if temp is not None:
                self.updateDirectoryView(temp)
            else:
                STATUS.emit('error', linuxcnc.OPERATOR_ERROR,
                            'file jumopath: {} not valid'.format(data))
                log.debug('file jumopath: {} not valid'.format(data))

    # jump directly to a saved path from the menu
    def jumpTriggered(self, data):
        if data.upper() == 'MEDIA':
            self.button2.setText('{}'.format(data))
            self.button2.setToolTip(
                'Jump to Media directory.\nLong press for Options.')
            self.showMediaDir()
        elif data.upper() == 'USER':
            self.button2.setText('{}'.format(data))
            self.button2.setToolTip(
                'Jump to User directory.\nLong press for Options.')
            self.showUserDir()
        else:
            self.button2.setText('{}'.format(data))
            self.button2.setToolTip('Jump to directory:\n{}'.format(
                self._jumpList.get(data)))
            self.updateDirectoryView(self._jumpList.get(data))

    # add a jump list path
    def onActionClicked(self):
        i = self.currentFolder
        try:
            self._jumpList[i] = i
        except Exception as e:
            print(e)
        button = QAction(QIcon.fromTheme('user-home'), i, self)
        # weird lambda i=i to work around 'function closure'
        button.triggered.connect(lambda state, i=i: self.jumpTriggered(i))
        self.settingMenu.addAction(button)

    # get current selection and update the path
    # then if the path is good load it into linuxcnc
    # record it in the preference file if available
    def _getPathActivated(self):
        if self.list.isVisible():
            row = self.list.selectionModel().currentIndex()
        else:
            row = self.table.selectionModel().currentIndex()
            self.listClicked(row)

        fname = self.currentPath
        if fname is None:
            return
        if fname:
            self.load(fname)

    def recordCopyPath(self):
        data, isFile = self.getCurrentSelected()
        if isFile:
            self.copyLine.setText(os.path.normpath(data))
            self.pasteButton.setEnabled(True)
        else:
            self.copyLine.setText('')
            self.pasteButton.setEnabled(False)
            STATUS.emit('error', OPERATOR_ERROR,
                        'Can only copy a file, not a folder')

    def paste(self):
        res = self.copyFile(self.copyLine.text(), self.textLine.text())
        if res:
            self.copyLine.setText('')
            self.pasteButton.setEnabled(False)

    ########################
    # helper functions
    ########################

    def addAction(self, i):
        axisButton = QAction(QIcon.fromTheme('user-home'), i, self)
        # weird lambda i=i to work around 'function closure'
        axisButton.triggered.connect(lambda state, i=i: self.jumpTriggered(i))
        self.settingMenu.addAction(axisButton)

    def showList(self, state=True):
        if state:
            self.table.hide()
            self.list.show()
        else:
            self.table.show()
            self.list.hide()

    def showTable(self, state=True):
        self.showList(not state)

    def showCopyControls(self, state):
        if state:
            self.copyBox.show()
            self.pasteButton.show()
        else:
            self.copyBox.hide()
            self.pasteButton.hide()

    def showMediaDir(self, quiet=False):
        self.updateDirectoryView(self.media_path, quiet)

    def showUserDir(self, quiet=False):
        self.updateDirectoryView(self.user_path, quiet)

    def copyFile(self, s, d):
        try:
            shutil.copy(s, d)
            return True
        except Exception as e:
            LOG.error("Copy file error: {}".format(e))
            STATUS.emit('error', OPERATOR_ERROR,
                        "Copy file error: {}".format(e))
            return False

    @pyqtSlot(float)
    @pyqtSlot(int)
    def scroll(self, data):
        if data > self._last:
            self.up()
        elif data < self._last:
            self.down()
        self._last = data

    # moves the selection up
    # used with MPG scrolling
    def up(self):
        self.select_row('up')

    # moves the selection down
    # used with MPG scrolling
    def down(self):
        self.select_row('down')

    def select_row(self, style='down'):
        style = style.lower()
        if self.list.isVisible():
            i = self.list.rootIndex()
            selectionModel = self.list.selectionModel()
        else:
            i = self.table.rootIndex()
            selectionModel = self.table.selectionModel()

        row = selectionModel.currentIndex().row()
        self.rows = self.model.rowCount(i)

        if style == 'last':
            row = self.rows
        elif style == 'up':
            if row > 0:
                row -= 1
            else:
                row = 0
        elif style == 'down':
            if row < self.rows - 1:
                row += 1
            else:
                row = self.rows - 1
        else:
            return
        top = self.model.index(row, 0, i)
        selectionModel.setCurrentIndex(
            top, QItemSelectionModel.Select | QItemSelectionModel.Rows)
        selection = QItemSelection(top, top)
        selectionModel.clearSelection()
        selectionModel.select(selection, QItemSelectionModel.Select)

    # returns the current highlighted (selected) path as well as
    # whether it's a file or not.
    def getCurrentSelected(self):
        if self.list.isVisible():
            selectionModel = self.list.selectionModel()
        else:
            selectionModel = self.table.selectionModel()
        index = selectionModel.currentIndex()
        dir_path = os.path.normpath(self.model.filePath(index))
        if self.model.fileInfo(index).isFile():
            return (dir_path, True)
        else:
            return (dir_path, False)

    # This can be class patched to do something else
    def load(self, fname=None):
        try:
            if fname is None:
                self._getPathActivated()
                return
            self.recordBookKeeping()
            ACTION.OPEN_PROGRAM(fname)
            STATUS.emit('update-machine-log', 'Loaded: ' + fname, 'TIME')
        except Exception as e:
            LOG.error("Load file error: {}".format(e))
            STATUS.emit('error', NML_ERROR, "Load file error: {}".format(e))

    # This can be class patched to do something else
    def recordBookKeeping(self):
        fname = self.currentPath
        if fname is None:
            return
        if self.PREFS_:
            self.PREFS_.putpref('last_loaded_directory', self.model.rootPath(),
                                str, 'BOOK_KEEPING')
            self.PREFS_.putpref('RecentPath_0', fname, str, 'BOOK_KEEPING')
コード例 #8
0
ファイル: UI.py プロジェクト: IvyyyyyH/Resume
class Window(QWidget):
    def __init__(self):
        """

        :param self:
        """
        super().__init__()
        self.title = '御魂计算器'
        self.left = 10
        self.top = 10
        self.width = 1500
        self.height = 800
        self.initUI()

    def initUI(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        # choose file
        self.file_path = None
        self.file_button = QPushButton("打开文件...", self)
        self.file_button.resize(480, 30)
        self.file_button.setCheckable(True)
        self.file_button.move(10, 10)
        self.file_button.clicked.connect(self.setFile)

        # initialize input

        # 式神
        self.label_shishen = QLabel(self)
        self.label_shishen.move(20, 50)
        self.label_shishen.setText("式神")
        self.shishen_box = QComboBox(self)
        all_shishen = []
        for shishen, data in SHISHEN_INFO.items():
            all_shishen.append(shishen)
        self.shishen_box.move(80, 37)
        self.shishen_box.resize(140, 50)
        self.shishen_box.addItem("选择你的式神")
        self.shishen_box.addItems(all_shishen)

        # 四件套
        self.label_main_yuhun = QLabel(self)
        self.label_main_yuhun.move(250, 50)
        self.label_main_yuhun.setText("四件套")
        self.main_yuhun_box = QComboBox(self)
        all_yuhun = []
        for yuhun, data in YUHUN_INCREASE.items():
            all_yuhun.append(yuhun)
        self.main_yuhun_box.move(300, 37)
        self.main_yuhun_box.resize(140, 50)
        self.main_yuhun_box.addItem("无")
        self.main_yuhun_box.addItems(all_yuhun)

        # 两件套
        self.label_minor_yuhun = QLabel(self)
        self.label_minor_yuhun.move(480, 50)
        self.label_minor_yuhun.setText("两件套")
        self.minor_yuhun_box = QComboBox(self)
        all_yuhun = []
        for increase in INCREASE_LIST:
            all_yuhun.append(increase)
        for yuhun, data in YUHUN_INCREASE.items():
            all_yuhun.append(yuhun)
        self.minor_yuhun_box.move(530, 37)
        self.minor_yuhun_box.resize(140, 50)
        self.minor_yuhun_box.addItem("无")
        self.minor_yuhun_box.addItems(all_yuhun)

        # 输出only
        self.label_attack_only = QLabel(self)
        self.label_attack_only.move(710, 50)
        self.attack_only_check = QCheckBox("仅限输出御魂", self)
        self.attack_only_check.move(730, 50)

        # 位置
        self.label_position_2 = QLabel(self)
        self.label_position_2.move(20, 90)
        self.label_position_2.setText("二号位主属性:")
        self.attack_2 = QCheckBox(u"攻击加成", self)
        self.attack_2.move(110, 87)
        self.defence_2 = QCheckBox(u"防御加成", self)
        self.defence_2.move(200, 87)
        self.health_2 = QCheckBox(u"生命加成", self)
        self.health_2.move(290, 87)
        self.speed = QCheckBox(u"速度", self)
        self.speed.move(380, 87)

        self.label_position_4 = QLabel(self)
        self.label_position_4.move(20, 130)
        self.label_position_4.setText("四号位主属性:")
        self.attack_4 = QCheckBox(u"攻击加成", self)
        self.attack_4.move(110, 127)
        self.defence_4 = QCheckBox(u"防御加成", self)
        self.defence_4.move(200, 127)
        self.health_4 = QCheckBox(u"生命加成", self)
        self.health_4.move(290, 127)
        self.res = QCheckBox(u"效果抵抗", self)
        self.res.move(380, 127)
        self.hit = QCheckBox(u"效果命中", self)
        self.hit.move(470, 127)

        self.label_position_6 = QLabel(self)
        self.label_position_6.move(20, 170)
        self.label_position_6.setText("六号位主属性:")
        self.attack_6 = QCheckBox(u"攻击加成", self)
        self.attack_6.move(110, 167)
        self.defence_6 = QCheckBox(u"防御加成", self)
        self.defence_6.move(200, 167)
        self.health_6 = QCheckBox(u"生命加成", self)
        self.health_6.move(290, 167)
        self.crit = QCheckBox(u"暴击", self)
        self.crit.move(380, 167)
        self.critdmg = QCheckBox(u"暴击伤害", self)
        self.critdmg.move(470, 167)

        # 目标
        self.target = QLabel(self)
        self.target.move(20, 210)
        self.target.setText("目标属性: ")
        self.target_box = QComboBox(self)
        all_target = ["速度", "攻击x爆伤", "生命x爆伤", "生命", "效果命中", "效果抵抗", "命中抵抗", "暴击"]
        self.target_box.move(100, 198)
        self.target_box.resize(130, 50)
        self.target_box.addItem("选择目标...")
        self.target_box.addItems(all_target)

        self.target_up = QLabel(self)
        self.target_up.move(20, 250)
        self.target_up.setText("上限")
        self.target_line_up = QLineEdit(self)
        self.target_line_up.move(80, 250)
        self.target_line_up.resize(100, 20)

        self.target_low = QLabel(self)
        self.target_low.move(20, 290)
        self.target_low.setText("下限")
        self.target_line_low = QLineEdit(self)
        self.target_line_low.move(80, 290)
        self.target_line_low.resize(100, 20)

        self.target_button = QPushButton(self)
        self.target_button.move(200, 250)
        self.target_button.setText("确认")
        self.target_button.resize(80, 60)
        self.target_button.clicked.connect(self.setRequest)

        self.target_text = QLabel(self)
        self.target_text.move(300, 200)

        self.target_text.setText("单击删除单个")
        self.clear_button = QPushButton(self)
        self.clear_button.move(380, 194)
        self.clear_button.setText("清除全部")
        self.clear_button.clicked.connect(self.clearRequest)

        self.target_list = []
        self.target_listView = QListView(self)
        self.target_listView.move(300, 225)
        self.target_listView.resize(200, 100)
        self.target_listView.clicked.connect(self.listView_clicked)

        # 有效属性选择
        self.effect = QLabel(self)
        self.effect.move(20, 350)
        self.effect.setText("有效属性选择:")
        self.gongji_check = QCheckBox(u"攻击加成", self)
        self.gongji_check.move(110, 347)
        self.shengming_check = QCheckBox(u"生命加成", self)
        self.shengming_check.move(200, 347)
        self.sudu_check = QCheckBox(u"速度", self)
        self.sudu_check.move(290, 347)
        self.baoji_check = QCheckBox(u"暴击", self)
        self.baoji_check.move(380, 347)
        self.baoshang_check = QCheckBox(u"暴击伤害", self)
        self.baoshang_check.move(110, 387)
        self.mingzhong_check = QCheckBox(u"效果命中", self)
        self.mingzhong_check.move(200, 387)
        self.dikang_check = QCheckBox(u"效果抵抗", self)
        self.dikang_check.move(290, 387)

        self.shuju_request_label = QLabel(self)
        self.shuju_request_label.move(480, 350)
        self.shuju_request_label.setText("有效属性: ")
        self.shuju_request_line = QLineEdit(self)
        self.shuju_request_line.move(550, 350)
        self.shuju_request_line.resize(60, 20)

        # 计算
        self.start_button = QPushButton(self)
        self.start_button.setText("开始运算")
        self.start_button.move(480, 390)
        self.start_button.resize(100, 50)
        self.start_button.clicked.connect(self.calculate)

        # 计算数据
        self.shishen_yuhun_set = QLabel(self)
        self.shishen_yuhun_set.move(20, 430)
        self.shishen_yuhun_set.setText("计算数据:")
        self.shishen_table = QTableWidget(self)
        self.shishen_table.setColumnCount(8)
        self.shishen_table.setHorizontalHeaderLabels(["御魂序号", "暴击", "攻击x爆伤", "生命", "生命x爆伤", "速度", "效果抵抗", "效果命中"])
        self.shishen_table.setRowCount(10)
        self.shishen_table.move(20, 470)
        self.shishen_table.resize(830, 400)

        # 已经计算好的式神
        self.ready_sets = []
        self.ready_sets_dict = dict()
        self.ready_set_label = QLabel(self)
        self.ready_set_label.setText("御魂序号: ")
        self.ready_set_label.move(900, 130)
        self.ready_set_line = QLineEdit(self)
        self.ready_set_line.move(960, 130)
        self.set_name_label = QLabel(self)
        self.set_name_label.setText("套装名称: ")
        self.set_name_label.move(900, 170)
        self.set_name_line = QLineEdit(self)
        self.set_name_line.move(960, 170)
        self.add_set_button = QPushButton(self)
        self.add_set_button.setText("记录")
        self.add_set_button.move(1120, 126)
        self.add_set_button.resize(60, 80)
        self.add_set_button.clicked.connect(self.add_set)

        self.listview_title = QLabel(self)
        self.listview_title.setText("套装:")
        self.listview_title.move(900, 210)
        self.sets_listview = QListView(self)
        self.sets_listview.move(960, 220)
        self.sets_listview.resize(300, 200)
        self.sets_listview.clicked.connect(self.sets_clicked)


        #显示套装
        self.show_set_label = QLabel(self)
        self.show_set_label.setText("御魂序号: ")
        self.show_set_label.move(900, 450)
        self.show_set_line = QLineEdit(self)
        self.show_set_line.move(960, 450)
        self.show_set_line.resize(180, 20)
        self.show_set_button = QPushButton(self)
        self.show_set_button.setText("显示")
        self.show_set_button.move(1200, 447)
        self.show_set_button.resize(90, 35)
        self.show_set_button.clicked.connect(self.showSet)

        self.show_set_table = QTableWidget(self)
        self.show_set_table.setColumnCount(6)
        self.show_set_table.setRowCount(6)
        self.show_set_table.setHorizontalHeaderLabels(["一号位", "二号位", "三号位", "四号位", "五号位", "六号位"])
        self.show_set_table.move(900, 500)
        self.show_set_table.resize(500, 300)
        self.show()

    def showSet(self):
        if self.show_set_line.text():
            yuhun_set = self.show_set_line.text().split(', ')
            if len(yuhun_set) == 6 and self.file_path:
                all_data = get_data(self.file_path)
                for yuhun in yuhun_set:
                    data = all_data[int(yuhun)]
                    i = 0
                    for name, num in data.items():
                        if name != "御魂ID" and name != "位置" and name != "御魂等级" and name != "御魂星级":
                            message = name + ": "+ str(num)
                            self.show_set_table.setItem(i, data["位置"] - 1, QTableWidgetItem(str(message)))
                            i += 1

    def sets_clicked(self, qModelIndex):
        clicked_set = self.ready_sets_dict[self.ready_sets[qModelIndex.row()]]
        message = "御魂序号:[" + ','.join(clicked_set) + "], 确认删除吗?"
        reply = QMessageBox.information(self, "确认删除?", message, QMessageBox.Yes | QMessageBox.No)
        if reply == QMessageBox.Yes:
            temp = self.ready_sets[qModelIndex.row()]
            self.ready_sets.remove(temp)
            slm = QStringListModel()
            slm.setStringList(self.ready_sets)
            self.ready_sets_dict.pop(temp, None)
            self.sets_listview.setModel(slm)

    def add_set(self):
        yuhun_set = self.ready_set_line.text()
        yuhun_set_name = self.set_name_line.text()
        if yuhun_set and yuhun_set_name and yuhun_set_name not in self.ready_sets:
            self.ready_sets_dict[yuhun_set_name] = yuhun_set.split(',')
            self.ready_sets.append(yuhun_set_name)
            slm = QStringListModel()
            slm.setStringList(self.ready_sets)
            self.sets_listview.setModel(slm)

    def calculate(self):
        if self.file_path:
            data = get_data(self.file_path)
            if data and self.shishen_box.currentText() != "选择你的式神"\
                    and self.shishen_box.currentText() != u"------SP------"\
                    and self.shishen_box.currentText() != u"-----SSR------"\
                    and self.shishen_box.currentText() != u"-----SR------" \
                    and self.shishen_box.currentText() != u"------R------" \
                    and self.shishen_box.currentText() != u"------N------" :
                t = time.time()
                # remove data in use
                for name, set in self.ready_sets_dict.items():
                    print(name + ":" + str(set) + "is in use")
                    for each in set:
                        data.pop(int(each), None)
                data_loc = get_data_loc(data)
                position_2 = []
                value_2 = []
                position_4 = []
                value_4 = []
                position_6 = []
                value_6 = []
                if self.attack_2.isChecked():
                    position_2.append("攻击加成")
                    value_2.append(55)
                if self.defence_2.isChecked():
                    position_2.append("防御加成")
                    value_2.append(55)
                if self.health_2.isChecked():
                    position_2.append("生命加成")
                    value_2.append(55)
                if self.sudu_check.isChecked():
                    position_2.append("速度")
                    value_2.append(57)
                if self.attack_4.isChecked():
                    position_4.append("攻击加成")
                    value_4.append(55)
                if self.defence_4.isChecked():
                    position_4.append("防御加成")
                    value_4.append(55)
                if self.health_4.isChecked():
                    position_4.append("生命加成")
                    value_4.append(55)
                if self.res.isChecked():
                    position_4.append("效果抵抗")
                    value_4.append(55)
                if self.hit.isChecked():
                    position_4.append("效果命中")
                    value_4.append(55)
                if self.attack_6.isChecked():
                    position_6.append("攻击加成")
                    value_6.append(55)
                if self.defence_6.isChecked():
                    position_6.append("防御加成")
                    value_6.append(55)
                if self.health_6.isChecked():
                    position_6.append("生命加成")
                    value_6.append(55)
                if self.crit.isChecked():
                    position_6.append("暴击")
                    value_6.append(55)
                if self.critdmg.isChecked():
                    position_6.append("暴击伤害")
                    value_6.append(89)

                effective_list = [self.baoshang_check.isChecked(), self.baoshang_check.isChecked(),
                                  self.gongji_check.isChecked(), self.sudu_check.isChecked(),
                                  self.shengming_check.isChecked(), self.dikang_check.isChecked(),
                                  self.mingzhong_check.isChecked()]

                effective_num = 0
                if self.shuju_request_line.text():
                    effective_num = int(self.shuju_request_line.text())
                filter_data_loc = filter_all(data_loc, position_2, value_2, position_4, value_4, position_6, value_6,
                                             effective_list, effective_num, self.attack_only_check.isChecked(), 0)
                yuhun_filter = {}
                if self.main_yuhun_box.currentText() != "无":
                    yuhun_filter[self.main_yuhun_box.currentText()] = 4
                if self.minor_yuhun_box.currentText() != "无":
                    if self.minor_yuhun_box.currentText() != self.main_yuhun_box.currentText():
                        yuhun_filter[self.minor_yuhun_box.currentText()] = 2
                    else:
                        yuhun_filter[self.main_yuhun_box.currentText()] = 6
                combo, num = form_all_combs(filter_data_loc, yuhun_filter)
                shishen_data = SHISHEN_INFO[self.shishen_box.currentText()]
                filter_rules = dict()
                for item in self.target_list:
                    yuhun_result = [x.strip() for x in item.split(',')]
                    yuhun_result[1] = yuhun_result[1][5:]
                    yuhun_result[2] = yuhun_result[2][4:]
                    temp = dict()
                    temp["up"] = float(yuhun_result[2])
                    temp["low"] = float(yuhun_result[1])
                    name = yuhun_result[0]
                    filter_rules[name] = temp
                yuhun_result = filter_combo(combo, shishen_data, filter_rules)
                self.shishen_table.setRowCount(len(yuhun_result))
                i = 0
                for item in yuhun_result:
                    xuhao = item[u"combo"]
                    baoji = item[u"暴击"]
                    gongbao = item[u"攻击x爆伤"]
                    shengming = item[u"总生命"]
                    shengbao = item[u"生命x爆伤"]
                    sudu = item[u"速度"]
                    dikang = item[u"式神抵抗"]
                    mingzhong = item[u"式神命中"]

                    self.shishen_table.setItem(i, 0, QTableWidgetItem(', '.join(str(e) for e in xuhao)))
                    self.shishen_table.setItem(i, 1, QTableWidgetItem(str(baoji)))
                    self.shishen_table.setItem(i, 2, QTableWidgetItem(str(gongbao)))
                    self.shishen_table.setItem(i, 3, QTableWidgetItem(str(shengming)))
                    self.shishen_table.setItem(i, 4, QTableWidgetItem(str(shengbao)))
                    self.shishen_table.setItem(i, 5, QTableWidgetItem(str(sudu)))
                    self.shishen_table.setItem(i, 6, QTableWidgetItem(str(dikang)))
                    self.shishen_table.setItem(i, 7, QTableWidgetItem(str(mingzhong)))
                    i += 1
                used_time = time.time() - t
                print("Calculating took: ", used_time, " seconds")

    def listView_clicked(self, qModelIndex):
        reply = QMessageBox.information(self, "确认删除?", "确认删除选定项吗", QMessageBox.Yes | QMessageBox.No)
        if reply == QMessageBox.Yes:
            temp = self.target_list[qModelIndex.row()]
            self.target_list.remove(temp)
            slm = QStringListModel()
            slm.setStringList(self.target_list)
            self.target_listView.setModel(slm)

    def setRequest(self):
        text = self.target_box.currentText()
        low = self.target_line_low.text()
        up = self.target_line_up.text()
        if not low:
            low = '0'
        if not up:
            up = '30000'
        temp_string = text + ",low: " + low + ",up: " + up
        # have to be unique
        if temp_string in self.target_list:
            return
        if text == "选择目标...":
            return
        self.target_list.append(temp_string)
        slm = QStringListModel()
        slm.setStringList(self.target_list)
        self.target_listView.setModel(slm)

    def clearRequest(self):
        self.target_list = []
        slm = QStringListModel()
        slm.setStringList(self.target_list)
        self.target_listView.setModel(slm)
        return

    def setFile(self):
        if (self.file_button.isChecked()):
            options = QFileDialog.Options()
            options |= QFileDialog.DontUseNativeDialog
            fileName, _ = QFileDialog.getOpenFileName(self, "QFileDialog.getOpenFileName()", "",
                                                      "All Files (*);;Python Files (*.py)", options=options)
            self.file_path = fileName
            self.file_button.setText(self.file_path)
        else:
            self.file_button.setText("打开文件...")
コード例 #9
0
ファイル: file_manager.py プロジェクト: def187/linuxcnc
class FileManager(QWidget, _HalWidgetBase):
    def __init__(self, parent=None):
        super(FileManager, self).__init__(parent)
        self.title = 'PyQt5 file system view - pythonspot.com'
        self.left = 10
        self.top = 10
        self.width = 640
        self.height = 480
        self.default_path = (os.path.join(os.path.expanduser('~'), 'linuxcnc/nc_files/examples'))
        self.user_path = (os.path.join('/media'))
        self.currentPath = None
        self.EXT = INFO.PROGRAM_FILTERS_EXTENSIONS
        self.initUI()

    def initUI(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        self.model = QFileSystemModel()
        self.model.setRootPath(QDir.currentPath())
        self.model.setFilter(QDir.AllDirs | QDir.NoDot | QDir.Files)
        self.model.setNameFilterDisables(False)
        self.model.setNameFilters(self.EXT)

        self.list = QListView()
        self.list.setModel(self.model)
        self.updateDirectoryView(self.default_path)
        self.list.setWindowTitle("Dir View")
        self.list.resize(640, 480)
        self.list.clicked[QModelIndex].connect(self.clicked)
        self.list.activated.connect(self._getPathActivated)
        #self.list.currentChanged = self.currentChanged
        self.list.setAlternatingRowColors(True)

        self.cb = QComboBox()
        self.cb.currentTextChanged.connect(self.filterChanged)
        self.cb.addItems(self.EXT)
        #self.cb.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))

        self.button = QPushButton()
        self.button.setText('Media')
        self.button.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
        self.button.setToolTip('Jump to Media directory')
        self.button.clicked.connect(self.onMediaClicked)

        self.button2 = QPushButton()
        self.button2.setText('User')
        self.button2.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
        self.button2.setToolTip('Jump to linuxcnc directory')
        self.button2.clicked.connect(self.onUserClicked)

        hbox = QHBoxLayout()
        hbox.addWidget(self.button)
        hbox.addWidget(self.button2)
        hbox.addWidget(self.cb)

        windowLayout = QVBoxLayout()
        windowLayout.addWidget(self.list)
        windowLayout.addLayout(hbox)
        self.setLayout(windowLayout)
        self.show()

    # this could return the current/previous selected as it's selected.
    # need to uncomment monkey patch of self.list.currentChanged above
    # so far this is not needed
    def currentChanged(self,c,p):
        dir_path = self.model.filePath(c)
        print('-> ',dir_path)

    def updateDirectoryView(self, path):
        self.list.setRootIndex(self.model.setRootPath(path))

    def filterChanged(self, text):
        self.model.setNameFilters([text])

    def clicked(self, index):
        # the signal passes the index of the clicked item
        dir_path = self.model.filePath(index)
        if self.model.fileInfo(index).isFile():
            self.currentPath = dir_path
            return
        root_index = self.model.setRootPath(dir_path)
        self.list.setRootIndex(root_index)

    def onMediaClicked(self):
        self.updateDirectoryView(self.user_path)

    def onUserClicked(self):
        self.updateDirectoryView(self.default_path)

    def select_row(self, style):
        style = style.lower()
        selectionModel = self.list.selectionModel()
        row = selectionModel.currentIndex().row()
        self.rows = self.model.rowCount(self.list.rootIndex())

        if style == 'last':
            row = self.rows
        elif style == 'up':
            if row > 0:
                row -= 1
            else:
                row = 0
        elif style == 'down':
            if row < self.rows:
                row += 1
            else:
                row = self.rows
        else:
            return
        top = self.model.index(row, 0, self.list.rootIndex())
        selectionModel.setCurrentIndex(top, QItemSelectionModel.Select | QItemSelectionModel.Rows)
        selection = QItemSelection(top, top)
        selectionModel.clearSelection()
        selectionModel.select(selection, QItemSelectionModel.Select)

    # returns the current highlighted (selected) path as well as
    # whether it's a file or not.
    def getCurrentSelected(self):
        selectionModel = self.list.selectionModel()
        index = selectionModel.currentIndex()
        dir_path = self.model.filePath(index)
        if self.model.fileInfo(index).isFile():
            return (dir_path, True)
        else:
            return (dir_path, False)

    def _hal_init(self):
        if self.PREFS_:
            last_path = self.PREFS_.getpref('last_loaded_directory', self.default_path, str, 'BOOK_KEEPING')
            self.updateDirectoryView(last_path)
            LOG.debug("lAST FILE PATH: {}".format(last_path))
        else:
            LOG.debug("lAST FILE PATH: {}".format(self.default_path))
            self.updateDirectoryView(self.default_path)

    # get current selection and update the path
    # then if the path is good load it into linuxcnc
    # record it in the preference file if available
    def _getPathActivated(self):
        row = self.list.selectionModel().currentIndex()
        self.clicked(row)

        fname = self.currentPath
        if fname is None: 
            return
        if fname:
            self.load(fname)

    # this can be class patched to do something else
    def load(self, fname=None):
        if fname is None:
            self._getPathActivated()
            return
        self.recordBookKeeping()
        ACTION.OPEN_PROGRAM(fname)
        STATUS.emit('update-machine-log', 'Loaded: ' + fname, 'TIME')

    # this can be class patched to do something else
    def recordBookKeeping(self):
        fname = self.currentPath
        if fname is None: 
            return
        if self.PREFS_:
            self.PREFS_.putpref('last_loaded_directory', self.model.rootPath(), str, 'BOOK_KEEPING')
            self.PREFS_.putpref('RecentPath_0', fname, str, 'BOOK_KEEPING')

    # moves the selection up
    # used with MPG scrolling
    def up(self):
        self.select_row('up')

    # moves the selection down
    # used with MPG scrolling
    def down(self):
        self.select_row('down')
コード例 #10
0
    class Example(QWidget):
        def __init__(self):
            super().__init__()
            self.clear_lineedit = QLineEdit(self)
            self.info_sort = ''
            self.list = []
            self.dict = {}
            self.flag_print_file_info = True
            self.initUI()

        def initUI(self):

            self.setGeometry(300, 300, 940, 650)

            self.setWindowTitle('Первая программа')

            self.myListView = QListView(self)

            self.myListView.resize(300, 500)

            self.myListView.move(600, 0)

            self.cal = QCalendarWidget(self)

            self.cal.resize(500, 500)

            self.cal.move(0, 0)

            self.time = QTimeEdit(self)

            self.time.resize(50, 50)

            self.time.move(520, 250)

            self.helps = QLabel('Введите событие:', self)

            self.helps.move(0, 530)

            self.input_ivents = QLineEdit(self)

            self.input_ivents.resize(200, 50)

            self.input_ivents.move(130, 520)

            self.setStyleSheet("QLabel { font-size:15px}")

            self.button = QPushButton('Добавить', self)

            self.button.move(80, 580)

            self.print_file_info()

            self.button.clicked.connect(self.push)

            self.show()

        def print_file_info(self):
            if len(z) > 1:
                for x in range(len(z)):
                    x = z[x].split()
                    self.dict[x[1]] = x[0]
                    x = x[1].split('.')
                    x = ''.join(x)
                    self.list.append(x)
            elif len(z) == 2:
                x = z[0].split()
                self.dict[x[1]] = x[0]
                x = x[1].split('.')
                x = ''.join(x)
                self.list.append(x)
            if self.flag_print_file_info:
                for x in range(len(self.list)):
                    self.list[x] = int(self.list[x])
                self.list.sort()
                model = QtGui.QStandardItemModel()
                self.myListView.setModel(model)
                for x in range(len(self.list)):
                    self.list[x] = str(self.list[x])
                for e in self.list:
                    for x in self.dict.keys():
                        if ''.join(x.split('.')) == str(e):
                            p = x.split('.')
                            i = QtGui.QStandardItem(self.dict[x] + '  ' +
                                                    p[2] + '.' + p[1] + '.' +
                                                    p[0] + ' ' + p[3] + ':' +
                                                    p[-1])
                            model.appendRow(i)
                self.show()
                self.flag_print_file_info = False

        def push(self):
            time: QTime = self.time.time()
            self.ivent = self.input_ivents.text()

            self.info_input = ''

            date: QDate = self.cal.selectedDate()

            self.info_input += str(date.year()) + '.'
            self.info_sort += str(date.year())
            if len(str(date.month())) == 1:
                self.info_input += '0' + str(date.month()) + '.'
                self.info_sort += '0' + str(date.month())
            else:
                self.info_input += str(date.month()) + '.'
                self.info_sort += str(date.month())
            if len(str(date.day())) == 1:
                self.info_input += '0' + str(date.day()) + '.'
                self.info_sort += '0' + str(date.day())
            else:
                self.info_input += str(date.day()) + '.'
                self.info_sort += str(date.day())
            if len(str(time.hour())) == 1:
                self.info_input += '0' + str(time.hour()) + '.'
                self.info_sort += '0' + str(time.hour())
            else:
                self.info_input += str(time.hour()) + '.'
                self.info_sort += str(time.hour())
            if len(str(time.minute())) == 1:
                self.info_input += '0' + str(time.minute())
                self.info_sort += '0' + str(time.minute())
            else:
                self.info_input += str(time.minute())
                self.info_sort += str(time.minute())

            self.info_sort = int(self.info_sort)

            self.list.append(self.info_sort)
            self.dict[self.info_input] = self.ivent
            for x in range(len(self.list)):
                self.list[x] = int(self.list[x])
            self.list.sort()
            self.info_sort = ''
            model = QtGui.QStandardItemModel()
            self.myListView.setModel(model)
            for x in range(len(self.list)):
                self.list[x] = str(self.list[x])
            for e in self.list:
                for x in self.dict.keys():
                    if ''.join(x.split('.')) == str(e):
                        p = x.split('.')
                        i = QtGui.QStandardItem(self.dict[x] + '  ' + p[2] +
                                                '.' + p[1] + '.' + p[0] + ' ' +
                                                p[3] + ':' + p[-1])
                        model.appendRow(i)
            with open('file.txt', 'w', encoding='utf-8') as g:
                g.seek(0)
                for x in self.dict.keys():
                    g.write(self.dict[x] + ' ' + x + '\n')
            g.close()
コード例 #11
0
class FileManager(QWidget, _HalWidgetBase):
    def __init__(self, parent=None):
        super(FileManager, self).__init__(parent)
        self.title = 'Qtvcp File System View'
        self.left = 10
        self.top = 10
        self.width = 640
        self.height = 480
        self.media_path = (os.path.join(os.path.expanduser('~'),
                                        'linuxcnc/nc_files'))
        user = os.path.split(os.path.expanduser('~'))[-1]
        self.user_path = (os.path.join('/media', user))
        self.currentPath = None
        self.currentFolder = None
        self.initUI()

    def initUI(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        pasteBox = QHBoxLayout()
        self.textLine = QLineEdit()
        self.textLine.setToolTip('Current Director/selected File')
        self.pasteButton = QToolButton()
        self.pasteButton.setEnabled(False)
        self.pasteButton.setText('Paste')
        self.pasteButton.setToolTip(
            'Copy file from copy path to current directory/file')
        self.pasteButton.clicked.connect(self.paste)
        self.pasteButton.hide()
        pasteBox.addWidget(self.textLine)
        pasteBox.addWidget(self.pasteButton)

        self.copyBox = QFrame()
        hbox = QHBoxLayout()
        hbox.setContentsMargins(0, 0, 0, 0)
        self.copyLine = QLineEdit()
        self.copyLine.setToolTip('File path to copy from, when pasting')
        self.copyButton = QToolButton()
        self.copyButton.setText('Copy')
        self.copyButton.setToolTip('Record current file as copy path')
        self.copyButton.clicked.connect(self.recordCopyPath)
        hbox.addWidget(self.copyButton)
        hbox.addWidget(self.copyLine)
        self.copyBox.setLayout(hbox)
        self.copyBox.hide()

        self.model = QFileSystemModel()
        self.model.setRootPath(QDir.currentPath())
        self.model.setFilter(QDir.AllDirs | QDir.NoDot | QDir.Files)
        self.model.setNameFilterDisables(False)
        self.model.rootPathChanged.connect(self.folderChanged)

        self.list = QListView()
        self.list.setModel(self.model)
        self.updateDirectoryView(self.media_path)
        self.list.resize(640, 480)
        self.list.clicked[QModelIndex].connect(self.listClicked)
        self.list.activated.connect(self._getPathActivated)
        self.list.setAlternatingRowColors(True)

        self.cb = QComboBox()
        self.cb.currentIndexChanged.connect(self.filterChanged)
        self.fillCombobox(INFO.PROGRAM_FILTERS_EXTENSIONS)
        self.cb.setMinimumHeight(30)
        self.cb.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,
                                          QSizePolicy.Fixed))

        self.button2 = QToolButton()
        self.button2.setText('Media')
        self.button2.setSizePolicy(
            QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
        self.button2.setMinimumSize(60, 30)
        self.button2.setToolTip('Jump to Media directory')
        self.button2.clicked.connect(self.onJumpClicked)

        SettingMenu = QMenu(self)
        self.settingMenu = SettingMenu
        for i in ('Media', 'User'):
            axisButton = QAction(QIcon.fromTheme('user-home'), i, self)
            # weird lambda i=i to work around 'function closure'
            axisButton.triggered.connect(
                lambda state, i=i: self.jumpTriggered(i))
            SettingMenu.addAction(axisButton)
        self.button2.setMenu(SettingMenu)

        self.button3 = QToolButton()
        self.button3.setText('Add Jump')
        self.button3.setSizePolicy(
            QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
        self.button3.setMinimumSize(60, 30)
        self.button3.setToolTip('Add current directory to jump button list')
        self.button3.clicked.connect(self.onActionClicked)

        hbox = QHBoxLayout()
        hbox.addWidget(self.button2)
        hbox.addWidget(self.button3)
        hbox.insertStretch(2, stretch=0)
        hbox.addWidget(self.cb)

        windowLayout = QVBoxLayout()
        windowLayout.addLayout(pasteBox)
        windowLayout.addWidget(self.copyBox)
        windowLayout.addWidget(self.list)
        windowLayout.addLayout(hbox)
        self.setLayout(windowLayout)
        self.show()

    def _hal_init(self):
        if self.PREFS_:
            last_path = self.PREFS_.getpref('last_loaded_directory',
                                            self.media_path, str,
                                            'BOOK_KEEPING')
            self.updateDirectoryView(last_path)
            LOG.debug("lAST FILE PATH: {}".format(last_path))
        else:
            LOG.debug("lAST FILE PATH: {}".format(self.media_path))
            self.updateDirectoryView(self.media_path)

    #########################
    # callbacks
    #########################

    # add shown text and hidden filter data from the INI
    def fillCombobox(self, data):
        for i in data:
            self.cb.addItem(i[0], i[1])

    def folderChanged(self, data):
        self.currentFolder = data
        self.textLine.setText(data)

    def updateDirectoryView(self, path):
        self.list.setRootIndex(self.model.setRootPath(path))

    # retrieve selected filter (it's held as QT.userData)
    def filterChanged(self, index):
        userdata = self.cb.itemData(index)
        self.model.setNameFilters(userdata)

    def listClicked(self, index):
        # the signal passes the index of the clicked item
        dir_path = self.model.filePath(index)
        if self.model.fileInfo(index).isFile():
            self.currentPath = dir_path
            self.textLine.setText(self.currentPath)
            return
        root_index = self.model.setRootPath(dir_path)
        self.list.setRootIndex(root_index)

    def onUserClicked(self):
        self.showUserDir()

    def onMediaClicked(self):
        self.showMediaDir()

    def onJumpClicked(self):
        data = self.button2.text()
        if data == 'Media':
            self.showMediaDir()
        elif data == 'User':
            self.showUserDir()
        else:
            self.updateDirectoryView(self.button2.text())

    def jumpTriggered(self, data):
        if data == 'Media':
            self.button2.setText('{}'.format(data))
            self.button2.setToolTip('Jump to Media directory')
            self.showMediaDir()
        elif data == 'User':
            self.button2.setText('{}'.format(data))
            self.button2.setToolTip('Jump to User directory')
            self.showUserDir()
        else:
            self.button2.setText('{}'.format(data))
            self.button2.setToolTip('Jump to directory: {}'.format(data))
            self.updateDirectoryView(self.button2.text())

    def onActionClicked(self):
        i = self.currentFolder
        button = QAction(QIcon.fromTheme('user-home'), i, self)
        # weird lambda i=i to work around 'function closure'
        button.triggered.connect(lambda state, i=i: self.jumpTriggered(i))
        self.settingMenu.addAction(button)

    # get current selection and update the path
    # then if the path is good load it into linuxcnc
    # record it in the preference file if available
    def _getPathActivated(self):
        row = self.list.selectionModel().currentIndex()
        self.listClicked(row)

        fname = self.currentPath
        if fname is None:
            return
        if fname:
            self.load(fname)

    def recordCopyPath(self):
        data, isFile = self.getCurrentSelected()
        if isFile:
            self.copyLine.setText(os.path.normpath(data))
            self.pasteButton.setEnabled(True)
        else:
            self.copyLine.setText('')
            self.pasteButton.setEnabled(False)
            STATUS.emit('error', OPERATOR_ERROR,
                        'Can only copy a file, not a folder')

    def paste(self):
        res = self.copyFile(self.copyLine.text(), self.textLine.text())
        if res:
            self.copyLine.setText('')
            self.pasteButton.setEnabled(False)

    ########################
    # helper functions
    ########################

    def showCopyControls(self, state):
        if state:
            self.copyBox.show()
            self.pasteButton.show()
        else:
            self.copyBox.hide()
            self.pasteButton.hide()

    def showMediaDir(self):
        self.updateDirectoryView(self.user_path)

    def showUserDir(self):
        self.updateDirectoryView(self.media_path)

    def copyFile(self, s, d):
        try:
            shutil.copy(s, d)
            return True
        except Exception as e:
            LOG.error("Copy file error: {}".format(e))
            STATUS.emit('error', OPERATOR_ERROR,
                        "Copy file error: {}".format(e))
            return False

    # moves the selection up
    # used with MPG scrolling
    def up(self):
        self.select_row('up')

    # moves the selection down
    # used with MPG scrolling
    def down(self):
        self.select_row('down')

    def select_row(self, style='down'):
        style = style.lower()
        selectionModel = self.list.selectionModel()
        row = selectionModel.currentIndex().row()
        self.rows = self.model.rowCount(self.list.rootIndex())

        if style == 'last':
            row = self.rows
        elif style == 'up':
            if row > 0:
                row -= 1
            else:
                row = 0
        elif style == 'down':
            if row < self.rows:
                row += 1
            else:
                row = self.rows
        else:
            return
        top = self.model.index(row, 0, self.list.rootIndex())
        selectionModel.setCurrentIndex(
            top, QItemSelectionModel.Select | QItemSelectionModel.Rows)
        selection = QItemSelection(top, top)
        selectionModel.clearSelection()
        selectionModel.select(selection, QItemSelectionModel.Select)

    # returns the current highlighted (selected) path as well as
    # whether it's a file or not.
    def getCurrentSelected(self):
        selectionModel = self.list.selectionModel()
        index = selectionModel.currentIndex()
        dir_path = self.model.filePath(index)
        if self.model.fileInfo(index).isFile():
            return (dir_path, True)
        else:
            return (dir_path, False)

    # This can be class patched to do something else
    def load(self, fname=None):
        if fname is None:
            self._getPathActivated()
            return
        self.recordBookKeeping()
        ACTION.OPEN_PROGRAM(fname)
        STATUS.emit('update-machine-log', 'Loaded: ' + fname, 'TIME')

    # This can be class patched to do something else
    def recordBookKeeping(self):
        fname = self.currentPath
        if fname is None:
            return
        if self.PREFS_:
            self.PREFS_.putpref('last_loaded_directory', self.model.rootPath(),
                                str, 'BOOK_KEEPING')
            self.PREFS_.putpref('RecentPath_0', fname, str, 'BOOK_KEEPING')
コード例 #12
0
ファイル: DiaMorView.py プロジェクト: berkeozenc/DiaMor
class DiaMorView(QMainWindow):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):

        system = platform.system()

        self.projectPath_label = QLabel(self)
        self.projectPath_label.setText("Select a project folder")
        self.projectPath_label.move(22, 30)
        self.projectPath_label.resize(400, 30)

        self.xml_lineEdit = ClickableLineEdit(self)
        self.xml_lineEdit.move(20, 70)
        self.xml_lineEdit.resize(400, 30)
        self.xml_lineEdit.setPlaceholderText("Choose xml file")
        self.xml_lineEdit.setReadOnly(True)

        self.xml_button = QPushButton(self)
        self.xml_button.move(430, 74)
        self.xml_button.resize(20, 20)
        icon = QIcon()
        icon.addPixmap(QPixmap("assets/folder.png"))
        self.xml_button.setIcon(icon)
        self.xml_button.setIconSize(QSize(20, 20))

        self.lexiconFile_lineEdit = ClickableLineEdit(self)
        self.lexiconFile_lineEdit.move(20, 110)
        self.lexiconFile_lineEdit.resize(400, 30)
        #self.lexiconFile_lineEdit.clicked.connect(self.showFileSelection)
        self.lexiconFile_lineEdit.setPlaceholderText("Choose lexicon file")
        self.lexiconFile_lineEdit.setReadOnly(True)

        self.lexiconFile_button = QPushButton(self)
        self.lexiconFile_button.move(430, 114)
        self.lexiconFile_button.resize(20, 20)
        icon = QIcon()
        icon.addPixmap(QPixmap("assets/folder.png"))
        self.lexiconFile_button.setIcon(icon)
        self.lexiconFile_button.setIconSize(QSize(20, 20))

        self.twolFileList_Label = QLabel(self)
        self.twolFileList_Label.setText("Found .twol files: ")
        self.twolFileList_Label.move(22, 160)
        self.twolFileList_Label.resize(400, 30)

        self.twolRefresh_button = QPushButton("Refresh", self)
        self.twolRefresh_button.move(350, 160)

        self.twolFileList_ListWidget = QListView(self)
        self.twolFileList_ListWidgetModel = QStandardItemModel(
            self.twolFileList_ListWidget)
        self.twolFileList_ListWidget.setModel(
            self.twolFileList_ListWidgetModel)
        self.twolFileList_ListWidget.move(20, 200)
        self.twolFileList_ListWidget.resize(430, 300)
        self.twolFileList_ListWidget.setDragDropMode(
            QAbstractItemView.InternalMove)
        self.twolFileList_ListWidget.show()
        #self.twolFileList_ListWidget.selectionModel().selectionChanged.connect(self.t)

        self.generate_Button = QPushButton("Generate", self)
        self.generate_Button.move(350, 510)
        self.generate_Button.setEnabled(False)

        if system == "Darwin":
            self.projectPath_label.move(22, 10)
            self.xml_lineEdit.move(20, 50)
            self.xml_button.move(430, 54)
            self.lexiconFile_lineEdit.move(20, 90)
            self.lexiconFile_button.move(430, 94)
            self.twolFileList_Label.move(22, 140)
            self.twolRefresh_button.move(350, 140)
            self.twolFileList_ListWidget.move(20, 180)
            self.generate_Button.move(350, 490)

        self.statusBar()
        #openFile.setShortcut('Ctrl+O')
        #createProjectMenuBtn.triggered.connect(self.createProject)
        self.openProjectMenuBtn = QAction('Open', self)
        self.openProjectMenuBtn.setShortcut('Ctrl+O')
        self.openProjectMenuBtn.setStatusTip('Open existing project')
        self.saveProjectMenuBtn = QAction('Save', self)
        self.saveProjectMenuBtn.setShortcut('Ctrl+S')
        self.saveProjectMenuBtn.setStatusTip('Save existing project')

        menubar = self.menuBar()
        fileMenu = menubar.addMenu('&Project')
        fileMenu.addAction(self.openProjectMenuBtn)
        fileMenu.addAction(self.saveProjectMenuBtn)

        self.setGeometry(50, 50, 470, 550)
        self.setWindowTitle('DiaMor')
        self.show()

    def t(self):
        print("order changed")

    def showWarning(self, message):
        QMessageBox.about(self, "Warning", message)

    def showDirectoryDialog(self):
        return QFileDialog.getExistingDirectory(self, "Select Directory")

    def showFileDialog(self, path, fileType):
        return QFileDialog.getOpenFileName(self, 'Open file', path, fileType)

    def clearTwolList(self):
        self.twolFileList_ListWidgetModel.clear()

    def addToTwolList(self, fileName, state):
        item = QStandardItem(fileName)
        item.setCheckable(True)
        item.setCheckState(state)
        item.setEditable(False)
        item.setDropEnabled(False)
        self.twolFileList_ListWidgetModel.appendRow(item)
        '''
コード例 #13
0
class App(QMainWindow):
    def __init__(self, user_, userId_):
        try:
            super().__init__()
            self.client_ = Client(user_, userId_)
            self.user = user_
            self.title = user_ + ': welcome to financial chat room'
            self.userId = userId_
            self.left = 0
            self.top = 0
            self.width = 440
            self.height = 650
            self.initUI()
            self.count_messages = 0
            ithread = threading.Thread(target=self.reciveMessage)
            ithread.daemon = True
            ithread.start()
        except:
            exc_type, exc_value, exc_traceback = sys.exc_info()
            error = repr(
                traceback.format_exception(exc_type, exc_value, exc_traceback))
            print('Error starting Browers: %s' % (error))

    def initUI(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        self.view = QListView(self)
        self.view.move(15, 15)
        self.view.resize(400, 580)
        self.model = QStandardItemModel()

        self.user_message = QLineEdit(self)
        self.user_message.move(30, 610)
        self.user_message.resize(280, 30)
        self.user_message.setPlaceholderText('write a message')

        self.button = QPushButton('Send', self)
        self.button.move(320, 610)
        self.button.resize(40, 30)
        self.button.clicked.connect(self.on_click)
        self.show()

    def on_click(self):
        try:
            self.show_in_chatbox(self.user_message.text())
            self.client_.sendMessage_to_chatroom(self.user_message.text())
            self.user_message.clear()
        except:
            exc_type, exc_value, exc_traceback = sys.exc_info()
            error = repr(
                traceback.format_exception(exc_type, exc_value, exc_traceback))
            print('**** ERROR %s' % error)

    def reciveMessage(self):
        while True:
            try:
                print('Browers reciveMessage start...')
                resul = self.client_.reciveMessage_from_chatroom()
                print('Browers reciveMessage got something...')

                if resul is not None:
                    self.show_in_chatbox(str(resul))
            except:
                exc_type, exc_value, exc_traceback = sys.exc_info()
                error = repr(
                    traceback.format_exception(exc_type, exc_value,
                                               exc_traceback))
                print('** ERROR: %s' % error)

    def show_in_chatbox(self, message):
        self.count_messages += 1
        if self.count_messages > 50:
            self.model.removeRow(0)
        self.model.appendRow(QStandardItem(message))
        self.model.appendRow(QStandardItem('--------------'))
        self.view.setModel(self.model)


# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = App('noel', 1)
# sys.exit(app.exec_())
コード例 #14
0
ファイル: main.py プロジェクト: zhangenter/bf_chat
class Main(QWidget):
    def __init__(self, user, width=160, height=660):
        super().__init__()
        self.user = user

        self.lv = QListView(self)
        self.lv.setViewMode(QListView.ListMode)
        self.lv.setIconSize(QSize(30, 30))
        # self.lb.setGridSize(QSize(30,30))
        self.lv.resize(width, height)
        self.lv.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.lv.setResizeMode(QListView.Adjust)
        self.lv_model = QStandardItemModel()
        self.lv.setModel(self.lv_model)
        # self.lb_model.appendRow(QStandardItem(QIcon("./client/image/man.png"), "普通员工A"))
        # self.lb_model.appendRow(QStandardItem(QIcon("./client/image/woman.png"), "普通员工B"))
        self.lv.doubleClicked.connect(self.lv_clicked)

        MsgWorker().do_update = self.do_update
        self.query_all_users()

    def query_all_users(self):
        MsgWorker().send_msg(msg_lib.build_get_all_users_msg())

    def do_update(self, all_users):
        self.all_users = all_users
        for user in self.all_users:
            self.lv_model.appendRow(
                QStandardItem(QIcon("./client/image/man.png"), user.nick_name))

            # self.lb.insert(tk.END, user.nick_name)

    def lv_clicked(self, model_index):
        user = self.all_users[model_index.row()]
        self.chat_to({'mode': 'user', 'data': user})

    def send(self):
        pass
        # val = self.sdTxt.get('1.0', tk.END)
        # MsgWorker().send_msg(val.encode())
        # self.rcTxt.tag_config("tag_me", foreground="green")
        # self.rcTxt.insert(tk.INSERT, '我:%s'%val, ("tag_me"))

    chat_form = None

    def chat_to(self, user):
        if not self.chat_form:
            self.chat_form = Chat()
            self.chat_form.after_close = self.do_after_close
            self.chat_form.show()

        self.chat_form.chat_to(user)
        self.chat_form.setWindowState(self.windowState()
                                      & ~QtCore.Qt.WindowMinimized
                                      | QtCore.Qt.WindowActive)
        self.chat_form.raise_()
        self.chat_form.activateWindow()

    def do_after_close(self):
        self.chat_form = None

    def closeEvent(self, event):
        if self.chat_form:
            self.chat_form.close()
        MsgWorker().send_msg(msg_lib.build_logout_msg(self.user.name))
コード例 #15
0
    def initUI(self):
        
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        #a_combobox = QWidgets.QComboBox()
        comboA = QtWidgets.QComboBox(self)
        comboB = QtWidgets.QComboBox(self)
        #comboA.setGeometry(QtCore.QRect(400, 180, 200, 50))
        comboA.setGeometry(400, 200, 150, 80)
        comboB.setGeometry(20, 300, 220, 40)
        layoutA = QtWidgets.QVBoxLayout(comboA)
        layoutB = QtWidgets.QVBoxLayout(comboB)

        comboA.setStyleSheet("font: 20px; border-style: outset; border-width:0px ; border-color: rbg(128,128,128); color:rgb(0,0,0); background-color: rgb(255,255,255);");
        comboB.setStyleSheet("font: 20px; border-style: outset; border-width:0px ; border-color: rbg(128,128,128); color:rgb(0,0,0); background-color: rgb(255,255,255);");
        comboA.addItem("選擇連線硬體")
        comboA.addItem("Arduino")
        comboA.addItem("Circuit")
        comboA.addItem("ESP-8266")
        comboA.addItem("Picoboard")
        comboA.addItem("Raspberry Pi")
        comboB.addItem("選擇燒錄硬體")
        comboB.addItem("Arduino Uno")
        comboB.addItem("ESP-8266")
        comboB.addItem("Circuit")
        ##預設值
        #comboA.setCurrentIndex(0)
         
        #print (comboA.currentText())
        comboA.activated.connect(self.comboA_selectionchange)
        comboB.activated.connect(self.comboB_selectionchange)
        layoutA.addWidget(comboA)
        layoutB.addWidget(comboB)

        #label
        l_v = QLabel('v:'+version,self) #//版本號
        l_v.resize(80,25)
        l_v.setStyleSheet("font: 12px; border-style: outset; color:rgb(255,0,255);");
        l_v.move(20,20)

        l_A = QLabel("連接硬體功能",self)
        l_A.setAlignment(QtCore.Qt.AlignCenter)
        l_A.resize(150,35)
        l_A.setStyleSheet("font: 20px;text-align:center; color:rgb(255,255,255); background-color: rgb(233,0,125);");
        l_A.move(400,300)
        l_B = QLabel('',self)
        l_B.setPixmap(self.pixmap)
        l_B.resize(300,160)
        l_B.move(350,10)

        l_C =QLabel('燒錄韌體',self)
        l_C.move(250,300)
        l_C.setAlignment(QtCore.Qt.AlignCenter) #//*置中*/
        l_C.resize(120,35)
        l_C.setStyleSheet("font: 20px;text-align:center; color:rgb(255,255,255); background-color: rgb(233,0,125);");

        l_D =QLabel('開始創作',self)
        l_D.setAlignment(QtCore.Qt.AlignLeft)
        l_D.resize(120,35)
        l_D.setStyleSheet("font: 16px; border-style: outset; border-width:0px ; border-color: rbg(128,128,128); color:rgb(174, 182, 191); ");
        l_D.move(600,175)

        l_E =QLabel('選擇硬體',self)
        l_E.setAlignment(QtCore.Qt.AlignLeft)
        l_E.resize(120,35)
        l_E.setStyleSheet("font: 16px; border-style: outset; border-width:0px ; border-color: rbg(128,128,128); color:rgb(174, 182, 191); ");
        l_E.move(400,175)

        l_F =QLabel('確認硬體',self)
        l_F.setAlignment(QtCore.Qt.AlignLeft)
        l_F.resize(120,35)
        l_F.setStyleSheet("font: 16px; border-style: outset; border-width:0px ; border-color: rbg(128,128,128); color:rgb(174, 182, 191); ");
        l_F.move(20,175)


        b_port = QPushButton("連接埠",self)
        b_port.resize(120,35)
        b_port.setStyleSheet("font: 20px;text-align:center; color:rgb(255,255,255); background-color: rgb(233,0,125);");
        b_port.setToolTip("偵測設備port")
        b_port.move(250,200)
        b_port.clicked.connect(self.b_port_clicked)

        
        #l_B = QLabel("設備port",self)
        #l_B.move(164,10)
        #https://blog.csdn.net/jia666666/article/details/81624550
        listviewA = QListView(self)
        listviewA.setStyleSheet("font: 20px;  background-color: rgb(255,255,255);");
        listviewA.resize(220,80)
        listviewA.move(20,200)
        slm=QStringListModel()

        ##port
        self.qList=serial_ports()
        ##listviewA.qList=['aaaa','bbbb','cccc']
        slm.setStringList(self.qList)
        listviewA.setModel(slm)
        listviewA.clicked.connect(self.listviewA_clicked)

        b_class = QPushButton("OSEP課程資源",self)
        b_class.setStyleSheet("font: 20px;text-align:center; color:rgb(255,255,255); background-color: rgb(233,0,125);");
        b_class.setToolTip("瀏覽器開啟OSEP課程資源")
        b_class.resize(150,35)
        b_class.move(600,200)
        b_class.clicked.connect(self.b_class_clicked)

        b_url = QPushButton("OSEP線上操作",self)
        b_url.setStyleSheet("font: 20px;text-align:center; color:rgb(255,255,255); background-color: rgb(233,0,125);");
        b_url.setToolTip("瀏覽器開啟OSEP線上操作網站")
        b_url.resize(150,35)
        b_url.move(600,250)
        b_url.clicked.connect(self.b_url_clicked)

        b_offline = QPushButton("OSEP離線操作",self)
        b_offline.resize(150,35)
        b_offline.setStyleSheet("font: 20px;text-align:center; color:rgb(128,128,128); background-color: rgb(255,255,255);");
        b_offline.setToolTip("OSEP離線操作")
        b_offline.move(600,300)
        b_offline.clicked.connect(self.b_offline_clicked)

        b_clear = QPushButton("重置OSEP",self)
        b_clear.setToolTip("clear python.exe")
        b_clear.resize(150,35)
        b_clear.setStyleSheet("font: 20px;text-align:center; color:rgb(128,128,128); background-color: rgb(255,255,255);");
        b_clear.move(600,65)
        b_clear.clicked.connect(self.b_clear_clicked)

        b_about = QPushButton("關於OSEP",self)
        b_about.setToolTip("關於OSEP")
        b_about.resize(150,35)
        b_about.setStyleSheet("font: 20px; color: rgb(128,128,128);  text-align::center; ");
        b_about.move(600,20)
        b_about.clicked.connect(self.b_about_clicked)
        
        self.show()
コード例 #16
0
class CentralWidgetParkingson(QWidget):
    pacients_tab: QWidget  # Una vez seleccionado paciente, mostrara sus datos
    cronometro_tab: QWidget  # Una vez seleccionado paciente, lo testara
    evolution_tab: QWidget  # Una vez seleccionado paciente, mostrara su rendimiento

    pacients_list_view: QListView  # Mostrara los pacientes en lista
    actions_buttons: dict  # Continene los botones de la app

    general_layout: QVBoxLayout
    buttons_layout: QHBoxLayout  # el layout de los botones de arriba
    content_layout: QHBoxLayout  # los layout de los tabs y el listview

    ADD_button_key = "add"
    DELETE_button_key = "delete"
    EDIT_button_key = "edit"

    @Utils.function_error_safety
    def __init__(self, user:str, parent=None):
        super(QWidget, self).__init__(parent)
        self.general_layout = QVBoxLayout()
        self.buttons_layout = QHBoxLayout()
        self.content_layout = QHBoxLayout()

        self.actions_buttons = {
            CentralWidgetParkingson.ADD_button_key: QPushButton('Anadir'),
            CentralWidgetParkingson.DELETE_button_key: QPushButton('Eliminar'),
            CentralWidgetParkingson.EDIT_button_key: QPushButton('Editar')
        }

        for x in self.actions_buttons:
            self.actions_buttons[x].setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
            self.actions_buttons[x].setObjectName(x + "_button")
            self.buttons_layout.addWidget(self.actions_buttons[x])

        self.buttons_layout.setAlignment(Qt.AlignLeft)
        self.buttons_layout.setSpacing(20)

        self.pacients_list_view = QListView()
        self.pacients_list_view.resize(200, 400)
        self.parent_tab_widget = QTabWidget()
        self.parent_tab_widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.pacients_tab: PacientWidget = PacientWidget()  # Tab1 Color

        # self.rendimiento_tab = MplCanvas(self, width=5, height=4, dpi=100)  # Tab2 Grafica
        self.evolution_tab = EvolutionTab(user)

        self.cronometro_tab = Cronometro(user)
        self.parent_tab_widget.resize(300, 300)  # Tab Parent

        self.parent_tab_widget.addTab(self.pacients_tab, "Paciente")
        self.parent_tab_widget.addTab(self.evolution_tab, "Evolucion")
        self.parent_tab_widget.addTab(self.cronometro_tab, "Cronómetro")

        self.pacients_list_view.setMinimumSize(200, 400)
        self.pacients_list_view.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
        self.pacients_list_view.setContextMenuPolicy(Qt.CustomContextMenu)

        self.content_layout.addWidget(self.pacients_list_view, stretch=3, alignment=Qt.AlignTop)
        self.content_layout.addWidget(self.parent_tab_widget, stretch=9)

        # self.general_layout.addLayout(self.buttons_layout)
        self.general_layout.addLayout(self.content_layout)

        self.setMinimumSize(900, 600)
        self.setLayout(self.general_layout)
コード例 #17
0
WINDOW_WIDTH = 400
WINDOW_HEIGHT = 300

app = QApplication([])

model = QSqlQueryModel()
model.setQuery("SELECT id, key, value FROM Dict")
model.setHeaderData(0, Qt.Horizontal, "ID")
model.setHeaderData(1, Qt.Horizontal, "KEY")
model.setHeaderData(2, Qt.Horizontal, "VALUE")

list_view = QListView()
list_view.setWindowTitle('QListView')
list_view.setModel(model)
list_view.move(100, 50)
list_view.resize(WINDOW_WIDTH, WINDOW_HEIGHT)
list_view.show()

list_view_2 = QListView()
list_view_2.setWindowTitle('QListView + ItemDelegate')
list_view_2.setItemDelegate(ListViewDelegate())
list_view_2.setModel(model)
list_view_2.move(list_view.geometry().right(), 50)
list_view_2.resize(WINDOW_WIDTH, WINDOW_HEIGHT)
list_view_2.show()

table_view = QTableView()
table_view.setWindowTitle('QTableView')
table_view.setModel(model)
table_view.move(list_view.pos().x(), list_view.geometry().bottom())
table_view.resize(WINDOW_WIDTH, WINDOW_HEIGHT)
コード例 #18
0
ファイル: Gui.py プロジェクト: akulinski/MovieScrape
class Gui(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.logger = logging.getLogger(__name__)
        logging.basicConfig(filename='example.log', level=logging.DEBUG)

        #geometry
        self.initText = QStandardItem("Click genreate to select movie")
        self.db = DatabaseController.Controller()
        self.left = 500
        self.top = 50
        self.width = 320
        self.height = 300
        self.setUp()
        #self.interface()

        self.show()

    def setUp(self):
        self.setGeometry(self.left, self.top, self.width, self.height)

        self.createHorizontalLayout()

        windowLayout = QVBoxLayout()
        windowLayout.addWidget(self.horizontalGroupBox)
        self.setLayout(windowLayout)

    def createHorizontalLayout(self):
        self.horizontalGroupBox = QGroupBox("Choose next movie to watch")
        layout = QHBoxLayout()

        # Create textbox
        self.textbox = QListView(self)  #dispaly title
        self.textbox.move(20, 20)
        self.textbox.resize(280, 40)

        self.model = QStandardItemModel(self.textbox)
        self.model.appendRow(self.initText)
        self.textbox.setModel(self.model)
        layout.addWidget(self.textbox)

        buttonBlue = QPushButton('Select Movie', self)
        buttonBlue.clicked.connect(self.selectMovie)
        layout.addWidget(buttonBlue)

        self.horizontalGroupBox.setLayout(layout)

    @pyqtSlot()
    def selectMovie(self):
        self.mainThread = threading.Thread(target=Main.main(self.db))
        self.mainThread.start()
        self.mainThread.join()

        self.commonList = self.db.selectComon()

        #print("LEN: "+len(self.commonList))
        x = self.commonList[0]
        title = x[0]
        rating = x[1]
        info = x[2]
        tmp = QStandardItem(str(title) + str(rating) + str(info))
        logtmp = (str(title) + str(rating) + str(info)).encode("utf-8")

        self.logger.debug("Napis=%s", logtmp)
        #print("GUI: "+str(tmp))
        self.model.appendRow(tmp)

        self.model.removeRow(0)
        self.textbox.setModel(self.model)
コード例 #19
0
ファイル: chat.py プロジェクト: zhangenter/bf_chat
class Chat(QWidget):
    msg_signal = pyqtSignal(dict)
    after_close = None
    chats = []
    cur_chat = None

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

        self.msg_signal.connect(self.fill_msg)
        MsgWorker().do_recv_msg = self.do_recv_msg
        self.setWindowTitle('')
        self.op_bar = QFrame(self)
        self.op_bar.setStyleSheet('background-color:rgb(255, 255, 255);')
        self.send_bar = QFrame(self)
        self.send_bar.setStyleSheet('background-color:rgb(255, 255, 255);')
        self.rcTxt = QTextBrowser(self)
        self.rcTxt.setStyleSheet('background-color:rgb(255, 255, 255);')
        self.sdTxt = QTextEdit(self)
        self.sdTxt.setStyleSheet('background-color:rgb(255, 255, 255);')
        self.btn = QPushButton("发送", self.send_bar)
        self.btn.clicked.connect(self.send)
        self.lv = QListView(self)
        self.lv.setViewMode(QListView.ListMode)
        self.lv.setIconSize(QSize(30, 30))
        self.lv.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.lv.setResizeMode(QListView.Adjust)
        self.lv_model = QStandardItemModel()
        self.lv.setModel(self.lv_model)
        self.lv.clicked.connect(self.lv_clicked)
        self.lv.move(0, 0)

        w, h = 600, 400
        self.resize(800, 600)

    def resizeEvent(self, evt):
        self.after_resize(evt.size().width(), evt.size().height())

    def after_resize(self, w, h):
        lv_width = 200
        sdTxt_height = 120
        bar_height = 30
        self.op_bar.move(200, h - sdTxt_height - bar_height * 2)
        self.op_bar.resize(w - lv_width, bar_height)
        self.send_bar.move(200, h - bar_height)
        self.send_bar.resize(w - lv_width, bar_height)

        self.lv.resize(lv_width, h)
        self.rcTxt.move(lv_width, 0)
        self.rcTxt.resize(w - lv_width, h - sdTxt_height - bar_height * 2)
        self.sdTxt.move(lv_width, h - sdTxt_height - bar_height)
        self.sdTxt.resize(w - lv_width, sdTxt_height)

    def lv_clicked(self, model_index):
        cur_chat = self.chats[model_index.row()]
        if cur_chat['mode'] == 'user':
            self.setWindowTitle(cur_chat['data'].nick_name)

    def refresh_cur_chat(self):
        if self.cur_chat['mode'] == 'user':
            self.setWindowTitle(self.cur_chat['data'].nick_name)

    def get_in_chat_index(self, chat):
        if chat['mode'] == 'user':
            name = chat['data'].name
            match = lambda x: x['mode'] == 'user' and x['data'].name == name
        for i in range(len(self.chats)):
            if match(self.chats[i]):
                return i

        return -1

    def chat_to(self, chat):
        i = self.get_in_chat_index(chat)
        if i == -1:
            if chat['mode'] == 'user':
                self.lv_model.appendRow(
                    QStandardItem(QIcon("./client/image/man.png"),
                                  chat['data'].nick_name))
            self.chats.append(chat)
            self.cur_chat = chat
            i = len(self.chats) - 1
        else:
            self.cur_chat = self.chats[i]
        self.refresh_cur_chat()
        self.lv.setCurrentIndex(self.lv_model.index(i, 0))

    def fill_msg(self, data):
        ufrom = data['from']
        uto = data['to']
        val = data['val']
        ufrom_nickname = ufrom
        try:
            self.rcTxt.setPlainText(self.rcTxt.toPlainText() + '%s:%s\n' %
                                    (ufrom_nickname, val))
        except Exception as ex:
            print(ex)

    def do_recv_msg(self, data):
        self.msg_signal.emit(data)

    def send(self):
        # val = self.sdTxt.toHtml()
        val = self.sdTxt.toPlainText()
        if self.cur_chat['mode'] == 'user':
            MsgWorker().send_msg(
                msg_lib.build_chat_msg(MsgWorker().user_info.name,
                                       self.cur_chat['data'].name, val))
        # self.rcTxt.setHtml(self.rcTxt.toHtml()+'\n我:%s'%val)
        self.rcTxt.setPlainText(self.rcTxt.toPlainText() + '我:%s\n' % val)
        self.sdTxt.setPlainText('')

    def closeEvent(self, event):
        self.chats.clear()
        if self.after_close:
            self.after_close()
コード例 #20
0
    def initUI(self):
        global button1
        global button2
        global button3
        global button4
        global button5

        self.setWindowTitle(self.title)
        self.setMaximumSize(620, 400)
        self.setMinimumSize(620, 700)
        self.setGeometry(self.left, self.top, self.width, self.height)
        self.setWindowIcon(QIcon("images.ico"))

        button1 = QPushButton('Select Files', self)
        button1.setToolTip('This is an example button')
        button1.move(70, 60)
        button1.resize(100, 30)
        button1.clicked.connect(self.openFileNamesDialog)

        button2 = QPushButton('Run for All', self)
        button2.setToolTip('This is an example button')
        button2.move(70, 480)
        button2.resize(240, 30)
        button2.clicked.connect(self.trim)
        button2.setEnabled(False)

        button3 = QPushButton('Run for Affacted', self)
        button3.setToolTip('This is an example button')
        button3.move(310, 450)
        button3.resize(240, 30)
        button3.clicked.connect(self.trim_affacted)
        button3.setEnabled(False)

        button4 = QPushButton('Check Affacted Files', self)
        button4.setToolTip('This is an example button')
        button4.move(70, 450)
        button4.resize(240, 30)
        button4.clicked.connect(self.check_Extra_spaces, )
        button4.setEnabled(False)

        button5 = QPushButton('Reset', self)
        button5.setToolTip('This is an example button')
        button5.move(310, 480)
        button5.resize(240, 30)
        button5.clicked.connect(self.reset)
        button5.setEnabled(False)

        button6 = QPushButton('Close', self)
        button6.setToolTip('This is an example button')
        button6.move(450, 630)
        button6.resize(100, 30)
        button6.clicked.connect(self.close_window)

        # button7 = QPushButton('See logs', self)
        # button7.setToolTip('This is an example button')
        # button7.move(250, 630)
        # button7.resize(100, 30)
        # button7.clicked.connect(self.openpop_up)

        label2 = QLabel('Set Output Path :', self)
        label2.move(70, 155)

        global textbox1
        global textbox2
        global textbox3
        global model, list1

        textbox1 = QLineEdit(self)
        textbox1.move(170, 60)
        textbox1.resize(380, 30)
        textbox1.setReadOnly(True)

        textbox2 = QLineEdit(desktop, self)
        textbox2.move(170, 150)
        textbox2.resize(380, 30)

        list1 = QListView(self)
        list1.setWindowTitle('Affected File List')
        list1.setMinimumSize(100, 200)
        list1.move(70, 240)
        list1.resize(480, 26)
        list1.setEditTriggers(QAbstractItemView.NoEditTriggers)

        global progress
        progress = QProgressBar(self)
        progress.move(70, 530)
        progress.resize(500, 26)
        progress.setValue(0)

        self.show()