Beispiel #1
0
    def set_layout(self):
        if hasattr(self, 'main_layout'):
            for i in reversed(range(self.main_layout.count())):
                if self.main_layout.itemAt(i).widget() is not None:
                    self.main_layout.itemAt(i).widget().deleteLater()
            for i in reversed(range(self.main_layout.count())):
                if self.main_layout.itemAt(i).layout() is not None:
                    self.main_layout.itemAt(i).layout().deleteLater()
        else:
            self.main_layout = QHBoxLayout()
            self.hatter.addLayout(self.main_layout)

        groups = QWidget()
        groups.setFixedWidth((self.sorok_szama * 50) + 200)
        widgets_layout = QVBoxLayout()
        groups.setLayout(widgets_layout)

        for n in range(self.csoportok_szama):  # csoportok száma
            locals()['csoport_layout' + str(n)] = QGridLayout(
            )  # Létrehozzuk az adott sorszámú csoport layout-ját
            locals()['csoport_layout' + str(n)].setContentsMargins(0, 0, 0, 0)
            locals()['csoport_layout' + str(n)].setHorizontalSpacing(0)
            locals()['csoport_layout' + str(n)].setVerticalSpacing(0)
            widgets_layout.addLayout(locals()[
                'csoport_layout' +
                str(n)])  # Hozzáadjuk a a layout-ot a widget_layout-hoz
            for i in range(
                    len(self.csoportok[n])
            ):  # len(self.csoportok[n]) : csoporton belüli sorok száma
                # Végigmegyünk a sorokon   :  i: sorok száma, n: csoport száma
                # a layout 1. oszlopát feltöltjük a tömbben tárolt custom widget-ekkel
                locals()['csoport_layout' + str(n)].addWidget(
                    self.csoportok[n][i], i + 1, 0)
                # Itt töltjük fel az eredmény-widget-eket (tombben tárolva, mint a GroupMemberWidget-ek) eredmenyek[x, y, z] x: csoport, y: oszlop, z: sor
                for x in range(
                        len(self.csoportok[n])
                ):  # Ez lesz az oszlop(max = sorok száma) x: oszlop száma
                    locals()['csoport_layout' + str(n)].addWidget(
                        self.eredmenyek[n][i][x], i + 1, x + 1)
            locals()['csoport_layout' + str(n)].addWidget(
                QLabel("Csoport_" + str(n + 1)), 0, 0)

        lista_layout = QVBoxLayout()
        lista_layout.addWidget(self.autofill_button)
        lista_layout.addWidget(self.resztvevok)
        lista_layout.addWidget(self.generate_button)
        # lista_layout.addWidget(self.clear_button)

        scroll = QScrollArea()
        scroll.setWidget(groups)
        scroll.setFixedWidth((self.sorok_szama * 50) + 220)
        scroll.setFixedHeight(600)
        scroll.updateGeometry()

        self.main_layout.addWidget(scroll)
        self.main_layout.addLayout(lista_layout)
Beispiel #2
0
    def set_layout(self):

        if hasattr(self, 'main_layout'):
            for i in reversed(range(self.main_layout.count())):
                if self.main_layout.itemAt(i).widget() is not None:
                    self.main_layout.itemAt(i).widget().deleteLater()
            for i in reversed(range(self.main_layout.count())):
                if self.main_layout.itemAt(i).layout() is not None:
                    self.main_layout.itemAt(i).layout().deleteLater()
        else:
            self.main_layout = QHBoxLayout()
            self.hatter.addLayout(self.main_layout)

        groups = QWidget()
        groups.setFixedWidth(((self.sorok_szama + 5) * 50) + 200)
        widgets_layout = QVBoxLayout()
        groups.setLayout(widgets_layout)

        for n in range(self.csoportok_szama):  # csoportok száma
            locals()['csoport_layout' + str(n)] = QGridLayout(
            )  # Létrehozzuk az adott sorszámú csoport layout-ját
            locals()['csoport_layout' + str(n)].setContentsMargins(0, 0, 0, 0)
            locals()['csoport_layout' + str(n)].setHorizontalSpacing(0)
            locals()['csoport_layout' + str(n)].setVerticalSpacing(0)
            widgets_layout.addLayout(locals()[
                'csoport_layout' +
                str(n)])  # Hozzáadjuk a a layout-ot a widget_layout-hoz
            locals()['csoport_layout' + str(n)].addWidget(
                QLabel("Csoport_" + str(n + 1)), 0, 0, Qt.AlignHCenter)
            sorok = len(self.csoportok[n])
            for k in range(sorok):
                locals()['csoport_layout' + str(n)].addWidget(
                    QLabel(str(k + 1)), 0, k + 1, Qt.AlignHCenter)
            locals()['csoport_layout' + str(n)].addWidget(
                QLabel("NY"), 0, sorok + 5, Qt.AlignHCenter)
            locals()['csoport_layout' + str(n)].addWidget(
                QLabel("V"), 0, sorok + 6, Qt.AlignHCenter)
            locals()['csoport_layout' + str(n)].addWidget(
                QLabel("K"), 0, sorok + 7, Qt.AlignHCenter)
            locals()['csoport_layout' + str(n)].addWidget(
                QLabel("P"), 0, sorok + 8, Qt.AlignHCenter)
            locals()['csoport_layout' + str(n)].addWidget(
                QLabel("H"), 0, sorok + 9, Qt.AlignHCenter)
            for i in range(
                    len(self.csoportok[n])
            ):  # len(self.csoportok[n]) : csoporton belüli sorok száma
                # Végigmegyünk a sorokon   :  i: sorok száma, n: csoport száma

                # N: HÁNYADIK CSOPORT, I: HÁNYADIK OSZLOP-OT TÖLTJÜK
                # a layout 1. oszlopát feltöltjük a tömbben tárolt custom widget-ekkel
                # self.csoportok[n][i] N-EDIK CSOPORT I-DIK SORÁBAN A NÉV
                locals()['csoport_layout' + str(n)].addWidget(
                    self.csoportok[n][i], i + 1, 0)
                # Itt töltjük fel az eredmény-widget-eket, és a szummákat (tombben tárolva, mint a GroupMemberWidget-ek)
                # eredmenyek[n, y, i] n: csoport, y: oszlop, i: sor
                for x in range(
                        len(self.csoportok[n])
                ):  # Ez lesz az oszlop(max = sorok száma) x: oszlop száma
                    locals()['csoport_layout' + str(n)].addWidget(
                        self.eredmenyek[n][i][x], i + 1, x + 1)
                # szum_eredmenyek[x, y, z] x: csoport, y: oszlop, z: sor
                for y in range(5):  # 5 kockát rakunk ki
                    locals()['csoport_layout' + str(n)].addWidget(
                        self.szum_eredmenyek[n][y][i], i + 1, 5 + x + y + 1)

            # locals()['csoport_layout' + str(n)].addWidget(QLabel("Csoport_" + str(n + 1)), 0, 0)

        lista_layout = QVBoxLayout()
        lista_layout.addWidget(self.refresh_button)

        scroll = QScrollArea()
        scroll.setWidget(groups)
        scroll.setFixedWidth(((self.sorok_szama + 5) * 50) + 220)
        scroll.setFixedHeight(680)

        self.main_layout.addWidget(scroll)
        self.main_layout.addLayout(lista_layout)
Beispiel #3
0
class DatasheetView(QMainWindow):
    def __init__(self, pdfPath=None, openPages=[1]):

        super().__init__()

        if pdfPath:
            self.myPdfContext = PDFContext(pdfPath, openPages)

        # store diretory for debugging purposes
        self.svgDirectory = self.myPdfContext.directory

        # window dimensions
        self.top = 300
        self.left = 800
        self.width = 860
        self.height = 980

        self.setGeometry(self.left, self.top, self.width, self.height)

        # window title
        self.setWindowTitle("BetterSheets")

        # sets up main layout -- splitters
        self.initUILayout()
        self.initUIToolbar()
        self.initToC()

        # self.initPdfViewer()  # must be called after initUI to ensure PDFContext object exists
        self.show()

        print(self.mainDisplay.getVisibleChild())

    def initUILayout(self):

        # set left-side, Dynamic View
        self.dynamicViewDisplay = QLabel()

        self.vBoxA = QVBoxLayout()
        self.vBoxA.addWidget(self.dynamicViewDisplay)

        self.groupA = QGroupBox()
        self.groupA.setTitle("Dynamic Veiw")
        self.groupA.setLayout(self.vBoxA)

        # set left-side, Static View
        self.staticViewDisplay = QLabel()

        self.vBoxB = QVBoxLayout()
        self.vBoxB.addWidget(self.staticViewDisplay)

        self.groupB = QGroupBox()
        self.groupB.setTitle("Static View")
        self.groupB.setLayout(self.vBoxB)

        # add Dynamic and Static Views to resizeable left-side Splitter
        self.altViewSplit = QSplitter(Qt.Vertical)
        self.altViewSplit.addWidget(self.groupA)
        self.altViewSplit.addWidget(self.groupB)

        # set up Tools View section
        self.toolsTabView = QTabWidget()
        self.toolsTabView.setTabsClosable(True)
        self.toolsTabView.setMovable(True)
        self.toolsTabView.setDocumentMode(True)
        # self.toolsTabView.setTabBarAutoHide(True)

        # add attribute for storing page notes
        self.notesDB = []
        self.notesDisplay = QListWidget(self)
        self.notesDisplay.setMaximumHeight(200)

        # add ToC to Tools View
        self.ToCListView = QListWidget()
        self.toolsTabView.addTab(self.ToCListView, "Table of Contents")

        # add notes list to tools view
        self.toolsTabView.addTab(self.notesDisplay, "Notes")

        # add tools view to the left-side splitter
        self.altViewSplit.addWidget(self.toolsTabView)

        # set up main viewport
        self.mainDisplay = QDatasheetPageDisplayWidget(self.myPdfContext)
        self.mainDisplay.renderPages(1, 4)

        self.mainScroller = QScrollArea(self)
        self.mainScroller.setWidget(self.mainDisplay)
        self.mainScroller.setWidgetResizable(True)
        self.mainScroller.setBackgroundRole(QtGui.QPalette.Dark)
        self.mainScroller.setFixedHeight(800)

        print(self.mainScroller.viewport().childrenRect())

        # set up document tools

        self.hBoxDocTools = QHBoxLayout()

        self.searchLabel = QLabel("Search: ")
        self.searchBox = QLineEdit()
        self.searchBox.setPlaceholderText("Search")

        # self.

        self.vBoxMain = QVBoxLayout()
        self.vBoxMain.addWidget(self.mainScroller)

        self.notesArea = QLineEdit()
        self.notesArea.setPlaceholderText("Add a note about this page...")
        self.notesArea.returnPressed.connect(self.onAddNote)

        self.vBoxMain.addWidget(self.notesArea)

        self.mainViewGroup = QGroupBox()
        self.mainViewGroup.setTitle("Main View")
        self.mainViewGroup.setLayout(self.vBoxMain)

        # join both sides together
        self.leftRightSplit = QSplitter(Qt.Horizontal)
        self.leftRightSplit.addWidget(self.altViewSplit)
        self.leftRightSplit.addWidget(self.mainViewGroup)

        self.setCentralWidget(self.leftRightSplit)

    def initUIToolbar(self):

        mainMenu = self.menuBar(
        )  # get the menu bar already in use by this QMainWindow subclass

        fileMenu = mainMenu.addMenu("File")
        editMenu = mainMenu.addMenu("Edit")
        LayoutMenu = mainMenu.addMenu("Layout")
        AboutMenu = mainMenu.addMenu("About")

        saveAction = fileMenu.addAction("Save")
        quitAction = fileMenu.addAction("Exit Bettersheets")
        quitAction.triggered.connect(self.quitApp)
        copyAction = editMenu.addAction("Copy")
        resetAction = LayoutMenu.addAction("Reset Default Layout")

        self.toolBar = self.addToolBar("Tools")
        self.toolBar.addAction(saveAction)
        self.toolBar.addAction(copyAction)

    def contextMenuEvent(self, event):
        # return super().contextMenuEvent(event)
        contextMenu = QMenu()

        selectAction = contextMenu.addAction("Select Area")
        extractAction = contextMenu.addAction("Extract Content")
        openAction = contextMenu.addAction("Open PDF")
        closeAction = contextMenu.addAction("Close PDF")
        quitAction = contextMenu.addAction("Quit")

        triggered_action = contextMenu.exec_(self.mapToGlobal(event.pos()))

        if triggered_action == quitAction:
            self.quitApp()

    def quitApp(self):
        self.close()

    def onAddNote(self):
        print("note added")

        text = self.notesArea.text()

        if text:
            self.notesDB.append(text)
            self.notesDisplay.clear()
            self.notesDisplay.addItems(self.notesDB)
            self.notesArea.clear()

    def initPdfViewer(self, openPages: int):
        pass

    def initToC(self):

        # get table of contents
        ToC = self.myPdfContext.getToC()
        ToC_headings_list = [x[1] for x in ToC]

        self.ToCListView.clear()
        self.ToCListView.addItems(ToC_headings_list)
Beispiel #4
0
class PrettySL(QWidget):
    """
    This is the base widget to contain the graph view of the cutscene.

    :param MainFrame mainframe: application mainframe
    :param QWidget op: parent widget
    """
    def __init__(self, mainframe, op):
        QWidget.__init__(self)
        self.mainframe = mainframe
        self.op = op
        self.graph = self.op.link
        self.table = self.op.link.items
        self.lastButtonPressed = None
        self.needsRefresh = False
        self.tree = None
        self.subtree = []
        self.delete = None

        # View initializations...
        self.lab = None
        self.idLabel = None
        self.edit = None
        self.lkst = None
        self.rels = None

        self.initData()
        self.initUI()

    def initData(self):
        """
        Initialize the data to be used.
        """
        self.lab = None
        self.actionIDs = self.graph.getIDs()
        self.actionObjs = []
        for act in self.table:
            self.actionObjs.append(act[0])

    def initUI(self):
        """
        Initializes the GUI.
        Does lots of stuff.
        """
        self.grid = QGridLayout()
        self.setLayout(self.grid)

        self.tree = TreeWidget(self, self.actionObjs, self.actionIDs,
                               self.table)

        self.scrollArea = QScrollArea()
        self.scrollArea.setBackgroundRole(QPalette.Dark)
        self.scrollArea.setWidget(self.tree)
        if self.tree.rect().width() < 600:
            self.scrollArea.setFixedWidth(self.tree.rect().width() + 25)
        else:
            self.scrollArea.setFixedWidth(600)
        if self.tree.rect().height() < 600:
            self.scrollArea.setFixedHeight(self.tree.rect().height())
        else:
            self.scrollArea.setFixedHeight(600)
        self.scrollArea.ensureWidgetVisible(self.tree, 500, 500)

        self.grid.addWidget(self.scrollArea, 0, 0, 10, 3)

        self.legend = Legend(self)
        self.grid.addWidget(self.legend, 0, 3, 1, 2)

        self.setWindowModality(Qt.ApplicationModal)
        self.show()

    def trackIndex(self, index):
        """
        Update the Tree and info views with a new index.

        :param int index: the new index
        """
        self.needsRefresh = True
        self.lastButtonPressed = index
        self.subtree = self.graph.subTree(index)
        # Request all the lines and boxes be redrawn.
        self.tree.update()
        self.initInfoUI(index)

    def deleteSubtree(self):
        """
        Delete the subtree of the current selected index.
        """
        if not popup(
                "Are you certain you want to delete this item and it's subtree?\n(Everything in red and"
                " yellow will be deleted)", "Warning"):
            return
        self.graph.delItem(self.lastButtonPressed)
        self.lab.close()
        self.initData()
        self.lastButtonPressed = None
        self.delete.close()
        self.delete = None
        self.subtree = []
        self.needsRefresh = True
        self.idLabel.close()
        self.edit.clicked.disconnect()
        self.edit.close()
        self.op.linkstored.save()
        self.tree.close()
        self.tree = TreeWidget(self, self.actionObjs, self.actionIDs,
                               self.table)
        self.grid.addWidget(self.tree, 0, 0, 10, 3)

    def initInfoUI(self, index):
        """
        Initialize the node info GUI.
        Does a lot of stuff.

        :param int index: index of node to display info for
        """
        if not self.lab:
            self.lab = QLabel(self, text="Selected element summary:")
            self.grid.addWidget(self.lab, 2, 3, 1, 2)
            idt = ""
            if isinstance(self.table[index][0], Speak):
                idt += self.table[index][0].speaker + " says:\n\n"
            idt += self.actionIDs[index]
            self.idLabel = QLabel(self, text=idt)
            self.idLabel.setFixedSize(300, 40)
            self.idLabel.setWordWrap(True)
            self.grid.addWidget(self.idLabel, 3, 3, 1, 2)
            self.edit = QPushButton(self, text="Edit")
            self.edit.clicked.connect(lambda: self.enter(index))
            self.grid.addWidget(self.edit, 4, 3, 1, 2)
            self.lkst = QLabel(self, text="Selected element links to:")
            self.grid.addWidget(self.lkst, 5, 3, 1, 2)
            self.rels = QLabel(self)
            self.rels.setMaximumWidth(300)
            text = ""
            for relation in self.table[index][1:len(self.table[index])]:
                text += "(" + str(relation) + ") " + self.graph.getOneID(
                    self.table[relation][0]) + "\n\n"
            self.rels.setText(text)
            self.grid.addWidget(self.rels, 6, 3, 1, 2)
        else:
            text = ""
            idt = ""
            if isinstance(self.table[index][0], Speak):
                idt += self.table[index][0].speaker + " says:\n\n"
            idt += self.actionIDs[index]
            self.idLabel.setText(idt)
            for relation in self.table[index][1:len(self.table[index])]:
                text += "(" + str(relation) + ") " + self.graph.getOneID(
                    self.table[relation][0]) + "\n\n"
            self.rels.setText(text)
            self.edit.clicked.disconnect()
            self.edit.clicked.connect(lambda: self.enter(index))
        if not self.delete:
            self.delete = QPushButton(self, text="Delete element and subtree")
            self.delete.clicked.connect(self.deleteSubtree)
            self.grid.addWidget(self.delete, 1, 3, 1, 2)

    def enter(self, index):
        """
        Leave the graph view and edit a node.

        :param int index: index of node to edit
        """
        load = self.graph.getItem(index)
        self.close()
        self.op.view.setText("Graphic View")
        self.op.view.clicked.disconnect()
        self.op.view.clicked.connect(lambda: self.op.viewF(True))
        self.op.listview.changeFrame(load, index)
Beispiel #5
0
 def getScrollArea(self):
     #setup PoC quickviews
     scrollArea = QScrollArea()
     scrollArea.setWidgetResizable(True)
     scrollArea.setFixedHeight(291)
     return scrollArea