Esempio n. 1
0
    def __init__(self):
        QMainWindow.__init__(self)

        self.widget = QWidget()
        self.primary_layout = QHBoxLayout()
        self.file_contents = QTreeWidget()
        self.secondary_layout = QFormLayout()

        self.name = QLineEdit()
        self.texture_height = QLineEdit()
        self.texture_width = QLineEdit()
        self.texture_size = QLineEdit()
        self.mipmap_count = QSpinBox()
        self.face_count = QSpinBox()

        self.type = QComboBox()

        self.image = QLabel()
        self.preview = QImage()

        self.save_dds_button = QPushButton()
        self.import_dds_button = QPushButton()

        self.file_menu = self.menuBar().addMenu("File")
        self.file_open = self.file_menu.addAction("Open")
        self.file_save = self.file_menu.addAction("Save")
        self.file_save_as = self.file_menu.addAction("Save As...")

        self.edit_menu = self.menuBar().addMenu("Edit")
        self.edit_import_dds = self.edit_menu.addAction("Import DDS")
        self.edit_import_raw = self.edit_menu.addAction("Import Raw")
        self.edit_export = self.edit_menu.addAction("Export")
        self.edit_delete = self.edit_menu.addAction("Delete")
        self.edit_menu.addSeparator()

        self.initWindow()
Esempio n. 2
0
    def __init__(self):
        super(PugdebugExpressionViewer, self).__init__()

        # Action for adding a new expression
        self.add_action = QAction(QIcon.fromTheme('list-add'), "&Add", self)
        self.add_action.triggered.connect(self.handle_add_action)

        # Action for deleting selected expressions
        self.delete_action = QAction(QIcon.fromTheme('list-remove'), "&Delete",
                                     self)
        self.delete_action.setShortcut(QKeySequence("Del"))
        self.delete_action.setShortcutContext(Qt.WidgetShortcut)
        self.delete_action.triggered.connect(self.handle_delete_action)

        self.toolbar = QToolBar()
        self.toolbar.setIconSize(QSize(16, 16))
        self.toolbar.addAction(self.add_action)
        self.toolbar.addAction(self.delete_action)

        self.tree = QTreeWidget()
        self.tree.setColumnCount(3)
        self.tree.setHeaderLabels(['Expression', 'Type', 'Value'])
        self.tree.setSelectionMode(QAbstractItemView.ContiguousSelection)
        self.tree.setContextMenuPolicy(Qt.CustomContextMenu)
        self.tree.customContextMenuRequested.connect(self.show_context_menu)
        self.tree.addAction(self.delete_action)

        layout = QVBoxLayout()
        layout.addWidget(self.toolbar)
        layout.addWidget(self.tree)
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)

        self.restore_state()

        self.tree.itemChanged.connect(self.handle_item_changed)
Esempio n. 3
0
    def __init__(self, info):
        """Property Window

        Args:
            info ([type]): [description]
        """
        super().__init__()
        self.setWindowTitle('Info')

        self.treeview = QTreeWidget()
        self.treeview.setHeaderLabels(["Property", "Value"])
        name_item = QTreeWidgetItem(["Name", info.file_name])
        hash_item = QTreeWidgetItem(["Hash", info.file_hash])
        location_item = QTreeWidgetItem(["Location", info.file_path])
        tag_item = QTreeWidgetItem(["Tags", info.tags])
        created_item = QTreeWidgetItem(['Created', str(info.created)])

        self.treeview.addTopLevelItem(name_item)
        self.treeview.addTopLevelItem(hash_item)
        self.treeview.addTopLevelItem(location_item)
        self.treeview.addTopLevelItem(tag_item)
        self.treeview.addTopLevelItem(created_item)

        self.setWidget(self.treeview)
Esempio n. 4
0
    def createCourseGroup(self):
        groupBox = QGroupBox(
            string._('Step 2:Select sourse resource to backup'))

        self.CourseListBox = QVBoxLayout()
        self.CourseListBox.addStretch(1)

        self.CourseTreeList = QTreeWidget()
        self.CourseTreeList.setHeaderHidden(True)
        self.CourseTreeList.setEnabled(False)
        self.CourseTreeList.itemExpanded.connect(self.ExpandCourse)
        self.CourseTreeListRoot = QTreeWidgetItem(self.CourseTreeList)
        self.CourseTreeListRoot.setText(0, string._("All course"))
        self.CourseTreeListRoot.setFlags(self.CourseTreeListRoot.flags()
                                         | QtCore.Qt.ItemIsTristate
                                         | QtCore.Qt.ItemIsUserCheckable)
        self.CourseTreeListRoot.setCheckState(0, QtCore.Qt.Unchecked)

        HLayout = QHBoxLayout()
        HLayout.addWidget(self.CourseTreeList)

        groupBox.setLayout(HLayout)

        return groupBox
Esempio n. 5
0
    def tab_exif_ui(self, model):
        """
		Set the reference to model and set exif data into widget
		:param model:
		:return:
		"""
        self.model = model
        exif = self.model.get_exif()

        layout = QVBoxLayout()

        if exif:
            result_exif = QTreeWidget()
            self.fill_widget(result_exif, exif)
            result_exif.setHeaderLabel("Data")
        else:  # if general info on current image is empty
            result_exif = QLabel()
            result_exif.setAlignment(Qt.AlignCenter)
            result_exif.setText("No Exif available for this file")

        layout.addWidget(result_exif)

        self.tab_widget.setTabText(1, "Exif")
        self.tab_exif.setLayout(layout)
Esempio n. 6
0
    def __init__(self, parent=None):
        super().__init__(parent)

        data_len_per_dim = 5
        layout = QBoxLayout(QBoxLayout.TopToBottom, self)

        label_container = QWidget(self)
        layout.addWidget(label_container)
        label_container_layout = QHBoxLayout(label_container)
        label = QLabel('Tensor Rank', self)
        label.setAlignment(Qt.AlignHCenter)
        label_container_layout.addWidget(label)
        show_all_button = QPushButton('Expand/Collapse', self)
        label_container_layout.addWidget(show_all_button)

        tw = QTreeWidget(self)
        layout.addWidget(tw)
        tw.setColumnCount(2)
        tw.setHeaderLabels(["where", "rank", "size"])

        for x in range(data_len_per_dim):
            x_child = QTreeWidgetItem(["x:{}".format(x)])
            for y in range(data_len_per_dim):
                y_child = QTreeWidgetItem(["y:{}".format(y)])
                for z in range(data_len_per_dim):
                    z_child = QTreeWidgetItem(["z:{}".format(z), "({},{},{})".format(1, 1, 1), "{}x{}x{}".format(10, 10, 10)])
                    y_child.addChild(z_child)
                x_child.addChild(y_child)
            tw.addTopLevelItem(x_child)

        self.is_expanded = False
        def toggle_expand():
            tw.collapseAll() if self.is_expanded else tw.expandAll()
            self.is_expanded = not self.is_expanded

        show_all_button.clicked.connect(toggle_expand)
Esempio n. 7
0
    def __init__(self, parent: MainWindow, renderers: List[Renderer]) -> None:
        """Initialize the Editor."""
        super().__init__(parent=parent)
        self.renderers = renderers

        self.tree_widget = QTreeWidget()
        self.tree_widget.setHeaderHidden(True)
        self.stacked_widget = QStackedWidget()
        self.layout = QHBoxLayout()
        self.layout.addWidget(self.tree_widget)
        self.layout.addWidget(self.stacked_widget)

        def _selection_callback() -> None:
            for item in self.tree_widget.selectedItems():
                widget_idx = item.data(0, Qt.ItemDataRole.UserRole)
                self.stacked_widget.setCurrentIndex(widget_idx)

        self.tree_widget.itemSelectionChanged.connect(_selection_callback)

        self.setLayout(self.layout)
        self.setWindowTitle("Editor")
        self.setModal(True)

        self.update()
Esempio n. 8
0
 def _initView(self):
     layout = QVBoxLayout(self)
     layout.setContentsMargins(20, 30, 20, 30)
     layout.setSpacing(20)
     # 头像
     hlayout = QHBoxLayout()
     hlayout.addItem(
         QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum))
     hlayout.addWidget(AvatarWidget(self))
     hlayout.addItem(
         QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum))
     layout.addLayout(hlayout, 1)
     # 搜索框
     layout.addWidget(SearchWidget(self), 1)
     # 目录
     self._menuTree = QTreeWidget(self)
     self._menuTree.setFrameShape(QTreeWidget.NoFrame)
     self._menuTree.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
     self._menuTree.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
     self._menuTree.setEditTriggers(QTreeWidget.NoEditTriggers)
     self._menuTree.setIndentation(0)  # 去掉缩进
     self._menuTree.setAnimated(True)
     self._menuTree.setHeaderHidden(True)
     layout.addWidget(self._menuTree, 4)
Esempio n. 9
0
    def get_variable_table(self, context):
        context_key = context.replace(' ', '-').lower()

        if context_key in self.variable_tables:
            table = self.variable_tables[context_key]
        else:
            table = QTreeWidget()
            table.setColumnCount(3)
            table.setHeaderLabels(['Name', 'Type', 'Value'])

            self.variable_tables[context_key] = table

            if context == 'Locals':
                self.insertTab(0, table, context)
            else:
                self.addTab(table, context)

            table.itemDoubleClicked.connect(
                self.handle_variable_double_clicked
            )

            self.setCurrentIndex(0)

        return table
Esempio n. 10
0
    def __init__(self, parent=None):
        """
        Constructor
        
        @param parent reference to the parent widget (QWidget)
        """
        super(SqlConnectionWidget, self).__init__(parent)

        layout = QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)

        self.__connectionTree = QTreeWidget(self)
        self.__connectionTree.setObjectName("connectionTree")
        self.__connectionTree.setHeaderLabels([self.tr("Database")])
        self.__connectionTree.header().setSectionResizeMode(
            QHeaderView.Stretch)
        refreshAction = QAction(self.tr("Refresh"), self.__connectionTree)
        self.__schemaAction = QAction(self.tr("Show Schema"),
                                      self.__connectionTree)

        refreshAction.triggered.connect(self.refresh)
        self.__schemaAction.triggered.connect(self.showSchema)

        self.__connectionTree.addAction(refreshAction)
        self.__connectionTree.addAction(self.__schemaAction)
        self.__connectionTree.setContextMenuPolicy(Qt.ActionsContextMenu)

        layout.addWidget(self.__connectionTree)

        self.__activating = False

        self.__connectionTree.itemActivated.connect(self.__itemActivated)
        self.__connectionTree.currentItemChanged.connect(
            self.__currentItemChanged)

        self.__activeDb = ""
Esempio n. 11
0
    def __init__(self, parent=None):
        super().__init__(parent=parent)
        self.setWindowTitle("QTreeWidget 使用")

        # 实例化
        self.tree_widget = QTreeWidget()
        # 设置列数
        self.tree_widget.setColumnCount(2)
        # 设置树形控件头部标题
        self.tree_widget.setHeaderLabels(["键", "值"])

        # 根节点
        root = QTreeWidgetItem()
        root.setText(0, "根")
        root.setText(1, "---")

        # 设置子节点 1
        child_1 = QTreeWidgetItem(root)
        child_1.setText(0, "子 1 键")  # 第1列
        child_1.setText(1, "子 1 值")  # 第2列
        child_1.setIcon(
            0, QIcon("03_高级界面控件/示例内容/sources/python-96.png"))  # 为第1列添加图标

        # 设置子节点 2
        child_2 = QTreeWidgetItem(root)
        child_2.setText(0, "子 2 键")  # 第1列
        child_2.setText(1, "子 2 值")  # 第2列
        child_2.setIcon(
            0, QIcon("03_高级界面控件/示例内容/sources/golang-96.png"))  # 为第2列添加图标

        self.tree_widget.addTopLevelItem(root)
        self.tree_widget.clicked.connect(self.tree_click)

        h_layout = QHBoxLayout()
        h_layout.addWidget(self.tree_widget)
        self.setLayout(h_layout)
Esempio n. 12
0
    def __init__(self, parent=None):
        super(TreeSymbolsWidget, self).__init__(parent)
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        self.tree = QTreeWidget()
        self.tree.setFrameShape(0)
        vbox.addWidget(self.tree)
        self.tree.header().setHidden(True)
        self.tree.setSelectionMode(self.tree.SingleSelection)
        self.tree.setAnimated(True)
        self.tree.header().setHorizontalScrollMode(
            QAbstractItemView.ScrollPerPixel)
        self.tree.header().setSectionResizeMode(0,
                                                QHeaderView.ResizeToContents)
        self.tree.header().setStretchLastSection(False)
        self.actualSymbols = ('', {})
        self.docstrings = {}
        self.collapsedItems = {}

        self.tree.itemClicked.connect(self._go_to_definition)
        self.tree.itemActivated.connect(self._go_to_definition)
        self.tree.setContextMenuPolicy(Qt.CustomContextMenu)

        self.customContextMenuRequested['const QPoint &'].connect(
            self._menu_context_tree)
        # self.connect(
        #    self,
        #    SIGNAL("customContextMenuRequested(const QPoint &)"),
        #    self._menu_context_tree)
        # self.connect(self, SIGNAL("itemCollapsed(QTreeWidgetItem *)"),
        #             self._item_collapsed)
        # self.connect(self, SIGNAL("itemExpanded(QTreeWidgetItem *)"),
        #             self._item_expanded)

        IDE.register_service('symbols_explorer', self)
Esempio n. 13
0
    def __init__(self, parent=None, update=True):
        QDialog.__init__(self, parent=parent)
        layout = QVBoxLayout()
        self.tree = QTreeWidget()
        layout.addWidget(self.tree)
        self.setLayout(layout)

        self._mgr = cacheMemoryManager

        self._tracked_caches = {}

        # tree setup code
        self.tree.setHeaderLabels(["cache", "memory", "roi", "dtype", "type", "info", "id"])
        self._idIndex = self.tree.columnCount() - 1
        self.tree.setColumnHidden(self._idIndex, True)
        self.tree.setSortingEnabled(True)
        self.tree.clear()

        self._root = TreeNode()

        # refresh every x seconds (see showEvent())
        self.timer = QTimer(self)
        if update:
            self.timer.timeout.connect(self._updateReport)
Esempio n. 14
0
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QSplitter, QListWidget, QTreeWidget, QTextEdit, QMainWindow

if __name__ == '__main__':
    app = QApplication([])

    win = QMainWindow()

    splitter = QSplitter()
    list = QListWidget()
    tree = QTreeWidget()
    text = QTextEdit()

    splitter.setOrientation(Qt.Vertical)
    splitter.addWidget(list)
    splitter.addWidget(tree)
    splitter.addWidget(text)

    win.setCentralWidget(splitter)
    win.show()

    app.exec()
Esempio n. 15
0
    def __init__(self, df=None):
        super().__init__()
        self.df = df
        self.resize(721, 586)

        # set up ok and cancel buttin box
        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setGeometry(QRect(360, 520, 341, 32))
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel
                                          | QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")

        # set up chart select type tree widget in the left
        self.select_chart_type = QTreeWidget(self)
        self.select_chart_type.setGeometry(QRect(30, 30, 191, 471))
        self.select_chart_type.setObjectName("select_chart_type")

        self.scatter_plot = QTreeWidgetItem(self.select_chart_type)
        self.scatter = QTreeWidgetItem(self.scatter_plot)
        self.scatter_3d = QTreeWidgetItem(self.scatter_plot)

        self.line_plot = QTreeWidgetItem(self.select_chart_type)
        self.line = QTreeWidgetItem(self.line_plot)

        self.bar_plot = QTreeWidgetItem(self.select_chart_type)
        self.bar = QTreeWidgetItem(self.bar_plot)

        self.density_plot = QTreeWidgetItem(self.select_chart_type)
        self.density_contour = QTreeWidgetItem(self.density_plot)
        self.density_heatmap = QTreeWidgetItem(self.density_plot)
        self.histogram = QTreeWidgetItem(self.select_chart_type)

        self.select_chart_type.setCurrentItem(self.scatter)
        self.select_chart_type.currentItemChanged.connect(self.updateSetting)

        # set tab widget in the right
        self.scatter_tw = PlotSetting_2d(self, self.df)
        self.scatter_3d_tw = PlotSetting_3d(self, self.df)
        self.line_tw = PlotSetting_line_bar(self, self.df)
        self.bar_tw = PlotSetting_bar(self, self.df)
        self.density_contour_tw = PlotSetting_density_contour(self, self.df)
        self.density_heatmap_tw = PlotSetting_density_heatmap(self, self.df)
        self.histogram_tw = PlotSetting_histogram(self, self.df)

        self.scatter_tw.show()
        self.scatter_3d_tw.hide()
        self.line_tw.hide()
        self.bar_tw.hide()
        self.density_contour_tw.hide()
        self.density_heatmap_tw.hide()
        self.histogram_tw.hide()

        self.buttonBox.accepted.connect(self.ok)
        self.buttonBox.rejected.connect(self.cancel)
        QMetaObject.connectSlotsByName(self)
        self.setText()

        self.setWindowTitle("Plot Setting")
        self.setWindowIcon(QIcon('resource/icon.ico'))
        self.setWindowIconText('viuplot')
        self.show()
Esempio n. 16
0
    def __init__(self, parent=None):
        super().__init__()
        self.parent = parent
        self.setWindowTitle(self.tr("Disk Partition"))
        self.setLayout(QVBoxLayout())

        self.parent.lilii_settings["/"] = None
        self.parent.lilii_settings["/home"] = None

        hlayout = QHBoxLayout()
        self.layout().addLayout(hlayout)

        hlayout.addSpacerItem(QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Maximum))

        label1 = QLabel()
        label1.setText(self.tr("Select where the Lime GNU/Linux is going to be installed: "))
        hlayout.addWidget(label1)

        self.combo_box = QComboBox()
        self.combo_box.setFixedWidth(400)
        for disk in disksList():
            self.combo_box.addItem("{} - {} ({})".format(disk.model, mbToGB(disk.getSize()), disk.path))

        hlayout.addWidget(self.combo_box)

        self.label2 = QPushButton()
        self.label2.setStyleSheet("border: none;")
        self.label2.setIcon(QIcon(":/images/disk.svg"))
        self.label2.setIconSize(QSize(20, 20))
        self.label2.setText("{}".format(diskType(disksList()[0]) or self.tr("Unknown")))
        hlayout.addWidget(self.label2)

        self.refreshButton = QPushButton()
        self.refreshButton.setIcon(QIcon(":/images/refresh.svg"))
        self.refreshButton.setIconSize(QSize(24, 24))
        self.refreshButton.setToolTip(self.tr("Refresh disk information"))
        hlayout.addWidget(self.refreshButton)

        hlayout.addSpacerItem(QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Maximum))

        self.treePartitionWidget = QTreeWidget()
        self.layout().addWidget(self.treePartitionWidget)

        header = self.treePartitionWidget.headerItem()
        header.setText(0, self.tr("Disk Part"))
        header.setText(1, self.tr("File System"))
        header.setText(2, self.tr("Mount Point"))
        header.setText(3, self.tr("Size"))

        self.treePartitionWidget.setColumnWidth(0, 450)
        self.treePartitionWidget.setColumnWidth(1, 150)
        self.treePartitionWidget.setColumnWidth(2, 200)
        self.treePartitionWidget.setColumnWidth(3, 100)


        hlayout = QHBoxLayout()
        self.layout().addLayout(hlayout)

        hlayout.addSpacerItem(QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Maximum))

        self.editPartitionButton = QPushButton()
        self.editPartitionButton.setText(self.tr("Edit"))
        hlayout.addWidget(self.editPartitionButton)

        self.zeroPartitionButton = QPushButton()
        self.zeroPartitionButton.setText(self.tr("Reset"))
        hlayout.addWidget(self.zeroPartitionButton)



        if not is_efi():
            hlayout = QHBoxLayout()
            self.layout().addLayout(hlayout)

            hlayout.addSpacerItem(QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Maximum))

            bootLabel = QLabel()
            bootLabel.setText(self.tr("Where to install the bootloader:"))
            hlayout.addWidget(bootLabel)

            self.combo_box2 = QComboBox()
            self.combo_box2.setFixedWidth(400)
            for disk in disksList():
                self.combo_box2.addItem("{} - {} ({})".format(disk.model, mbToGB(disk.getSize()), disk.path))

            self.parent.lilii_settings["bootloader"] = disksList()[0].path
            hlayout.addWidget(self.combo_box2)

            hlayout.addSpacerItem(QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Maximum))
            self.combo_box2.currentIndexChanged.connect(self.bootloaderDiskSelect)


            self.parent.lilii_settings["/boot"] = None

        else:
            self.parent.lilii_settings["/boot/efi"] = None

        self.editPartitionButton.clicked.connect(self.diskConnect)
        self.combo_box.currentIndexChanged.connect(self.diskSelect)
        self.zeroPartitionButton.clicked.connect(self.diskPartitionClear)
        self.refreshButton.clicked.connect(self.diskRefresh)

        self.diskPartitionList(diskInfo(disksList()[self.combo_box.currentIndex()]))
    def __init__(self):
        super().__init__()
        self.completed = 0
        self.setWindowTitle('Validation and Ingestion Process')
        self.setFixedSize(1000, 800)
        mainwidget = QWidget()
        self.setCentralWidget(mainwidget)
        mainlayout = QVBoxLayout()
        cleansetitlelayout = QHBoxLayout()
        cleansecontainergrid = QGridLayout()
        cleansecontainergrid.setColumnStretch(1, 4)
        cleansecontainerlayout = QVBoxLayout()
        cleanseinfolayout = QHBoxLayout()
        cleansebuttlayout = QHBoxLayout()
        cleansestatuslayout = QHBoxLayout()
        validationtitlelayout = QHBoxLayout()
        validationcontainergrid = QGridLayout()
        validationcontainergrid.setColumnStretch(1, 4)
        validationcontainerlayout = QVBoxLayout()
        validationinfolayout = QHBoxLayout()
        validationbuttlayout = QHBoxLayout()
        validationstatuslayout = QHBoxLayout()
        logtitlelayout = QHBoxLayout()
        logcontainergrid = QGridLayout()
        ingestioncontainerlayout = QHBoxLayout()
        ingestiblecontainerlayout = QVBoxLayout()
        ingestibletitlelayout = QHBoxLayout()
        ingestibletreelayout = QHBoxLayout()
        noningestiblecontainerlayout = QVBoxLayout()
        noningestibletitlelayout = QHBoxLayout()
        noningestibletreelayout = QHBoxLayout()
        logentrycontainerlayout = QVBoxLayout()
        logentryinfolayout = QHBoxLayout()
        logentrynamelayout = QHBoxLayout()
        logentryteamlayout = QHBoxLayout()
        logentrytimelayout = QHBoxLayout()
        logentrypathlayout = QHBoxLayout()
        logentryboxlayout = QHBoxLayout()
        preingestionlayout = QHBoxLayout()

        hline1 = QFrame()
        hline1.setFrameShape(QFrame.HLine)
        hline2 = QFrame()
        hline2.setFrameShape(QFrame.HLine)
        hline3 = QFrame()
        hline3.setFrameShape(QFrame.HLine)

        vline1 = QFrame()
        vline1.setFrameShape(QFrame.VLine)
        vline2 = QFrame()
        vline2.setFrameShape(QFrame.VLine)

        cleansetitlelabel = QLabel('Cleansing Overview')

        cleansetitlelayout.addStretch()
        cleansetitlelayout.addWidget(cleansetitlelabel)
        cleansetitlelayout.addStretch()

        cleanseinfolabel = QLabel('Cleanse Un-Cleansed Log Files')

        cleanseinfolayout.addStretch()
        cleanseinfolayout.addWidget(cleanseinfolabel)
        cleanseinfolayout.addStretch()

        cleansebutt = QPushButton('Cleanse')

        cleansebuttlayout.addStretch()
        cleansebuttlayout.addWidget(cleansebutt)
        cleansebuttlayout.addStretch()

        cleansestatuslabel = QLabel('Status: All log files are cleansed.')

        cleansestatuslayout.addStretch()
        cleansestatuslayout.addWidget(cleansestatuslabel)
        cleansestatuslayout.addStretch()

        cleansecontainerlayout.addStretch()
        cleansecontainerlayout.addLayout(cleanseinfolayout)
        cleansecontainerlayout.addLayout(cleansebuttlayout)
        cleansecontainerlayout.addLayout(cleansestatuslayout)
        cleansecontainerlayout.addStretch()

        cleansetable = QTableWidget()
        cleanseheaderlabels = ['Location/Name', 'Cleansed']
        self.create_table(cleansetable, cleanseheaderlabels)

        cleansecontainergrid.addLayout(cleansecontainerlayout, 0, 0)
        cleansecontainergrid.addWidget(cleansetable, 0, 1)

        validationtitlelabel = QLabel('Validation Overview')

        validationtitlelayout.addStretch()
        validationtitlelayout.addWidget(validationtitlelabel)
        validationtitlelayout.addStretch()

        validationinfolabel = QLabel('Validate Un-Validated Log Files')

        validationinfolayout.addStretch()
        validationinfolayout.addWidget(validationinfolabel)
        validationinfolayout.addStretch()

        validatebutt = QPushButton('Validate')

        validationbuttlayout.addStretch()
        validationbuttlayout.addWidget(validatebutt)
        validationbuttlayout.addStretch()

        validatestatuslabel = QLabel('Status: All log files are validated.')

        validationstatuslayout.addStretch()
        validationstatuslayout.addWidget(validatestatuslabel)
        validationstatuslayout.addStretch()

        validationcontainerlayout.addStretch()
        validationcontainerlayout.addLayout(validationinfolayout)
        validationcontainerlayout.addLayout(validationbuttlayout)
        validationcontainerlayout.addLayout(validationstatuslayout)
        validationcontainerlayout.addStretch()

        validatetable = QTableWidget()
        validateheaderlabels = ['Location/Name', 'Validated']
        self.create_table(validatetable, validateheaderlabels)

        validationcontainergrid.addLayout(validationcontainerlayout, 0, 0)
        validationcontainergrid.addWidget(validatetable, 0, 1)

        logtitlelabel = QLabel('Log Overview')

        logtitlelayout.addStretch()
        logtitlelayout.addWidget(logtitlelabel)
        logtitlelayout.addStretch()

        ingestibletitlelabel = QLabel('Ingestible Log Entries')

        ingestibletitlelayout.addStretch()
        ingestibletitlelayout.addWidget(ingestibletitlelabel)
        ingestibletitlelayout.addStretch()

        ingestibletree = QTreeWidget()
        data = [
            'Log Entry ####', 'Log Entry ####+1', 'Log Entry ####+2',
            'Log Entry ####+3', 'Log Entry ####+4', 'Log Entry ####+5',
            'Log Entry ####+6', 'Log Entry ####+7', 'Log Entry ####+8'
        ]
        self.create_treelist(ingestibletree, data)

        ingestibletreelayout.addStretch()
        ingestibletreelayout.addWidget(ingestibletree)
        ingestibletreelayout.addStretch()

        ingestiblecontainerlayout.addLayout(ingestibletitlelayout)
        ingestiblecontainerlayout.addLayout(ingestibletreelayout)

        noningestibletitlelabel = QLabel('Non-Ingestible Log Entries')

        noningestibletitlelayout.addStretch()
        noningestibletitlelayout.addWidget(noningestibletitlelabel)
        noningestibletitlelayout.addStretch()

        noningestibletree = QTreeWidget()
        nondata = [
            'Log Entry ####', 'Log Entry ####+1', 'Log Entry ####+2',
            'Log Entry ####+3', 'Log Entry ####+4', 'Log Entry ####+5',
            'Log Entry ####+6', 'Log Entry ####+7', 'Log Entry ####+8'
        ]
        self.create_treelist(noningestibletree, nondata)

        noningestibletreelayout.addStretch()
        noningestibletreelayout.addWidget(noningestibletree)
        noningestibletreelayout.addStretch()

        noningestiblecontainerlayout.addLayout(noningestibletitlelayout)
        noningestiblecontainerlayout.addLayout(noningestibletreelayout)

        ingestioncontainerlayout.addLayout(ingestiblecontainerlayout)
        ingestioncontainerlayout.addWidget(vline1)
        ingestioncontainerlayout.addLayout(noningestiblecontainerlayout)
        ingestioncontainerlayout.addWidget(vline2)

        logentryinfolabel = QLabel('Selected Log Entry Information')

        logentryinfolayout.addStretch()
        logentryinfolayout.addWidget(logentryinfolabel)
        logentryinfolayout.addStretch()

        logentrynamelabel = QLabel('Name: Log Entry ####')

        logentrynamelayout.addStretch()
        logentrynamelayout.addWidget(logentrynamelabel)
        logentrynamelayout.addStretch()

        logentryteamlabel = QLabel('Team: R|B|W')

        logentryteamlayout.addStretch()
        logentryteamlayout.addWidget(logentryteamlabel)
        logentryteamlayout.addStretch()

        logentrytimelabel = QLabel('Timestamp: Time of the Log Entry')

        logentrytimelayout.addStretch()
        logentrytimelayout.addWidget(logentrytimelabel)
        logentrytimelayout.addStretch()

        logentrypathlabel = QLabel(
            'File Path: File path of file that created the Log Entry')

        logentrypathlayout.addStretch()
        logentrypathlayout.addWidget(logentrypathlabel)
        logentrypathlayout.addStretch()

        logentrydatalabel = QLabel('Data:    ')
        logentrydataptedit = QPlainTextEdit(
            'Any data corresponding to this log entry will go here.')

        logentryboxlayout.addStretch()
        logentryboxlayout.addWidget(logentrydatalabel)
        logentryboxlayout.addWidget(logentrydataptedit)
        logentryboxlayout.addStretch()

        logentrycontainerlayout.addLayout(logentryinfolayout)
        logentrycontainerlayout.addLayout(logentrynamelayout)
        logentrycontainerlayout.addLayout(logentryteamlayout)
        logentrycontainerlayout.addLayout(logentrytimelayout)
        logentrycontainerlayout.addLayout(logentrypathlayout)
        logentrycontainerlayout.addLayout(logentryboxlayout)

        logcontainergrid.addLayout(ingestioncontainerlayout, 0, 0)
        logcontainergrid.addLayout(logentrycontainerlayout, 0, 1)

        nontoingestbutt = QPushButton(
            'Move all Non-Ingestible Log Entries into Ingestible')
        discardbutt = QPushButton('Discard All Non-Ingestible Log Entries')
        ingestbutt = QPushButton(
            'Ingest Log Entries and Continue to Navigator')
        ingestbutt.clicked.connect(self.on_ingest_button_clicked)

        preingestionlayout.addStretch()
        preingestionlayout.addWidget(nontoingestbutt)
        preingestionlayout.addStretch()
        preingestionlayout.addWidget(discardbutt)
        preingestionlayout.addStretch()
        preingestionlayout.addWidget(ingestbutt)
        preingestionlayout.addStretch()

        mainlayout.addLayout(cleansetitlelayout)
        mainlayout.addLayout(cleansecontainergrid)
        mainlayout.addWidget(hline1)
        mainlayout.addLayout(validationtitlelayout)
        mainlayout.addLayout(validationcontainergrid)
        mainlayout.addWidget(hline2)
        mainlayout.addLayout(logtitlelayout)
        mainlayout.addLayout(logcontainergrid)
        mainlayout.addWidget(hline3)
        mainlayout.addLayout(preingestionlayout)
        mainwidget.setLayout(mainlayout)
Esempio n. 18
0
    def setup_ui(self, delete_roi_window_instance, regions_of_interest, dataset_rtss, deleting_rois_structure_tuple):
        # Initialise the 2 lists for containing the ROI(s) that we are going to keep and delete respectively
        self.regions_of_interest_to_keep = []
        self.regions_of_interest_to_delete = []
        # This is for holding the original list of ROI(s)
        self.regions_of_interest_list = regions_of_interest
        # This is for holding the DICOM dataset of that specific patient
        self.dataset_rtss = dataset_rtss
        # Assigning new tuple for holding the deleting ROI(s)
        self.deleting_rois_structure_tuple = deleting_rois_structure_tuple

        # Initialise a DeleteROIWindow
        if platform.system() == 'Darwin':
            self.stylesheet_path = "src/res/stylesheet.qss"
        else:
            self.stylesheet_path = "src/res/stylesheet-win-linux.qss"
        stylesheet = open(resource_path(self.stylesheet_path)).read()
        window_icon = QIcon()
        window_icon.addPixmap(QPixmap(resource_path("src/res/images/icon.ico")), QIcon.Normal, QIcon.Off)
        delete_roi_window_instance.setObjectName("DeleteRoiWindowInstance")
        delete_roi_window_instance.setWindowIcon(window_icon)
        delete_roi_window_instance.resize(800, 606)

        # Create a vertical box to hold all widgets
        self.delete_roi_window_instance_vertical_box = QVBoxLayout()
        self.delete_roi_window_instance_vertical_box.setObjectName("DeleteRoiWindowInstanceVerticalBox")

        # Create a label for holding the window's title
        self.delete_roi_window_title = QLabel()
        self.delete_roi_window_title.setObjectName("DeleteRoiWindowTitle")
        self.delete_roi_window_title.setProperty("QLabelClass", "window-title")
        self.delete_roi_window_title.setAlignment(Qt.AlignLeft)
        self.delete_roi_window_instance_vertical_box.addWidget(self.delete_roi_window_title)

        # Create a label for holding the instruction of how to delete the ROIs
        self.delete_roi_window_instruction = QLabel()
        self.delete_roi_window_instruction.setObjectName("DeleteRoiWindowInstruction")
        self.delete_roi_window_instruction.setAlignment(Qt.AlignCenter)
        self.delete_roi_window_instance_vertical_box.addWidget(self.delete_roi_window_instruction)


        # Create a horizontal box for holding the 2 lists and the move left, move right buttons
        self.delete_roi_window_keep_and_delete_box = QHBoxLayout()
        self.delete_roi_window_keep_and_delete_box.setObjectName("DeleteRoiWindowKeepAndDeleteBox")
        # ================================= KEEP BOX =================================
        # Create a vertical box for holding the label and the tree view for holding the ROIs that we are keeping
        self.delete_roi_window_keep_vertical_box = QVBoxLayout()
        self.delete_roi_window_keep_vertical_box.setObjectName("DeleteRoiWindowKeepVerticalBox")
        # Create a label for the tree view with the list of ROIs to keep
        self.delete_roi_window_keep_tree_view_label = QLabel()
        self.delete_roi_window_keep_tree_view_label.setObjectName("DeleteRoiWindowKeepTreeViewLabel")
        self.delete_roi_window_keep_tree_view_label.setProperty("QLabelClass", ["tree-view-label", "tree-view-label-keep-delete"])
        self.delete_roi_window_keep_tree_view_label.setAlignment(Qt.AlignCenter)
        self.delete_roi_window_keep_tree_view_label.setSizePolicy(
            QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
        self.delete_roi_window_keep_tree_view_label.resize(self.delete_roi_window_keep_tree_view_label.sizeHint().width(),
                                                      self.delete_roi_window_keep_tree_view_label.sizeHint().height())
        self.delete_roi_window_keep_vertical_box.addWidget(self.delete_roi_window_keep_tree_view_label)
        # Create a tree view for containing the list of ROIs to keep
        self.delete_roi_window_keep_tree_view = QTreeWidget()
        self.delete_roi_window_keep_tree_view.setObjectName("DeleteRoiWindowKeepTreeView")
        self.delete_roi_window_keep_tree_view.setHeaderHidden(True)
        self.delete_roi_window_keep_tree_view.setSizePolicy(
            QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
        self.delete_roi_window_keep_tree_view.resize(
            self.delete_roi_window_keep_tree_view.sizeHint().width(),
            self.delete_roi_window_keep_tree_view.sizeHint().height())
        self.delete_roi_window_keep_vertical_box.addWidget(self.delete_roi_window_keep_tree_view)
        self.delete_roi_window_keep_vertical_box.setStretch(1, 4)
        # Create a widget to hold the keep vertical box
        self.delete_roi_window_keep_widget = QWidget()
        self.delete_roi_window_keep_widget.setObjectName("DeleteRoiWindowKeepWidget")
        self.delete_roi_window_keep_widget.setLayout(self.delete_roi_window_keep_vertical_box)
        self.delete_roi_window_keep_and_delete_box.addStretch(1)
        self.delete_roi_window_keep_and_delete_box.addWidget(self.delete_roi_window_keep_widget)
        # ================================= KEEP BOX =================================


        # ================================= MOVE LEFT/RIGHT BOX =================================
        # Create a vertical box for holding the 2 buttons for moving left and right
        self.delete_roi_window_move_left_right_vertical_box = QVBoxLayout()
        self.delete_roi_window_move_left_right_vertical_box.setObjectName("DeleteRoiWindowMoveLeftRightVerticalBox")
        # Create Move Right Button / Delete Button
        self.move_right_button = QPushButton()
        self.move_right_button.setObjectName("MoveRightButton")
        self.move_right_button.setSizePolicy(
            QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
        self.move_right_button.resize(self.move_right_button.sizeHint().width(),
                                                    self.move_right_button.sizeHint().height())
        self.move_right_button.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.move_right_button.clicked.connect(self.move_right_button_onClicked)
        self.move_right_button.setProperty("QPushButtonClass", "fail-button")
        self.delete_roi_window_move_left_right_vertical_box.addStretch(1)
        self.delete_roi_window_move_left_right_vertical_box.addWidget(self.move_right_button)
        # Create Move Left Button / Keep Button
        self.move_left_button = QPushButton()
        self.move_left_button.setObjectName("MoveLeftButton")
        self.move_left_button.setSizePolicy(
            QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
        self.move_left_button.resize(self.move_left_button.sizeHint().width(),
                                      self.move_left_button.sizeHint().height())
        self.move_left_button.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.move_left_button.clicked.connect(self.move_left_button_onClicked)
        self.move_left_button.setProperty("QPushButtonClass", "success-button")
        self.delete_roi_window_move_left_right_vertical_box.addWidget(self.move_left_button)
        self.delete_roi_window_move_left_right_vertical_box.addStretch(1)
        # Create a widget for holding the 2 buttons
        self.delete_roi_window_move_left_right_widget = QWidget()
        self.delete_roi_window_move_left_right_widget.setObjectName("DeleteRoiWindowMoveLeftRightWidget")
        self.delete_roi_window_move_left_right_widget.setLayout(self.delete_roi_window_move_left_right_vertical_box)
        self.delete_roi_window_keep_and_delete_box.addWidget(self.delete_roi_window_move_left_right_widget)
        # ================================= MOVE LEFT/RIGHT BOX =================================


        # ================================= DELETE BOX =================================
        # Create a vertical box for holding the label and the tree view for holding the ROIs that we are deleting
        self.delete_roi_window_delete_vertical_box = QVBoxLayout()
        self.delete_roi_window_delete_vertical_box.setObjectName("DeleteRoiWindowDeleteVerticalBox")
        # Create a label for the tree view with the list of ROIs to delete
        self.delete_roi_window_delete_tree_view_label = QLabel()
        self.delete_roi_window_delete_tree_view_label.setObjectName("DeleteRoiWindowDeleteTreeViewLabel")
        self.delete_roi_window_delete_tree_view_label.setProperty("QLabelClass",
                                                                ["tree-view-label", "tree-view-label-keep-delete"])
        self.delete_roi_window_delete_tree_view_label.setAlignment(Qt.AlignCenter)
        self.delete_roi_window_delete_tree_view_label.setSizePolicy(
            QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
        self.delete_roi_window_delete_tree_view_label.resize(
            self.delete_roi_window_delete_tree_view_label.sizeHint().width(),
            self.delete_roi_window_delete_tree_view_label.sizeHint().height())
        self.delete_roi_window_delete_vertical_box.addWidget(self.delete_roi_window_delete_tree_view_label)
        # Create a tree view for containing the list of ROIs to delete
        self.delete_roi_window_delete_tree_view = QTreeWidget()
        self.delete_roi_window_delete_tree_view.setObjectName("DeleteRoiWindowDeleteTreeView")
        self.delete_roi_window_delete_tree_view.setHeaderHidden(True)
        self.delete_roi_window_delete_tree_view.setSizePolicy(
            QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
        self.delete_roi_window_delete_tree_view.resize(
            self.delete_roi_window_delete_tree_view.sizeHint().width(),
            self.delete_roi_window_delete_tree_view.sizeHint().height())
        self.delete_roi_window_delete_vertical_box.addWidget(self.delete_roi_window_delete_tree_view)
        self.delete_roi_window_delete_vertical_box.setStretch(1, 4)
        # Create a widget to hold the delete vertical box
        self.delete_roi_window_delete_widget = QWidget()
        self.delete_roi_window_delete_widget.setObjectName("DeleteRoiWindowDeleteWidget")
        self.delete_roi_window_delete_widget.setLayout(self.delete_roi_window_delete_vertical_box)
        self.delete_roi_window_keep_and_delete_box.addWidget(self.delete_roi_window_delete_widget)
        self.delete_roi_window_keep_and_delete_box.addStretch(1)
        self.delete_roi_window_keep_and_delete_box.setStretch(1, 4)
        self.delete_roi_window_keep_and_delete_box.setStretch(3, 4)
        # ================================= DELETE BOX =================================
        # Create a widget to hold the keep and delete box
        self.delete_roi_window_keep_and_delete_widget = QWidget()
        self.delete_roi_window_keep_and_delete_widget.setObjectName("DeleteRoiWindowKeepAndDeleteWidget")
        self.delete_roi_window_keep_and_delete_widget.setLayout(self.delete_roi_window_keep_and_delete_box)
        self.delete_roi_window_instance_vertical_box.addWidget(self.delete_roi_window_keep_and_delete_widget)


        # Create a horizontal box to hold 2 action buttons for this window
        self.delete_roi_window_action_buttons_box = QHBoxLayout()
        self.delete_roi_window_action_buttons_box.setObjectName("DeleteRoiWindowActionButtonsBox")
        # Create the cancel button
        self.delete_roi_window_cancel_button = QPushButton()
        self.delete_roi_window_cancel_button.setObjectName("DeleteRoiWindowCancelButton")
        self.delete_roi_window_cancel_button.setSizePolicy(
            QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
        self.delete_roi_window_cancel_button.resize(self.delete_roi_window_cancel_button.sizeHint().width(),
                                     self.delete_roi_window_cancel_button.sizeHint().height())
        self.delete_roi_window_cancel_button.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.delete_roi_window_cancel_button.clicked.connect(self.on_cancel_button_clicked)
        self.delete_roi_window_cancel_button.setProperty("QPushButtonClass", "fail-button")
        self.delete_roi_window_action_buttons_box.addStretch(1)
        self.delete_roi_window_action_buttons_box.addWidget(self.delete_roi_window_cancel_button)
        # Create the confirm button
        self.delete_roi_window_confirm_button = QPushButton()
        self.delete_roi_window_confirm_button.setObjectName("DeleteRoiWindowConfirmButton")
        self.delete_roi_window_confirm_button.setSizePolicy(
            QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
        self.delete_roi_window_confirm_button.resize(self.delete_roi_window_confirm_button.sizeHint().width(),
                                                    self.delete_roi_window_confirm_button.sizeHint().height())
        self.delete_roi_window_confirm_button.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.delete_roi_window_confirm_button.clicked.connect(self.confirm_button_onClicked)
        self.delete_roi_window_confirm_button.setEnabled(False)
        self.delete_roi_window_confirm_button.setProperty("QPushButtonClass", "success-button")
        self.delete_roi_window_action_buttons_box.addWidget(self.delete_roi_window_confirm_button)
        # Create a widget to hold the action buttons
        self.delete_roi_window_action_buttons_widget = QWidget()
        self.delete_roi_window_action_buttons_widget.setObjectName("DeleteRoiWindowActionButtonsWidget")
        self.delete_roi_window_action_buttons_widget.setLayout(self.delete_roi_window_action_buttons_box)
        self.delete_roi_window_instance_vertical_box.addWidget(self.delete_roi_window_action_buttons_widget)

        # Set text for all attributes
        self.retranslate_ui(delete_roi_window_instance)
        # Create a central widget to hold the vertical layout box
        self.delete_roi_window_instance_central_widget = QWidget()
        self.delete_roi_window_instance_central_widget.setObjectName("DeleteRoiWindowInstanceCentralWidget")
        self.delete_roi_window_instance_central_widget.setLayout(self.delete_roi_window_instance_vertical_box)
        self.delete_roi_window_instance_vertical_box.setStretch(2, 4)
        # Set the central widget for the main window and style the window
        delete_roi_window_instance.setCentralWidget(self.delete_roi_window_instance_central_widget)
        delete_roi_window_instance.setStyleSheet(stylesheet)

        # Load the ROIs in
        self.display_rois_in_listViewKeep()
        # Set the selection mode to multi so that we can select multiple ROIs to delete
        self.delete_roi_window_keep_tree_view.setSelectionMode(QAbstractItemView.MultiSelection)
        self.delete_roi_window_delete_tree_view.setSelectionMode(QAbstractItemView.MultiSelection)

        QtCore.QMetaObject.connectSlotsByName(delete_roi_window_instance)
Esempio n. 19
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(970, 650)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.horizontalLayout = QtWidgets.QHBoxLayout(self.centralwidget)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.splitter = QtWidgets.QSplitter(self.centralwidget)
        self.splitter.setOrientation(QtCore.Qt.Horizontal)
        self.splitter.setHandleWidth(1)
        self.splitter.setObjectName("splitter")
        self.horizontalLayout.addWidget(self.splitter)
        MainWindow.setCentralWidget(self.centralwidget)

        # 文件树形目录浏览器
        self.tree = QTreeView()
        self.model = QtWidgets.QFileSystemModel()
        self.model.setRootPath('')
        self.nameFile = ["*.png", "*.jpg", "*.jpeg"]
        self.model.setNameFilterDisables(False)
        self.model.setNameFilters(self.nameFile)
        self.tree.setModel(self.model)
        self.tree.setAnimated(False)
        self.tree.setIndentation(20)
        self.tree.setWindowTitle("Dir View")
        self.tree.setSortingEnabled(True)
        self.tree.setColumnHidden(1, True)
        self.tree.setColumnHidden(2, True)
        self.tree.setColumnHidden(3, True)
        self.tree.doubleClicked.connect(self.openFileFromTreeList)
        # 图库管理器
        self.tree_2 = QTreeWidget()
        self.tree_2.setColumnCount(1)
        # 设置表头信息:隐藏表头
        self.tree_2.setHeaderHidden(1)
        # 设置root和root2为self.tree的子树,所以root和root2就是跟节点
        root = QTreeWidgetItem(self.tree_2)
        root2 = QTreeWidgetItem(self.tree_2)
        # 设置根节点的名称
        root.setText(0, '第一节点')
        root2.setText(0, '第二节点')
        # 为root节点设置子结点
        child1 = QTreeWidgetItem(root)
        child1.setText(0, 'child1')
        child1.setText(1, 'name1')
        child2 = QTreeWidgetItem(root)
        # 设置child2节点的图片
        child2.setText(0, 'child2')
        child2.setText(1, 'name2')

        # 实例化QToolBox
        self.toolBox = QToolBox()
        # 设置左侧导航栏 toolBox 在左右拉拽时的最小宽度
        self.toolBox.setMinimumWidth(100)
        # 给QToolBox添加两个子项目
        self.toolBox.addItem(self.tree, "文件资源")
        self.toolBox.addItem(self.tree_2, "图库")

        # 给QSplitter添加第一个窗体(QToolBox)
        self.splitter.addWidget(self.toolBox)

        #菜单栏
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(10, 10, 820, 30))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.menu1_file = QtWidgets.QMenu(self.menubar)
        self.menu1_file.setObjectName("menu1_file")
        self.menu2_edit = QtWidgets.QMenu(self.menubar)
        self.menu2_edit.setObjectName("menu2_edit")
        self.menu3_imageLib = QtWidgets.QMenu(self.menubar)
        self.menu3_imageLib.setObjectName("menu3_imageLib")
        self.menu4_image = QtWidgets.QMenu(self.menubar)
        self.menu4_image.setObjectName("menu4_image")
        self.menu6_user = QtWidgets.QMenu(self.menubar)
        self.menu6_user.setObjectName("menu6_user")
        self.menu5_help = QtWidgets.QMenu(self.menubar)
        self.menu5_help.setObjectName("menu5_help")
        MainWindow.setMenuBar(self.menubar)

        #menu Action
        #################action1######################
        self.action_1_1 = QtWidgets.QAction(MainWindow)
        self.action_1_1.setObjectName("action_1_1")  #打开
        self.action_1_1.triggered.connect(self.openfile)
        self.action_1_2 = QtWidgets.QAction(MainWindow)
        self.action_1_2.setObjectName("action_1_2")  #保存
        self.action_1_3 = QtWidgets.QAction(MainWindow)
        self.action_1_3.setObjectName("action_1_3")  #退出
        #################action2######################
        self.action_2_1 = QtWidgets.QAction(MainWindow)
        self.action_2_1.setObjectName("action_2_1")  #图片编辑
        self.action_2_1.triggered.connect(self.openChildWindow)
        #################action3######################
        self.action_3_1 = QtWidgets.QAction(MainWindow)
        self.action_3_1.setObjectName("action_3_1")  #图库管理器
        self.action_3_1.triggered.connect(self.imageLibUi)
        #################action4######################
        self.action_4_1 = QtWidgets.QAction(MainWindow)
        self.action_4_1.setObjectName("action_4_1")  # 添加图片
        self.action_4_2 = QtWidgets.QAction(MainWindow)
        self.action_4_2.setObjectName("action_4_2")  # 删除图片
        self.action_4_3 = QtWidgets.QAction(MainWindow)
        self.action_4_3.setObjectName("action_4_3")  # 重命名
        #################action5######################
        self.action_5 = QtWidgets.QAction(MainWindow)
        self.action_5.setObjectName("action_5")  #帮助
        #################action6######################
        self.action_6 = QtWidgets.QAction(MainWindow)
        self.action_6.setObjectName("action_6")  #用户管理
        self.action_6.triggered.connect(self.userManager)

        #给menu添加Action
        self.menu1_file.addAction(self.action_1_1)  #打开
        self.menu1_file.addAction(self.action_1_2)  #保存
        self.menu1_file.addAction(self.action_1_3)  #退出
        self.menu2_edit.addAction(self.action_2_1)  #图片编辑
        self.menu3_imageLib.addAction(self.action_3_1)  #图库管理器
        self.menu4_image.addAction(self.action_4_1)  #添加图片
        self.menu4_image.addAction(self.action_4_2)  #删除图片
        self.menu4_image.addAction(self.action_4_3)  #重命名
        self.menu6_user.addAction(self.action_6)  #用户管理
        self.menu5_help.addAction(self.action_5)  #帮助
        self.menubar.addAction(self.menu1_file.menuAction())
        self.menubar.addAction(self.menu2_edit.menuAction())
        self.menubar.addAction(self.menu3_imageLib.menuAction())
        self.menubar.addAction(self.menu4_image.menuAction())
        self.menubar.addAction(self.menu5_help.menuAction())
        self.menubar.addAction(self.menu6_user.menuAction())

        #Icon
        icon = QtGui.QIcon()
        icon2 = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("Icon/openfile.png"), QtGui.QIcon.Normal,
                       QtGui.QIcon.Off)
        icon2.addPixmap(QtGui.QPixmap("Icon/edit.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.action_1_1.setIcon(icon)
        self.action_2_1.setIcon(icon2)

        #工具栏
        self.toolBar = QtWidgets.QToolBar(MainWindow)
        self.toolBar.setInputMethodHints(QtCore.Qt.ImhHiddenText
                                         | QtCore.Qt.ImhSensitiveData)
        self.toolBar.setObjectName("toolBar")
        MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)
        self.toolBar.addAction(self.action_1_1)
        self.toolBar.addAction(self.action_2_1)

        #状态栏
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        #初始化默认窗体
        #初始化默认窗体(图片显示窗体)
        self.imageView = ImageView()
        # 在主窗口里添加子窗口
        self.splitter.addWidget(self.imageView)

        #是普通用户还是管理员
        self

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

        # 创建默认存放文件的文件夹:
        cur_dir = "C:"
        folder_name = 'InfraredImage'
        if os.path.isdir("C:/InfraredImage"):
            print("Already exist!")
        else:
            os.mkdir(os.path.join(cur_dir, folder_name))
            os.mkdir("C:/InfraredImage/TmpImg")
Esempio n. 20
0
    def __init__(self, context, parent=None):
        """
        :type context: segyviewlib.SliceViewContext
        :type parent: QObject
        """
        QWidget.__init__(self, parent, Qt.WindowStaysOnTopHint | Qt.Window)
        self.setVisible(False)

        self._context = context
        self._context.context_changed.connect(self._settings_changed)
        self._context.data_changed.connect(self._settings_changed)
        self._context.data_source_changed.connect(self._settings_changed)

        f_layout = QFormLayout()

        self._iline_count = QLabel("")
        self._xline_count = QLabel("")
        self._offset_count = QLabel("")
        self._sample_count = QLabel("")
        self._minimum_value = QLabel("")
        self._maximum_value = QLabel("")

        f_layout.addRow("Inline Count:", self._iline_count)
        f_layout.addRow("Crossline Count:", self._xline_count)
        f_layout.addRow("Offset Count:", self._offset_count)
        f_layout.addRow("Sample Count:", self._sample_count)

        if self._context._has_data:
            f_layout.addRow("Minimum Value:", self._minimum_value)
            f_layout.addRow("Maximum Value:", self._maximum_value)

        # iline
        self._il_ctrl = IndexController(parent=self,
                                        context=self._context,
                                        slice_direction_index_source=SliceDirection.inline)
        self._il_ctrl.index_changed.connect(self._index_changed_fn(SliceDirection.inline))
        self._il_ctrl.min_max_changed.connect(self.iline_limits_changed)

        # xline
        self._xl_ctrl = IndexController(parent=self,
                                        context=self._context,
                                        slice_direction_index_source=SliceDirection.crossline)
        self._xl_ctrl.index_changed.connect(self._index_changed_fn(SliceDirection.crossline))
        self._xl_ctrl.min_max_changed.connect(self.xline_limits_changed)

        # depth
        self._depth_ctrl = IndexController(parent=self,
                                           context=self._context,
                                           slice_direction_index_source=SliceDirection.depth)
        self._depth_ctrl.index_changed.connect(self._index_changed_fn(SliceDirection.depth))
        self._depth_ctrl.min_max_changed.connect(self.depth_limits_changed)

        # sample
        self._sample_ctrl = SampleScaleController(self)
        self._sample_ctrl.min_max_changed.connect(self.sample_limits_changed)

        self._symmetric_scale = QCheckBox()
        self._symmetric_scale.toggled.connect(self._context.set_symmetric_scale)

        self._samples_unit = QComboBox()
        self._samples_unit.addItems(['Time (ms)', 'Depth (m)'])
        self._samples_unit.currentIndexChanged[str].connect(self.samples_unit)

        # view
        self._view_label = QLabel("")
        self._view_label.setDisabled(True)
        self._indicator_visibility = QCheckBox()
        self._indicator_visibility.toggled.connect(self._show_indicators)
        self._indicator_visibility.toggled.connect(lambda: self._set_view_label(self._indicator_visibility.isChecked()))

        self._interpolation_combo = QComboBox()
        self._interpolations_names = ['nearest', 'catrom', 'sinc']
        self._interpolation_combo.addItems(self._interpolations_names)
        self._interpolation_combo.currentIndexChanged.connect(self._interpolation_changed)

        # plot export settings
        self._plt_settings_wdgt = PlotExportSettingsWidget(self, parent._slice_view_widget, self._context)

        # define tree layout
        tree_def = {"": [
            {"Inline": [{"set_expanded": True},
                        {"": self._align(self._il_ctrl.current_index_label)},
                        {"Inline:": self._align(self._il_ctrl.index_widget)},
                        {"Minimum:": self._align(self._il_ctrl.min_spinbox, self._il_ctrl.min_checkbox)},
                        {"Maximum:": self._align(self._il_ctrl.max_spinbox, self._il_ctrl.max_checkbox)}
                        ]
             },
            {"Crossline": [{"set_expanded": True},
                           {"": self._align(self._xl_ctrl.current_index_label)},
                           {"Crossline:": self._align(self._xl_ctrl.index_widget)},
                           {"Minimum:": self._align(self._xl_ctrl.min_spinbox, self._xl_ctrl.min_checkbox)},
                           {"Maximum:": self._align(self._xl_ctrl.max_spinbox, self._xl_ctrl.max_checkbox)}
                           ]
             },
            {"Depth": [{"set_expanded": True},
                       {"": self._align(self._depth_ctrl.current_index_label)},
                       {"Depth:": self._align(self._depth_ctrl.index_widget)},
                       {"Minimum:": self._align(self._depth_ctrl.min_spinbox, self._depth_ctrl.min_checkbox)},
                       {"Maximum:": self._align(self._depth_ctrl.max_spinbox, self._depth_ctrl.max_checkbox)},
                       {"Type": self._align(self._samples_unit)}
                       ]
             },
            {"Color Scale": [
                {"Custom min.:": self._align(self._sample_ctrl.min_spinbox, self._sample_ctrl.min_checkbox)},
                {"Custom max.:": self._align(self._sample_ctrl.max_spinbox, self._sample_ctrl.max_checkbox)},
                {"Symmetric scale:": self._align(self._symmetric_scale)}
            ]
            },
            {"View": [{"": self._align(self._view_label)},
                      {"Show Indicators:": self._align(self._indicator_visibility)},
                      {"Interpolation Type:": self._align(self._interpolation_combo)}
                      ]
             },
            {"Plot export dimensions": [
                {"": self._align(self._plt_settings_wdgt.label)},
                {"Fixed size": self._align(self._plt_settings_wdgt.checkbox)},
                {"Width:": self._align(self._plt_settings_wdgt.width_spinbox)},
                {"Height:": self._align(self._plt_settings_wdgt.height_spinbox)},
                {"Units:": self._align(self._plt_settings_wdgt.units_combobox)}
            ]
            }
        ]}

        # setup the menu/navigation tree widget
        self._tree = QTreeWidget(self)
        self._tree.setHeaderHidden(True)
        self._tree.setColumnCount(2)
        self._tree.setColumnWidth(0, 140)
        self._tree.setColumnWidth(1, 180)

        self._build_tree(self._tree, tree_def, self._tree.invisibleRootItem())

        # layout
        vertical_layout = QVBoxLayout()
        button_layout = QHBoxLayout()
        button_layout.setContentsMargins(0, 0, 0, 0)
        close_button = QPushButton("Close")
        close_button.clicked.connect(self.close)
        button_layout.addStretch()
        button_layout.addWidget(close_button)

        vertical_layout.addLayout(f_layout, 0)
        vertical_layout.addStretch()
        vertical_layout.addWidget(self._tree, 1)
        vertical_layout.addStretch()
        vertical_layout.addLayout(button_layout, 0)

        self.setLayout(vertical_layout)
        self.setMinimumSize(390, 740)
Esempio n. 21
0
    def test(self):
        company = self.search_bar.get()

        # Noms d'entreprise déjà présente dans la Bdd Utile pour les Tests
        c0 = mydb.cursor()
        nom_ent = """Select nom_ent from entreprise"""
        c0.execute(nom_ent)
        d0 = c0.fetchall()
        for row in d0:
            print(row)

        # Récupération du numéro d'entreprise correspondant au nom
        entreprise = (self.search_bar.get(), )
        print("\n")
        c1 = mydb.cursor(prepared=True)
        no_ent = """Select no_ent from entreprise where nom_ent = %s"""
        c1.execute(no_ent, entreprise)
        d1 = c1.fetchone()

        # Récupération du numéro d'identification des employés de l'entreprise
        c2 = mydb.cursor(prepared=True)
        id_pers = """Select id_pers from emploi where no_ent = %s"""
        c2.execute(id_pers, d1)
        d2 = c2.fetchall()

        # Affichage des informations des employés
        for row in d2:
            cursor = mydb.cursor(prepared=True)
            requete = """SELECT * FROM personne where id_pers =%s"""
            parametres = (row[0], )
            cursor.execute(requete, parametres)
            data = cursor.fetchall()

            for row in data:
                # Récupération du nom de poste des employés
                c3 = mydb.cursor(prepared=True)
                nom_poste = """SELECT nom_poste FROM personne where id_pers =%s"""
                p2 = (row[0], )
                c3.execute(nom_poste, p2)
                d3 = c3.fetchone()
            # Récupération de l'odre hierarchique des employés
            c6 = mydb.cursor(prepared=True)
            ordre_hier = """SELECT ordre_hierarchique FROM type_poste where nom_type_poste =%s """
            p4 = (d3[0].decode("utf-8"), )
            c6.execute(ordre_hier, p4)
            d6 = c6.fetchone()

        app = QApplication(sys.argv)
        window = QWidget()
        layout = QVBoxLayout(window)

        window.setWindowTitle("Arbre hiérarchique")

        window.resize(1000, 1000)

        trWidget = QTreeWidget()
        trWidget.setHeaderLabels([
            'Numero',
            'Id des employés',
            'Informations personnelles',
            '',
        ])
        # breakpoint()
        nbpersonne = 0
        i = 1
        cg = QTreeWidgetItem(trWidget, [str(d1[0])])
        for id_pers in d2:
            cursor2 = mydb.cursor(prepared=True)
            requete2 = """SELECT * FROM personne where id_pers =%s"""
            parametres2 = (id_pers[0], )
            cursor2.execute(requete2, parametres2)
            data2 = cursor2.fetchone()

            c1 = QTreeWidgetItem(cg, [
                str(data2[0]),
                str(data2[1].decode("utf-8")),
                str(data2[2].decode("utf-8"))
            ])
            c2 = QTreeWidgetItem(c1, [str(data2[3].decode("utf-8"))])
            c3 = QTreeWidgetItem(c2, ["", str(data2[4].decode("utf-8"))])
            c4 = QTreeWidgetItem(c3, ["", str(data2[5].decode("utf-8"))])
            c5 = QTreeWidgetItem(c4, ["", str(data2[6].decode("utf-8"))])
            layout.addWidget(trWidget)

        window.show()

        sys.exit(app.exec_())
Esempio n. 22
0
    def __init__(self, theParent):
        QDialog.__init__(self, theParent)

        logger.debug("Initialising GuiProjectLoad ...")
        self.setObjectName("GuiProjectLoad")

        self.mainConf  = nw.CONFIG
        self.theParent = theParent
        self.theTheme  = theParent.theTheme
        self.openState = self.NONE_STATE
        self.openPath  = None

        sPx = self.mainConf.pxInt(16)
        nPx = self.mainConf.pxInt(96)
        iPx = self.theTheme.baseIconSize

        self.outerBox = QVBoxLayout()
        self.innerBox = QHBoxLayout()
        self.outerBox.setSpacing(sPx)
        self.innerBox.setSpacing(sPx)

        self.setWindowTitle(self.tr("Open Project"))
        self.setMinimumWidth(self.mainConf.pxInt(650))
        self.setMinimumHeight(self.mainConf.pxInt(400))
        self.setModal(True)

        self.nwIcon = QLabel()
        self.nwIcon.setPixmap(self.theParent.theTheme.getPixmap("novelwriter", (nPx, nPx)))
        self.innerBox.addWidget(self.nwIcon, 0, Qt.AlignTop)

        self.projectForm = QGridLayout()
        self.projectForm.setContentsMargins(0, 0, 0, 0)

        self.listBox = QTreeWidget()
        self.listBox.setSelectionMode(QAbstractItemView.SingleSelection)
        self.listBox.setDragDropMode(QAbstractItemView.NoDragDrop)
        self.listBox.setColumnCount(3)
        self.listBox.setHeaderLabels([
            self.tr("Working Title"),
            self.tr("Words"),
            self.tr("Last Opened"),
        ])
        self.listBox.setRootIsDecorated(False)
        self.listBox.itemSelectionChanged.connect(self._doSelectRecent)
        self.listBox.itemDoubleClicked.connect(self._doOpenRecent)
        self.listBox.setIconSize(QSize(iPx, iPx))

        treeHead = self.listBox.headerItem()
        treeHead.setTextAlignment(self.C_COUNT, Qt.AlignRight)
        treeHead.setTextAlignment(self.C_TIME, Qt.AlignRight)

        self.lblRecent = QLabel("<b>%s</b>" % self.tr("Recently Opened Projects"))
        self.lblPath   = QLabel("<b>%s</b>" % self.tr("Path"))
        self.selPath   = QLineEdit("")
        self.selPath.setReadOnly(True)

        self.browseButton = QPushButton("...")
        self.browseButton.setMaximumWidth(int(2.5*self.theTheme.getTextWidth("...")))
        self.browseButton.clicked.connect(self._doBrowse)

        self.projectForm.addWidget(self.lblRecent,    0, 0, 1, 3)
        self.projectForm.addWidget(self.listBox,      1, 0, 1, 3)
        self.projectForm.addWidget(self.lblPath,      2, 0, 1, 1)
        self.projectForm.addWidget(self.selPath,      2, 1, 1, 1)
        self.projectForm.addWidget(self.browseButton, 2, 2, 1, 1)
        self.projectForm.setColumnStretch(0, 0)
        self.projectForm.setColumnStretch(1, 1)
        self.projectForm.setColumnStretch(2, 0)
        self.projectForm.setVerticalSpacing(self.mainConf.pxInt(4))
        self.projectForm.setHorizontalSpacing(self.mainConf.pxInt(8))

        self.innerBox.addLayout(self.projectForm)

        self.buttonBox = QDialogButtonBox(QDialogButtonBox.Open | QDialogButtonBox.Cancel)
        self.buttonBox.accepted.connect(self._doOpenRecent)
        self.buttonBox.rejected.connect(self._doCancel)

        self.newButton = self.buttonBox.addButton(self.tr("New"), QDialogButtonBox.ActionRole)
        self.newButton.clicked.connect(self._doNewProject)

        self.delButton = self.buttonBox.addButton(self.tr("Remove"), QDialogButtonBox.ActionRole)
        self.delButton.clicked.connect(self._doDeleteRecent)

        self.outerBox.addLayout(self.innerBox)
        self.outerBox.addWidget(self.buttonBox)
        self.setLayout(self.outerBox)

        self._populateList()
        self._doSelectRecent()

        keyDelete = QShortcut(self.listBox)
        keyDelete.setKey(QKeySequence(Qt.Key_Delete))
        keyDelete.activated.connect(self._doDeleteRecent)

        logger.debug("GuiProjectLoad initialisation complete")

        return
    def __init__(self, parent):
        super(EditorConfiguration, self).__init__()
        self._preferences, vbox = parent, QVBoxLayout(self)

        # groups
        group1 = QGroupBox(translations.TR_PREFERENCES_EDITOR_CONFIG_INDENT)
        group2 = QGroupBox(translations.TR_PREFERENCES_EDITOR_CONFIG_MARGIN)
        group3 = QGroupBox(translations.TR_LINT_DIRTY_TEXT)
        group4 = QGroupBox(translations.TR_PEP8_DIRTY_TEXT)
        group5 = QGroupBox(translations.TR_HIGHLIGHTER_EXTRAS)
        group6 = QGroupBox(translations.TR_TYPING_ASSISTANCE)
        group7 = QGroupBox(translations.TR_DISPLAY)

        # groups container
        container_widget_with_all_preferences = QWidget()
        formFeatures = QGridLayout(container_widget_with_all_preferences)

        # Indentation
        hboxg1 = QHBoxLayout(group1)
        hboxg1.setContentsMargins(5, 15, 5, 5)
        self._spin, self._checkUseTabs = QSpinBox(), QComboBox()
        self._spin.setRange(1, 10)
        self._spin.setValue(settings.INDENT)
        hboxg1.addWidget(self._spin)
        self._checkUseTabs.addItems([
            translations.TR_PREFERENCES_EDITOR_CONFIG_SPACES.capitalize(),
            translations.TR_PREFERENCES_EDITOR_CONFIG_TABS.capitalize()
        ])
        self._checkUseTabs.setCurrentIndex(int(settings.USE_TABS))
        hboxg1.addWidget(self._checkUseTabs)
        formFeatures.addWidget(group1, 0, 0)

        # Margin Line
        hboxg2 = QHBoxLayout(group2)
        hboxg2.setContentsMargins(5, 15, 5, 5)
        self._checkShowMargin = QCheckBox(
            translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_MARGIN_LINE)
        self._checkShowMargin.setChecked(settings.SHOW_MARGIN_LINE)
        hboxg2.addWidget(self._checkShowMargin)
        self._spinMargin = QSpinBox()
        self._spinMargin.setRange(50, 100)
        self._spinMargin.setSingleStep(2)
        self._spinMargin.setValue(settings.MARGIN_LINE)
        hboxg2.addWidget(self._spinMargin)
        hboxg2.addWidget(QLabel(translations.TR_CHARACTERS))
        formFeatures.addWidget(group2, 0, 1)

        # Display Errors
        vboxDisplay = QVBoxLayout(group7)
        vboxDisplay.setContentsMargins(5, 15, 5, 5)
        self._checkHighlightLine = QComboBox()
        self._checkHighlightLine.addItems([
            translations.TR_PREFERENCES_EDITOR_CONFIG_ERROR_USE_BACKGROUND,
            translations.TR_PREFERENCES_EDITOR_CONFIG_ERROR_USE_UNDERLINE
        ])
        self._checkHighlightLine.setCurrentIndex(
            int(settings.UNDERLINE_NOT_BACKGROUND))
        hboxDisplay1 = QHBoxLayout()
        hboxDisplay1.addWidget(QLabel(translations.TR_DISPLAY_ERRORS))
        hboxDisplay1.addWidget(self._checkHighlightLine)
        hboxDisplay2 = QHBoxLayout()
        self._checkDisplayLineNumbers = QCheckBox(
            translations.TR_DISPLAY_LINE_NUMBERS)
        self._checkDisplayLineNumbers.setChecked(settings.SHOW_LINE_NUMBERS)
        hboxDisplay2.addWidget(self._checkDisplayLineNumbers)
        vboxDisplay.addLayout(hboxDisplay1)
        vboxDisplay.addLayout(hboxDisplay2)
        formFeatures.addWidget(group7, 1, 0, 1, 0)

        # Find Lint Errors (highlighter)
        vboxg3 = QVBoxLayout(group3)
        self._checkErrors = QCheckBox(
            translations.TR_PREFERENCES_EDITOR_CONFIG_FIND_ERRORS)
        self._checkErrors.setChecked(settings.FIND_ERRORS)
        self._checkErrors.stateChanged[int].connect(self._disable_show_errors)
        self._showErrorsOnLine = QCheckBox(
            translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_TOOLTIP_ERRORS)
        self._showErrorsOnLine.setChecked(settings.ERRORS_HIGHLIGHT_LINE)
        self._showErrorsOnLine.stateChanged[int].connect(
            self._enable_errors_inline)
        vboxg3.addWidget(self._checkErrors)
        vboxg3.addWidget(self._showErrorsOnLine)
        vboxg3.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding))
        formFeatures.addWidget(group3, 2, 0)

        # Find PEP8 Errors (highlighter)
        vboxg4 = QHBoxLayout(group4)
        vboxg4.setContentsMargins(5, 15, 5, 5)
        vvbox = QVBoxLayout()
        self._checkStyle = QCheckBox(
            translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_PEP8)
        self._checkStyle.setChecked(settings.CHECK_STYLE)
        self._checkStyle.stateChanged[int].connect(self._disable_check_style)
        vvbox.addWidget(self._checkStyle)
        self._checkStyleOnLine = QCheckBox(
            translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_TOOLTIP_PEP8)
        self._checkStyleOnLine.setChecked(settings.CHECK_HIGHLIGHT_LINE)
        self._checkStyleOnLine.stateChanged[int].connect(
            self._enable_check_inline)
        vvbox.addWidget(self._checkStyleOnLine)
        vvbox.addItem(
            QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding))
        vboxg4.addLayout(vvbox)
        # Container for tree widget and buttons
        widget = QWidget()
        hhbox = QHBoxLayout(widget)
        hhbox.setContentsMargins(0, 0, 0, 0)
        # Tree Widget with custom item delegate
        # always adds uppercase text
        self._listIgnoreViolations = QTreeWidget()
        self._listIgnoreViolations.setObjectName("ignore_pep8")
        self._listIgnoreViolations.setItemDelegate(ui_tools.CustomDelegate())
        self._listIgnoreViolations.setMaximumHeight(80)
        self._listIgnoreViolations.setHeaderLabel(
            translations.TR_PREFERENCES_EDITOR_CONFIG_IGNORE_PEP8)
        for ic in settings.IGNORE_PEP8_LIST:
            self._listIgnoreViolations.addTopLevelItem(QTreeWidgetItem([ic]))
        hhbox.addWidget(self._listIgnoreViolations)
        box = QVBoxLayout()
        box.setContentsMargins(0, 0, 0, 0)
        btn_add = QPushButton(QIcon(":img/add_small"), '')
        btn_add.setMaximumSize(26, 24)
        btn_add.clicked.connect(self._add_code_pep8)
        box.addWidget(btn_add)
        btn_remove = QPushButton(QIcon(":img/delete_small"), '')
        btn_remove.setMaximumSize(26, 24)
        btn_remove.clicked.connect(self._remove_code_pep8)
        box.addWidget(btn_remove)
        box.addItem(QSpacerItem(0, 0, QSizePolicy.Fixed,
                                QSizePolicy.Expanding))
        hhbox.addLayout(box)
        vboxg4.addWidget(widget)
        formFeatures.addWidget(group4)

        # Show Python3 Migration, DocStrings and Spaces (highlighter)
        vboxg5 = QVBoxLayout(group5)
        vboxg5.setContentsMargins(5, 15, 5, 5)
        self._showMigrationTips = QCheckBox(
            translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_MIGRATION)
        self._showMigrationTips.setChecked(settings.SHOW_MIGRATION_TIPS)
        vboxg5.addWidget(self._showMigrationTips)
        self._checkForDocstrings = QCheckBox(
            translations.TR_PREFERENCES_EDITOR_CONFIG_CHECK_FOR_DOCSTRINGS)
        self._checkForDocstrings.setChecked(settings.CHECK_FOR_DOCSTRINGS)
        vboxg5.addWidget(self._checkForDocstrings)
        self._checkShowSpaces = QCheckBox(
            translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_TABS_AND_SPACES)
        self._checkShowSpaces.setChecked(settings.SHOW_TABS_AND_SPACES)
        vboxg5.addWidget(self._checkShowSpaces)
        self._checkIndentationGuide = QCheckBox(
            translations.TR_SHOW_INDENTATION_GUIDE)
        self._checkIndentationGuide.setChecked(settings.SHOW_INDENTATION_GUIDE)
        vboxg5.addWidget(self._checkIndentationGuide)
        formFeatures.addWidget(group5, 3, 0)

        # End of line, Stop Scrolling At Last Line, Trailing space, Word wrap
        vboxg6 = QVBoxLayout(group6)
        vboxg6.setContentsMargins(5, 15, 5, 5)
        self._checkEndOfLine = QCheckBox(
            translations.TR_PREFERENCES_EDITOR_CONFIG_END_OF_LINE)
        self._checkEndOfLine.setChecked(settings.USE_PLATFORM_END_OF_LINE)
        vboxg6.addWidget(self._checkEndOfLine)
        self._checkEndAtLastLine = QCheckBox(
            translations.TR_PREFERENCES_EDITOR_CONFIG_END_AT_LAST_LINE)
        self._checkEndAtLastLine.setChecked(settings.END_AT_LAST_LINE)
        vboxg6.addWidget(self._checkEndAtLastLine)
        self._checkTrailing = QCheckBox(
            translations.TR_PREFERENCES_EDITOR_CONFIG_REMOVE_TRAILING)
        self._checkTrailing.setChecked(settings.REMOVE_TRAILING_SPACES)
        vboxg6.addWidget(self._checkTrailing)
        self._allowWordWrap = QCheckBox(
            translations.TR_PREFERENCES_EDITOR_CONFIG_WORD_WRAP)
        self._allowWordWrap.setChecked(settings.ALLOW_WORD_WRAP)
        vboxg6.addWidget(self._allowWordWrap)
        formFeatures.addWidget(group6, 3, 1)

        # pack all the groups
        vbox.addWidget(container_widget_with_all_preferences)
        vbox.addItem(
            QSpacerItem(0, 10, QSizePolicy.Expanding, QSizePolicy.Expanding))

        self._preferences.savePreferences.connect(self.save)
Esempio n. 24
0
    def __init__(self, parent: QWidget, filename: str,
                 torrent_info: TorrentInfo,
                 control_thread: 'ControlManagerThread'):
        super().__init__(parent)

        self.app = QApplication.instance()

        self._torrent_filepath = Path(filename)

        self._torrent_info = torrent_info
        download_info = torrent_info.download_info
        self._control_thread = control_thread
        self._control = control_thread.control

        vbox = QVBoxLayout(self)

        self._download_dir = self.get_directory(
            self._control.last_download_dir)

        vbox.addWidget(QLabel('Download directory:'))
        vbox.addWidget(self._get_directory_browse_widget())

        vbox.addWidget(QLabel('Announce URLs:'))

        url_tree = QTreeWidget()
        url_tree.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
        url_tree.header().close()
        vbox.addWidget(url_tree)
        for i, tier in enumerate(torrent_info.announce_list):
            tier_item = QTreeWidgetItem(url_tree)
            tier_item.setText(0, 'Tier {}'.format(i + 1))
            for url in tier:
                url_item = QTreeWidgetItem(tier_item)
                url_item.setText(0, url)
        url_tree.expandAll()
        vbox.addWidget(url_tree, 1)

        file_tree = QTreeWidget()
        file_tree.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
        file_tree.setHeaderLabels(('Name', 'Size'))
        file_tree.header().setSectionResizeMode(0,
                                                QHeaderView.ResizeToContents)
        self._file_items = []
        self._traverse_file_tree(download_info.suggested_name,
                                 download_info.file_tree, file_tree)
        file_tree.sortItems(0, Qt.AscendingOrder)
        file_tree.expandAll()
        file_tree.itemClicked.connect(self._update_checkboxes)
        vbox.addWidget(file_tree, 3)

        self._selection_label = QLabel(
            TorrentAddingDialog.SELECTION_LABEL_FORMAT.format(
                len(download_info.files),
                humanize_size(download_info.total_size)))
        vbox.addWidget(self._selection_label)

        self._ipfsadd_checkbox = QCheckBox(
            'Import files to IPFS when download is complete')
        self._ipfsadd_checkbox.setCheckState(Qt.Unchecked)
        # vbox.addWidget(self._ipfsadd_checkbox)

        self._button_box = QDialogButtonBox(self)
        self._button_box.setOrientation(Qt.Horizontal)
        self._button_box.setStandardButtons(QDialogButtonBox.Cancel
                                            | QDialogButtonBox.Ok)
        self._button_box.button(QDialogButtonBox.Ok).clicked.connect(
            self.submit_torrent)
        self._button_box.button(QDialogButtonBox.Cancel).clicked.connect(
            self.close)
        vbox.addWidget(self._button_box)

        self.setWindowTitle('Add Torrent')

        self.setMinimumSize(
            QSize(self.app.desktopGeometry.width() / 3,
                  (2 * self.app.desktopGeometry.height()) / 3))
    def __init__(self, theParent, theProject):
        QDialog.__init__(self, theParent)

        logger.debug("Initialising GuiWritingStats ...")
        self.setObjectName("GuiWritingStats")

        self.mainConf   = nw.CONFIG
        self.theParent  = theParent
        self.theProject = theProject
        self.theTheme   = theParent.theTheme
        self.optState   = theProject.optState

        self.logData    = []
        self.filterData = []
        self.timeFilter = 0.0
        self.wordOffset = 0

        self.setWindowTitle("Writing Statistics")
        self.setMinimumWidth(self.mainConf.pxInt(420))
        self.setMinimumHeight(self.mainConf.pxInt(400))
        self.resize(
            self.mainConf.pxInt(self.optState.getInt("GuiWritingStats", "winWidth",  550)),
            self.mainConf.pxInt(self.optState.getInt("GuiWritingStats", "winHeight", 500))
        )

        # List Box
        wCol0 = self.mainConf.pxInt(
            self.optState.getInt("GuiWritingStats", "widthCol0", 180)
        )
        wCol1 = self.mainConf.pxInt(
            self.optState.getInt("GuiWritingStats", "widthCol1", 80)
        )
        wCol2 = self.mainConf.pxInt(
            self.optState.getInt("GuiWritingStats", "widthCol2", 80)
        )

        self.listBox = QTreeWidget()
        self.listBox.setHeaderLabels(["Session Start", "Length", "Words", "Histogram"])
        self.listBox.setIndentation(0)
        self.listBox.setColumnWidth(self.C_TIME, wCol0)
        self.listBox.setColumnWidth(self.C_LENGTH, wCol1)
        self.listBox.setColumnWidth(self.C_COUNT, wCol2)

        hHeader = self.listBox.headerItem()
        hHeader.setTextAlignment(self.C_LENGTH, Qt.AlignRight)
        hHeader.setTextAlignment(self.C_COUNT, Qt.AlignRight)

        sortValid = (Qt.AscendingOrder, Qt.DescendingOrder)
        sortCol = self.optState.validIntRange(
            self.optState.getInt("GuiWritingStats", "sortCol", 0), 0, 2, 0
        )
        sortOrder = self.optState.validIntTuple(
            self.optState.getInt("GuiWritingStats", "sortOrder", Qt.DescendingOrder),
            sortValid, Qt.DescendingOrder
        )
        self.listBox.sortByColumn(sortCol, sortOrder)
        self.listBox.setSortingEnabled(True)

        # Word Bar
        self.barHeight = int(round(0.5*self.theTheme.fontPixelSize))
        self.barWidth = self.mainConf.pxInt(200)
        self.barImage = QPixmap(self.barHeight, self.barHeight)
        self.barImage.fill(self.palette().highlight().color())

        # Session Info
        self.infoBox  = QGroupBox("Sum Totals", self)
        self.infoForm = QGridLayout(self)
        self.infoBox.setLayout(self.infoForm)

        self.labelTotal = QLabel(formatTime(0))
        self.labelTotal.setFont(self.theTheme.guiFontFixed)
        self.labelTotal.setAlignment(Qt.AlignVCenter | Qt.AlignRight)

        self.labelFilter = QLabel(formatTime(0))
        self.labelFilter.setFont(self.theTheme.guiFontFixed)
        self.labelFilter.setAlignment(Qt.AlignVCenter | Qt.AlignRight)

        self.novelWords = QLabel("0")
        self.novelWords.setFont(self.theTheme.guiFontFixed)
        self.novelWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)

        self.notesWords = QLabel("0")
        self.notesWords.setFont(self.theTheme.guiFontFixed)
        self.notesWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)

        self.totalWords = QLabel("0")
        self.totalWords.setFont(self.theTheme.guiFontFixed)
        self.totalWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)

        self.infoForm.addWidget(QLabel("Total Time:"),       0, 0)
        self.infoForm.addWidget(QLabel("Filtered Time:"),    1, 0)
        self.infoForm.addWidget(QLabel("Novel Word Count:"), 2, 0)
        self.infoForm.addWidget(QLabel("Notes Word Count:"), 3, 0)
        self.infoForm.addWidget(QLabel("Total Word Count:"), 4, 0)
        self.infoForm.addWidget(self.labelTotal,  0, 1)
        self.infoForm.addWidget(self.labelFilter, 1, 1)
        self.infoForm.addWidget(self.novelWords,  2, 1)
        self.infoForm.addWidget(self.notesWords,  3, 1)
        self.infoForm.addWidget(self.totalWords,  4, 1)
        self.infoForm.setRowStretch(5, 1)

        # Filter Options
        sPx = self.theTheme.baseIconSize

        self.filterBox  = QGroupBox("Filters", self)
        self.filterForm = QGridLayout(self)
        self.filterBox.setLayout(self.filterForm)

        self.incNovel = QSwitch(width=2*sPx, height=sPx)
        self.incNovel.setChecked(
            self.optState.getBool("GuiWritingStats", "incNovel", True)
        )
        self.incNovel.clicked.connect(self._updateListBox)

        self.incNotes = QSwitch(width=2*sPx, height=sPx)
        self.incNotes.setChecked(
            self.optState.getBool("GuiWritingStats", "incNotes", True)
        )
        self.incNotes.clicked.connect(self._updateListBox)

        self.hideZeros = QSwitch(width=2*sPx, height=sPx)
        self.hideZeros.setChecked(
            self.optState.getBool("GuiWritingStats", "hideZeros", True)
        )
        self.hideZeros.clicked.connect(self._updateListBox)

        self.hideNegative = QSwitch(width=2*sPx, height=sPx)
        self.hideNegative.setChecked(
            self.optState.getBool("GuiWritingStats", "hideNegative", False)
        )
        self.hideNegative.clicked.connect(self._updateListBox)

        self.groupByDay = QSwitch(width=2*sPx, height=sPx)
        self.groupByDay.setChecked(
            self.optState.getBool("GuiWritingStats", "groupByDay", False)
        )
        self.groupByDay.clicked.connect(self._updateListBox)

        self.filterForm.addWidget(QLabel("Count novel files"),        0, 0)
        self.filterForm.addWidget(QLabel("Count note files"),         1, 0)
        self.filterForm.addWidget(QLabel("Hide zero word count"),     2, 0)
        self.filterForm.addWidget(QLabel("Hide negative word count"), 3, 0)
        self.filterForm.addWidget(QLabel("Group entries by day"),     4, 0)
        self.filterForm.addWidget(self.incNovel,     0, 1)
        self.filterForm.addWidget(self.incNotes,     1, 1)
        self.filterForm.addWidget(self.hideZeros,    2, 1)
        self.filterForm.addWidget(self.hideNegative, 3, 1)
        self.filterForm.addWidget(self.groupByDay,   4, 1)
        self.filterForm.setRowStretch(5, 1)

        # Settings
        self.histMax = QSpinBox(self)
        self.histMax.setMinimum(100)
        self.histMax.setMaximum(100000)
        self.histMax.setSingleStep(100)
        self.histMax.setValue(
            self.optState.getInt("GuiWritingStats", "histMax", 2000)
        )
        self.histMax.valueChanged.connect(self._updateListBox)

        self.optsBox = QHBoxLayout()
        self.optsBox.addStretch(1)
        self.optsBox.addWidget(QLabel("Word count cap for the histogram"), 0)
        self.optsBox.addWidget(self.histMax, 0)

        # Buttons
        self.buttonBox = QDialogButtonBox()
        self.buttonBox.rejected.connect(self._doClose)

        self.btnClose = self.buttonBox.addButton(QDialogButtonBox.Close)
        self.btnClose.setAutoDefault(False)

        self.btnSave = self.buttonBox.addButton("Save As", QDialogButtonBox.ActionRole)
        self.btnSave.setAutoDefault(False)

        self.saveMenu = QMenu(self)
        self.btnSave.setMenu(self.saveMenu)

        self.saveJSON = QAction("JSON Data File (.json)", self)
        self.saveJSON.triggered.connect(lambda: self._saveData(self.FMT_JSON))
        self.saveMenu.addAction(self.saveJSON)

        self.saveCSV = QAction("CSV Data File (.csv)", self)
        self.saveCSV.triggered.connect(lambda: self._saveData(self.FMT_CSV))
        self.saveMenu.addAction(self.saveCSV)

        # Assemble
        self.outerBox = QGridLayout()
        self.outerBox.addWidget(self.listBox,   0, 0, 1, 2)
        self.outerBox.addLayout(self.optsBox,   1, 0, 1, 2)
        self.outerBox.addWidget(self.infoBox,   2, 0)
        self.outerBox.addWidget(self.filterBox, 2, 1)
        self.outerBox.addWidget(self.buttonBox, 3, 0, 1, 2)
        self.outerBox.setRowStretch(0, 1)

        self.setLayout(self.outerBox)

        logger.debug("GuiWritingStats initialisation complete")

        return
Esempio n. 26
0
    def initUI(self):

        mainlayout = QVBoxLayout()

        # layout containing the treewidgets
        sectionlistlayout = QHBoxLayout()

        # layout for filter form
        filterbox = QGroupBox("Filter")

        self.LEsecname = QLineEdit()
        self.LEsectype = QLineEdit()
        self.LEpropname = QLineEdit()

        filterlayout = QGridLayout()
        filterlayout.addWidget(QLabel("Section Name"), 1, 0)
        filterlayout.addWidget(QLabel("Section Type"), 2, 0)
        filterlayout.addWidget(QLabel("Property Name"), 3, 0)
        filterlayout.addWidget(self.LEsecname, 1, 1)
        filterlayout.addWidget(self.LEsectype, 2, 1)
        filterlayout.addWidget(self.LEpropname, 3, 1)
        filterbox.setLayout(filterlayout)

        self.LEsecname.textChanged.connect(self.filterSections)
        self.LEsectype.textChanged.connect(self.filterSections)
        self.LEpropname.textChanged.connect(self.filterSections)

        # define layout for the trre-widgets containing the sections
        self.section_tree = QTreeWidget()
        self.section_tree.setColumnCount(2)
        self.section_tree.setHeaderLabels(["Name", "Path"])
        self.section_tree.itemDoubleClicked.connect(self.toright)

        self.selection_tree = QTreeWidget()
        self.selection_tree.setColumnCount(2)
        self.selection_tree.setHeaderLabels(["Name", "Path"])
        self.selection_tree.itemDoubleClicked.connect(self.toleft)

        self.selection_tree.setSelectionMode(3)
        self.section_tree.setSelectionMode(3)

        self.settings.register("selected_secs", self.selected_sections)

        # buttons to move items of the tree-widgets
        movebuttonlayout = QVBoxLayout()
        btn_right = QToolButton()
        btn_right.setArrowType(Qt.RightArrow)
        btn_right.clicked.connect(self.toright)
        btn_left = QToolButton()
        btn_left.setArrowType(Qt.LeftArrow)
        btn_left.clicked.connect(self.toleft)

        movebuttonlayout.addStretch(1)
        movebuttonlayout.addWidget(btn_right)
        movebuttonlayout.addSpacing(1)
        movebuttonlayout.addWidget(btn_left)
        movebuttonlayout.addStretch(1)

        sectionlistlayout.addWidget(self.section_tree)
        sectionlistlayout.addSpacing(1)
        sectionlistlayout.addLayout(movebuttonlayout)
        sectionlistlayout.addSpacing(1)
        sectionlistlayout.addWidget(self.selection_tree)

        mainlayout.addLayout(sectionlistlayout)
        self.selectallcb = QCheckBox('select all (Ctrl+A)')
        self.selectallcb.stateChanged.connect(self.selectall)
        mainlayout.addWidget(self.selectallcb)
        mainlayout.addWidget(filterbox)

        self.setTitle("Select Sections")
        self.setLayout(mainlayout)
        self.adjustSize()
Esempio n. 27
0
    l1 = QTreeWidgetItem(["String A", "String B", "String C"])
    l2 = QTreeWidgetItem(["String AA", "String BB", "String CC"])

    for i in range(3):
        l1_child = QTreeWidgetItem(["Child A" + str(i), "Child B" + str(i), "Child C" + str(i)])
        l1.addChild(l1_child)

    for j in range(2):
        l2_child = QTreeWidgetItem(["Child AA" + str(j), "Child BB" + str(j), "Child CC" + str(j)])
        l2.addChild(l2_child)

    w = QWidget()
    w.resize(510, 210)

    tw = QTreeWidget(w)
    tw.resize(500, 200)
    tw.setColumnCount(3)
    tw.setHeaderLabels(["Column 1", "Column 2", "Column 3"])
    tw.addTopLevelItem(l1)
    tw.addTopLevelItem(l2)

    w.show()
    sys.exit(app.exec_())


### 딕셔너리 추가
#le = {123:'aaa'}
le = {}
le[456] = 'bbb' or le.update(456='bbb')
Esempio n. 28
0
    def __init__(self):
        super(demo, self).__init__()

        self.resize(600, 500)
        self.move(300, 300)
        self.setWindowTitle('Simple')

        tab = QTabWidget()
        # tab.tabBarClicked.connect(lambda : print(tab.currentIndex))
        tab1 = QWidget()

        tab.addTab(tab1, 'tab1')

        tab2 = QWidget()
        tab.addTab(tab2, 'tab2')

        tl1 = QTreeWidgetItem(["String A", "String B", "String C"])

        for i in range(3):
            l1_child = QTreeWidgetItem(
                ["Child A" + str(i), "Child B" + str(i), "Child C" + str(i)])
            tl1.addChild(l1_child)

        # lmenu = QtGui.QMenu()
        # lmenu.addAction("New", self.new())

        self.ftree = QTreeWidget()
        self.ftree.setColumnCount(3)
        self.ftree.setHeaderLabels(['id', 'name', 'size'])
        self.ftree.header().resizeSection(1, 0)
        # headerView.resizeSection(1,0)
        self.ftree.addTopLevelItem(tl1)

        # self.ftree, QtCore.SIGNAL('customContextMenuRequested (const QPoint&)'), self.openright)
        self.ftree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.ftree.customContextMenuRequested.connect(self.openMenu)
        # self.ftree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        # self.ftree.customContextMenuRequested.connect(self.on_context_menu)
        # ftree.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
        # QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'), self.on_context_menu)

        self.ftree1 = QTreeWidget()
        self.ftree1.setColumnCount(3)
        self.ftree1.setHeaderLabels(['id', 'name', 'size'])
        self.ftree1.header().resizeSection(1, 0)
        # headerView.resizeSection(1,0)
        self.ftree1.addTopLevelItem(tl1)

        # self.customContextMenuRequested.connect(self.on_context_menu)

        # self.ftree.contextMenuEvent = self.menu

        self.ftree.clear()
        self.ftree1.clear()

        fvbox = QVBoxLayout()
        fvbox.addWidget(self.ftree)
        tab1.setLayout(fvbox)

        fvbox1 = QVBoxLayout()
        fvbox1.addWidget(self.ftree1)
        tab2.setLayout(fvbox1)

        button = QPushButton('ok')

        hbox1 = QHBoxLayout()
        # hbox.addStretch(1)
        hbox1.addWidget(tab)

        hbox2 = QHBoxLayout()
        hbox2.addWidget(button)

        vbox = QVBoxLayout()
        # vbox.addStretch(1)
        vbox.addLayout(hbox1)
        vbox.addLayout(hbox2)

        self.setLayout(vbox)
Esempio n. 29
0
    def __init__(self, parent, keys, titles, ref_object, depth=1):
        super().__init__()
        # settings_frame = QGroupBox("Configuration")
        layout = QVBoxLayout()
        self.tabs = QTabWidget()

        self.single_tabs = []
        self.boxes = []
        self.box_labels = []
        self.ref = ref_object
        self.is_selected = ref_object.is_included
        self.parent = parent

        self.parent_boxes = []
        self.child_boxes = []
        self.parent_labels = []
        self.child_labels = []

        if depth == 2:
            self.checked = set(self.is_selected[0]+self.is_selected[1])


        if (depth==1):
            for i, k in enumerate(keys):
                self.single_tabs.append(QWidget())
                self.tabs.addTab(self.single_tabs[-1], titles[i])
                tab_layout = QVBoxLayout(self)
                for  kk in k.keys():
                    self.boxes.append(QCheckBox(kk,self))
                    self.box_labels.append(kk)
                    if kk in self.is_selected:
                        self.boxes[-1].setChecked(True)
                    tab_layout.addWidget(self.boxes[-1])  
                self.single_tabs[-1].setLayout(tab_layout)
        else:
            for i, k in enumerate(keys):
                self.single_tabs.append(QWidget())
                self.tabs.addTab(self.single_tabs[-1], titles[i])
                tab_layout = QVBoxLayout(self)
                tree    = QTreeWidget ()
                tree.itemChanged.connect(self.handleItemChanged)                 
                headerItem  = QTreeWidgetItem()
                item    = QTreeWidgetItem()
                
                for  kk in k[1].keys():
                    self.parent_boxes.append(QTreeWidgetItem(tree))
                    self.parent_labels.append(kk)
                    self.parent_boxes[-1].setText(0, kk)
                    self.parent_boxes[-1].setFlags(self.parent_boxes[-1].flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable)
                    for k2 in k[1][kk]:
                        self.child_boxes.append(QTreeWidgetItem(self.parent_boxes[-1]))
                        self.child_labels.append(k2)
                        self.child_boxes[-1].setFlags(self.child_boxes[-1].flags() | Qt.ItemIsUserCheckable)
                        self.child_boxes[-1].setText(0, k2)
                        if kk in self.is_selected[1]:
                            self.child_boxes[-1].setCheckState(0, Qt.Checked)
                        else:
                            self.child_boxes[-1].setCheckState(0, Qt.Unchecked)
                tab_layout.addWidget(tree)
                self.single_tabs[-1].setLayout(tab_layout)


        buttons = QGroupBox("")
        button_layout = QHBoxLayout()        
        self.button_ok=QPushButton('Speichern')
        if (depth==1):
            self.button_ok.clicked.connect(self.on_pushButton_ok)
        else:
            self.button_ok.clicked.connect(self.on_pushButton_ok_depth2)
        button_layout.addWidget(self.button_ok)

        self.button_cancel=QPushButton('Schließen')
        self.button_cancel.clicked.connect(self.on_pushButton_cancel)
        button_layout.addWidget(self.button_cancel)
        buttons.setLayout(button_layout)

        layout.addWidget(self.tabs)
        layout.addWidget(buttons)
        self.setLayout(layout)
Esempio n. 30
0
    def __init__(self, parent):

        super(ObjectTree, self).__init__(parent)

        self.tree = tree = QTreeWidget(
            self, selectionMode=QAbstractItemView.ExtendedSelection)
        self.properties_editor = ParameterTree(self)

        tree.setHeaderHidden(True)
        tree.setItemsExpandable(False)
        tree.setRootIsDecorated(False)
        tree.setContextMenuPolicy(Qt.ActionsContextMenu)

        #forward itemChanged singal
        tree.itemChanged.connect(\
            lambda item,col: self.sigItemChanged.emit(item,col))
        #handle visibility changes form tree
        tree.itemChanged.connect(self.handleChecked)

        self.CQ = CQRootItem()
        self.Imports = ImportRootItem()
        self.Helpers = HelpersRootItem()

        root = tree.invisibleRootItem()
        root.addChild(self.CQ)
        root.addChild(self.Imports)
        root.addChild(self.Helpers)

        tree.expandToDepth(1)

        self._export_STL_action = \
            QAction('Export as STL',
                    self,
                    enabled=False,
                    triggered=lambda: \
                        self.export('stl',
                                    self.preferences['STL precision']))

        self._export_STEP_action = \
            QAction('Export as STEP',
                    self,
                    enabled=False,
                    triggered=lambda: \
                        self.export('step'))

        self._clear_current_action = QAction(icon('delete'),
                                             'Clear current',
                                             self,
                                             enabled=False,
                                             triggered=self.removeSelected)

        self._toolbar_actions = \
            [QAction(icon('delete-many'),'Clear all',self,triggered=self.removeObjects),
             self._clear_current_action,]

        self.prepareMenu()

        tree.itemSelectionChanged.connect(self.handleSelection)
        tree.customContextMenuRequested.connect(self.showMenu)

        self.prepareLayout()