Example #1
0
 def add_line(label, text):
     row = table.rowCount()
     table.insertRow(table.rowCount())
     table_item = QtWidgets.QTableWidgetItem(label)
     table_item.setFlags(table_item.flags() &
          ~(Qt.ItemIsEditable))
     table.setItem(row, 0, table_item)
     table_item = QtWidgets.QTableWidgetItem(text)
     table_item.setFlags(table_item.flags() &
          ~(Qt.ItemIsEditable))
     table.setItem(row, 1, table_item)
Example #2
0
 def draw_table(headers=headers):
     """Fill the whole table with data from docked entries"""
     widget.tableDocked.clear()
     widget.tableDocked.setSortingEnabled(False)
     n_internal_columns = 3
     # check if requested headers in remarks
     headers = [i for i in headers if i in docked.remarks]
     # number of rows and columns
     widget.tableDocked.setColumnCount(len(headers) + n_internal_columns)
     widget.tableDocked.setRowCount(docked.n_entries)
     # fill table
     widget.tableDocked.setHorizontalHeaderLabels([""] *
                                                  n_internal_columns +
                                                  headers)
     for row, entry in enumerate(docked.entries):
         # hidden internal columns [n_entry, 'object', 'state']
         widget.tableDocked.setItem(row, 0,
                                    QtWidgets.QTableWidgetItem(str(row)))
         widget.tableDocked.setItem(
             row, 1,
             QtWidgets.QTableWidgetItem(str(entry['internal']['object'])))
         widget.tableDocked.setItem(
             row, 2,
             QtWidgets.QTableWidgetItem(str(entry['internal']['state'])))
         # assign to table cell
         for column, remark in enumerate(headers):
             value = entry['remarks'][remark]
             item = QtWidgets.QTableWidgetItem()
             item.setData(QtCore.Qt.EditRole, value)
             widget.tableDocked.setItem(row, column + n_internal_columns,
                                        item)
             widget.tableDocked.item(row, column +
                                     n_internal_columns).setTextAlignment(
                                         QtCore.Qt.AlignCenter)
     widget.tableDocked.resizeColumnsToContents()
     widget.tableDocked.resizeRowsToContents()
     for i in range(n_internal_columns):
         widget.tableDocked.hideColumn(i)
     # update columns menubar
     show_column.clear()
     hide_column.clear()
     for i in sorted(docked.remarks - set(headers)):
         action = show_column.addAction(i)
         action.triggered.connect(lambda chk, i=i: show_header(i))
     for i in headers:
         action = hide_column.addAction(i)
         action.triggered.connect(lambda chk, i=i: hide_header(i))
     # show table
     widget.tableDocked.setSortingEnabled(True)
     widget.tableDocked.show()
Example #3
0
    def _fill_list(self):
        """
        Create the list's data.
        """

        self.items_dict = {}

        # Checks the database log in order to obtain the date when each database was last downloaded.
        download_log_dict = {}
        if os.path.isfile(self.installer_protocol.download_log_filepath):
            with open(self.installer_protocol.download_log_filepath, "r") as l_fh:
                download_log_dict = json.loads(l_fh.read())

        # Configure the list of items is the 'all_components_list' from the PyMod Installer class.
        self.view.setRowCount(len(self.installer_protocol.components_list))
        for row_counter, component in enumerate(self.installer_protocol.components_list):
            # Create an item and set the component name as text.
            item = QtWidgets.QTableWidgetItem(component.full_name)
            # add a checkbox to the name
            item.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
            item.setCheckState(QtCore.Qt.Unchecked)
            # place the items in columns
            self.view.setItem(row_counter, self.component_col_idx, item)
            self.items_dict.update({component: item})


            # Set the names of the databases.
            self.view.setItem(row_counter, self.databases_col_idx, QtWidgets.QTableWidgetItem(component.databases_string))

            # Create another item displaying the status.
            graphic_status = 'Wait...'
            status = QtWidgets.QTableWidgetItem(graphic_status)
            status.setForeground(QtGui.QBrush(QtGui.QColor(191, 191, 191)))
            self.view.setItem(row_counter, self.status_col_idx, status)

            # Set the source URL.
            self.view.setItem(row_counter, self.source_col_idx, QtWidgets.QTableWidgetItem(component.remote_source))

            # Fill in the last downloaded column.
            if component.name in download_log_dict:
                last_downloaded_str = download_log_dict[component.name]
            else:
                last_downloaded_str = "Never"
            last_downloaded_item = QtWidgets.QTableWidgetItem(last_downloaded_str)
            self.view.setItem(row_counter, self.last_download_col_idx, last_downloaded_item)

            self.items_status_dict[component.name] = status
            self.items_last_download_dict[component.name] = last_downloaded_item
Example #4
0
    def set_data(self):

        verticalHeader = self.verticalHeader()
        verticalHeader.setSectionResizeMode(QtWidgets.QHeaderView.Fixed)
        verticalHeader.setDefaultSectionSize(self.row_labels_height)

        for i, row in enumerate(self.data):
            for j, value in enumerate(row):

                # Gets the value to show in the cell.
                if value is not None:
                    # Attempts to convert the value in a float.
                    try:
                        _value = float(value)
                    except ValueError:
                        _value = value
                else:
                    _value = "-"
                with warnings.catch_warnings():
                    warnings.simplefilter("ignore")
                    newitem = QtWidgets.QTableWidgetItem(_value)
                newitem.setData(QtCore.Qt.DisplayRole, _value)
                newitem.setFlags(QtCore.Qt.ItemIsEnabled)
                newitem.setTextAlignment(QtCore.Qt.AlignCenter)
                self.setItem(i, j, newitem)
        self.setHorizontalHeaderLabels(self.column_labels)
        if self.row_labels != None:
            self.setVerticalHeaderLabels(self.row_labels)
Example #5
0
 def addDistanceToList(self, traj):
     """
     Add a FRET set to the list
     """
     DA = '{} -> {}'.format(self.donorName, self.acceptorName)
     rowCount = self.tableWidget_FRET.rowCount()
     for r in range(rowCount):
         if DA == self.tableWidget_FRET.item(r, 0).text():
             break
     else:
         r = 0
         self.tableWidget_FRET.insertRow(r)
     self.tableWidget_FRET.setItem(
         r, 0,
         QtWidgets.QTableWidgetItem('{} -> {}'.format(
             self.donorName, self.acceptorName)))
     self.tableWidget_FRET.setItem(
         r, 1, QtWidgets.QTableWidgetItem('{:.1f}'.format(traj.mean_R_DA)))
     self.tableWidget_FRET.setItem(
         r, 2, QtWidgets.QTableWidgetItem('{:.1f}'.format(traj.sigma_R_DA)))
     self.tableWidget_FRET.setItem(
         r, 3, QtWidgets.QTableWidgetItem('{:.2f}'.format(traj.mean_E_DA)))
     self.tableWidget_FRET.setItem(
         r, 4,
         QtWidgets.QTableWidgetItem('{:.1f}'.format(traj.mean_R_DA_E)))
     self.tableWidget_FRET.setItem(
         r, 5, QtWidgets.QTableWidgetItem('{:.1f}'.format(traj.R_mp)))
     self.tableWidget_FRET.setItem(
         r, 6, QtWidgets.QTableWidgetItem('{:.1f}'.format(traj.R_attach)))
Example #6
0
    def populate_xlink_table():
        '''
        Populates the table with xlinks and mono-links according to which are currently set to be displayed
        '''

        obs_xlinks = viewer.obs_xlinks
        obs_monos = viewer.obs_monos

        w = form.table_xlinks

        #remove data if already
        w.setRowCount(0)

        entries = []

        for xl in obs_xlinks:

            str_dist = '{0:3.1f}'.format(xl.distance)
            entry = [xl.chain1, xl.resid1, xl.chain2, xl.resid2, str_dist]

            bAdded_entry = False
            if xl.distance <= viewer.threshold and viewer.show_satisied == True:
                entries.append(entry)
                bAdded_entry = True

            if xl.distance > viewer.threshold and viewer.show_violated == True:
                entries.append(entry)
                bAdded_entry = True

            # check that inters should be shown
            if bAdded_entry and xl.chain1 != xl.chain2 and viewer.show_inter == False:
                entries.pop()

            if bAdded_entry and xl.chain1 == xl.chain2 and viewer.show_intra == False:
                entries.pop()

        #now add the monolinks to end of table
        for m in obs_monos:
            if viewer.show_mono == True:
                entry = [m.chain, m.resid, '-', '-', '-']
                entries.append(entry)

        if entries:
            w.setColumnCount(len(entries[0]))
            w.setRowCount(len(entries))

            for i, row in enumerate(entries):
                for j, col in enumerate(row):
                    item = QtWidgets.QTableWidgetItem(col)
                    w.setItem(i, j, item)
                    #align text in centre of cell
                    item.setTextAlignment(Qt.AlignCenter)

            # set the columns to be equal width and fit in the table
            header = w.horizontalHeader()
            for i in range(0, len(entries[0])):
                header.setSectionResizeMode(i, QtWidgets.QHeaderView.Stretch)
    def _set_vertical_headers(self):
        # Get row count
        row_count = self.sceneTableWidget.rowCount()

        # Iterate in range, setting item
        for ind in range(row_count):
            # Create  arrows item
            arrows = QtWidgets.QTableWidgetItem('\u2195')
            arrows_font = arrows.font()
            arrows_font.setPointSize(20)
            arrows.setFont(arrows_font)
            self.sceneTableWidget.setVerticalHeaderItem(ind, arrows)
Example #8
0
 def addLabelToList(self, av):
     """
     Add a label and the computed mean dye position (MP) to the list
     """
     rowCount = self.tableWidget_MeanPos.rowCount()
     for r in range(rowCount):
         if self.labelName == self.tableWidget_MeanPos.item(r, 0).text():
             break
     else:
         r = 0
         self.tableWidget_MeanPos.insertRow(r)
     self.tableWidget_MeanPos.setItem(
         r, 0, QtWidgets.QTableWidgetItem(self.labelName))
     self.tableWidget_MeanPos.setItem(
         r, 1,
         QtWidgets.QTableWidgetItem(', '.join('{:.2f}'.format(p)
                                              for p in av.acv.mp)))
     if self.comboBox_donorName.findText(self.labelName) == -1:
         self.comboBox_donorName.addItem(self.labelName)
     if self.comboBox_acceptorName.findText(self.labelName) == -1:
         self.comboBox_acceptorName.addItem(self.labelName)
    def _populate_data(self):
        '''
        Main loop for populating the table and class data structures.
        '''
        # Clear rows
        self.sceneTableWidget.setRowCount(0)
        self.scene_list = self._update_scene_list()
        self._update_scene_dict()

        self._format_condensed_widget()

        for scene_name in self.scene_list:
            # Add a row for the scene
            row_number = self.sceneTableWidget.rowCount()
            self.sceneTableWidget.insertRow(row_number)
            self.sceneTableWidget.setRowHeight(row_number, 100)
            # Get data from scene_dict
            scene_image_label = self._get_scene_image_label(
                self.scene_dict[scene_name][SceneDictIndex.QPIXMAP])
            scene_message = self.scene_dict[scene_name][SceneDictIndex.MESSAGE]
            scene_actions = self.scene_dict[scene_name][SceneDictIndex.ACTIONS]

            # Set items within the new row
            self.sceneTableWidget.setItem(
                row_number, SceneTableColumn.NAME,
                QtWidgets.QTableWidgetItem(scene_name))
            self.sceneTableWidget.setCellWidget(row_number,
                                                SceneTableColumn.IMAGE,
                                                scene_image_label)
            self.sceneTableWidget.setItem(
                row_number, SceneTableColumn.MESSAGE,
                QtWidgets.QTableWidgetItem(scene_message))
            self.sceneTableWidget.setItem(
                row_number, SceneTableColumn.ACTIONS,
                QtWidgets.QTableWidgetItem(scene_actions))

        self._format_table()

        self.sceneTableWidget.selectionModel().clearSelection()
Example #10
0
    def populate_preferences(self):
        from . import preferences

        self.t_preferences_keys = list(preferences)

        w = self.form.t_preferences
        w.horizontalHeader().setStretchLastSection(True)
        w.setRowCount(len(self.t_preferences_keys))

        for row, key in enumerate(self.t_preferences_keys):
            item = QtWidgets.QTableWidgetItem(key)
            item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
            w.setItem(row, 0, item)

            item = QtWidgets.QTableWidgetItem()
            value = preferences[key]
            if isinstance(value, bool):
                item.setCheckState(Qt.Checked if value else Qt.Unchecked)
            else:
                item.setFlags(item.flags() & ~Qt.ItemIsUserCheckable)
                item.setText(str(value))
            w.setItem(row, 1, item)

        w.itemChanged.connect(self.update_preferences_item)
Example #11
0
    def setupUi(self, UpdateDialog):
        UpdateDialog.setObjectName("UpdateDialog")
        UpdateDialog.resize(950, 470)
        self.verticalLayout = QtWidgets.QVBoxLayout(UpdateDialog)
        self.verticalLayout.setObjectName("verticalLayout")
        self.select_comp_label = QtWidgets.QLabel(UpdateDialog)
        self.select_comp_label.setObjectName("select_comp_label")
        self.verticalLayout.addWidget(self.select_comp_label)
        self.components_tableWidget = QtWidgets.QTableWidget(UpdateDialog)
        default_font = QtGui.QFont()
        default_font.setPointSize(default_font.pointSize()-1)
        self.components_tableWidget.setFont(default_font)
        self.components_tableWidget.setProperty("showDropIndicator", False)
        self.components_tableWidget.setDragDropOverwriteMode(False)
        self.components_tableWidget.setAlternatingRowColors(True)
        self.components_tableWidget.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
        self.components_tableWidget.setGridStyle(QtCore.Qt.NoPen)
        self.components_tableWidget.setColumnCount(self.n_cols)
        self.components_tableWidget.setObjectName("components_tableWidget")
        self.components_tableWidget.setRowCount(1)
        vertical_header_item = QtWidgets.QTableWidgetItem()
        self.components_tableWidget.setVerticalHeaderItem(0, vertical_header_item)
        for i in range(self.n_cols):
            item = QtWidgets.QTableWidgetItem()
            self.components_tableWidget.setHorizontalHeaderItem(i, item)

        item = QtWidgets.QTableWidgetItem()
        self.components_tableWidget.setItem(0, self.component_col_idx, item)
        item = QtWidgets.QTableWidgetItem()
        self.components_tableWidget.setItem(0, self.databases_col_idx, item)
        self.components_tableWidget.horizontalHeader().setVisible(True)
        self.components_tableWidget.horizontalHeader().setCascadingSectionResizes(False)
        self.components_tableWidget.setColumnWidth(self.component_col_idx, 210)
        self.components_tableWidget.setColumnWidth(self.databases_col_idx, 180)
        self.components_tableWidget.setColumnWidth(self.status_col_idx, 190)
        # self.components_tableWidget.setColumnWidth(self.source_col_idx, 390)
        # self.components_tableWidget.setColumnWidth(self.last_download_col_idx, 250)

        self.components_tableWidget.horizontalHeader().setStretchLastSection(True)
        self.components_tableWidget.verticalHeader().setVisible(False)
        self.components_tableWidget.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
        self.verticalLayout.addWidget(self.components_tableWidget)
        self.statusLabel = QtWidgets.QLabel(UpdateDialog)
        self.statusLabel.setObjectName("statusLabel")
        self.verticalLayout.addWidget(self.statusLabel)
        self.installation_progressBar = QtWidgets.QProgressBar(UpdateDialog)
        self.installation_progressBar.setEnabled(True)
        self.installation_progressBar.setProperty("value", 10)
        self.installation_progressBar.setObjectName("installation_progressBar")
        self.verticalLayout.addWidget(self.installation_progressBar)
        self.buttonsHorizontalLayout = QtWidgets.QHBoxLayout()
        self.buttonsHorizontalLayout.setObjectName("buttonsHorizontalLayout")
        self.installSel_button = QtWidgets.QPushButton(UpdateDialog)
        self.installSel_button.setObjectName("installSel_button")
        self.buttonsHorizontalLayout.addWidget(self.installSel_button)
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.buttonsHorizontalLayout.addItem(spacerItem)
        self.cancel_button = QtWidgets.QPushButton(UpdateDialog)
        self.cancel_button.setObjectName("cancel_button")
        self.buttonsHorizontalLayout.addWidget(self.cancel_button)
        self.verticalLayout.addLayout(self.buttonsHorizontalLayout)

        UpdateDialog.setWindowTitle("Install and update databases")
        self.select_comp_label.setText("Select components to install or update")
        self.components_tableWidget.setSortingEnabled(True)
        self.components_tableWidget.horizontalHeaderItem(self.component_col_idx).setText("Component")
        self.components_tableWidget.horizontalHeaderItem(self.databases_col_idx).setText("Databases Names")
        self.components_tableWidget.horizontalHeaderItem(self.status_col_idx).setText("Status")
        self.components_tableWidget.horizontalHeaderItem(self.source_col_idx).setText("Source")
        self.components_tableWidget.horizontalHeaderItem(self.last_download_col_idx).setText("Last Downloaded")
        __sortingEnabled = self.components_tableWidget.isSortingEnabled()
        self.components_tableWidget.setSortingEnabled(False)
        self.components_tableWidget.setSortingEnabled(__sortingEnabled)
        self.statusLabel.setText("")
        self.cancel_button.setText("Cancel")
        self.installSel_button.setText("Install Selected")

        QtCore.QMetaObject.connectSlotsByName(UpdateDialog)