def __init__(self, path, extension, previewExtensions='bmp', notFoundImage=None, sort=FileSort()): super(FileChooser, self).__init__() gui.Widget.__init__(self) self.paths = None self.extension = extension self.setPreviewExtensions(previewExtensions) self.sort = sort self.selection = '' self.childY = {} self.notFoundImage = notFoundImage self.sortBy = self.sort.fields()[0] self.sortgroup = [] self.layout = QtGui.QGridLayout(self) self.sortBox = gui.GroupBox('Sort') self.layout.addWidget(self.sortBox, 0, 0) self.layout.setRowStretch(0, 0) self.layout.setColumnStretch(0, 0) self.layout.addWidget(QtGui.QWidget(), 1, 0) self.files_sc = QtGui.QScrollArea() self.files_sc.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) self.files_sc.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.layout.addWidget(self.files_sc, 0, 1, 2, -1) self.layout.setRowStretch(1, 1) self.layout.setColumnStretch(1, 1) self.files = QtGui.QWidget() self.files_sc.installEventFilter(self) self.files_sc.setWidget(self.files) self.files_sc.setWidgetResizable(True) self.children = FlowLayout(self.files) self.children.setSizeConstraint(QtGui.QLayout.SetMinimumSize) self.location = gui.TextView('') self.layout.addWidget(self.location, 2, 0, 1, -1) self.layout.setRowStretch(2, 0) self.refreshButton = self.sortBox.addWidget(gui.Button('Refresh')) for i, field in enumerate(self.sort.fields()): self.sortBox.addWidget( FileSortRadioButton(self, self.sortgroup, i == 0, field)) self.setPaths(path) @self.refreshButton.mhEvent def onClicked(value): self.refresh()
def __init__(self, path, extensions, previewExtensions='bmp', notFoundImage=None, sort=FileSort()): self.location = gui.TextView('') super(FileChooser, self).__init__(path, extensions, sort) self.setPreviewExtensions(previewExtensions) self.selection = '' self.childY = {} self.notFoundImage = notFoundImage # Try to find a "not found" icon if none is specified if not self.notFoundImage: for path in self.getPaths(): imgPath = os.path.join(path, 'notfound.thumb') if os.path.isfile(imgPath): self.notFoundImage = imgPath break if not self.notFoundImage or not os.path.isfile(self.notFoundImage): imgPath = getpath.getSysDataPath('notfound.thumb') self.notFoundImage = imgPath self.layout = QtWidgets.QGridLayout(self) self.sortBox = self.createSortBox() self.layout.addWidget(self.sortBox, 0, 0) self.layout.setRowStretch(0, 0) self.layout.setColumnStretch(0, 0) self.layout.addWidget(QtWidgets.QWidget(), 1, 0) self.files_sc = QtWidgets.QScrollArea() self.files_sc.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) self.files_sc.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.layout.addWidget(self.files_sc, 0, 1, 2, -1) self.layout.setRowStretch(1, 1) self.layout.setColumnStretch(1, 1) self.files = QtWidgets.QWidget() self.files_sc.installEventFilter(self) self.files_sc.setWidget(self.files) self.files_sc.setWidgetResizable(True) self.children = FlowLayout(self.files) self.children.setSizeConstraint(QtWidgets.QLayout.SetMinimumSize) self.layout.addWidget(self.location, 2, 0, 1, -1) self.layout.setRowStretch(2, 0)
def __init__(self, path, extension, previewExtensions='bmp', notFoundImage=None, sort=FileSort()): self.location = gui.TextView('') super(FileChooser, self).__init__(path, extension, sort) self.setPreviewExtensions(previewExtensions) self.selection = '' self.childY = {} self.notFoundImage = notFoundImage self.layout = QtGui.QGridLayout(self) self.sortBox = self.createSortBox() self.layout.addWidget(self.sortBox, 0, 0) self.layout.setRowStretch(0, 0) self.layout.setColumnStretch(0, 0) self.layout.addWidget(QtGui.QWidget(), 1, 0) self.files_sc = QtGui.QScrollArea() self.files_sc.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) self.files_sc.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.layout.addWidget(self.files_sc, 0, 1, 2, -1) self.layout.setRowStretch(1, 1) self.layout.setColumnStretch(1, 1) self.files = QtGui.QWidget() self.files_sc.installEventFilter(self) self.files_sc.setWidget(self.files) self.files_sc.setWidgetResizable(True) self.children = FlowLayout(self.files) self.children.setSizeConstraint(QtGui.QLayout.SetMinimumSize) self.layout.addWidget(self.location, 2, 0, 1, -1) self.layout.setRowStretch(2, 0)