示例#1
0
    def _fcn_cleanGui(self):
        """Clean the entire GUI."""
        # -------------- TABLES --------------
        # Info :
        self._infoTable.clear()
        self._infoTable.setRowCount(0)

        # Detection :
        self._DetectLocations.clear()
        self._DetectLocations.setRowCount(0)

        # -------------- LIST BOX --------------
        # Disconnect :
        self._PanSpecChan.currentIndexChanged.disconnect()
        # Clear items :
        self._PanSpecChan.clear()
        self._ToolDetectChan.clear()

        # -------------- VISUALS --------------
        # Channels :
        for k in range(len(self)):
            # Disconnect buttons :
            self._chanChecks[k].clicked.disconnect()
            self._yminSpin[k].valueChanged.disconnect()
            self._ymaxSpin[k].valueChanged.disconnect()
            # Delete elements :
            self._chanChecks[k].deleteLater()
            self._yminSpin[k].deleteLater(), self._ymaxSpin[k].deleteLater()
            self._chanWidget[k].deleteLater()
            self._chanLayout[k].deleteLater()
            self._chanLabels[k].deleteLater()
            self._amplitudeTxt[k].deleteLater()
            self._chanCanvas[k].parent = None
        QObjectCleanupHandler().add(self._chanGrid)
        QObjectCleanupHandler().clear()
        # Spectrogram :
        self._specCanvas.parent = None
        self._SpecW.deleteLater(), self._SpecLayout.deleteLater()
        self._specLabel.deleteLater()
        # Hypnogram :
        self._hypCanvas.parent = None
        self._HypW.deleteLater(), self._HypLayout.deleteLater()
        self._hypLabel.deleteLater()
        # Time axis :
        self._TimeAxis.parent = None
        self._TimeAxisW.deleteLater(), self._TimeLayout.deleteLater()
        self._timeLabel.deleteLater()
示例#2
0
def switch_layout(target_frame, new_layout):
    current_layout = target_frame.layout()
    if current_layout is not None:
        for i in reversed(range(current_layout.count())):
            current_layout.itemAt(i).widget().setParent(None)

    QObjectCleanupHandler().add(target_frame.layout())
    target_frame.setLayout(new_layout)
示例#3
0
    def buildCompInputRegion(self, numberOfComponenets=2):
        """Builds input region based on number of componenets"""
        # Remove previous widgets from the inputRegion
        for nameEdit, ratioEdit in zip(self.compNameLineEdits,
                                       self.compRatioLineEdits):
            QObjectCleanupHandler().add(nameEdit)
            QObjectCleanupHandler().add(ratioEdit)
        # Empty the lists
        self.compNameLineEdits = []
        self.compRatioLineEdits = []

        # Creating new widgets' instances
        for index in range(numberOfComponenets):
            self.compNameLineEdits.append(QLineEdit())
            self.compRatioLineEdits.append(QLineEdit())

        # Setting text alignment for every QLineEdit
        for nameEdit, ratioEdit in zip(self.compNameLineEdits,
                                       self.compRatioLineEdits):
            nameEdit.setAlignment(Qt.AlignLeft)
            ratioEdit.setAlignment(Qt.AlignCenter)

        # Adding widgets to inputBoxes' layout
        for index, (nameEdit, ratioEdit) in enumerate(
                zip(self.compNameLineEdits, self.compRatioLineEdits)):
            self.compInputLayout.addWidget(nameEdit, index, 0)
            self.compInputLayout.addWidget(ratioEdit, index, 1)

        # Setting placeholder text for every QLineEdit and QValidators
        # Preparing validators
        ratioValidator = QIntValidator()
        nameValidator = QRegularExpressionValidator()
        nameValidator.setRegularExpression(QRegularExpression(r"[\w\d]*"))
        for index, (nameEdit,
                    ratioEdit) in enumerate(zip(self.compNameLineEdits,
                                                self.compRatioLineEdits),
                                            start=1):
            strIndex = str(index)
            # Setting placeholders
            nameEdit.setPlaceholderText("Name " + strIndex)
            ratioEdit.setPlaceholderText("Ratio " + strIndex)
            # Setting validators
            nameEdit.setValidator(nameValidator)
            ratioEdit.setValidator(ratioValidator)
示例#4
0
 def add_bar_chart(self):
     Plotter.draw_and_print(self.input_data)
     layout = self.barChart.layout()
     if layout != None:
         QObjectCleanupHandler().add(self.barChart.layout())
     layout = QtWidgets.QVBoxLayout()
     label = QtWidgets.QLabel(self)
     pixmap = QPixmap('plt/bar_chart.png')
     pixmap = pixmap.scaled(451,331, Qt.KeepAspectRatio, Qt.FastTransformation)
     label.setPixmap(pixmap)
     layout.addWidget(label)
     self.barChart.setLayout(layout)
示例#5
0
 def new_function(outer_self, **kwargs):
     if inner_self.size:
         outer_self.resize(*inner_self.size)
     if inner_self.title:
         outer_self.setWindowTitle(inner_self.title)
     # Delete the old layout
     inner_self.clear_layout(outer_self.main_widget.layout())
     QObjectCleanupHandler().add(outer_self.main_widget.layout())
     # Get and set the new layout
     if kwargs:
         new_layout = func(outer_self, **kwargs)
     else:
         new_layout = func(outer_self)
     outer_self.main_widget.setLayout(new_layout)
     outer_self.show()
示例#6
0
 def add_main_plot(self):
     layout = self.mainPlot.layout()
     if layout != None:
         QObjectCleanupHandler().add(self.mainPlot.layout())
     layout = QtWidgets.QVBoxLayout()
     self.scGlowny = MplCanvas(self)
     for dane in self.input_data:
         self.scGlowny.axes.plot(dane[1],dane[4],label = dane[0], linewidth = 4)
     #sc.axes.text(1,3.6,"Wyniki firm względem czynników", horizontalalignment = 'center', verticalalignment = 'center', fontsize=12)
     self.scGlowny.axes.set_title("Wykres wyników firm względem czynników.")
     self.scGlowny.axes.grid(axis = 'y',color = 'gray', linestyle='-', linewidth = 1)
     self.scGlowny.axes.legend()
     self.scGlowny.correct_ticks()
     layout.addWidget(self.scGlowny)
     self.mainPlot.setLayout(layout)
示例#7
0
    def update(self, string):

        QObjectCleanupHandler().add(self.layout())

        scroll_bar_position = self.scroll.horizontalScrollBar().value()

        for widgets in self.findChildren(QWidget):
            widgets.deleteLater()

        dictionary = json.loads(string)
        credit = dictionary["creditos"]
        dictionary = dictionary["malla"]

        hbox = QHBoxLayout()

        legend = Legend()
        hbox.addWidget(legend)

        for semester_number in [
                str(index) for index in range(1,
                                              len(dictionary) + 1)
        ]:
            height = self.geometry().height() * semester_height_scale
            semester = Semester(number=semester_number,
                                credit=credit[semester_number],
                                height=height)
            semester.add_subjects(dictionary[semester_number])
            hbox.addWidget(semester)
            semester.send_semester_update.connect(self.receive_semester_update)
            semester.send_subject_state_update.connect(
                self.receive_subject_state_update)

        groupBox = QGroupBox()
        groupBox.setLayout(hbox)
        self.scroll = QScrollArea()
        self.scroll.setWidget(groupBox)
        self.scroll.setWidgetResizable(True)

        self.scroll.horizontalScrollBar().setValue(scroll_bar_position)

        hbox = QHBoxLayout()
        hbox.addWidget(self.scroll)
        self.setLayout(hbox)
    def _init_layout(self):
        """
        See:
            https://stackoverflow.com/questions/10416582/replacing-layout-on-a-qwidget-with-another-layout?lq=1
        """
        if self.layout():
            QObjectCleanupHandler().add(self.layout())

        self.widget_layout = QVBoxLayout()
        self.title_and_delete_layout = QHBoxLayout()
        self.title_and_delete_layout.addWidget(self.title)
        if self.delete_button:
            self.title_and_delete_layout.addWidget(self.delete_button)
        if self.add_process_button:
            self.title_and_delete_layout.addWidget(self.add_process_button)
        self.widget_layout.addLayout(self.title_and_delete_layout)
        self.widget_layout.addWidget(self.launch_button)
        self.widget_layout.addWidget(self.stop_button)
        self.setLayout(self.widget_layout)
示例#9
0
    def setup_ui(self, saves: list):
        self.start_thread.disconnect()
        QObjectCleanupHandler().add(self.layout())
        self.main_layout = QVBoxLayout()
        self.title = CustomQLabel(f"<h1>" + self.tr("Cloud Saves") +
                                  "</h1>\n" +
                                  self.tr("Found Saves for folowing Games"))
        self.sync_all_button = QPushButton(self.tr("Sync all games"))
        self.sync_all_button.clicked.connect(self.sync_all)
        self.main_layout.addWidget(self.title)
        self.main_layout.addWidget(self.sync_all_button)

        latest_save = {}
        for i in saves:
            latest_save[i.app_name] = i
        logger.info(f'Got {len(latest_save)} remote save game(s)')
        if len(latest_save) == 0:
            QMessageBox.information(
                self.tr("No Games Found"),
                self.tr("Your games don't support cloud save"))
            self.close()
            return
        self.widgets = []

        for igame in self.igames:
            game = self.core.get_game(igame.app_name)
            if not game.supports_cloud_saves:
                continue
            if latest_save.get(igame.app_name):
                sync_widget = SyncWidget(igame, latest_save[igame.app_name],
                                         self.core)
            else:
                continue
            self.main_layout.addWidget(sync_widget)
            self.widgets.append(sync_widget)

        self.ok_button = QPushButton("Ok")
        self.ok_button.clicked.connect(lambda: self.close())
        self.main_layout.addWidget(self.ok_button)

        self.setLayout(self.main_layout)
示例#10
0
    def refresh_search(self):
        """
        Called to refresh the advanced search
        """

        # Old values stored
        (fields, conditions, values, links, nots) = self.get_filters(False)

        # We remove the old layout
        self.clearLayout(self.layout())
        QObjectCleanupHandler().add(self.layout())

        # Links and add rows removed from every row
        self.rows_borders_removed()

        # Links and add rows reput in the good rows
        self.rows_borders_added(links)

        master_layout = QVBoxLayout()
        main_layout = QGridLayout()

        # Everything added to the layout
        for i in range(0, len(self.rows)):
            for j in range(0, 7):
                widget = self.rows[i][j]
                if widget != None:
                    main_layout.addWidget(widget, i, j)

        # Search button added at the end
        searchLayout = QHBoxLayout(None)
        searchLayout.setObjectName("search layout")
        self.search = QPushButton("Search")
        self.search.setFixedWidth(100)
        self.search.clicked.connect(self.launch_search)
        searchLayout.addWidget(self.search)
        searchLayout.setParent(None)

        # New layout added
        master_layout.addLayout(main_layout)
        master_layout.addLayout(searchLayout)
        self.setLayout(master_layout)
示例#11
0
    def _init_layout(self):
        if self.layout():
            QObjectCleanupHandler().add(self.layout())

        self.hbox1 = QHBoxLayout()
        self.hbox1.addWidget(self.directory_widget)
        self.hbox1.addWidget(self.process_id_label)
        if self.browse_folder_button:
            self.hbox1.addWidget(self.browse_folder_button)

        if self.close_button:
            self.hbox1.addWidget(self.close_button)

        self.hbox2 = QHBoxLayout()
        self.hbox2.addWidget(self.args_table_widget)

        self.hbox3 = QHBoxLayout()
        self.hbox3.addWidget(self.restart_button)

        self.vbox = QVBoxLayout()
        self.vbox.addLayout(self.hbox1)
        self.vbox.addLayout(self.hbox2)
        self.vbox.addLayout(self.hbox3)
        self.setLayout(self.vbox)
示例#12
0
 def add_pie_chart(self):
     layout = self.pieChart.layout()
     if layout != None:
         QObjectCleanupHandler().add(self.pieChart.layout())
     layout = QtWidgets.QVBoxLayout()
     self.scPie = MplCanvas(self)
     wyniki = []
     labele = []
     for dane in self.input_data:
         wyniki.append(sum(dane[4]))
         labele.append(dane[0])
     explode = []
     dex = wyniki.index(max(wyniki))
     for i in range(0,len(wyniki)):
         if i == dex:
             explode.append(0.05)
         else:
             explode.append(0.01)
     wyniki = array(wyniki)
     labele = array(labele)
     self.scPie.axes.pie(x = wyniki,labels = labele, explode = explode, shadow = False, autopct='%1.1f%%')
     self.scPie.axes.set_title("Udział w wynikach każdej z firm")
     layout.addWidget(self.scPie)
     self.pieChart.setLayout(layout)
示例#13
0
    def load_vms(self):
        """
            Description: Main core VM loader method. Will connect to oVirt, get the VM list and render them.
            Arguments: None
            Returns: Nothing
        """

        global conf, MAXHEIGHT, BACKGROUNDCSS, STANDARDCELLCSS

        QObjectCleanupHandler().add(self.layout())
        if not conf.USERNAME:
            quit()

        # Used to store row <-> VM correspondence
        self.vmdata = {}

        step = 0

        self.pbarlayout = QGridLayout(self)
        self.pbar = QProgressBar(self)
        self.grid = QGridLayout()
        self.grid.setHorizontalSpacing(0)

        # Initially, set the layout to the progress bar
        self.pbar.setGeometry(250, 250, 200, 100)
        self.pbar.setValue(0)
        self.pbarlayout.addWidget(self.pbar, 0, 0)
        self.setLayout(self.pbarlayout)

        self.setStyleSheet(BACKGROUNDCSS)

        try:
            # Try getting the VM list from oVirt
            vms_serv = conf.OVIRTCONN.vms_service()
            vmpools_serv = conf.OVIRTCONN.vm_pools_service()
            vms = sorted(vms_serv.list(),
                         key=self.p22p3_compare_vms(self.compare_vms))
            vmpools = sorted(vmpools_serv.list(),
                             key=self.p22p3_compare_vms(self.compare_vms))
        except Error:
            QMessageBox.critical(None,
                                 _('apptitle') + ': ' + _('error'),
                                 _('unexpected_connection_drop'))
            quit()

        # Set the main widget height based on the number of VMs
        winheight = self.vm_based_resize(len(vms) + len(vmpools))
        if len(vms) + len(vmpools) > 0:
            delta = int(100 / (len(vms) + len(vmpools)))
        else:
            delta = int(100)

        if vmpools:
            step = self.list_vmpools(1, delta, step, vmpools)
        if vms:
            self.list_vms(len(vmpools) + 1, delta, step, vms)

        # Once loading has concluded, progress bar is dismissed and the layout set to the QGridLayout
        self.pbar.hide()
        QObjectCleanupHandler().add(self.layout())

        # First row is special: Number of VMs + Toolbar
        total_machines = QLabel(
            _('total_machines') + ': <font color="#AA8738">' + str(len(vms)) +
            '</font>, ' + _('total_vmpools') + ': <font color="#AA8738">' +
            str(len(vmpools)) + '</font>', self)
        self.grid.addWidget(total_machines, 0, 0, 1, 3, Qt.AlignCenter)
        self.generate_toolbar()

        # We wrap the main widget inside another widget with a vertical scrollbar
        wrapper = QWidget()
        wrapper.setLayout(self.grid)
        scroll = QScrollArea()
        scroll.setWidget(wrapper)
        scroll.setWidgetResizable(True)
        scroll.setFixedHeight(winheight)
        layout = QVBoxLayout()
        layout.addWidget(scroll)

        layout.setContentsMargins(0, 0, 0, 20)
        self.setLayout(layout)