Example #1
0
    def setupUi(self, lista, query):

        formLayout = QFormLayout()
        groupBox = QGroupBox(f"Resultado de la búsqueda: {query}")
        labelLis = []
        comboList = []
        for i in range(len(lista)):

            f = open(lista[i]['name'], 'r', encoding='utf-8')
            jsonData = json.loads(f.read())
            f.close()
            labelLis.append(
                QLabel(
                    f'{jsonData["title"]} --- {round(float(lista[i]["distance"])*100, 2)}% --- {jsonData["categoria"]}'
                ))
            buttonOpen = QPushButton("Abrir noticia")
            buttonOpen.clicked.connect(self.make_openFile(lista[i]["name"]))
            comboList.append(buttonOpen)
            formLayout.addRow(labelLis[i], comboList[i])
        groupBox.setLayout(formLayout)
        scroll = QScrollArea(self)
        scroll.setWidget(groupBox)
        scroll.setWidgetResizable(True)
        scroll.setMinimumHeight(600)
        scroll.setMinimumWidth(1200)
        layout = QVBoxLayout(self)
        layout.addWidget(scroll)
        self.setWindowTitle("Noticias")
        self.resize(1200, 600)

        self.show()
        self.exec_()
Example #2
0
    def init_scroll_layout(self) -> QHBoxLayout:
        """
        The actual cards layout is inside a wrapper, inside a scroll area.
        Also adds it to the main layout.
        """

        scroll = QScrollArea()
        scroll.setWidgetResizable(True)
        scroll.setMinimumHeight(340)
        scroll.setMaximumHeight(500)
        wrapper = QWidget()
        layout = QHBoxLayout()
        wrapper.setLayout(layout)
        scroll.setWidget(wrapper)
        self.layout.addWidget(scroll)

        return layout