def __init__(self, path, parent=None): super(Window, self).__init__() self.config = configparser.ConfigParser() self.config.read('prefs.cfg') if Window.menu is None: Window.menu = GlobalMenu() Window.menu.new_window_signal.connect(self.on_parent_window) Window.menu.clean_up_signal.connect(self.on_clean_up) Window.menu.delete_signal.connect(self.on_delete) Window.menu.rename_signal.connect(self.on_rename) Window.menu.file_signal.connect(self.on_file) Window.menu.drawer_signal.connect(self.on_drawer) Window.menu.trash_action_signal.connect(self.on_empty_trash) self.setWindowTitle(path.rsplit('/', 1)[-1]) Window.pattern = self.config.get("background", "file") self.path = path self.widget = QWidget() self.palette = QPalette() self.palette.setBrush( QPalette.Background, QBrush(QPixmap(self.pattern))) self.widget.setPalette(self.palette) layout = QVBoxLayout(self) self._drag_widget = DragWidget(path, parent=self) self._drag_widget.new_window_signal.connect(self.on_new_window) self._drag_widget.query.connect(self.on_query) layout.addWidget(self._drag_widget) self.widget.setLayout(layout) scroll = QScrollArea() scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) scroll.setWidgetResizable(True) scroll.setWidget(self.widget) vlayout = QVBoxLayout(self) vlayout.setContentsMargins(0, 0, 0, 0) vlayout.setSpacing(0) vlayout.addWidget(scroll) self.setLayout(vlayout) Window.child_windows.append(self) self.center() self.show()
from PyQt5 import QtCore, QtWidgets from dragwidget import DragWidget if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) if hasattr(QtWidgets.QApplication, "setNavigationMode"): QtWidgets.QApplication.setNavigationMode( QtCore.Qt.NavigationModeCursorAuto) window = DragWidget() smallScreen = "-small-screen" in QtWidgets.QApplication.arguments() if smallScreen: window.showFullScreen() else: window.show() sys.exit(app.exec_())