Package: pyqt-viewer-widget
pyqt-viewer-widgetPyQt viewer widget which helps you make viewer application easilyRequirementsPyQt5 >= 5.8OverviewThis is image viewer widget, not an application itself. But you can make image viewer application out of this.For example, apps below are using this efficiently.pyqt-comic-viewer- Comic reading apppyqt-html-viewer- HTML viewer apppyqt-svg-viewer- SVG viewer appSetuppython -m pip install pyqt-viewer-widgetIncluded Packagepyqt-toast- to notify user the very beginning/last page when flip the pagepyqt-single-image-graphics-view- main viewFeaturesetExtensions(extensions: list)to set file extensions to show on the view (e.g. ['.html'])addFilenames(filenames: list, cur_filename: str = '')- Add filenames.cur_filenameis file's name which you want to set as current file.setFilenames(filenames: list, cur_filename: str = '')- Clear file list before adding files.addDirectory(dirname: str, cur_filename: str = '')- Add files in the directorysetDirectory(dirname: str, cur_filename: str = '')- Clear file list before adding files in the directorysetCurrentIndex(idx: int),getCurrentIndex() -> int. The latter one can be used for checking at least one file exists or not.setCurrentFilename(filename: str),getCurrentFilename() -> str.clear()Flip the page back and forth with prev, next button on bottom navigation widget, mouse wheel, left and right pad of keyboards.Being able to check the current pageBeing able to toggle the visibility of the bottom widgetGive the emitting signal when clicked prev, next, close buttons:prevSignal(str), nextSignal(str), closeSignal(bool)- prev/next signals' arguments are previous/next file's name. close signal's bool value is alwaysFalseto set the visibility of bottom widget (navigation widget) of viewer widgetFalse. There's alsoclearSignalwhich is emitted when there is no file. (except for init moment)When you've got the absoulte beginning/last of the files list, toast(pyqt-toast) will show up. You can get either direction of toast withgetFirstPageToast,getLastPageToastto change the toast's style such as font, color.setView(view: QWidget),getView() -> QWidgetsetBottomWidgetVisible(f: bool)to toggle the visibility of bottom navigation bar.getFirstPageToast() -> Toast,getLastPageToast() -> ToastsetWindowTitleBasedOnCurrentFileEnabled(f: bool, prefix: str)to set the title based on current file like "Prefix - def.png" if current file of viewer is "def.png". You can activate the feature by givingTrueto first argumentf. You can give the default window title toprefix.isWindowTitleBasedOnCurrentFileEnabled() -> boolremoveSomeFilesFromViewer(filenames_to_remove: list)is used when you want to remove some files in viewer, not all files. Iffilenames_to_removeincludes the file name which was not included in list, error will be occured.setHome(widget: QWidget)to set home page widget,goHome().Simple ExampleCode Example (Extremely basic image viewer)importosfromPyQt5.QtWidgetsimportQApplication,QMainWindow,QPushButtonfrompyqt_viewer_widgetimportViewerWidgetclassMainWindow(QMainWindow):def__init__(self):super().__init__()self.__initUi()def__initUi(self):self.__viewerWidget=ViewerWidget()dirname=os.path.join(os.getcwd(),'viewerWidgetExampleImagesDir')self.__viewerWidget.setExtensions(['.jpg'])self.__viewerWidget.setDirectory(dirname)self.__viewerWidget.closeSignal.connect(self.__bottomWidgetClosed)self.setCentralWidget(self.__viewerWidget)self.__setToolBar()def__setToolBar(self):self.__bottomWidgetToggleBtn=QPushButton('Show')self.__bottomWidgetToggleBtn.setCheckable(True)self.__bottomWidgetToggleBtn.setChecked(True)self.__bottomWidgetToggleBtn.toggled.connect(self.__viewerWidget.setBottomWidgetVisible)fileToolbar=self.addToolBar('File')fileToolbar.addWidget(self.__bottomWidgetToggleBtn)fileToolbar.setMovable(False)def__bottomWidgetClosed(self):self.__bottomWidgetToggleBtn.setChecked(False)if__name__=="__main__":importsysapp=QApplication(sys.argv)mainWindow=MainWindow()mainWindow.show()sys.exit(app.exec_())Resulthttps://user-images.githubusercontent.com/55078043/145040849-0c7326ed-e043-4a8b-8c55-c9b7e1d1756e.mp4Note: This is result of very first version.