コード例 #1
0
ファイル: PhotoViewer.py プロジェクト: davidiswhat/StudiOCR
    def contextMenuEvent(self, event):
        cmenu = Qw.QMenu(self)
        saveAs = cmenu.addAction("Save Image As")
        action = cmenu.exec_(self.mapToGlobal(event.pos()))
        clipboard = Qw.QApplication.clipboard()

        if action == saveAs:
            file_dialog = Qw.QFileDialog(self)
            dropdown_style = """QComboBox::item:checked {
                height: 12px;
                border: 1px solid #32414B;
                margin-top: 0px;
                margin-bottom: 0px;
                padding: 4px;
                padding-left: 0px;
                }"""

            file_dialog = Qw.QFileDialog()
            file_dialog.setStyleSheet(dropdown_style)
            file_dialog.setFileMode(Qw.QFileDialog.AnyFile)
            file_dialog.setAcceptMode(Qw.QFileDialog.AcceptSave)
            file_dialog.setNameFilters([
                "JPEG File (*.jpg)"])
            file_dialog.selectNameFilter("JPEG File (*.jpg)")
            file_dialog.setDefaultSuffix("jpg")

            if file_dialog.exec_():
                file = file_dialog.selectedFiles()[0]
                (self.pixmap).save(file, "JPG")
コード例 #2
0
    def open_file_dialog(self):
        self.file_dialog = QtWidgets.QFileDialog()
        self.file_dialog.setFileMode(QtWidgets.QFileDialog.DirectoryOnly)

        if self.file_dialog.exec_():
            initial_path = "S:/"
            path = QtWidgets.QFileDialog().getExistingDirectory(self, "Choose Existing Job", initial_path, QtWidgets.QFileDialog.DirectoryOnly)
            # path = self.file_dialog.getExistingDirectory(self, "Choose Existing Job", initial_path, QtWidgets.QFileDialog.DirectoryOnly)

            self.parse_job(path)
コード例 #3
0
ファイル: setlibrary.py プロジェクト: boom-roasted/ImageWAO
    def _chooseImportFolder(self):

        # prompt user to choose folder
        folder = QtWidgets.QFileDialog().getExistingDirectory(
            self,
            "Import to ...",
            self.pathEdit.text(),
            QtWidgets.QFileDialog().ShowDirsOnly,
        )

        if not folder == "":
            self.pathEdit.setText(folder)
コード例 #4
0
    def changeRootFolderDialog(self):

        # prompt user to choose folder
        folder = QtWidgets.QFileDialog().getExistingDirectory(
            self,
            "Choose Flight Folder",
            Path().home().anchor,
            QtWidgets.QFileDialog().ShowDirsOnly,
        )

        if not folder == "":

            # rebase view on new folder
            self.rebase(folder)
コード例 #5
0
ファイル: view.py プロジェクト: TDChina/NukeClass3
    def __init__(self):
        super(PackageToolUI, self).__init__(None, QtCore.Qt.WindowStaysOnTopHint)
        self.setWindowTitle('Package Nuke Script')
        self.setLayout(QtWidgets.QVBoxLayout())
        self.setFixedWidth(400)
        self.folder_layout = QtWidgets.QHBoxLayout()
        self.folder_label = QtWidgets.QLabel('Destination Folder:')
        self.folder_line = QtWidgets.QLineEdit()
        self.folder_button = QtWidgets.QPushButton('Select')
        self.folder_explorer = QtWidgets.QFileDialog()
        self.folder_layout.addWidget(self.folder_label)
        self.folder_layout.addWidget(self.folder_line)
        self.folder_layout.addWidget(self.folder_button)
        self.run_button = QtWidgets.QPushButton('Package Now!')
        self.progress_bar = QtWidgets.QProgressBar()
        self.progress_bar.setRange(0, 100)
        self.message = QtWidgets.QLabel()
        self.layout().addLayout(self.folder_layout)
        self.layout().addWidget(self.run_button)
        self.layout().addWidget(self.progress_bar)
        self.layout().addWidget(self.message)

        self.thread_pool = []
        self.close_flag = False
        self.close_timer = QtCore.QTimer()
コード例 #6
0
    def save_macro(self):
        """
        Save all macros, names, and key assignments
        File format is json for simplicity
        File location and name to be chosen by user

        Keycodes are simplified to either a char, if available, or the key name
        # TODO look into vk implementation, is it a larger set?
        # TODO currently have to write in the vk code as a separate entry
        # This is because when loading macros not all fields of a Key are
        # automatically filled if we pass in a char, or vk, by itself

        :return: None
        """

        cur_dir = os.path.dirname(os.path.realpath(__file__))
        file_query = QtWidgets.QFileDialog()
        save_file_path = file_query.getSaveFileName(directory=cur_dir,
                                                    filter='*.json')
        if save_file_path[0] == '':
            return

        class KeyCodeEncoder(json.JSONEncoder):
            def default(self, obj):
                # Extract the useful info from the keys, nothing more
                if isinstance(obj, KeyboardEvent):
                    return json.loads(obj.to_json())
                return json.JSONEncoder.default(self, obj)

        with open(save_file_path[0], 'w') as fp:
            json.dump(self.macros, fp, cls=KeyCodeEncoder, indent=4)
コード例 #7
0
    def elmaSourceFilePicker(self):
        dialog = QtWidgets.QFileDialog(self)
        dialog.setFileMode(QtWidgets.QFileDialog.ExistingFile)
        dialog.setWindowTitle("Select ELMA Source File:")

        if dialog.exec_():
            self.elmaSource.setText(dialog.selectedFiles()[0])
コード例 #8
0
 def selectUploadFiles(self):
     dlg = QtWidgets.QFileDialog(None, "选择上传文件")
     dlg.setFileMode(QtWidgets.QFileDialog.ExistingFiles)
     dlg.setViewMode(QtWidgets.QFileDialog.Detail)
     dlg.setModal(True)
     if dlg.exec_() == QtWidgets.QDialog.Accepted:
         self.uploadFiles.setText('\r\n'.join(dlg.selectedFiles()))
コード例 #9
0
def pb_upload_image_clicked():
    global upload_image_path

    # file dialog
    fd_upload_image = QtWidgets.QFileDialog()
    fd_upload_image.setFileMode(QtWidgets.QFileDialog.ExistingFile)
    fd_upload_image.setNameFilters(["Images (*.jpg)"])
    fd_upload_image.selectNameFilter("Images (*.jpg)")
    fd_upload_image.exec_()
    files = fd_upload_image.selectedFiles()

    # if image was uploaded
    if files:
        upload_image_path = files[0]

        # normalize image
        image = normalize_image(upload_image_path)
        cv2.imwrite("temp files/normalizeTemp.jpg", image)
        upload_image_path = "temp files/normalizeTemp.jpg"

        # display image
        display_image_faces(upload_image_path)
        display_image_objects(upload_image_path)

        # enable detecting faces and detecting objects
        pb_detect_faces.setDisabled(False)
        pb_detect_faces.repaint()
        pb_detect_objects.setDisabled(False)
        pb_detect_objects.repaint()

        # disable recognizing faces
        pb_recognize_faces.setDisabled(True)

        # clear results from previous detections
        reset_results()
コード例 #10
0
    def export_pdf(self):

        # Bug in qdarkstyle that makes dropdowns too large, so we need to add styles
        dropdown_style = """QComboBox::item:checked {
                height: 12px;
                border: 1px solid #32414B;
                margin-top: 0px;
                margin-bottom: 0px;
                padding: 4px;
                padding-left: 0px;
                }"""

        file_dialog = Qw.QFileDialog()
        file_dialog.setStyleSheet(dropdown_style)
        file_dialog.setFileMode(Qw.QFileDialog.AnyFile)
        file_dialog.setAcceptMode(Qw.QFileDialog.AcceptSave)
        file_dialog.setNameFilters(["PDF File (*.pdf)"])
        file_dialog.selectNameFilter("PDF File (*.pdf)")
        file_dialog.setDefaultSuffix("pdf")

        if file_dialog.exec_():
            file = file_dialog.selectedFiles()[0]
            imgs = []
            for page in self._pages:
                imgs.append(page.image)

            with open(file, "wb") as f:
                f.write(img2pdf.convert(imgs))
コード例 #11
0
    def _actionSaveProcessedImage(self):
        if self._view.labelProcessedImage.isImageSet:
            fileDialog = QtWidgets.QFileDialog(self._view)
            fileDialog.setFileMode(QtWidgets.QFileDialog.AnyFile)
            fileDialog.setNameFilter('Bitmap file (*.bmp *.dib);;'
                                     'JPEG file (*.jpeg *.jpg *.jpe);;'
                                     'JPEG 2000 file (*.jp2);;'
                                     'Portable Network Graphics file (*.png);;'
                                     'WebP file (*.webp);;'
                                     'Sun rasters file (*.ras *.sr);;'
                                     'Tagged Image file (*.tiff *.tif)')
            fileDialog.setAcceptMode(QtWidgets.QFileDialog.AcceptSave)
            fileDialog.setWindowTitle("Save processed image")

            if fileDialog.exec():
                filePath = fileDialog.selectedFiles()[0]

                if Application.Utils.FileOperations.is_path_exists_or_creatable_portable(filePath):
                    self.saveProcessedImageSignal.emit(filePath)
                else:
                    messagebox = QtWidgets.QMessageBox(self._view)
                    messagebox.setWindowTitle("Error")
                    messagebox.setText("Save processed image: invalid file path.")
                    messagebox.setIcon(QtWidgets.QMessageBox.Critical)
                    messagebox.exec()
        else:
            messagebox = QtWidgets.QMessageBox(self._view)
            messagebox.setWindowTitle("Error")
            messagebox.setText("Save processed image: no processed image.")
            messagebox.setIcon(QtWidgets.QMessageBox.Critical)
            messagebox.exec()
コード例 #12
0
    def on_load_song_clicked(self):
        fileDialog = QtWidgets.QFileDialog(self)
        supportedMimeTypes = ['audio/mpeg', 'application/ogg', 'audio/ogg', 'application/octet-stream']
        fileDialog.setMimeTypeFilters(supportedMimeTypes)
        # fileDialog.setFileMode(fileDialog.Directory & fileDialog.ExistingFile)
        fileDialog.setDirectory(self.song.file_path.parent.as_posix())
        if fileDialog.exec_() == QtWidgets.QDialog.Accepted:
            files = fileDialog.selectedFiles()
            file = files[0]
            if self.song is not None:
                del self.song

            self.song = Pys2Song(file)
            # Assure the song loads correctly
            try:
                self.song.handle is not None
            except BassException as bexc:
                box = QtWidgets.QMessageBox()
                box.setText(f"Unable to load {file=} because {bexc.desc}")
                box.exec_()
            else:
                self.song.position_updated.connect(self.on_song_position_updated)
                self.position_slide.setRange(0, self.song.duration)
                self.song.play()
                seconds = self.song.duration
                self.length.setText(str(seconds))
コード例 #13
0
 def showFileSelect_dialog(self):
     dialog = QtWidgets.QFileDialog()
     dialog.setFileMode(QtWidgets.QFileDialog.Directory)
     dialog.setOption(QtWidgets.QFileDialog.ShowDirsOnly)
     directory = dialog.getExistingDirectory(self, 'Choose Export path', "")
     if directory:
         self.filepath_le.setText(directory)
コード例 #14
0
ファイル: copy_learn.py プロジェクト: mrhhhdx/learn
 def openFileDialog(self):
     dialog = QtWidgets.QFileDialog()
     dialog.setFileMode(QtWidgets.QFileDialog.AnyFile)
     dialog.setViewMode(QtWidgets.QFileDialog.Detail)
     if dialog.exec_():
         fileNames = dialog.selectedFiles()
         self.textLineEdit.setText(fileNames[0])
コード例 #15
0
ファイル: fake_wx.py プロジェクト: zhiy0122/Librian
 def __enter__(self):
     self._dialog = QtWidgets.QFileDialog(parent=self._parentWindow,
                                          caption=self._title)
     self._dialog.setAcceptMode(QtWidgets.QFileDialog.AcceptMode.AcceptOpen)
     self._dialog.setFileMode(QtWidgets.QFileDialog.FileMode.DirectoryOnly)
     self._dialog.setOption(QtWidgets.QFileDialog.ShowDirsOnly, True)
     return self
コード例 #16
0
    def _browse(self) -> None:
        """Browse the file."""

        # Method
        text = ''
        value = ''
        method = self._TYPES[self._method_box.currentIndex()]

        # Get file(s) or folder
        dialog = QtWidgets.QFileDialog()
        if method == 'Folder':

            # Folder
            folder = dialog.getExistingDirectory()
            value = []

            # Get SVG(s) in the folder
            for item in os.listdir(folder):
                if item.endswith('.svg'):
                    path = os.path.join(folder, item)
                    if not path in value:
                        value.append(path)
        else:
            value = dialog.getOpenFileNames()[0]

        # Check if we got a list
        if isinstance(value, list):
            value = ';'.join(value)

        # Edit
        self._edit.setText(value)
        self.gotFiles.emit(value.split(';'))
コード例 #17
0
    def button_command(self):
        """
        Brings up a browser window and returns the value if a selection has been made
        Returns:
            val (str): the file or files from the dialog
        """
        file_dialog = QtWidgets.QFileDialog(caption=self.data.get('caption'),
                                            filter=self.data.get('filter'))
        file_modes = {
            'AnyFile': QtWidgets.QFileDialog.AnyFile,
            'ExistingFile': QtWidgets.QFileDialog.ExistingFile,
            'DirectoryOnly': QtWidgets.QFileDialog.DirectoryOnly,
            'ExistingFiles': QtWidgets.QFileDialog.ExistingFiles,
            'Directory': QtWidgets.QFileDialog.Directory
        }

        file_dialog.setFileMode(file_modes[self.data.get(
            'fileMode', 'AnyFile')])
        file_dialog.setDirectory(self.data.get('directory'))

        file_dialog.exec_()
        if not file_dialog.result():
            return

        if file_dialog.fileMode() == QtWidgets.QFileDialog.ExistingFiles:
            return map(str, file_dialog.selectedFiles())
        else:
            return str(file_dialog.selectedFiles()[0])
コード例 #18
0
    def file_browse(self):
        from PySide2 import QtWidgets

        file_browser = QtWidgets.QFileDialog()

        # If no path go to user home directory

        if self.file_path == '/':
            self.file_path = os.path.expanduser("~")
        if os.path.isfile(self.file_path):
            self.file_path = self.file_path.rsplit('/', 1)[0]

        file_browser.setDirectory(self.file_path)

        # If filter_type set to dir, open Directory Browser, if anything else, open File Browser

        if self.filter_type == 'dir':
            file_browser.setFileMode(QtWidgets.QFileDialog.Directory)
            if file_browser.exec_():
                self.setText(file_browser.selectedFiles()[0])
        else:
            file_browser.setFileMode(
                QtWidgets.QFileDialog.ExistingFile
            )  # Change to ExistingFiles to capture many files
            file_browser.setNameFilter(self.filter_type)
            if file_browser.exec_():
                self.setText(file_browser.selectedFiles()[0])
コード例 #19
0
ファイル: mainview.py プロジェクト: REW1L/VcsPresenter
    def openProject(self):
        dialog = QtWidgets.QFileDialog()
        dialog.setFileMode(QtWidgets.QFileDialog.Directory)
        dialog.setOption(QtWidgets.QFileDialog.ShowDirsOnly, True)
        path = dialog.getExistingDirectory(self, "Select Directory")
        if path != '':
            projectName = path.split(os.pathsep)[-1]
            controller = Controller(projectName)
            controller.setProjectVcs(path)
            controller.configureProject()
            self.controller = controller
            commits = controller.getCommits()
            lastCommit = commits[0]
            firstCommit = commits[0]
            for x in commits:
                if x.timestamp < firstCommit.timestamp:
                    firstCommit = x
                if x.timestamp > lastCommit.timestamp:
                    lastCommit = x
            minDate = QtCore.QDateTime.fromTime_t(int(firstCommit.timestamp))
            maxDate = QtCore.QDateTime.fromTime_t(int(lastCommit.timestamp))
            self.startDateEdit.setDateTimeRange(minDate, maxDate)
            self.startDateEdit.setDateTime(minDate)
            self.endDateEdit.setDateTimeRange(minDate, maxDate)
            self.endDateEdit.setDateTime(maxDate)

            self.brComboBox.addItems(["all"] + self.controller.getBranches())

            self.devComboBox.addItems(
                ["all"] + [x.email for x in self.controller.getAuthors()])

            self.outCommitFiles(commits)

            self.drawLines(commits)
コード例 #20
0
ファイル: plant_widgets.py プロジェクト: SilunZ/Rotordynamics
    def importModel(self):
        """
        Import open-loop SISO model (.jac file)
        include simplified ameloadj code that doesn't look into other auxiliary files (e.g. .la)
        """

        # turn off inputs
        self.inputList.clear()
        self.outputList.clear()
        self.resList.clear()
        self.tLinList.clear()
        self.inputList.setEnabled(False)
        self.outputList.setEnabled(False)
        self.resList.setEnabled(False)
        self.tLinList.setEnabled(False)

        # file selection widget
        cwd = os.path.dirname(self.filename)
        dlg = QtWidgets.QFileDialog(self, 'Select .jac file of open-loop, SISO model',
                                    cwd, '*.jac*')
        dlg.exec_()
        file = dlg.selectedFiles()
        if len(file) == 0:
            # loading canceled, back to start
            self.initUI()
            return
        else:
            # load file (using simplified version of ameloadj to restrict parsing to .jac file only)
            try:
                A, B, C, D = ameloadjlight(file[0])
                B = B[0]
                D = D[0]
                A = np.matrix(A)
                B = np.matrix(B)
                C = np.matrix(C)
                D = np.matrix(D)
                # Use Hessenberg decomposition to improve computation robustness for large systems

                H, Q = hessenberg(A, calc_q=True)
                H = np.matrix(H)
                Q = np.matrix(Q)
                ol = signal.lti(H, Q.H * B, C * Q, D)
                # ol = signal.lti(A, B, C, D)

                # save and plot
                self.OL = ol
                self.matchIO = 1
                self.light.setLight(2)
                self.resList.addItem(os.path.basename(file[0]))
                self.message.setText("File imported successfully")

                # move to next step with checkPlant
                self.checkPlant()

            except:
                # show error message and return
                errorDlg = ErrorDlg(4, os.path.basename(file[0]))
                errorDlg.exec_()
                self.initUI()
                return
コード例 #21
0
 def get_widget(self):
     picker = QtWidgets.QFileDialog(self.ui)
     picker.setMimeTypeFilters([
         'image/jpeg', 'image/png', 'image/bmp', 'image/tiff', 'image/gif',
         'image/webp'
     ])
     return picker
コード例 #22
0
    def onOpen(self):

        dialog = QtWidgets.QFileDialog()

        provider = IconProvider.IconProvider()
        dialog.setIconProvider(provider)
        dialog.setNameFilter(DIALOGFILTER)
        dialog.setNameFilterDetailsVisible(True)
        dialog.setDirectory(AIRFOILDATA)
        dialog.setFileMode(QtWidgets.QFileDialog.ExistingFiles)

        # open custom file dialog using custom icons
        if dialog.exec_():
            filenames = dialog.selectedFiles()
            selfilter = dialog.selectedNameFilter()

        try:
            filenames
        # do nothing if CANCEL button was pressed
        except NameError as error:
            logger.info('Error during file load: {}'.format(error))
            return

        if len(filenames) == 1:
            fileinfo = QtCore.QFileInfo(filenames[0])
            if 'su2' in fileinfo.suffix().lower():
                self.loadSU2(fileinfo.fileName())
                return

        for filename in filenames:
            self.loadAirfoil(filename)
コード例 #23
0
    def folderPathDialog(self):
        """
        updates folder_path label when called from pyside native button

        link to explanation on how to enable multiple directories selection:
            https://stackoverflow.com/questions/38252419/qt-get-qfiledialog-to-select-and-return-multiple-folders
        """
        if self.folder_path.text() == "":
            default_path = os.getenv("HOME")
        else:
            default_path = self.folder_path.text().split(self.paths_separator)[0]
        
        dialog = QtWidgets.QFileDialog(self, "Select a folder with textures for conversion:", default_path)
        dialog.setFileMode(QtWidgets.QFileDialog.Directory)

        # don't use native dialog, enable multiple dir selection
        dialog.setOption(QtWidgets.QFileDialog.DontUseNativeDialog, True)
        file_view = dialog.findChild(QtWidgets.QListView, 'listView')
        f_tree_view = dialog.findChild(QtWidgets.QTreeView)

        if file_view:
            file_view.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)
        if f_tree_view:
            f_tree_view.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)

        # exec dialog
        if dialog.exec_() == QtWidgets.QDialog.Accepted:
            path = str( self.paths_separator.join( dialog.selectedFiles() ) )
            self.folder_path.setText(path)
コード例 #24
0
 def open(self):
     self.file = QtWidgets.QFileDialog().getOpenFileName()
     self.img = cv2.imread(self.file[0])
     height, width, channels = self.img.shape
     print(height, width, channels)
     #self.ui.graphicsView.resize(height,width)
     self.updataImage(self.img)
コード例 #25
0
ファイル: fileManager.py プロジェクト: chaiyuntian/IDoLibrary
    def openFile(self):

        dialog = QtWidgets.QFileDialog()

        #加载对应的文件
        dialog.setFileMode(QtWidgets.QFileDialog.AnyFile)
        dialog.setViewMode(QtWidgets.QFileDialog.Detail)

        if dialog.exec_():
            fileNames = dialog.selectedFiles()

            #Todo:弹出窗口,判断文件类型,加载资源到文件栏
            #Todo:一次加载多个文件

        #判断当前所在资源窗口
        if (self.childWidget.windowName == "men"):
            self.childWidget.openPicture(fileNames[0], "men")
        elif (self.childWidget.windowName == "sence"):
            self.childWidget.openPicture(fileNames[0], "sence")
        elif (self.childWidget.windowName == "goods"):
            self.childWidget.openPicture(fileNames[0], "goods")
        elif (self.childWidget.windowName == "texture"):
            self.childWidget.openPicture(fileNames[0], "texture")
        elif (self.childWidget.windowName == "other"):
            self.childWidget.openPicture(fileNames[0], "other")

        elif (self.childWidget.windowName == "model_men"):
            self.childWidget.openModel(fileNames[0], "model_men")
        elif (self.childWidget.windowName == "model_sence"):
            self.childWidget.openModel(fileNames[0], "model_scene")
        elif (self.childWidget.windowName == "model_object"):
            self.childWidget.openModel(fileNames[0], "model_object")
        elif (self.childWidget.windowName == "model_other"):
            self.childWidget.openModel(fileNames[0], "model_other")
コード例 #26
0
 def save(self):
     print("save")
     file_name = QtWidgets.QFileDialog().getSaveFileName()
     print(file_name)
     save_file = file_name[0]
     cv2.imwrite(save_file, self.adjustimg)
     QMessageBox.information(self, "Message", "Save File")
コード例 #27
0
ファイル: core_install.py プロジェクト: Matth-D/cache_deleter
    def select_file(self):
        """Create File browser and set selected directory to delete file folder parameter."""

        file_dialog = QtWidgets.QFileDialog()
        file_dialog.setDirectory(HOME)
        folder_path = file_dialog.getExistingDirectory()
        self.delete_path_button.setText(folder_path)
コード例 #28
0
    def save_to_file(self):
        dialog = QtWidgets.QFileDialog()
        result = dialog.getSaveFileName(caption='Specify target file',
                                        filter='*.json')
        if not result[0] or not result[1]:
            return

        target_file = result[0]
        the_dict = {}

        for node in self.all_nodes:
            the_dict[str(node)] = {
                'class': node.node_class,
                'id': node.id,
                'x_pos': node.x(),
                'y_pos': node.y(),
                'widget_value': node.get_widget_value(),
                'stream_count': node.stream_count,
                'streams': {}
            }
            for stream in node.streams:
                if stream.output_stream:
                    the_dict[str(node)]['streams'][stream.index] = [
                        stream.output_stream.parent_class,
                        stream.output_stream.parent_id,
                        stream.output_stream.index
                    ]

        with open(target_file, 'w') as w:
            json.dump(the_dict, w, indent=2)
コード例 #29
0
    def __init__(self):
        super(MainWindow, self).__init__()
        self.setupUi(self)
        self.oc_window = OCWindow()
        self.otsu_window = OtsuWindow()
        self.rg_window = RGWindow()
        self.valid_window = ValidWindow()
        self.filedialog = QtWidgets.QFileDialog()
        self.errorBox = QtWidgets.QMessageBox()
        self.workThread = WorkThread()
        self.img = None

        # subWindow/thread signal-slot
        self.otsu_window.signal.connect(self.returnOtsu)
        self.workThread.signal.connect(self.returnWork)
        self.oc_window.signal.connect(self.returnOC)
        self.rg_window.signal.connect(self.returnRG)

        # menu action
        self.actionOpen.triggered.connect(self.open_img)
        self.actionSave.triggered.connect(self.save_img)
        self.actionClose.triggered.connect(self.close)
        self.actionOtsu.triggered.connect(self.beginOtsu)
        self.actionRG.triggered.connect(self.beginRG)

        # button & scroll
        self.newButton.clicked.connect(self.open_img)
        self.otsuButton.clicked.connect(self.beginOtsu)
        self.rgButton.clicked.connect(self.beginRG)
        self.ocButton.clicked.connect(self.beginOC)
        self.validButton.clicked.connect(self.beginValid)
        self.saveButton.clicked.connect(self.save_img)
        self.exitButton.clicked.connect(self.close)
        self.graphicsScroll.valueChanged.connect(self.show_img)
        self.graphicsScroll.sliderMoved.connect(self.show_img)
コード例 #30
0
ファイル: wingnet.py プロジェクト: TimoStoff/wingNet
    def browse_folders(self):
        self.tableWidget.clear()

        file_dialog = QtWidgets.QFileDialog(filter="*")
        file_dialog.setFileMode(QtWidgets.QFileDialog.DirectoryOnly)
        file_dialog.ShowDirsOnly = False
        file_dialog.setNameFilter("JPG (*.jpg)")
        file_dialog.setOption(QFileDialog.DontUseNativeDialog, True);
        file_dialog.setOption(QFileDialog.ShowDirsOnly, False)
        file_view = file_dialog.findChild(QtWidgets.QListView, 'listView')

        # to make it possible to select multiple directories:
        if file_view:
            file_view.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)
        f_tree_view = file_dialog.findChild(QtWidgets.QTreeView)
        if f_tree_view:
            f_tree_view.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)

        all_paths = []
        if file_dialog.exec():
            all_paths = file_dialog.selectedFiles()

        print("Currently containing {}".format(all_paths))
        if all_paths:  # if user didn't pick a directory don't continue
            for f_path in all_paths:
                if os.path.isfile(f_path):
                    self.image_paths.append(f_path)
                elif os.path.isdir(f_path):
                    self.folder_list.append(f_path)

            self.image_paths = module_data.get_image_paths(self.folder_list)
            for image_path, table_idx in zip(self.image_paths, range(0, len(self.image_paths), 1)):
                self.add_image_to_table(image_path, table_idx)
        self.btn_label_wings.setEnabled(True)