Exemple #1
0
    def __init__(self, status_bar):
        super(SynthPdfWidget, self).__init__()
        self.status_bar = status_bar
        layout = QHBoxLayout()
        self.list_view = QListWidget()
        self.list_view.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.list_view.setAlternatingRowColors(True)
        self.list_view.itemClicked.connect(self.click_item_signal)
        self.list_view.itemEntered.connect(self.click_item_signal)
        self.list_view.itemSelectionChanged.connect(
            self.change_selection_signal)

        controls_layout = QVBoxLayout()
        controls_layout.setAlignment(Qt.AlignTop)

        select_zone = SelectWidget(self.click_move_up, self.click_move_down,
                                   self.click_invert, self.click_delete)
        select_zone.setMinimumWidth(250)

        add_pages_button = QPushButton("Add Pages From PDF")
        add_pages_button.clicked.connect(self.add_pdf)

        controls_layout.addWidget(select_zone)
        controls_layout.addWidget(add_pages_button)

        layout.addWidget(self.list_view)
        layout.addLayout(controls_layout)
        self.setLayout(layout)
    def _add_box_with_requirements(self, alternative: RequirementList):
        group_box = self._create_box_in_grid()
        group_box.rows = []

        vertical_layout = QVBoxLayout(group_box)
        vertical_layout.setObjectName(f"Layout with index {self._current_last_index - 1}")
        vertical_layout.setAlignment(Qt.AlignTop)

        empty = True
        trick_level = LayoutTrickLevel.NO_TRICKS

        for item in sorted(alternative.items):
            if self.edit_mode:
                ItemRow(group_box, vertical_layout, self.resource_database, item, group_box.rows)
            else:
                if item.resource.resource_type == ResourceType.DIFFICULTY:
                    trick_level = LayoutTrickLevel.from_number(item.amount)
                else:
                    empty = False
                    label = QLabel(group_box)
                    if item.resource.resource_type == ResourceType.TRICK:
                        label.setText(f"{item.resource} ({LayoutTrickLevel.from_number(item.amount).long_name})")
                    else:
                        label.setText(item.pretty_text)

                    vertical_layout.addWidget(label)

        if self.edit_mode:
            tools_layout = QHBoxLayout(group_box)
            tools_layout.setObjectName(f"Tools layout with index {self._current_last_index - 1}")
            vertical_layout.addLayout(tools_layout)

            add_new_button = QPushButton(group_box)
            add_new_button.setText("New Requirement")
            tools_layout.addWidget(add_new_button)

            delete_button = QPushButton(group_box)
            delete_button.setText("Delete")
            delete_button.clicked.connect(partial(self._delete_alternative, group_box))
            tools_layout.addWidget(delete_button)

            def _new_row():
                empty_item = IndividualRequirement(
                    self.resource_database.get_by_type(ResourceType.ITEM)[0],
                    1, False
                )
                ItemRow(group_box, vertical_layout, self.resource_database, empty_item, group_box.rows)
                vertical_layout.removeItem(tools_layout)
                vertical_layout.addLayout(tools_layout)

            add_new_button.clicked.connect(_new_row)

        else:
            group_box.setTitle(f"Difficulty: {trick_level.long_name}")
            if empty:
                label = QLabel(group_box)
                label.setText("No requirements.")
                vertical_layout.addWidget(label)

        return group_box
Exemple #3
0
    def __init__(self, targetImage=None, axeSize=500, layer=None, parent=None):
        super().__init__(layer=layer, targetImage=targetImage, parent=parent)
        # options
        self.options = None
        self.mergeButton = QPushButton('Refresh')

        # button slot
        def f():
            self.dataChanged.emit()

        self.mergeButton.pressed.connect(f)

        # layout
        l = QVBoxLayout()
        l.setAlignment(Qt.AlignTop)
        l.addSpacing(30)
        l.addWidget(self.mergeButton)
        l.setContentsMargins(20, 0, 20, 25)  # left, top, right, bottom
        self.setLayout(l)
        self.adjustSize()
        self.setWhatsThis("""<b>Exposure Fusion</b>
                        In the layer stack use the context menu to select the layers to be merged. Next, press
                        the <i>Refresh</i> button.<br>
                        """)  # end setWhatsThis

        self.setDefaults()
class ResultBlockViewWidget(QMainWindow):
    # Конструктор
    def __init__(self, block_name, result, parent=None):
        super(ResultBlockViewWidget, self).__init__(parent)
        self.setWindowTitle(f'Результаты выполнения блока \'{block_name}\'')
        self.setWindowModality(Qt.ApplicationModal)
        self.setMinimumWidth(640)
        self.central_widget = QWidget()
        self.scroll = QScrollArea()
        self.layout = QVBoxLayout(self.central_widget)
        self.init_ui(result)

    # Метод инициализации UI
    def init_ui(self, result):
        self.scroll.setAlignment(Qt.AlignCenter)
        self.layout.setAlignment(Qt.AlignTop)
        self.setCentralWidget(self.central_widget)
        self.layout.addWidget(self.scroll)
        widget = QWidget()
        layout = QVBoxLayout(widget)
        for i in range(0, len(result)):
            result_label = QLabel(f'Команда №{i + 1}: \'{result[i][1].strip()}\'.')
            result_label.setAlignment(Qt.AlignCenter)
            if result[i][0] == 0:
                result_label.setStyleSheet('background-color: ForestGreen;')
            else:
                result_label.setStyleSheet('background-color: OrangeRed;')
            layout.addWidget(result_label)
        self.scroll.setWidget(widget)
Exemple #5
0
class Panel(QWidget):
	header_font = QFont()
	header_font.setBold(True)
	header_font.setPointSize(10)

	def __init__(self, name, script):
		QWidget.__init__(self)

		self.name = name
		self.script = script

		self.layout = QVBoxLayout()
		self.layout.setAlignment(Qt.AlignTop)
		self.layout.setMargin(0)

		self.header = QLabel(self.name)
		self.header.setFont(self.header_font)
		self.header.setAlignment(Qt.AlignLeft)
		self.header.setObjectName("header")
		self.layout.addWidget(self.header)

		self.grid = grid_layout_build(vars(self.script))

		self.layout.addLayout(self.grid)
		self.setLayout(self.layout)
Exemple #6
0
    def initAlphaSliderLayout(self):
        self.vboxAlphaBox = QGroupBox()
        self.vboxAlphaBox.setFixedWidth(120)
        layout = QVBoxLayout()
        layout.setAlignment(Qt.AlignCenter)
        TrimapBtn = HoverButtonTop(self, "Trimap")
        TrimapBtn.setText('蒙板')
        layout.addWidget(TrimapBtn)
        TrimapBtn.clicked.connect(lambda: self.Trimap_click(1))

        temp = MySlider(self, 'ImageAlphaSlider', Qt.Vertical)
        self.setSlider(temp, 'ImageAlphaSlider')
        temp.setTickPosition(QSlider.TicksBothSides)
        lef, rig, typ = config.sliderConfig['ImageAlphaSlider']
        temp.setSliderType(lef, rig, type=typ)
        temp.setFixedWidth(100)
        self.setSlider(temp, 'ImageAlphaSlider')
        layout.addWidget(temp)

        ImageBtn = HoverButtonBottom(self, "Image")
        ImageBtn.setText('原图')
        layout.addWidget(ImageBtn)
        ImageBtn.clicked.connect(lambda: self.Image_click(0))

        self.vboxAlphaBox.setLayout(layout)
Exemple #7
0
    def __init__(self):
        super(Main, self).__init__()
        self.setWindowTitle("Pi Photo")

        self.camera = CameraWorker()

        central_widget = QWidget()
        main_layout = QVBoxLayout(central_widget)
        self.setCentralWidget(central_widget)

        column_layout = QHBoxLayout()
        main_layout.addLayout(column_layout)

        self.attributes_panel = AttributesPanel(self.camera)
        column_layout.addWidget(self.attributes_panel)
        column_layout.setAlignment(self.attributes_panel, Qt.AlignTop)

        image_preview_layout = QVBoxLayout()
        column_layout.addLayout(image_preview_layout)

        self.preview = ImagePreview()
        image_preview_layout.addWidget(self.preview)
        image_preview_layout.setAlignment(self.preview, Qt.AlignTop)

        # start preview
        self.camera.frame_ready.connect(self.preview.set_image)
        self.camera.start()
Exemple #8
0
    def initUI(self):
        self.pacs_ctrl: PACS_ServerCtrl = PACS_OrthancServerCtrl()
        self.setGeometry(self.left, self.top, self.width, self.height)

        self.pacs_widget = PACS_MainWidget()
        self.dicom_widget = Dicom_Browser()
        # self.liver_support_widget = LiverSupportWidget()
        self.button_bar = MenuLeftPane()

        topLayout = QVBoxLayout()
        topLayout.setAlignment(Qt.AlignTop)
        topLayout.addWidget(self.button_bar)

        self.mainWidget = QDockWidget()
        self.mainWidget.setFeatures(QDockWidget.NoDockWidgetFeatures)
        self.mainWidget.setTitleBarWidget(QWidget())
        self.mainWidget.setWidget(self.dicom_widget)

        mainLayout = QHBoxLayout(self)
        mainLayout.setContentsMargins(QMargins(0, 0, 0, 0))
        mainLayout.addLayout(topLayout)
        mainLayout.addWidget(self.mainWidget)

        self.button_bar.pacs_btn.clicked.connect(self.show_PACSWidget)
        self.button_bar.dcm_btn.clicked.connect(self.show_DICOMBrowser)
        # self.button_bar.liv_support_btn.clicked.connect(self.show_liverSupport)
        self.pacs_widget.dcm_to_browser.connect(self.send_file_to_browser)

        self.show_PACSWidget()
    def _add_widget_for_requirement_array(self, requirement: Requirement):
        parents = [(self.parent, self.grid_layout)]
        self.grid_layout.setAlignment(Qt.AlignTop)

        next_title = ""

        current_depth = 0
        for depth, text in data_writer.pretty_print_requirement(requirement):
            if depth > current_depth:
                group_box = QGroupBox(parents[current_depth][0])
                group_box.setTitle(next_title)
                self._elements.append(group_box)
                vertical_layout = QVBoxLayout(group_box)
                vertical_layout.setAlignment(Qt.AlignTop)
                parents[current_depth][1].addWidget(group_box)
                parents.append((group_box, vertical_layout))

            elif depth < current_depth:
                parents.pop()

            current_depth = depth
            if "of the following" in text:
                next_title = text
            else:
                label = QLabel(parents[current_depth][0])
                label.setText(text)
                self._elements.append(label)
                parents[current_depth][1].addWidget(label)
Exemple #10
0
    def __init__(self, template, subject):
        Observation.__init__(self, subject)
        QWidget.__init__(self)
        self.maxNameLen = 13
        self.maxDescLen = 27
        self.maxCommandLen = 13
        self.template = template

        self.selected = False

        name = self.shortenString(template.backend_name, self.maxNameLen)
        description = self.shortenString(template.description, self.maxDescLen)
        runCommand = self.shortenString(template.run_command,
                                        self.maxCommandLen)
        self.setFixedSize(Theme.browser.item.size)

        layout = QVBoxLayout()

        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setAlignment(Qt.AlignTop)

        self.setLayout(layout)

        self.__initHeader__(name, runCommand)
        self.__initDescription__(description)
    def setup_starting_area_elements(self):
        game_description = default_prime2_game_description()
        world_to_group = {}
        self._starting_location_for_area = {}

        for row, world in enumerate(game_description.world_list.worlds):
            for column, is_dark_world in enumerate([False, True]):
                group_box = QGroupBox(self.starting_locations_contents)
                group_box.setTitle(world.correct_name(is_dark_world))
                vertical_layout = QVBoxLayout(group_box)
                vertical_layout.setContentsMargins(8, 4, 8, 4)
                vertical_layout.setSpacing(2)
                vertical_layout.setAlignment(QtCore.Qt.AlignTop)
                group_box.vertical_layout = vertical_layout

                world_to_group[world.correct_name(is_dark_world)] = group_box
                self.starting_locations_layout.addWidget(group_box, row, column)

        for world in game_description.world_list.worlds:
            for area in sorted(world.areas, key=lambda a: a.name):
                group_box = world_to_group[world.correct_name(area.in_dark_aether)]
                check = QtWidgets.QCheckBox(group_box)
                check.setText(area.name)
                check.area_location = AreaLocation(world.world_asset_id, area.area_asset_id)
                check.stateChanged.connect(functools.partial(self._on_check_starting_area, check))
                group_box.vertical_layout.addWidget(check)
                self._starting_location_for_area[area.area_asset_id] = check

        self.starting_area_quick_fill_ship.clicked.connect(self._starting_location_on_select_ship)
        self.starting_area_quick_fill_save_station.clicked.connect(self._starting_location_on_select_save_station)
class AddonsPage(QWidget):
    def __init__(self, parent):
        super(AddonsPage, self).__init__()
        self.setMinimumSize(700, 500)
        self.main = parent.parent
        self.addonsManager = AddonsManager(self.main)
        self.addonsManager.loadaddons()
        self.widgets = []
        self.layoutMain = QVBoxLayout(self)
        self.scroll = QScrollArea(self)
        self.scroll.setWidgetResizable(True)
        self.title = QLabel("Addons")
        self.title.setAlignment(Qt.AlignHCenter)
        self.layoutMain.addWidget(self.title)
        self.layoutMain.addWidget(self.scroll)

        self.container = QWidget()
        self.scroll.setWidget(self.container)
        self.layout = QVBoxLayout(self.container)
        self.label = QLabel("Pas de addons")
        self.label.setAlignment(Qt.AlignHCenter)
        self.layout.addWidget(self.label)
        for i in self.addonsManager.imported:
            self.addonW = AddonWidget(self.main, self, i.replace(".", "/").split("/")[-2])
            self.widgets.append(self.addonW)
            self.layout.addWidget(self.addonW)
            self.layout.setAlignment(self.addonW, Qt.AlignTop)
            self.label.hide()

    def launchaddons(self, function, args=None):
        self.addonsManager.launchaddons(self.widgets, function, args)
Exemple #13
0
    def _setup_ui(self):
        status_bar = self.statusBar()
        status_bar.setSizeGripEnabled(False)
        status_bar.setContentsMargins(4, 0, 0, 0)
        status_bar.setStyleSheet('QStatusBar::item {border: None;}')
        self._status = QLabel('STATUS')
        status_bar.addWidget(self._status)

        # Create a central widget, give it a layout, and set it up
        central = QWidget(self)
        self.setCentralWidget(central)
        layout = QVBoxLayout()
        layout.setMargin(10)
        central.setLayout(layout)

        ag = ApolloGroup(self, "INTERFACE")
        dsky_sw = ApolloLabeledSwitch(self, "DSKY")
        monitor_sw = ApolloLabeledSwitch(self, "MONITOR", labelwidth=62)
        fdai_sw = ApolloLabeledSwitch(self, "FDAI")

        dsky_sw.switch.setChecked(True)
        monitor_sw.switch.setChecked(True)
        fdai_sw.switch.setChecked(False)
        dsky_sw.switch.stateChanged.connect(self.toggle_dsky)
        monitor_sw.switch.stateChanged.connect(self.toggle_monitor)
        fdai_sw.switch.stateChanged.connect(self.toggle_fdai)

        ag.addWidget(dsky_sw)
        ag.addWidget(monitor_sw)
        ag.addWidget(fdai_sw)

        layout.addWidget(ag)
        layout.setAlignment(ag, Qt.AlignTop | Qt.AlignLeft)
        layout.addStretch()
class EasyDialog(QDialog):
    """QDialog extended with some extra utility functions"""
    def __init__(self, buttons=None):
        super().__init__()

        self.buttons = []
        self.layout = QVBoxLayout()
        self.layout.setAlignment(Qt.AlignCenter)

        if buttons is not None:
            for button in buttons:
                self.add_button(button[0], button[1])

    def add_button(self, text, function):
        new_button = QPushButton(text)
        new_button.clicked.connect(function)
        self.layout.addWidget(new_button)
        self.buttons.append(new_button)

    def finish(self):
        self.setLayout(self.layout)
        self.show()

    def keyPressEvent(self, event):
        if not event.key() == Qt.Key_Escape:
            super().keyPressEvent(event)
Exemple #15
0
    def __init__(self, parent):
        super().__init__()

        self.client = parent
        parent.maw = self
        parent.l.addWidget(self)

        l = QVBoxLayout()
        self.setLayout(l)
        l.setAlignment(Qt.AlignTop)

        tb = self.setupTopBar()

        l.addWidget(tb)

        parent.setMinimumSize(parent.size())
        parent.setMaximumSize(parent.screen().size())

        parent.screenChanged.connect(self.ScreenChanged)

        parent.hide()
        parent.setWindowFlag(Qt.CustomizeWindowHint)
        parent.setWindowFlag(Qt.WindowMaximizeButtonHint)
        parent.show()

        self.show()
Exemple #16
0
class Ui_PortraitViewer(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)

        self.show_buttons_layout = QHBoxLayout()
        self.show_buttons_layout.setAlignment(QtGui.Qt.AlignCenter)
        self.show_st_button = QPushButton(text="Show ST")
        self.show_bu_button = QPushButton(text="Show BU")
        self.show_buttons_layout.addWidget(self.show_st_button)
        self.show_buttons_layout.addWidget(self.show_bu_button)

        self.display = QGraphicsView()
        self.display.setMinimumSize(256, 256)

        self.portrait_name_label = QLabel(text="(None)")
        self.portrait_name_label.setAlignment(QtGui.Qt.AlignCenter)

        self.navigation_buttons_layout = QHBoxLayout()
        self.navigation_buttons_layout.setAlignment(QtGui.Qt.AlignCenter)
        self.back_button = QPushButton("<")
        self.current_image_label = QLabel(text="0 / 0")
        self.forward_button = QPushButton(">")
        self.navigation_buttons_layout.addWidget(self.back_button)
        self.navigation_buttons_layout.addWidget(self.current_image_label)
        self.navigation_buttons_layout.addWidget(self.forward_button)

        self.main_layout = QVBoxLayout()
        self.main_layout.setAlignment(QtGui.Qt.AlignCenter)
        self.main_layout.addLayout(self.show_buttons_layout)
        self.main_layout.addWidget(self.display)
        self.main_layout.addWidget(self.portrait_name_label)
        self.main_layout.addLayout(self.navigation_buttons_layout)
        self.setLayout(self.main_layout)
class LabelConfigurator(QFrame):
    def __init__(self, boxManager):
        super().__init__()
        # Objects
        self.boxManager = boxManager
        self.layout = QVBoxLayout(self)
        self.isOccludedButton = Check('Occluded', False)
        self.isTruncatedButton = Check('Truncated', False)
        self.isGroupOfButton = Check('Group Of', False)
        self.isDepictionButton = Check('Depiction', False)
        self.isInsideButton = Check('Inside', False)

        # Layout
        self.layout.setAlignment(Qt.AlignTop | Qt.AlignCenter)
        self.layout.addWidget(self.isOccludedButton)
        self.layout.addWidget(self.isTruncatedButton)
        self.layout.addWidget(self.isGroupOfButton)
        self.layout.addWidget(self.isDepictionButton)
        self.layout.addWidget(self.isInsideButton)

        # Styling
        self.layout.setContentsMargins(5, 10, 5, 10)
        self.layout.setSpacing(15)

        # Connections
        self.isOccludedButton.stateChanged.connect(
            boxManager.setNewBoxIsOccluded)
        self.isTruncatedButton.stateChanged.connect(
            boxManager.setNewBoxIsTruncated)
        self.isGroupOfButton.stateChanged.connect(
            boxManager.setNewBoxIsGroupOf)
        self.isDepictionButton.stateChanged.connect(
            boxManager.setNewBoxIsDepiction)
        self.isInsideButton.stateChanged.connect(boxManager.setNewBoxIsInside)
Exemple #18
0
    def __init__(self, parent, action):
        super(FortuneWidget, self).__init__(parent, action)
        self.setObjectName("FancyDockWidgetFromCoolPlugin")
        self.setWindowTitle("Sample Python Plugin")

        content = QWidget()
        self.setWidget(content)

        # Create layout and label
        layout = QVBoxLayout(content)
        content.setLayout(layout)
        self.text = QLabel(content)
        self.text.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        self.text.setFont(cutter.Configuration.instance().getFont())
        layout.addWidget(self.text)

        button = QPushButton(content)
        button.setText("Want a fortune?")
        button.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        button.setMaximumHeight(50)
        button.setMaximumWidth(200)
        layout.addWidget(button)
        layout.setAlignment(button, Qt.AlignHCenter)

        button.clicked.connect(self.generate_fortune)
        cutter.core().seekChanged.connect(self.generate_fortune)

        self.show()
Exemple #19
0
    def __init__(self, targetImage=None, axeSize=500, layer=None, parent=None):
        super().__init__(layer=layer, targetImage=targetImage, parent=parent)
        # options
        self.options = None
        self.mergeButton = QPushButton('Refresh')
        self.mergeButton.setMaximumWidth(80)
        self.warn = QLabel(
            'Use the layer stack context menu\nto add or remove layers to merge.'
        )

        # self.warn.setStyleSheet("QLabel {color : yellow; }")

        # button slot
        def f():
            self.dataChanged.emit()

        self.mergeButton.pressed.connect(f)

        # layout
        l = QVBoxLayout()
        l.setAlignment(Qt.AlignTop | Qt.AlignHCenter)
        l.addSpacing(30)
        l.addWidget(self.mergeButton)
        l.addSpacing(100)
        l.addWidget(self.warn)
        l.setContentsMargins(20, 0, 20, 25)  # left, top, right, bottom
        self.setLayout(l)
        self.adjustSize()
        self.setWhatsThis("""<b>Exposure Fusion</b>
                        In the layer stack use the context menu to select the layers to be merged. Next, press
                        the <i>Refresh</i> button.<br>
                        """)  # end setWhatsThis

        self.setDefaults()
    def __init__(self, parent, message: str):
        """
        Information dialog

        :param parent: gui's main window
        :param message: Message to display
        """
        QDialog.__init__(self, parent)

        self.setFixedSize(QSize(350, 80))

        self.info = QLabel(message)
        self.info.setAlignment(Qt.AlignCenter)

        # Quit buttons
        self.ok_btn = QPushButton("Ok")
        self.ok_btn.clicked.connect(self.accept)
        self.ok_btn.setFixedSize(QSize(60, 33))

        # Layout
        layout = QVBoxLayout()
        layout.addWidget(self.info)
        layout.addWidget(self.ok_btn)
        layout.setAlignment(self.ok_btn, Qt.AlignCenter)
        self.setLayout(layout)

        self.setStyleSheet(get_stylesheet("dialog"))
Exemple #21
0
    def _set_layout(self):
        """
        Creates this Widget's Layout
        """
        box = QVBoxLayout()
        box.setContentsMargins(0, 0, 0, 0)

        box.addSpacing(20)
        AboutLabel("Made by\nOlivier Lécluse & Thomas Lécluse", box)

        logo = QLabel()
        logo.setPixmap(QPixmap("assets/LDC-light"))
        logo.setFixedSize(QSize(512, 222))  # Original dimension is 2048x888, we divided by 4
        logo.setScaledContents(True)
        box.addWidget(logo)
        box.setAlignment(logo, Qt.AlignCenter)

        AboutLabel(
            f'{self.links_style}<a href="https://bradsprojects.com/digirule2/">&gt; Digirule2 project &lt;</a>', box, True)

        AboutLabel(
            f'{self.links_style}<a href="https://github.com/wawachief/DigiQt">&gt; GitHub project &lt;</a>', box, True)

        AboutLabel(
            f'Contact: {self.contact_style}<a href="mailto:[email protected]">[email protected]</a>', box, True)

        AboutLabel(f"Version: {self.config.get('main', 'APP_VERSION')}", box)

        box.addSpacing(20)

        self.setLayout(box)
Exemple #22
0
    def create_view_attack(self):
        table_headers = [
            "ATT&CK Tactic",
            "ATT&CK Technique ",
        ]
        table = QTableWidget()
        table.setColumnCount(len(table_headers))
        table.verticalHeader().setVisible(False)
        table.setSortingEnabled(False)
        table.setEditTriggers(QAbstractItemView.NoEditTriggers)
        table.setFocusPolicy(Qt.NoFocus)
        table.setSelectionMode(QAbstractItemView.NoSelection)
        table.setHorizontalHeaderLabels(table_headers)
        table.horizontalHeader().setDefaultAlignment(Qt.AlignLeft)
        table.horizontalHeader().setStretchLastSection(True)
        table.setShowGrid(False)
        table.horizontalHeader().setSectionResizeMode(
            0, QHeaderView.ResizeToContents)
        table.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch)
        #table.setStyleSheet("QTableWidget::item { padding: 25px; }")

        attack_view_layout = QVBoxLayout()
        attack_view_layout.setAlignment(Qt.AlignTop)

        self.attack_table = table

        attack_view_layout.addWidget(self.attack_table)
        self.tab_attack.setLayout(attack_view_layout)

        return table
Exemple #23
0
    def _layout(self):
        layout = QHBoxLayout(self)
        self.setLayout(layout)

        self.tree = QTreeView(self)
        self.tree.setModel(self.model)
        self.tree.setUniformRowHeights(True)
        self.tree.setColumnWidth(0, 200)
        self.tree.setDragEnabled(True)
        self.tree.setDragDropMode(QAbstractItemView.InternalMove)
        self.tree.viewport().setAcceptDrops(True)
        layout.addWidget(self.tree, 1)

        buttons = QVBoxLayout()
        buttons.setAlignment(Qt.AlignTop)

        add_button = QPushButton(QIcon.fromTheme("list-add"), "", self)
        add_button.setToolTip("Add application")
        add_button.clicked.connect(self.on_add)
        buttons.addWidget(add_button)

        mkdir_button = QPushButton(QIcon.fromTheme("folder-new"), "", self)
        mkdir_button.setToolTip("Make directory")
        mkdir_button.clicked.connect(self.on_mkdir)
        buttons.addWidget(mkdir_button)

        delete_button = QPushButton(QIcon.fromTheme("list-remove"), "", self)
        delete_button.setToolTip("Remove selected item")
        delete_button.clicked.connect(self.on_delete)
        buttons.addWidget(delete_button)

        layout.addLayout(buttons)
Exemple #24
0
class Slider(QWidget):
    def __init__(self, name, min_value, max_value):
        QWidget.__init__(self)
        self.setObjectName(name)
        self.slider = QSlider(Qt.Orientation.Vertical)
        self.slider.setMaximum(max_value)
        self.slider.setMinimum(min_value)
        self.label = QLabel(name)
        self.label.setAlignment(Qt.AlignCenter)
        min_width = self.label.fontMetrics().boundingRect(
            str(min_value)).width()
        max_width = self.label.fontMetrics().boundingRect(
            str(max_value)).width()
        minimum_width = max(min_width, max_width)
        self.value = QLabel(self.to_string(min_value))
        self.value.setAlignment(Qt.AlignCenter)
        self.value.setMinimumWidth(minimum_width)
        self.value.setText(self.to_string(self.slider.sliderPosition()))
        self.layout = QVBoxLayout()
        self.layout.addWidget(self.label, alignment=Qt.AlignHCenter)
        self.layout.addWidget(self.slider, alignment=Qt.AlignHCenter)
        self.layout.addWidget(self.value, alignment=Qt.AlignHCenter)
        self.layout.setAlignment(Qt.AlignCenter)
        self.setLayout(self.layout)
        self.slider.valueChanged.connect(self.callback)

    def callback(self, value):
        self.value.setText(self.to_string(value))

    def to_string(self, value):
        return f"{value}"
Exemple #25
0
    def __init__(self, track, subject, index):
        self.track = track
        self._code = ""

        super().__init__(subject, index)

        self.setAttribute(Qt.WA_StyledBackground)
        self.setStyleSheet(Theme.track.cell.style)

        self.setFixedHeight(Theme.track.cell.height)

        layout = QVBoxLayout()
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setAlignment(Qt.AlignTop)

        self.setLayout(layout)

        self.layout().addWidget(self.nameLabel)

        self._initContentPreview()

        self.updateStyle()

        self.add_responder(events.view.main.CellEditName,
                           self.editNameResponder)
        self.add_responder(events.view.track.Select, self.trackSelectResponder)
Exemple #26
0
    def _initLabels(self):
        self.backendName = QLabel(self.track.template.backend_name)
        self.backendName.setFont(Theme.track.header.backendNameFont)
        self.backendName.setStyleSheet(Theme.track.header.backendNameStyle)

        self.nameLabel.setFont(Theme.track.header.userNameFont)
        self.nameLabel.setStyleSheet(Theme.track.header.userNameStyle)
        self.nameLabel.setMaxLength(15)

        vlayout = QVBoxLayout()
        vlayout.setSpacing(0)
        vlayout.setContentsMargins(0, 0, 0, 0)
        vlayout.addWidget(self.backendName)
        vlayout.addWidget(self.nameLabel)
        vlayout.setAlignment(Qt.AlignLeft)

        layout = QHBoxLayout()
        layout.setSpacing(18)
        layout.setContentsMargins(18, 9, 18, 18)

        self.icon = QSvgWidget(self.track.template.icon_path())
        self.icon.setFixedSize(36, 36)

        layout.addWidget(self.icon)
        layout.addLayout(vlayout)
        self.setLayout(layout)
Exemple #27
0
class DownloadPage(QWidget):
    def __init__(self, parent):
        super(DownloadPage, self).__init__()
        self.setMinimumSize(500, 300)
        self.parent = parent
        self.nbDownload = 0
        self.layoutMain = QVBoxLayout(self)
        self.scroll = QScrollArea(self)
        self.scroll.setWidgetResizable(True)
        self.title = QLabel("Téléchargements")
        self.title.setAlignment(Qt.AlignHCenter)
        self.layoutMain.addWidget(self.title)
        self.layoutMain.addWidget(self.scroll)

        self.container = QWidget()
        self.scroll.setWidget(self.container)
        self.layout = QVBoxLayout(self.container)
        self.label = QLabel("Pas de téléchargement")
        self.label.setAlignment(Qt.AlignHCenter)
        self.layout.addWidget(self.label)

    def downloadrequested(self, download):
        if download:
            if download.state() == QWebEngineDownloadItem.DownloadRequested:
                path = QFileDialog.getSaveFileName(self, "Sauver comme",
                                                   download.path())
                if path == "":
                    return
                else:
                    download.setPath(path[0])
                    download.accept()
                    self.add(
                        DownloadWidget(
                            download,
                            self.parent.parent.browserWidget.url().toString(),
                            self.parent.parent))

                    self.show()
            else:
                QMessageBox.warning(self, "ERREUR",
                                    "Le téléchargement n'a pas été demandé.")
        else:
            QMessageBox.warning(self, "ERREUR", "Le téléchargement est nul.")

    def add(self, downloadwidget):
        downloadwidget.downloadSignal.removeClicked.connect(self.remove)
        self.layout.addWidget(downloadwidget)
        self.layout.setAlignment(downloadwidget, Qt.AlignTop)
        self.nbDownload += 1
        if self.nbDownload >= 0:
            self.label.hide()

    def remove(self):
        downloadwidget = self.sender().parent
        self.layout.removeWidget(downloadwidget)
        downloadwidget.deleteLater()
        self.nbDownload -= 1
        if self.nbDownload <= 0:
            self.label.show()
Exemple #28
0
class Layout(Slots):
    def __init__(self):
        super().__init__()

    def stored_location_layout(self):
        self.stored_directories_title = QLabel(constants.stored_dir_str)

        # Combo box and its properties
        self.stored_dir_dropdown = QComboBox()
        self.stored_dir_dropdown.addItems(self.get_list_items())
        self.stored_dir_dropdown.setCursor(QCursor(Qt.PointingHandCursor))
        self.stored_dir_dropdown.setStyleSheet(stored_dir_dropdown_styles)

        # Layout grid for combo box widget
        self.stored_dirs_layout = QGridLayout()
        self.stored_dirs_layout.addWidget(self.stored_directories_title, 0, 0)
        self.stored_dirs_layout.addWidget(self.stored_dir_dropdown, 0, 1)
        self.stored_dirs_layout.setColumnStretch(1, 2)
        self.stored_dirs_layout.setContentsMargins(0, 16, 0, 32)

        return self.stored_dirs_layout

    def push_to_group_layout(self):
        # Create a group
        self.group_push_to = QGroupBox(constants.push_branch_str)
        self.group_push_to.setStyleSheet(group_widgets_styles)

        # Create the layout for the branch widgets
        self.pushToLayout = QVBoxLayout()
        self.pushToLayout.setAlignment(Qt.AlignTop)
        self.pushToLayout.setContentsMargins(16, 24, 16, 24)

        # Set the layout to the group
        self.group_push_to.setLayout(self.pushToLayout)

        # Create the staging button and its properties
        self.staging_btn = QPushButton(constants.master_to_staging_str)
        self.staging_btn.clicked.connect(
            lambda: self.handle_branch_push_to_git(constants.master, constants.
                                                   staging))
        self.staging_btn.setCursor(QCursor(Qt.PointingHandCursor))
        self.staging_btn.setStyleSheet(button_styles)

        # Create the production button and its properties
        self.prod_btn = QPushButton(constants.staging_to_prod_str)
        self.prod_btn.setCursor(QCursor(Qt.PointingHandCursor))
        self.prod_btn.clicked.connect(lambda: self.handle_branch_push_to_git(
            constants.staging, constants.production))
        self.prod_btn.setStyleSheet(button_styles)

        self.thread = Thread()
        self.thread.finished.connect(lambda: self.staging_btn.setEnabled(True))
        self.thread.finished.connect(lambda: self.prod_btn.setEnabled(True))

        # Add the button widgets to the layout
        self.pushToLayout.addWidget(self.staging_btn)
        self.pushToLayout.addWidget(self.prod_btn)

        return self.group_push_to
    def _create_area_list_selection(self, parent: QtWidgets.QWidget, layout: QtWidgets.QGridLayout,
                                    all_area_locations: List[AreaLocation],
                                    on_check: Callable[[List[AreaLocation], bool], None],
                                    ):
        world_to_group = {}
        checks_for_world = {}
        checks_for_area = {}

        worlds, areas_by_world = self._areas_by_world_from_locations(all_area_locations)
        worlds.sort(key=lambda it: it.name)

        def _on_check_area(c, _):
            if not self._during_batch_check_update:
                on_check([c.area_location], c.isChecked())

        def _on_check_world(c, _):
            if not self._during_batch_check_update:
                world_list = self.game_description.world_list
                w = world_list.world_by_asset_id(c.world_asset_id)
                world_areas = [world_list.area_to_area_location(a)
                               for a in w.areas if c.is_dark_world == a.in_dark_aether
                               if a.area_asset_id in checks_for_area]
                on_check(world_areas, c.isChecked())

        for row, world in enumerate(worlds):
            for column, is_dark_world in enumerate(dark_world_flags(world)):
                group_box = QGroupBox(parent)
                world_check = QtWidgets.QCheckBox(group_box)
                world_check.setText(world.correct_name(is_dark_world))
                world_check.world_asset_id = world.world_asset_id
                world_check.is_dark_world = is_dark_world
                world_check.stateChanged.connect(functools.partial(_on_check_world, world_check))
                world_check.setTristate(True)
                vertical_layout = QVBoxLayout(group_box)
                vertical_layout.setContentsMargins(8, 4, 8, 4)
                vertical_layout.setSpacing(2)
                vertical_layout.setAlignment(QtCore.Qt.AlignTop)
                separator = QtWidgets.QFrame()
                separator.setFrameShape(QtWidgets.QFrame.HLine)
                separator.setFrameShadow(QtWidgets.QFrame.Sunken)
                group_box.vertical_layout = vertical_layout
                group_box.vertical_layout.addWidget(world_check)
                group_box.vertical_layout.addWidget(separator)

                world_to_group[world.correct_name(is_dark_world)] = group_box
                layout.addWidget(group_box, row, column)
                checks_for_world[world.correct_name(is_dark_world)] = world_check

        for world in worlds:
            for area in sorted(areas_by_world[world.world_asset_id], key=lambda a: a.name):
                group_box = world_to_group[world.correct_name(area.in_dark_aether)]
                check = QtWidgets.QCheckBox(group_box)
                check.setText(area.name)
                check.area_location = AreaLocation(world.world_asset_id, area.area_asset_id)
                check.stateChanged.connect(functools.partial(_on_check_area, check))
                group_box.vertical_layout.addWidget(check)
                checks_for_area[area.area_asset_id] = check

        return checks_for_world, checks_for_area
Exemple #30
0
    def _init_widgets(self):
        self.view = QTabWidget()  # QGraphicsView()

        self.traceTab = QWidget()
        tracelayout = QVBoxLayout()

        self.traceView = QGraphicsView()
        self.traceScene = QGraphicsScene()
        self.traceView.setScene(self.traceScene)

        self.listView = QTableWidget(0, 2)  # row, col
        self.listView.setHorizontalHeaderItem(0, QTableWidgetItem("Trace ID"))
        self.listView.setHorizontalHeaderItem(1, QTableWidgetItem("Input ID"))
        self.listView.setSelectionMode(QAbstractItemView.SingleSelection)
        self.listView.setSelectionBehavior(QAbstractItemView.SelectRows)
        # self.listView.horizontalHeader().setStretchLastSection(True)
        # self.listView.horizontalHeader().setSectionResizeModel(0, QHeaderView.Stretch)
        self.listView.cellClicked.connect(self._switch_current_trace)

        self.traceSeedButton = QPushButton("View Input Seed")
        self.traceSeedButton.clicked.connect(self._view_input_seed)

        tracelayout.addWidget(self.traceView)
        tracelayout.addWidget(self.listView)
        tracelayout.addWidget(self.traceSeedButton)
        self.traceTab.setLayout(tracelayout)

        self.multiView = QWidget()
        multiLayout = QVBoxLayout()
        self.multiTraceList = QTableWidget(0, 2)  # row, col
        self.multiTraceList.setSelectionMode(QAbstractItemView.MultiSelection)
        self.multiTraceList.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.multiTraceList.setHorizontalScrollMode(
            self.multiTraceList.ScrollPerPixel)
        self.multiTraceList.setHorizontalHeaderItem(
            0, QTableWidgetItem("Trace ID"))
        self.multiTraceList.setHorizontalHeaderItem(
            1, QTableWidgetItem("Input ID"))
        self.selectMultiTrace = QPushButton("Refresh Heatmap")
        self.selectMultiTrace.clicked.connect(self._refresh_heatmap)
        multiLayout.addWidget(self.multiTraceList)
        multiLayout.addWidget(self.selectMultiTrace)
        self.multiView.setLayout(multiLayout)

        self.view.addTab(self.traceTab, "SingleTrace")
        self.view.addTab(self.multiView, "MultiTrace HeatMap")
        self.SINGLE_TRACE = 0
        self.MULTI_TRACE = 1

        self.view.currentChanged.connect(self._on_tab_change)

        self._reset()

        layout = QVBoxLayout()
        layout.addWidget(self.view)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setAlignment(self.view, Qt.AlignLeft)

        self.setLayout(layout)