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
class Deck(QVBoxLayout):
    def __init__(self, heading, color=True):
        super().__init__()
        logging.info(f'[Deck] {heading} init')
        self.addWidget(Heading(heading))
        self.use_color = color
        self.cards = []
        self.buttons = []
        self.heading = heading

        self.scroll_area = QScrollArea()
        self.scroll_area.setWidgetResizable(True)
        self.addWidget(self.scroll_area)

        self.v_scroll = QVBoxLayout()
        self.v_scroll.setSpacing(SPACING)
        self.v_scroll.addStretch()

        self.scroll_widget = QWidget()
        self.scroll_widget.setLayout(self.v_scroll)
        self.scroll_area.setFixedWidth(WIDTH_WITH_SCROLL)
        self.scroll_area.setWidget(self.scroll_widget)

    def add_card_button(self, card):
        return self.insert_button_at_index(card, 0)

    def insert_button_at_index(self, card, index):
        button = CardButton(card)
        self.v_scroll.insertWidget(index, button)
        color = COLOR[card.color] if self.use_color else COLOR['gray']
        button.set_color(color)
        self.cards.insert(index, card.name)
        self.buttons.append(button)
        return button

    def remove_card_button(self, button):
        self.cards.remove(button.card.name)
        self.buttons.remove(button)
        self.removeWidget(button)
        button.deleteLater()

    def clear(self):
        logging.info(f'[Deck] clear {self.heading}')
        for button in self.buttons:
            button.deleteLater()
        self.cards.clear()
        self.buttons.clear()
Beispiel #3
0
class CenterLayout(QGridLayout):
    def __init__(self):
        super(CenterLayout, self).__init__()

        self.inputs_widget = QWidget()
        self.inputs_layout = InputsLayout()
        self.inputs_widget.setLayout(self.inputs_layout)
        self.input_scroll_wrap = QScrollArea()
        self.input_scroll_wrap.setHorizontalScrollBarPolicy(
            Qt.ScrollBarAlwaysOff)
        self.input_scroll_wrap.setFixedWidth(
            self.inputs_widget.sizeHint().width())
        self.input_scroll_wrap.setWidget(self.inputs_widget)

        self.output_widget = QWidget()
        self.output_layout = OutputLayout()
        self.output_widget.setLayout(self.output_layout)

        self.tmpWidget2 = QWidget()

        self.addWidget(self.input_scroll_wrap, 1, 1, 1, 1)
        self.addWidget(self.output_widget, 1, 2, 1, 1)
Beispiel #4
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 #5
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 #6
0
class EECalculator(QMainWindow):
    def __init__(self, parent):
        QMainWindow.__init__(self)
        # TODO:use framelesswindow
        # self.setWindowFlags(Qt.FramelessWindowHint)
        self.InitUI()

    def RefreshWidgets(self,target,name):
        while target.count():
            Child = target.takeAt(0)
            if Child.widget():
                Child.widget().deleteLater()
        if name==modules[0]:
            target.addWidget(homepage.MainWidget())
        if name==modules[1]:
            target.addWidget(rc.MainWidget())
        if name==modules[2]:
            target.addWidget(tcap.MainWidget())
        if name==modules[3]:
            target.addWidget(ne555.MainWidget())
            
        
    def InitUI(self):
        # Set Window Size
        self.resize(800, 600)
        self.setMinimumSize(QSize(800, 600))
        # Set Window Titile
        self.setWindowTitle("EE Calculator")

        # Create Main Widgets
        self.MainWidget = QWidget()
        self.MainLayout = QHBoxLayout(self.MainWidget)
        # Create Display Widgets
        self.DisplayWidget = QWidget(self.MainWidget)
        self.DisplayLayout = QGridLayout(self.DisplayWidget)
        # Create Menu Area&Widgets
        self.MenuScrollArea = QScrollArea(self.MainWidget)
        self.MenuScrollAreaContents = QWidget()
        self.MenuScrollAreaLayout = QVBoxLayout(self.MenuScrollAreaContents)

        ButtonList=[]
        i = 0
        for module in modules:
            ButtonList.append(QPushButton(module))
            ButtonList[i].setFixedWidth(198)
            ButtonList[i].setFixedHeight(66)
            ButtonList[i].clicked.connect(partial(self.RefreshWidgets,self.DisplayLayout,module))
            self.MenuScrollAreaLayout.addWidget(ButtonList[i])
            i += 1
        self.MenuScrollAreaLayout.addStretch(1)

        # Setup Widget&LAyout
        self.MenuScrollArea.setFixedWidth(200)
        self.MenuScrollAreaLayout.setMargin(0)
        self.MenuScrollAreaLayout.setSpacing(0)
        self.DisplayLayout.setMargin(0)
        self.MainLayout.setMargin(0)
        self.MenuScrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.MenuScrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.MenuScrollArea.setWidget(self.MenuScrollAreaContents)

        self.DisplayLayout.addWidget(homepage.MainWidget())

        self.MainLayout.addWidget(self.MenuScrollArea)
        self.MainLayout.addWidget(self.DisplayWidget)
        self.setCentralWidget(self.MainWidget)