コード例 #1
0
ファイル: importTab.py プロジェクト: michel-cf/pynfinitton
    def __init__(self, parent):
        QWidget.__init__(self, parent)

        layout = QGridLayout()

        pan_zoom = QScrollArea()
        self._selection_area = drawWidget.DrawWidget(pan_zoom)

        pan_zoom.setWidget(self._selection_area)
        layout.addWidget(pan_zoom, 0, 0, 4, 1)

        self._import_button = QPushButton('Import icon',
                                          self,
                                          clicked=self._on_import_button_click)
        layout.addWidget(self._import_button, 0, 1, 1, 4)

        self._zoom_in_button = QPushButton('Zoom in',
                                           self,
                                           clicked=self._on_zoom_in_click)
        layout.addWidget(self._zoom_in_button, 1, 1, 1, 2)

        self._zoom_out_button = QPushButton('Zoom out',
                                            self,
                                            clicked=self._on_zoom_out_click)
        layout.addWidget(self._zoom_out_button, 1, 3, 1, 2)

        self.setLayout(layout)
コード例 #2
0
class DeviceTab(QWidget, Form):
    def __init__(self, parent=None, database=None):
        super(DeviceTab, self).__init__(parent)
        Form.__init__(self, parent)
        self._database = database
        self._table_name = "DEVICE"
        self._table = Device
        self._layout = QFormLayout(self)
        self._child_widgets_not_set = True 

        self._scroll = QScrollArea(self)
        self._scroll.setWidgetResizable(True)
        self._layout.addRow(self._scroll)
        self._scroll_contents = QWidget(self)
        self._scroll_contents.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self._scroll_contents.setObjectName("cscroll")
        self._scroll_contents.setStyleSheet('QWidget[objectName^="cscroll"] {background-color: #FFFFFF;}')
        self._scroll.setWidget(self._scroll_contents)
        self._scroll_layout = QFormLayout(self._scroll_contents)

        self.connectWidgets()
        self.setDeviceArea()

    def setDeviceArea(self):
        form_box = FormGroupBox("Device Information", self)
        form_box.frame_layout.addRow("Name:", Device.NAME.value)
        form_box.frame_layout.addRow("Model:", Device.MODEL.value)
        form_box.frame_layout.addRow("Serial:", Device.SERIAL.value)
        form_box.frame_layout.addRow("Location:", Device.LOCATION.value)
        self._scroll_layout.addRow(form_box)

        
コード例 #3
0
    def init_ui(self):
        main_layout = QVBoxLayout()

        scroll_content = QWidget()
        task_box_layout = QGridLayout()
        scroll_content.setLayout(task_box_layout)
        row = 0

        unit_types = list(
            set(self.game_model.game.faction_for(player=True).ground_units))
        unit_types.sort(key=lambda u: u.name)
        for row, unit_type in enumerate(unit_types):
            self.add_purchase_row(unit_type, task_box_layout, row)
        stretch = QVBoxLayout()
        stretch.addStretch()
        task_box_layout.addLayout(stretch, row, 0)

        scroll_content.setLayout(task_box_layout)
        scroll = QScrollArea()
        scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        scroll.setWidgetResizable(True)
        scroll.setWidget(scroll_content)
        main_layout.addWidget(scroll)
        self.setLayout(main_layout)
コード例 #4
0
class EconomicTab(QWidget, Form):
    def __init__(self, parent=None, database=None):
        super(EconomicTab, self).__init__(parent)
        Form.__init__(self, parent)
        self._database = database
        self._table_name = "ECONOMIC"
        self._table = Economic
        self._layout = QFormLayout(self)
        self._child_widgets_not_set = True

        self._scroll = QScrollArea(self)
        self._scroll.setWidgetResizable(True)
        self._layout.addRow(self._scroll)
        self._scroll_contents = QWidget(self)
        self._scroll_contents.setSizePolicy(QSizePolicy.Expanding,
                                            QSizePolicy.Expanding)
        self._scroll_contents.setObjectName("ecoscroll")
        self._scroll_contents.setStyleSheet(
            'QWidget[objectName^="ecoscroll"] {background-color: #FFFFFF;}')
        self._scroll.setWidget(self._scroll_contents)
        self._scroll_layout = QFormLayout(self._scroll_contents)

        self.connectWidgets()
        self.setEconomicArea()

    def setEconomicArea(self):
        form_box = FormGroupBox("Economic Information", self)
        form_box.frame_layout.addRow("Employment Status:", Economic.POC.value)
        form_box.frame_layout.addRow("Home Value:", Economic.HOME_VAL.value)
        form_box.frame_layout.addRow("Income:", Economic.INCOME.value)
        self._scroll_layout.addRow(form_box)
コード例 #5
0
    def init_ui(self):
        self.mainLayout = QVBoxLayout()

        scroll_content = QWidget()
        task_box_layout = QGridLayout()
        scroll_content.setLayout(task_box_layout)

        for g in self.cp.ground_objects:
            # Airbase groups are the objects that are hidden on the map because
            # they're shown in the base menu.
            if not g.airbase_group:
                continue

            # Of these, we need to ignore the FOB structure itself since that's
            # not supposed to be targetable.
            if isinstance(self.cp, Fob) and isinstance(g, BuildingGroundObject):
                continue

            group_info = QBaseDefenseGroupInfo(self.cp, g, self.game)
            task_box_layout.addWidget(group_info)

        scroll_content.setLayout(task_box_layout)
        scroll = QScrollArea()
        scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        scroll.setWidgetResizable(True)
        scroll.setWidget(scroll_content)

        self.mainLayout.addWidget(scroll)

        self.setLayout(self.mainLayout)
コード例 #6
0
    def __init__(self, cp: ControlPoint, game_model: GameModel) -> None:
        super().__init__()
        self.cp = cp
        self.game_model = game_model
        self.transfers: Dict[Type[UnitType, int]] = defaultdict(int)

        main_layout = QVBoxLayout()

        scroll_content = QWidget()
        task_box_layout = QGridLayout()

        unit_types = set(
            self.game_model.game.faction_for(player=True).ground_units)
        sorted_units = sorted(
            {u
             for u in unit_types if self.cp.base.total_units_of_type(u)},
            key=lambda u: u.name,
        )
        for row, unit_type in enumerate(sorted_units):
            self.add_unit_row(unit_type, task_box_layout, row)
        stretch = QVBoxLayout()
        stretch.addStretch()
        task_box_layout.addLayout(stretch, task_box_layout.count(), 0)

        scroll_content.setLayout(task_box_layout)
        scroll = QScrollArea()
        scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        scroll.setWidgetResizable(True)
        scroll.setWidget(scroll_content)
        main_layout.addWidget(scroll)
        self.setLayout(main_layout)
コード例 #7
0
    def __init__(self, cp: ControlPoint, game_model: GameModel):
        super().__init__(self)
        self.cp = cp
        self.game_model = game_model

        self.bought_amount_labels = {}
        self.existing_units_labels = {}

        main_layout = QVBoxLayout()
        self.setLayout(main_layout)

        scroll_content = QWidget()
        task_box_layout = QGridLayout()
        scroll_content.setLayout(task_box_layout)

        units_column = sorted(cp.base.armor, key=lambda u: u.name)

        count = 0
        for count, unit_type in enumerate(units_column):
            self.add_purchase_row(unit_type, task_box_layout, count)
        stretch = QVBoxLayout()
        stretch.addStretch()
        task_box_layout.addLayout(stretch, count, 0)

        scroll_content.setLayout(task_box_layout)
        scroll = QScrollArea()
        scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        scroll.setWidgetResizable(True)
        scroll.setWidget(scroll_content)
        main_layout.addWidget(scroll)
コード例 #8
0
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)
コード例 #9
0
class PlayersWidget(QWidget):
    def __init__(self):
        factory = ApiRequestFactory.get_instance()
        QWidget.__init__(self)

        page_list = factory.get_players_from_page(1)

        self.layout = QVBoxLayout()

        label_widget = QWidget()
        label_widget.layout = QVBoxLayout()
        for page_obj in page_list[0]:
            for pl in page_obj[1]:
                lb_text = pl.first_name + ' ' + pl.last_name

                if pl.position is not None and (pl.position is not ''
                                                or pl.position is not ' '):
                    lb_text = lb_text + ': ' + pl.position

                player_lb = QLabel(text=lb_text)
                label_widget.layout.addWidget(player_lb)

        label_widget.setLayout(label_widget.layout)

        self.scroll_widget = QScrollArea()
        self.scroll_widget.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.scroll_widget.setBackgroundRole(QPalette.Light)
        self.scroll_widget.setWidgetResizable(True)

        self.scroll_widget.setWidget(label_widget)
        self.layout.addWidget(self.scroll_widget)

        self.setLayout(self.layout)
コード例 #10
0
class HomeInfoTab(QWidget, Form):
    def __init__(self, parent=None, database=None):
        super(HomeInfoTab, self).__init__(parent)
        Form.__init__(self, parent)
        self._database = database
        self._table_name = "HOME_INFO"
        self._table = HomeInfo
        self._layout = QFormLayout(self)
        self._child_widgets_not_set = True

        self._scroll = QScrollArea(self)
        self._scroll.setWidgetResizable(True)
        self._layout.addRow(self._scroll)
        self._scroll_contents = QWidget(self)
        self._scroll_contents.setSizePolicy(QSizePolicy.Expanding,
                                            QSizePolicy.Expanding)
        self._scroll_contents.setObjectName("hinfoscroll")
        self._scroll_contents.setStyleSheet(
            'QWidget[objectName^="hinfoscroll"] {background-color: #FFFFFF;}')
        self._scroll.setWidget(self._scroll_contents)
        self._scroll_layout = QFormLayout(self._scroll_contents)

        self.connectWidgets()
        self.setHomeInfoArea()

    def setHomeInfoArea(self):
        form_box = FormGroupBox("Home Information", self)
        form_box.frame_layout.addRow("Parcel:", HomeInfo.PARCEL.value)
        form_box.frame_layout.addRow("RedFin Home Value:",
                                     HomeInfo.REDFIN_VAL.value)
        self._scroll_layout.addRow(form_box)
コード例 #11
0
ファイル: main_window.py プロジェクト: pauljxtan/blog-code
    def _widgets(self):
        splitter = QSplitter()

        # -- Left
        left_splitter = QSplitter(Qt.Vertical)
        splitter.addWidget(left_splitter)

        # Top left
        filetree = FileTree(self._root_path,
                            self._on_filetree_selection_changed)
        left_splitter.addWidget(filetree)

        # Bottom left
        tagging = Tagging()
        left_splitter.addWidget(tagging)

        # -- Right
        image = ImageDisplay()
        # Wrap it in a resizable scroll area
        area = QScrollArea()
        area.setWidget(image)
        area.setWidgetResizable(True)
        area.setAlignment(Qt.AlignCenter)
        splitter.addWidget(area)

        # A slight hack to split width equally
        splitter.setSizes([100000, 100000])

        return splitter, filetree, tagging, image
コード例 #12
0
    def _init_widgets(self):
        layout = QVBoxLayout()

        # address

        lbl_addr = QLabel()
        lbl_addr.setText("Address")

        txt_addr = QLineEdit()
        txt_addr.returnPressed.connect(self._on_address_entered)
        self._txt_addr = txt_addr

        top_layout = QHBoxLayout()
        top_layout.addWidget(lbl_addr)
        top_layout.addWidget(txt_addr)

        self._view = QMemoryView(self.state, self.workspace)

        area = QScrollArea()
        self._scrollarea = area
        area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        area.setWidgetResizable(True)

        area.setWidget(self._view)

        layout.addLayout(top_layout)
        layout.addWidget(area)
        layout.setContentsMargins(0, 0, 0, 0)

        self.setLayout(layout)
コード例 #13
0
    def __init__(self, config, resource):
        """Setup each channel widget and place in QVBoxlayout"""
        QWidget.__init__(self)
        self.config = config
        self.resource = resource

        area = QScrollArea()
        contents = QWidget()
        rows = QVBoxLayout(contents)
        layout = QVBoxLayout(self)
        layout.addWidget(area)
        area.setWidget(contents)
        area.setWidgetResizable(True)
        layout.setContentsMargins(0, 0, 0, 0)
        rows.setContentsMargins(0, 0, 0, 0)
        rows.setSpacing(0)

        self.channels = []
        for channel in config["channels"]:
            self.channels.append(
                ChannelWidget(channel["channel"], config, resource))
            rows.addWidget(self.channels[-1])

        # Set initial status and set status timer
        self.update_status()
        self.timer = QTimer()
        self.timer.timeout.connect(self.update_status)
        self.timer.start(UPDATE_INTERVAL)
コード例 #14
0
ファイル: match_stat.py プロジェクト: jczigany/scorer
    def __init__(self, parent=None):
        super(MatchStatWindow, self).__init__(parent)
        self.setModal(True)
        self.setWindowTitle("Mérkőzés választása")
        self.resize(740, 600)
        self.layout = QVBoxLayout()
        self.setLayout(self.layout)

        self.merkozesek = QListWidget()
        self.merkozesek.setFixedHeight(200)
        self.merkozesek.setFixedWidth(730)
        self.merkozesek.itemDoubleClicked.connect(self.stat_game)
        self.layout.addWidget(self.merkozesek)
        self.szumma = MatchSumWidget(self)
        self.layout.addWidget(self.szumma)
        self.history = QWidget()
        self.history.setFixedWidth(690)
        self.history_layout = QGridLayout()
        self.history.setLayout(self.history_layout)
        scroll = QScrollArea()
        scroll.setWidget(self.history)
        scroll.setWidgetResizable(True)
        self.layout.addWidget(scroll)

        self.match_valasztas()
コード例 #15
0
    class __Tab(QWidget):
        """ This code is for showing device specific items. This is just a scrollable display area. """
        def __init__(self):
            self.logger = logging.getLogger(__name__)
            self.logger.debug("Initializing")
            super().__init__()
            self.setLayout(QVBoxLayout())
            self.__scroll_area = QScrollArea(self)
            size_policy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
            size_policy.setHorizontalStretch(0)
            size_policy.setVerticalStretch(0)
            size_policy.setHeightForWidth(
                self.__scroll_area.hasHeightForWidth())
            self.__scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
            self.__scroll_area.setHorizontalScrollBarPolicy(
                Qt.ScrollBarAsNeeded)
            self.__scroll_area.setSizeAdjustPolicy(
                QAbstractScrollArea.AdjustToContents)
            self.__scroll_area.setSizePolicy(size_policy)
            self.__scroll_area.setWidgetResizable(True)
            self.layout().addWidget(self.__scroll_area)
            self.logger.debug("Initialized")

        def add_contents(self, contents):
            self.logger.debug("running")
            self.__scroll_area.setWidget(contents)
            self.logger.debug("done")
コード例 #16
0
    def __init__(self, cp: ControlPoint, game_model: GameModel):
        super().__init__()
        self.cp = cp
        self.setMinimumWidth(500)

        layout = QVBoxLayout()
        self.setLayout(layout)

        scroll_content = QWidget()
        task_box_layout = QGridLayout()
        scroll_content.setLayout(task_box_layout)

        for convoy in game_model.game.coalition_for(
                cp.captured).transfers.convoys.departing_from(cp):
            group_info = DepartingConvoyInfo(convoy)
            task_box_layout.addWidget(group_info)

        for cargo_ship in game_model.game.coalition_for(
                cp.captured).transfers.cargo_ships.departing_from(cp):
            group_info = DepartingConvoyInfo(cargo_ship)
            task_box_layout.addWidget(group_info)

        scroll_content.setLayout(task_box_layout)
        scroll = QScrollArea()
        scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        scroll.setWidgetResizable(True)
        scroll.setWidget(scroll_content)
        layout.addWidget(scroll)
コード例 #17
0
def wrap_image(image: ImageView) -> QScrollArea:
    """Wraps an image in a scrollable and resizable container."""
    area = QScrollArea()
    area.setWidget(image)
    area.setWidgetResizable(True)
    area.setAlignment(Qt.AlignCenter)
    return area
コード例 #18
0
    def __init__(self, base_path, file, file_config, parent=None):
        super().__init__(parent)

        board = BanBoard(file, file_config)
        board_area = QScrollArea()
        board_area.setWidget(board)
        board_area.setWidgetResizable(True)
        self.setCentralWidget(board_area)

        self.stbar = QStatusBar()

        # add a save button at the right bottom corner
        save_btn = BanButton(
            "save",
            objectName="appBtn_save",
            toolTip="save xban file",
            shortcut="Ctrl+S",
        )

        shadow = QGraphicsDropShadowEffect(self,
                                           blurRadius=10,
                                           offset=5,
                                           color=QColor("lightgrey"))
        save_btn.setGraphicsEffect(shadow)
        save_btn.pressed.connect(board.save_board)

        self.stbar.addPermanentWidget(save_btn)
        self.setStatusBar(self.stbar)
        log_handler = QLogHandler(self)
        root_logger = logging.getLogger()
        root_logger.addHandler(log_handler)
        log_handler.signal.log_msg.connect(
            partial(self.stbar.showMessage, timeout=1500))
        self.stbar.showMessage(f"Initiate {file}", 1500)
        self.show()
コード例 #19
0
    def init_ui(self):
        main_layout = QVBoxLayout()

        units = {
            PinpointStrike:
            db.find_unittype(PinpointStrike, self.game.player_name),
        }

        scroll_content = QWidget()
        task_box_layout = QGridLayout()
        scroll_content.setLayout(task_box_layout)
        row = 0

        for task_type in units.keys():
            units_column = list(set(units[task_type]))
            if len(units_column) == 0: continue
            units_column.sort(key=lambda x: db.PRICES[x])
            for unit_type in units_column:
                row = self.add_purchase_row(unit_type, task_box_layout, row)
            stretch = QVBoxLayout()
            stretch.addStretch()
            task_box_layout.addLayout(stretch, row, 0)

        scroll_content.setLayout(task_box_layout)
        scroll = QScrollArea()
        scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        scroll.setWidgetResizable(True)
        scroll.setWidget(scroll_content)
        main_layout.addWidget(scroll)
        self.setLayout(main_layout)
コード例 #20
0
ファイル: page2.py プロジェクト: chusopr/musync
    def __init__(self):
        super().__init__()
        page2Layout = QVBoxLayout(self)

        table_header = QHBoxLayout()
        label0 = QLabel()
        label0.setObjectName("label0")
        table_header.addWidget(label0)
        table_header.addItem(QSpacerItem(1, 1, QSizePolicy.Expanding, QSizePolicy.Minimum))
        label1 = QLabel()
        label1.setObjectName("label1")
        table_header.addWidget(label1)
        page2Layout.addLayout(table_header)

        hLine = QFrame(self.__songs_table)
        hLine.setFrameShape(QFrame.HLine)
        hLine.setFrameShadow(QFrame.Sunken)
        page2Layout.addWidget(hLine)

        scrollArea = QScrollArea()
        scrollClient = QWidget()
        scrollClient.setObjectName("scrollClient")
        scrollArea.setWidgetResizable(True)
        scrollArea.setWidget(scrollClient)
        page2Layout.addWidget(scrollArea)

        self.__new_song_row.connect(self.__add_song_row)
コード例 #21
0
class PeopleTab(QWidget, Form):
    def __init__(self, parent=None, database=None):
        super(PeopleTab, self).__init__(parent)
        Form.__init__(self, parent)
        self._database = database
        self._table_name = "PEOPLE"
        self._table = People
        self._layout = QFormLayout(self)
        self._child_widgets_not_set = True

        self._scroll = QScrollArea(self)
        self._scroll.setWidgetResizable(True)
        self._layout.addRow(self._scroll)
        self._scroll_contents = QWidget(self)
        self._scroll_contents.setSizePolicy(QSizePolicy.Expanding,
                                            QSizePolicy.Expanding)
        self._scroll_contents.setObjectName("peoscroll")
        self._scroll_contents.setStyleSheet(
            'QWidget[objectName^="peoscroll"] {background-color: #FFFFFF;}')
        self._scroll.setWidget(self._scroll_contents)
        self._scroll_layout = QFormLayout(self._scroll_contents)

        self.connectWidgets()
        self.setPeopleArea()

    def setPeopleArea(self):
        form_box = FormGroupBox("Occupant Information", self)
        form_box.frame_layout.addRow("Number of Occupants:",
                                     People.PEOPLE_COUNT.value)
        form_box.frame_layout.addRow("Occupant Ages:", People.AGES.value)
        form_box.frame_layout.addRow("Highest Education:",
                                     People.HIGHEST_EDU.value)
        self._scroll_layout.addRow(form_box)
コード例 #22
0
class Downloads(QWidget):
    def __init__(self):
        super(Downloads, self).__init__()
        self.history = get_download_history()
        self.history.reverse()

        self.layout = QStackedLayout()
        self.layout.setMargin(0)

        self.page_widget = QScrollArea()
        self.page_widget.setWidgetResizable(True)

        widget = QWidget(self.page_widget)
        widget.setMinimumWidth(350)
        self.page_widget.setWidget(widget)

        self.page_layout = QVBoxLayout(widget, alignment=Qt.AlignTop)
        self.page_layout.setMargin(0)
        self.page_layout.setContentsMargins(25, 25, 25, 25)
        self.layout.addWidget(self.page_widget)
        self.layout.setCurrentWidget(self.page_widget)

        if len(self.history) == 0:
            self.history_empty_label = QLabel('No downloads',
                                              alignment=Qt.AlignCenter)
            self.layout.addWidget(self.history_empty_label)
            self.layout.setCurrentWidget(self.history_empty_label)

        for item in self.history:
            self.page_layout.addWidget(DownloadItem(item=item))

        self.setLayout(self.layout)
コード例 #23
0
    def _init_widgets(self):
        if self._state.am_none():
            return

        layout = QVBoxLayout()
        area = QScrollArea()
        area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        area.setWidgetResizable(True)

        table = QTableWidget(0, 0)
        table.setColumnCount(len(self.COLUMNS))
        table.setHorizontalHeaderLabels(self.COLUMNS)

        self.table = table
        layout.addWidget(table)

        # common ones
        layout.setSpacing(0)
        layout.addStretch(0)
        layout.setContentsMargins(2, 2, 2, 2)

        # the container
        container = QFrame()
        container.setAutoFillBackground(True)
        palette = container.palette()
        palette.setColor(container.backgroundRole(), Qt.white)
        container.setPalette(palette)
        container.setLayout(layout)

        area.setWidget(container)

        base_layout = QVBoxLayout()
        base_layout.addWidget(area)
        self.setLayout(base_layout)
コード例 #24
0
class BaseTab(QWidget):
    """
    Class that encapsulates logic for a tab that displays an RDP connection, regardless of its origin
    (network or file).
    """

    def __init__(self, viewer: QRemoteDesktop, parent: QWidget = None):
        """
        :param viewer: the RDP viewer widget
        :param parent: the parent widget
        """
        super().__init__(parent, Qt.WindowFlags())
        self.widget = viewer

        self.writeInCaps = False
        self.text = QTextEdit()
        self.text.setReadOnly(True)
        self.text.setMinimumHeight(150)
        self.log = logging.getLogger(LOGGER_NAMES.PLAYER)

        self.tabLayout = QVBoxLayout()

        self.scrollViewer = QScrollArea()
        self.scrollViewer.setWidget(self.widget)

        self.tabLayout.addWidget(self.scrollViewer, 10)
        self.tabLayout.addWidget(self.text, 2)

        self.setLayout(self.tabLayout)
コード例 #25
0
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)
コード例 #26
0
    def init_ui(self):
        main_layout = QVBoxLayout()

        units = {
            CAP: db.find_unittype(CAP, self.game.player_name),
            CAS: db.find_unittype(CAS, self.game.player_name),
        }

        scroll_content = QWidget()
        task_box_layout = QGridLayout()
        row = 0

        for task_type in units.keys():
            units_column = list(set(units[task_type]))
            if len(units_column) == 0: continue
            units_column.sort(key=lambda x: db.PRICES[x])
            for unit_type in units_column:
                if self.cp.is_carrier and not unit_type in db.CARRIER_CAPABLE:
                    continue
                if self.cp.is_lha and not unit_type in db.LHA_CAPABLE:
                    continue
                row = self.add_purchase_row(unit_type, task_box_layout, row)
            stretch = QVBoxLayout()
            stretch.addStretch()
            task_box_layout.addLayout(stretch, row, 0)

        scroll_content.setLayout(task_box_layout)
        scroll = QScrollArea()
        scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        scroll.setWidgetResizable(True)
        scroll.setWidget(scroll_content)
        main_layout.addWidget(scroll)
        self.setLayout(main_layout)
コード例 #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()
コード例 #28
0
class ServerDatabaseSystem(QWidget):
    def __init__(self, open_file_call, conn):
        super().__init__()
        self.conn = conn
        self.cursor = self.conn.cursor()
        self.open_file_call = open_file_call

        self.setStyleSheet(styles.file_path_button)
        self.setMaximumHeight(HEIGHT)

        self.v_layout = QVBoxLayout()

        self.area = QScrollArea(self)
        self.area.setWidgetResizable(True)

        self.refresh_btn = QPushButton(QIcon(icon.RESET_I()), '', self)
        self.refresh_btn.clicked.connect(self.refresh)

        self.v_layout.addWidget(self.refresh_btn)
        self.v_layout.addWidget(self.area)

        self.set_scroll_area()

        self.setLayout(self.v_layout)

    def refresh(self):
        w = self.area.widget()
        w.setParent(None)
        del w
        self.set_scroll_area()

    def set_scroll_area(self):
        scroll_content = QWidget(self.area)
        scroll_layout = QVBoxLayout(scroll_content)

        scroll_content.setLayout(scroll_layout)

        self.cursor.callproc('getAllTablesFromSchema',
                             ["sistem_visokoskolske_ustanove"])
        _list = sorted(format_mysql(self.cursor.stored_results()))

        for table in _list:
            '''if os.path.isdir(file_absolute_path):
                scroll_layout.addWidget(Folder(scroll_content,
                                               self.open_file_call,
                                               self.connection + os.path.sep + table))
                continue

            if os.path.splitext(file_absolute_path)[1] != '.csv':
                continue
            '''
            scroll_layout.addWidget(
                SQLTable(scroll_content, table[1], table[1],
                         self.open_file_call))

        scroll_layout.addStretch(1)

        self.area.setWidget(scroll_content)
        self.cursor.close()
コード例 #29
0
 def _wrap_in_scroll_area(
     self,
     widget: QWidget,
 ) -> QScrollArea:
     scroll_area = QScrollArea(self)
     scroll_area.setWidget(widget)
     scroll_area.setWidgetResizable(True)
     return scroll_area
コード例 #30
0
 def make_tab(self, title):
     area = QScrollArea()
     field = Field(area, title)
     area.setBackgroundRole(QPalette.Mid)
     area.setWidgetResizable(True)
     area.setWidget(self.add_fields(self, title, field))
     self.fields.append(field)
     return area