Example #1
0
    def _setup_ui(self):
        self.setFrameStyle(QFrame.StyledPanel | QFrame.Raised)

        layout = QGridLayout(self)
        self.setLayout(layout)
        layout.setMargin(1)
        layout.setHorizontalSpacing(10)
        layout.setVerticalSpacing(1)

        self._create_header('MONITOR', layout, 0)
        self._mon_temp = self._create_meas('TEMP', layout, 1, 0, True)
        self._vccint = self._create_meas('VCCINT', layout, 2, 0, False)
        self._vccaux = self._create_meas('VCCAUX', layout, 3, 0, False)
        self._p3v3io = self._create_meas('+3V3IO', layout, 4, 0, False)

        self._create_header('AGC', layout, 2)
        self._agc_temp = self._create_meas('TEMP', layout, 1, 2, True)
        self._bplssw = self._create_meas('BPLSSW', layout, 2, 2, False)
        self._p4sw = self._create_meas('+4SW', layout, 3, 2, False)

        label = QLabel('MEASUREMENTS', self)
        font = label.font()
        font.setPointSize(12)
        font.setBold(True)
        label.setFont(font)
        label.setAlignment(Qt.AlignCenter)
        layout.addWidget(label, 4, 2, 1, 2, Qt.AlignRight)
Example #2
0
class StatisticsPanel(QWidget):
    _MAX_STAT_ROW = 3

    def __init__(self, parent: QWidget = None):
        super().__init__(parent)
        self.spinner = QtWaitingSpinner(parent=self, centerOnParent=True,
                                        disableParentWhenSpinning=True)

        self.spinner.setInnerRadius(15)
        self.layout = QGridLayout()
        self.layout.setHorizontalSpacing(2)
        self.layout.setVerticalSpacing(4)
        self.setLayout(self.layout)

    def setStatistics(self, stat: Dict[str, object]) -> None:
        item: QLayoutItem = self.layout.takeAt(0)
        while item:
            item.widget().deleteLater()
            self.layout.removeItem(item)
            item = self.layout.takeAt(0)
        r: int = 0
        c: int = 0
        for k, v in stat.items():
            self.layout.addWidget(QLabel('{}:'.format(k), self), r, c, 1, 1,
                                  alignment=Qt.AlignLeft)
            self.layout.addWidget(QLabel('{}'.format(str(v)), self), r, c + 1, 1, 1,
                                  alignment=Qt.AlignLeft)
            r += 1
            if r % StatisticsPanel._MAX_STAT_ROW == 0:
                self.layout.setColumnMinimumWidth(c + 2, 5)  # separator
                c += 3
                r = 0
Example #3
0
    def initUI(self):
        grid = QGridLayout()
        grid.setHorizontalSpacing(2)
        grid.setVerticalSpacing(2)
        # Reference
        # https://stackoverflow.com/questions/16673074/how-can-i-fully-disable-resizing-a-window-including-the-resize-icon-when-the-mou
        grid.setSizeConstraint(QLayout.SetFixedSize)
        self.setLayout(grid)

        # This is register
        self.ent = Register()

        # This is display value of register
        self.lcd = QLCDNumber(self)
        self.lcd.setDigitCount(self.max_chars + 2)
        self.lcd.setSmallDecimalPoint(True)
        self.lcd.display(self.ent.get_text())
        self.lcd.setStyleSheet("QLCDNumber {color:darkgreen;}")
        self.lcd.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        grid.addWidget(self.lcd, 0, 0, 1, 4)
        grid.setRowMinimumHeight(0, 40)

        for key in self.keys_info:
            but = QPushButton(key['label'])
            method_name = key['method']
            method = getattr(self, method_name)
            but.clicked.connect(method)
            but.setStyleSheet(
                "QPushButton {font-size:12pt; padding:5px 30px; color:#666;}")
            but.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
            grid.addWidget(but, key['y'], key['x'], key['h'], key['w'])
Example #4
0
    def __init__(self):
        super().__init__()

        self._squares = [[SquareView((i, j)) for j in range(20)]
                         for i in range(20)]
        self._board_size = 20

        # Setup the layout
        layout = QGridLayout()
        layout.setHorizontalSpacing(2)
        layout.setVerticalSpacing(2)

        for i in range(self._board_size):
            # Row numbers decreasing
            row_label = Label("row", str(self._board_size - i))
            # TODO: Get alignment in styles/styles.qss
            row_label.setAlignment(Qt.AlignRight)
            layout.addWidget(row_label, i, 0)

            for j in range(self._board_size):
                layout.addWidget(self.squares[i][j], i, j + 1)

        # Column labels
        for i in range(self._board_size):
            col_label = Label("column", chr(i + ord("a")))
            # TODO: Get alignment in styles/styles.qss
            col_label.setAlignment(Qt.AlignHCenter)
            layout.addWidget(col_label, self._board_size, i + 1)

        self.setLayout(layout)
Example #5
0
class QConditionsWidget(QFrame):
    """
    UI Component to display Turn Number, Day Time & Hour and weather combined.
    """
    def __init__(self):
        super(QConditionsWidget, self).__init__()
        self.setProperty("style", "QConditionsWidget")

        self.layout = QGridLayout()
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.setHorizontalSpacing(0)
        self.layout.setVerticalSpacing(0)
        self.setLayout(self.layout)

        self.time_turn_widget = QTimeTurnWidget()
        self.time_turn_widget.setStyleSheet("QGroupBox { margin-right: 0px; }")
        self.layout.addWidget(self.time_turn_widget, 0, 0)

        self.weather_widget = QWeatherWidget()
        self.weather_widget.setStyleSheet(
            "QGroupBox { margin-top: 5px; margin-left: 0px; border-left: 0px; }"
        )
        self.weather_widget.hide()
        self.layout.addWidget(self.weather_widget, 0, 1)

    def setCurrentTurn(self, turn: int, conditions: Conditions) -> None:
        """Sets the turn information display.

        :arg turn Current turn number.
        :arg conditions Current time and weather conditions.
        """
        self.time_turn_widget.setCurrentTurn(turn, conditions)
        self.weather_widget.setCurrentTurn(turn, conditions)
        self.weather_widget.show()
Example #6
0
    def __init__(self, parent, data):
        super(SegmentsWidget, self).__init__(parent)

        layout = QGridLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setVerticalSpacing(1)
        layout.setHorizontalSpacing(
            UIContext.getScaledWindowSize(16, 16).width())

        self.segments = []
        for segment in data.segments:
            if segment.readable or segment.writable or segment.executable:
                self.segments.append(segment)
        self.segments.sort(key=lambda segment: segment.start)

        row = 0
        for segment in self.segments:
            begin = "0x%x" % segment.start
            end = "0x%x" % segment.end

            permissions = ""
            if segment.readable:
                permissions += "r"
            else:
                permissions += "-"
            if segment.writable:
                permissions += "w"
            else:
                permissions += "-"
            if segment.executable:
                permissions += "x"
            else:
                permissions += "-"

            rangeLayout = QHBoxLayout()
            rangeLayout.setContentsMargins(0, 0, 0, 0)
            beginLabel = headers.ClickableAddressLabel(begin)
            dashLabel = QLabel("-")
            dashLabel.setFont(binaryninjaui.getMonospaceFont(self))
            endLabel = headers.ClickableAddressLabel(end)
            rangeLayout.addWidget(beginLabel)
            rangeLayout.addWidget(dashLabel)
            rangeLayout.addWidget(endLabel)
            layout.addLayout(rangeLayout, row, 0)

            permissionsLabel = QLabel(permissions)
            permissionsLabel.setFont(binaryninjaui.getMonospaceFont(self))
            layout.addWidget(permissionsLabel, row, 1)

            row += 1

        layout.setColumnStretch(2, 1)
        self.setLayout(layout)
    def init_ui(self):
        layout = QGridLayout()
        layout.setHorizontalSpacing(1)
        layout.addWidget(QAircraftRecruitmentMenu(self.cp, self.game_model), 0,
                         0)

        planned = QGroupBox("Planned Flights")
        planned_layout = QVBoxLayout()
        planned_layout.addWidget(QPlannedFlightsView(self.game_model, self.cp))
        planned.setLayout(planned_layout)
        layout.addWidget(planned, 0, 1)

        self.setLayout(layout)
Example #8
0
    def __init__(self, parent=None):
        super().__init__(parent=parent)

        # Create layout
        layout = QGridLayout()
        layout.setHorizontalSpacing(0)
        layout.setVerticalSpacing(0)

        self.letters = {}

        for letter, (i, j) in self.letter_positions.items():
            self.letters[letter] = UsedLetter(letter)
            layout.addWidget(self.letters[letter], i, j)

        self.setLayout(layout)
Example #9
0
 def _create_cells(self) -> Tuple[QWidget, List[List[FE14MapCell]]]:
     widget = QWidget(parent=self)
     layout = QGridLayout()
     cells = []
     for r in range(0, 32):
         row = []
         for c in range(0, 32):
             cell = self._create_cell(r, c)
             layout.addWidget(cell, r, c)
             row.append(cell)
         cells.append(row)
     layout.setVerticalSpacing(0)
     layout.setHorizontalSpacing(0)
     widget.setLayout(layout)
     return widget, cells
Example #10
0
    def __init__(self):
        super().__init__()

        self._analysis = None
        self._cancel_message_box = None

        self._title = PageTitle("Initialisation de l'analyse", False, self)

        self._stat_component = StatComponent()
        self._image_component = ImageComponent()
        self._progress_component = ProgressComponent()

        components_layout = QGridLayout()
        components_layout.setHorizontalSpacing(20)
        components_layout.setColumnStretch(0, 6)
        components_layout.setColumnStretch(1, 5)

        components_layout.addWidget(self._stat_component, 0, 0)
        components_layout.addWidget(self._image_component, 0, 1)
        components_layout.addWidget(self._progress_component, 1, 0, 1, 2)

        self._return_button = StylizedButton("Annuler", "yellow")
        self._return_button.setSizePolicy(QSizePolicy.Maximum,
                                          QSizePolicy.Maximum)

        button_layout = QHBoxLayout()
        button_layout.setAlignment(Qt.AlignRight)
        button_layout.setSpacing(35)
        button_layout.addWidget(self._return_button)

        main_layout = QVBoxLayout()
        main_layout.addWidget(self._title)
        main_layout.addLayout(components_layout)
        main_layout.addLayout(button_layout)

        self.setLayout(main_layout)

        self._return_button.clicked.connect(self._returnClick)

        self._analysis_thread = AnalysisThread()
        self._analysis_thread.initialized.connect(
            self._neuralNetworkInitialized)
        self._analysis_thread.imageProcessed.connect(self._imageProcessed)
        self._analysis_thread.completed.connect(self._analysisFinished)

        self._post_analysis_thread = PostAnalysisThread()
        self._post_analysis_thread.completed.connect(
            self._postAnalysisFinished)
Example #11
0
    def buildRightDataDisplays(self):
        grid = QGridLayout()

        for index, display in enumerate(constants.RIGHT_DATA_DISPLAYS):
            units = display['units'] if 'units' in display else ''
            widget = QSmallDataDisplay(self, display['label'], units)

            self.dataDisplays[display['field']] = widget
            grid.addWidget(widget,
                           int(index / constants.RIGHT_DATA_DISPLAYS_PER_ROW),
                           index % constants.RIGHT_DATA_DISPLAYS_PER_ROW)

        grid.setHorizontalSpacing(1)
        grid.setVerticalSpacing(1)

        return grid
Example #12
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setFont(QFont("Berlin Sans FB", 10))
        self.setWindowTitle("File ENC")
        self.setFixedSize(500, 220)

        self.btn_src = QPushButton("browse")
        self.btn_dst = QPushButton("browse")
        self.btn_enc = QPushButton("Encrypt")
        self.btn_dec = QPushButton("Decrypt")
        self.btn_src.setFixedSize(60, WIDGET_HEIGHT)
        self.btn_dst.setFixedSize(60, WIDGET_HEIGHT)
        self.btn_src.clicked.connect(self.open_file_dialog)
        self.btn_dst.clicked.connect(self.open_dir_dialog)
        self.btn_enc.clicked.connect(self.encrypt_file)
        self.btn_dec.clicked.connect(self.decrypt_file)

        self.LE_file_path = QLineEdit()
        self.LE_file_path.setPlaceholderText("Source File Path...")
        self.LE_file_path.setFixedHeight(WIDGET_HEIGHT)
        self.LE_file_path.setReadOnly(True)

        self.LE_dir_path = QLineEdit()
        self.LE_dir_path.setPlaceholderText("Destination Path...")
        self.LE_dir_path.setFixedHeight(WIDGET_HEIGHT)
        self.LE_dir_path.setReadOnly(True)

        self.LE_key = QLineEdit()
        self.LE_key.setPlaceholderText("Enter the Cipher Key...")
        self.LE_key.setFixedHeight(WIDGET_HEIGHT)

        layout = QGridLayout()
        layout.setRowMinimumHeight(0, 30)
        layout.addWidget(self.btn_src, 0, 1)
        layout.addWidget(self.btn_dst, 1, 1)
        layout.addWidget(self.btn_enc, 3, 0, 1, 2, alignment=Qt.AlignHCenter)
        layout.addWidget(self.btn_dec, 4, 0, 1, 2, alignment=Qt.AlignHCenter)
        layout.addWidget(self.LE_file_path, 0, 0)
        layout.addWidget(self.LE_dir_path, 1, 0)
        layout.addWidget(self.LE_key, 2, 0, 1, 2)
        layout.setHorizontalSpacing(10)
        layout.setHorizontalSpacing(0)
        print(layout.rowStretch(0))
        self.setLayout(layout)
        self.show()
Example #13
0
class PuzzleGrid(QWidget):
    def __init__(self, parent=None, **kwargs):
        super().__init__(parent=parent, **kwargs)

        # Create layout
        self.layout = QGridLayout()
        self.layout.setHorizontalSpacing(0)
        self.layout.setVerticalSpacing(0)

        self.tiles = []
        for v in range(TILES_VERTICAL):
            for h in range(TILES_HORIZONTAL):
                tile = Tile(parent=self)
                self.tiles.append(tile)
                self.layout.addWidget(tile, v, h, 1, 1)

        self.setLayout(self.layout)

    def loadPuzzle(self, puzzle):
        i = 0
        for row in puzzle:
            for letter in row:
                self.tiles[i].setLetter(letter)
                i += 1

    def reveal(self, letter=None):
        revealed = 0
        for tile in self.tiles:
            if letter is None or tile.text() == letter.upper():
                tile.reveal()
                revealed += 1
        return revealed

    def hide(self, letter):
        for tile in self.tiles:
            if tile.text() == letter.upper():
                tile.hide()

    def clear(self):
        for tile in self.tiles:
            tile.setLetter(None)
Example #14
0
    def initPixelInfoLayout(self):
        layout = QGridLayout()
        layout.setColumnStretch(3, 9)
        layout.setVerticalSpacing(0)
        layout.setHorizontalSpacing(20)

        self.pixelXY1Label = QLabel()
        self.pixelXY2Label = QLabel()
        self.pixelIndex1Label = QLabel()
        self.pixelIndex2Label = QLabel()
        self.pixelColor1Label = QLabel()
        self.pixelColor2Label = QLabel()

        layout.addWidget(self.pixelXY1Label,
                         0,
                         0,
                         alignment=Qt.AlignLeft | Qt.AlignTop)
        layout.addWidget(self.pixelXY2Label,
                         1,
                         0,
                         alignment=Qt.AlignLeft | Qt.AlignTop)
        layout.addWidget(self.pixelIndex1Label,
                         0,
                         1,
                         alignment=Qt.AlignLeft | Qt.AlignTop)
        layout.addWidget(self.pixelIndex2Label,
                         1,
                         1,
                         alignment=Qt.AlignLeft | Qt.AlignTop)
        layout.addWidget(self.pixelColor1Label,
                         0,
                         2,
                         alignment=Qt.AlignLeft | Qt.AlignTop)
        layout.addWidget(self.pixelColor2Label,
                         1,
                         2,
                         alignment=Qt.AlignLeft | Qt.AlignTop)

        return layout
Example #15
0
 def generate_layout(self):
     layout = QGridLayout()
     layout.setMargin(7)
     layout.setHorizontalSpacing(7)
     layout.setVerticalSpacing(7)
     inner_layouts = []
     for row, col in itertools.product(range(3), range(3)):
         inner_layout = QGridLayout()
         inner_layout.setMargin(0)
         inner_layout.setHorizontalSpacing(3)
         inner_layout.setVerticalSpacing(3)
         inner_layouts.append(inner_layout)
         layout.addLayout(inner_layout, row, col)
     for cell in range(len(self.cells)):
         row = int(cell / 9)
         col = int(cell % 9)
         band = int(row / 3)
         stack = int(col / 3)
         box = int(band * 3 + stack)
         minirow = int(row % 3)
         minicol = int(col % 3)
         inner_layouts[box].addWidget(self.cells[cell], minirow, minicol)
     self.setLayout(layout)
Example #16
0
class _Widget(QWidget):
    _SPACER: int = 20

    def __init__(self, parent=None):
        super().__init__(parent)
        self.mainLayout = QVBoxLayout(self)
        self.byTime = QCheckBox('By time', self)
        self.byDate = QCheckBox('By date', self)
        self.group = QButtonGroup(self)
        butLayout = QHBoxLayout()
        butLayout.addWidget(self.byDate)
        butLayout.addWidget(self.byTime)
        self.group.addButton(self.byDate)
        self.group.addButton(self.byTime)
        self.addRowBut = QPushButton('Add interval', self)
        self.addRowBut.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.gLayout = QGridLayout()
        self.mainLayout.addLayout(butLayout)
        self.mainLayout.addWidget(self.addRowBut, 0, Qt.AlignLeft)
        self.mainLayout.addLayout(self.gLayout)
        self.gLayout.setHorizontalSpacing(self._SPACER)
        self.group.setExclusive(False)
        self.byDate.setChecked(True)
        self.byTime.setChecked(True)
Example #17
0
class Ui_Dialog(object):
    def setupUi(self, Dialog):
        if not Dialog.objectName():
            Dialog.setObjectName(u"Dialog")
        Dialog.resize(450, 235)
        Dialog.setMinimumSize(QSize(450, 235))
        Dialog.setMaximumSize(QSize(450, 235))
        Dialog.setStyleSheet(u"QDialog {\n" "	background:rgb(51,51,51);\n" "}")
        self.verticalLayout = QVBoxLayout(Dialog)
        self.verticalLayout.setSpacing(0)
        self.verticalLayout.setObjectName(u"verticalLayout")
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.frame_2 = QFrame(Dialog)
        self.frame_2.setObjectName(u"frame_2")
        self.frame_2.setStyleSheet(u"background:rgb(51,51,51);")
        self.frame_2.setFrameShape(QFrame.NoFrame)
        self.frame_2.setFrameShadow(QFrame.Plain)
        self.verticalLayout_2 = QVBoxLayout(self.frame_2)
        self.verticalLayout_2.setSpacing(0)
        self.verticalLayout_2.setObjectName(u"verticalLayout_2")
        self.verticalLayout_2.setContentsMargins(2, 2, 2, 2)
        self.frame_top = QFrame(self.frame_2)
        self.frame_top.setObjectName(u"frame_top")
        self.frame_top.setMinimumSize(QSize(0, 55))
        self.frame_top.setMaximumSize(QSize(16777215, 55))
        self.frame_top.setStyleSheet(u"background:rgb(91,90,90);")
        self.frame_top.setFrameShape(QFrame.NoFrame)
        self.frame_top.setFrameShadow(QFrame.Plain)
        self.horizontalLayout = QHBoxLayout(self.frame_top)
        self.horizontalLayout.setSpacing(0)
        self.horizontalLayout.setObjectName(u"horizontalLayout")
        self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
        self.lab_heading = QLabel(self.frame_top)
        self.lab_heading.setObjectName(u"lab_heading")
        font = QFont()
        font.setFamily(u"Segoe UI")
        font.setPointSize(14)
        self.lab_heading.setFont(font)
        self.lab_heading.setStyleSheet(u"color:rgb(255,255,255);")
        self.lab_heading.setAlignment(Qt.AlignCenter)

        self.horizontalLayout.addWidget(self.lab_heading)

        self.bn_min = QPushButton(self.frame_top)
        self.bn_min.setObjectName(u"bn_min")
        self.bn_min.setMinimumSize(QSize(55, 55))
        self.bn_min.setMaximumSize(QSize(55, 55))
        self.bn_min.setStyleSheet(u"QPushButton {\n"
                                  "	border: none;\n"
                                  "	background-color: rgb(51,51,51);\n"
                                  "}\n"
                                  "QPushButton:hover {\n"
                                  "	background-color: rgb(0,143,150);\n"
                                  "}\n"
                                  "QPushButton:pressed {	\n"
                                  "	background-color: rgb(51,51,51);\n"
                                  "}")
        icon = QIcon()
        icon.addFile(u"icons/1x/hideAsset 53.png", QSize(), QIcon.Normal,
                     QIcon.Off)
        self.bn_min.setIcon(icon)
        self.bn_min.setIconSize(QSize(22, 12))
        self.bn_min.setAutoDefault(False)
        self.bn_min.setFlat(True)

        self.horizontalLayout.addWidget(self.bn_min)

        self.bn_close = QPushButton(self.frame_top)
        self.bn_close.setObjectName(u"bn_close")
        self.bn_close.setMinimumSize(QSize(55, 55))
        self.bn_close.setMaximumSize(QSize(55, 55))
        self.bn_close.setStyleSheet(u"QPushButton {\n"
                                    "	border: none;\n"
                                    "	background-color: rgb(51,51,51);\n"
                                    "}\n"
                                    "QPushButton:hover {\n"
                                    "	background-color: rgb(0,143,150);\n"
                                    "}\n"
                                    "QPushButton:pressed {	\n"
                                    "	background-color: rgb(51,51,51);\n"
                                    "}")
        icon1 = QIcon()
        icon1.addFile(u"icons/1x/closeAsset 43.png", QSize(), QIcon.Normal,
                      QIcon.Off)
        self.bn_close.setIcon(icon1)
        self.bn_close.setIconSize(QSize(22, 22))
        self.bn_close.setAutoDefault(False)
        self.bn_close.setFlat(True)

        self.horizontalLayout.addWidget(self.bn_close)

        self.verticalLayout_2.addWidget(self.frame_top)

        self.frame_bottom = QFrame(self.frame_2)
        self.frame_bottom.setObjectName(u"frame_bottom")
        self.frame_bottom.setStyleSheet(u"background:rgb(91,90,90);")
        self.frame_bottom.setFrameShape(QFrame.StyledPanel)
        self.frame_bottom.setFrameShadow(QFrame.Raised)
        self.gridLayout = QGridLayout(self.frame_bottom)
        self.gridLayout.setObjectName(u"gridLayout")
        self.gridLayout.setHorizontalSpacing(5)
        self.gridLayout.setVerticalSpacing(0)
        self.gridLayout.setContentsMargins(15, -1, 35, 0)
        self.bn_east = QPushButton(self.frame_bottom)
        self.bn_east.setObjectName(u"bn_east")
        self.bn_east.setMinimumSize(QSize(69, 25))
        self.bn_east.setMaximumSize(QSize(69, 25))
        font1 = QFont()
        font1.setFamily(u"Segoe UI")
        font1.setPointSize(12)
        self.bn_east.setFont(font1)
        self.bn_east.setStyleSheet(u"QPushButton {\n"
                                   "	border: 2px solid rgb(51,51,51);\n"
                                   "	border-radius: 5px;	\n"
                                   "	color:rgb(255,255,255);\n"
                                   "	background-color: rgb(51,51,51);\n"
                                   "}\n"
                                   "QPushButton:hover {\n"
                                   "	border: 2px solid rgb(0,143,150);\n"
                                   "	background-color: rgb(0,143,150);\n"
                                   "}\n"
                                   "QPushButton:pressed {	\n"
                                   "	border: 2px solid rgb(0,143,150);\n"
                                   "	background-color: rgb(51,51,51);\n"
                                   "}")
        self.bn_east.setAutoDefault(False)

        self.gridLayout.addWidget(self.bn_east, 1, 3, 1, 1)

        self.lab_icon = QLabel(self.frame_bottom)
        self.lab_icon.setObjectName(u"lab_icon")
        self.lab_icon.setMinimumSize(QSize(40, 40))
        self.lab_icon.setMaximumSize(QSize(40, 40))

        self.gridLayout.addWidget(self.lab_icon, 0, 0, 1, 1)

        self.bn_west = QPushButton(self.frame_bottom)
        self.bn_west.setObjectName(u"bn_west")
        self.bn_west.setMinimumSize(QSize(69, 25))
        self.bn_west.setMaximumSize(QSize(69, 25))
        self.bn_west.setFont(font1)
        self.bn_west.setStyleSheet(u"QPushButton {\n"
                                   "	border: 2px solid rgb(51,51,51);\n"
                                   "	border-radius: 5px;	\n"
                                   "	color:rgb(255,255,255);\n"
                                   "	background-color: rgb(51,51,51);\n"
                                   "}\n"
                                   "QPushButton:hover {\n"
                                   "	border: 2px solid rgb(0,143,150);\n"
                                   "	background-color: rgb(0,143,150);\n"
                                   "}\n"
                                   "QPushButton:pressed {	\n"
                                   "	border: 2px solid rgb(0,143,150);\n"
                                   "	background-color: rgb(51,51,51);\n"
                                   "}")
        self.bn_west.setAutoDefault(False)

        self.gridLayout.addWidget(self.bn_west, 1, 2, 1, 1)

        self.lab_message = QLabel(self.frame_bottom)
        self.lab_message.setObjectName(u"lab_message")
        self.lab_message.setFont(font1)
        self.lab_message.setStyleSheet(u"color:rgb(255,255,255);")
        self.lab_message.setWordWrap(True)

        self.gridLayout.addWidget(self.lab_message, 0, 1, 1, 3)

        self.verticalLayout_2.addWidget(self.frame_bottom)

        self.verticalLayout.addWidget(self.frame_2)

        self.retranslateUi(Dialog)

        QMetaObject.connectSlotsByName(Dialog)

    # setupUi

    def retranslateUi(self, Dialog):
        Dialog.setWindowTitle(
            QCoreApplication.translate("Dialog", u"Dialog", None))
        self.lab_heading.setText("")
        self.bn_min.setText("")
        self.bn_close.setText("")
        self.bn_east.setText("")
        self.lab_icon.setText("")
        self.bn_west.setText("")
        self.lab_message.setText("")
    def __init__(self):
        super(VlsmCalculation, self).__init__()

        # Use language settings
        self.ml = ManageLng()

        # App attributes
        self.network_ip = None
        self.prefix = None
        self.network_hosts = None
        self.length_of_subnets = []
        self.subnets = []

        main_layout = QVBoxLayout()
        main_layout.setSpacing(10)
        main_layout.setAlignment(Qt.AlignTop)
        self.setLayout(main_layout)

        top_bar = QGridLayout()

        # Left, top, right and bottom margins
        top_bar.setContentsMargins(40, 15, 40, 15)
        top_bar.setHorizontalSpacing(40)
        main_layout.addLayout(top_bar)

        self.starting_network_address_label = QLabel(self.ml.get_tr_text("tab_vlsm_starting_net"))
        self.endpoint_numbers_per_network_label = QLabel(self.ml.get_tr_text("tab_vlsm_endpoint_nums"))
        self.starting_network_prefix_label = QLabel(self.ml.get_tr_text("tab_vlsm_starting_net_prefix"))

        self.starting_network_address_input = QLineEdit()
        self.starting_network_address_input.returnPressed.connect(self.calculation_action)

        self.starting_network_prefix_input = QLineEdit()
        self.starting_network_prefix_input.returnPressed.connect(self.calculation_action)

        self.endpoint_numbers_per_network_input = QLineEdit()
        self.endpoint_numbers_per_network_input.returnPressed.connect(self.calculation_action)

        top_bar.addWidget(self.starting_network_address_label, 0, 0)
        top_bar.addWidget(self.starting_network_address_input, 0, 1)

        top_bar.addWidget(self.starting_network_prefix_label, 1, 0)
        top_bar.addWidget(self.starting_network_prefix_input, 1, 1)

        top_bar.addWidget(self.endpoint_numbers_per_network_label, 2, 0)
        top_bar.addWidget(self.endpoint_numbers_per_network_input, 2, 1)

        self.calculation_button = QPushButton(self.ml.get_tr_text("tab_vlsm_calc_btn"))
        self.calculation_button.setIcon(QIcon("static/images/get_info.png"))
        self.calculation_button.clicked.connect(self.calculation_action)
        main_layout.addWidget(self.calculation_button, alignment=Qt.AlignCenter)

        self.table = QTableWidget()
        self.table.setColumnCount(6)
        self.table.itemDoubleClicked.connect(copy_text_action)

        # Set table header labels
        self.table_column_names = [self.ml.get_tr_text("table_column_network_add"),
                                   self.ml.get_tr_text("table_column_ip_range"),
                                   self.ml.get_tr_text("table_column_broadcast_add"),
                                   self.ml.get_tr_text("table_column_subnet_mask"),
                                   self.ml.get_tr_text("table_column_prefix"),
                                   self.ml.get_tr_text("table_column_addressable_host")]

        self.table.setHorizontalHeaderLabels(self.table_column_names)

        # Automatic resizing of the columns to the content
        self.table.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch)
        self.table.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch)
        self.table.horizontalHeader().setSectionResizeMode(2, QHeaderView.Stretch)

        # Fixed height of table rows
        self.table.verticalHeader().setSectionResizeMode(QHeaderView.Fixed)

        # Set table text align of vertical header
        self.table.verticalHeader().setDefaultAlignment(Qt.AlignCenter)

        main_layout.addWidget(self.table)
Example #19
0
class CentralWidgetOverview(QWidget):
    """
    CentralWidget of MainWindow
    """

    __selected_stylesheet = ("QPushButton {"
                           "border: 1px solid #adadad;"
                           "background-color: #ffffff;"
                           "padding-top: 3px;"
                           "padding-bottom: 3px;"
                           "border-top-left-radius:5px;"
                           "border-top-right-radius:5px;"
                           "}"
                           "QPushButton:hover {"
                           "border: 1px solid #0078d7;"
                           "background-color: #e5f1fb;"
                           "}")

    __normal_stylesheet = ("QPushButton {"
                           "border: 1px solid #adadad;"
                           "background-color: #D9D9DA;"
                           "padding-top: 3px;"
                           "padding-bottom: 3px;"
                           "border-top-left-radius:5px;"
                           "border-top-right-radius:5px;"
                           "}"
                           "QPushButton:hover {"
                           "border: 1px solid #0078d7;"
                           "background-color: #e5f1fb;"
                           "}")
    current_datatype = datatypes.Raum
    instance = None

    def __init__(self, data_handler, get_overview_funct, current_datatype=None):
        super(CentralWidgetOverview, self).__init__()
        CentralWidgetOverview.set_instance(self)

        self.data_handler = data_handler
        self.get_overview_funct = get_overview_funct
        self.current_overview = None

        if not (current_datatype is None):
            CentralWidgetOverview.set_current_datatype(current_datatype)

        # tabs
        self.tab_raeume = QPushButton("Räume")
        self.tab_aufsichtspersonen = QPushButton("Aufsichtspersonen")
        self.tab_pruefungen = QPushButton("Prüfungen")

        self.tab_raeume.clicked.connect(lambda: self.update_current_datatype(datatypes.Raum))
        self.tab_aufsichtspersonen.clicked.connect(lambda: self.update_current_datatype(datatypes.Aufsichtsperson))
        self.tab_pruefungen.clicked.connect(lambda: self.update_current_datatype(datatypes.Pruefung))

        self.tab_raeume.setStyleSheet(self.__normal_stylesheet)
        self.tab_aufsichtspersonen.setStyleSheet(self.__normal_stylesheet)
        self.tab_pruefungen.setStyleSheet(self.__normal_stylesheet)


        #layout
        self.grid_layout = QGridLayout()
        self.setLayout(self.grid_layout)

        self.grid_layout.setHorizontalSpacing(0)
        self.grid_layout.setVerticalSpacing(0)

        self.grid_layout.addWidget(self.tab_raeume,0,0)
        self.grid_layout.addWidget(self.tab_aufsichtspersonen,0,1)
        self.grid_layout.addWidget(self.tab_pruefungen,0,2)
        self.grid_layout.setMargin(0)

        #overview
        self.update_current_datatype(CentralWidgetOverview.get_current_datatype(), force_update=True)

        # add update listener
        data_handler.add_update_listener(self.data_updated)



    def data_updated(self, datatype):
        """
        called when data updated
        :param datatype: class of datatypes.py
        :return:
        """
        if CentralWidgetOverview.get_current_datatype() == datatype:
            # remove old overview
            if self.current_overview != None:
                self.grid_layout.removeWidget(self.current_overview)
                self.current_overview.deleteLater()

            self.set_current_overview()
        else:
            self.update_current_datatype(datatype)


    def update_current_datatype(self, datatype, force_update = False):
        """
        updates the widget based on datatype
        :param datatype: class of datatypes.py
        :return: None
        """
        if CentralWidgetOverview.get_current_datatype() != datatype or force_update:
            # update button paletts
            if CentralWidgetOverview.get_current_datatype() == datatypes.Raum:
                self.tab_raeume.setStyleSheet(self.__normal_stylesheet)
            elif CentralWidgetOverview.get_current_datatype() == datatypes.Aufsichtsperson:
                self.tab_aufsichtspersonen.setStyleSheet(self.__normal_stylesheet)
            elif CentralWidgetOverview.get_current_datatype() == datatypes.Pruefung:
                self.tab_pruefungen.setStyleSheet(self.__normal_stylesheet)

            if datatype == datatypes.Raum:
                self.tab_raeume.setStyleSheet(self.__selected_stylesheet)
            elif datatype == datatypes.Aufsichtsperson:
                self.tab_aufsichtspersonen.setStyleSheet(self.__selected_stylesheet)
            elif datatype == datatypes.Pruefung:
                self.tab_pruefungen.setStyleSheet(self.__selected_stylesheet)

            #remove old overview
            if self.current_overview != None:
                self.grid_layout.removeWidget(self.current_overview)
                self.current_overview.deleteLater()

            #update overview
            CentralWidgetOverview.set_current_datatype(datatype)
            self.set_current_overview()

    def set_current_overview(self):
        """
        sets the overview and adds it to layout
        :return: None
        """
        self.current_overview = self.get_overview_funct(self.data_handler, CentralWidgetOverview.get_current_datatype(), self)
        self.grid_layout.addWidget(self.current_overview,1,0,1,6)

    def paintEvent(self, event:QPaintEvent):
        """
        draws background
        :param event:
        :return: None
        """
        color = QColor(240,240,240)
        white = QColor(255,255,255)
        custom_painter = QPainter(self)
        custom_painter.fillRect(self.rect(), white)

    @staticmethod
    def set_current_datatype(datatype):
        CentralWidgetOverview.current_datatype = datatype
    @staticmethod
    def get_current_datatype():
        return CentralWidgetOverview.current_datatype


    @staticmethod
    def set_instance(instance):
        CentralWidgetOverview.instance = instance
    @staticmethod
    def get_instance():
        return CentralWidgetOverview.instance
Example #20
0
    def __init__(self, parent, data):
        super(SectionsWidget, self).__init__(parent)

        layout = QGridLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setVerticalSpacing(1)
        layout.setHorizontalSpacing(
            UIContext.getScaledWindowSize(16, 16).width())

        maxNameLen = 0
        for section in data.sections.values():
            if len(section.name) > maxNameLen:
                maxNameLen = len(section.name)
        if maxNameLen > 32:
            maxNameLen = 32

        self.sections = []
        for section in data.sections.values():
            if section.semantics != SectionSemantics.ExternalSectionSemantics:
                self.sections.append(section)
        self.sections.sort(key=lambda section: section.start)

        row = 0
        for section in self.sections:
            name = section.name
            if len(name) > maxNameLen:
                name = name[:maxNameLen - 1] + "…"

            begin = "0x%x" % section.start
            end = "0x%x" % section.end
            typeName = section.type

            permissions = ""
            if data.is_offset_readable(section.start):
                permissions += "r"
            else:
                permissions += "-"
            if data.is_offset_writable(section.start):
                permissions += "w"
            else:
                permissions += "-"
            if data.is_offset_executable(section.start):
                permissions += "x"
            else:
                permissions += "-"

            semantics = ""
            if section.semantics == SectionSemantics.ReadOnlyCodeSectionSemantics:
                semantics = "Code"
            elif section.semantics == SectionSemantics.ReadOnlyDataSectionSemantics:
                semantics = "Ready-only Data"
            elif section.semantics == SectionSemantics.ReadWriteDataSectionSemantics:
                semantics = "Writable Data"

            nameLabel = QLabel(name)
            nameLabel.setFont(binaryninjaui.getMonospaceFont(self))
            layout.addWidget(nameLabel, row, 0)

            rangeLayout = QHBoxLayout()
            rangeLayout.setContentsMargins(0, 0, 0, 0)
            beginLabel = headers.ClickableAddressLabel(begin)
            dashLabel = QLabel("-")
            dashLabel.setFont(binaryninjaui.getMonospaceFont(self))
            endLabel = headers.ClickableAddressLabel(end)
            rangeLayout.addWidget(beginLabel)
            rangeLayout.addWidget(dashLabel)
            rangeLayout.addWidget(endLabel)
            layout.addLayout(rangeLayout, row, 1)

            permissionsLabel = QLabel(permissions)
            permissionsLabel.setFont(binaryninjaui.getMonospaceFont(self))
            layout.addWidget(permissionsLabel, row, 2)
            typeLabel = QLabel(typeName)
            typeLabel.setFont(binaryninjaui.getMonospaceFont(self))
            layout.addWidget(typeLabel, row, 3)
            semanticsLabel = QLabel(semantics)
            semanticsLabel.setFont(binaryninjaui.getMonospaceFont(self))
            layout.addWidget(semanticsLabel, row, 4)

            row += 1

        layout.setColumnStretch(5, 1)
        self.setLayout(layout)
Example #21
0
    def __init__(self):
        super(IpInformation, self).__init__()

        # Use language settings
        self.ml = ManageLng()

        main_layout = QGridLayout()
        self.setLayout(main_layout)

        # Prefix-mask-conversion group box
        self.prefix_mask_box = QGroupBox(
            self.ml.get_tr_text("tab_ip_information_prefix_mask_conv"))
        self.prefix_mask_box.setMaximumHeight(90)
        main_layout.addWidget(self.prefix_mask_box, 0, 0)
        prefix_mask_box_layout = QGridLayout()
        prefix_mask_box_layout.setContentsMargins(200, 20, 200, 20)
        prefix_mask_box_layout.setHorizontalSpacing(30)
        self.prefix_mask_box.setLayout(prefix_mask_box_layout)

        self.prefix_input = QLineEdit()
        self.prefix_input.setMaxLength(3)
        self.prefix_input.setAlignment(Qt.AlignCenter)
        self.prefix_input.setPlaceholderText(
            self.ml.get_tr_text("tab_ip_information_prefix_ptext"))
        prefix_mask_box_layout.addWidget(self.prefix_input, 0, 0)
        self.mask_input = QLineEdit()
        self.mask_input.setMaxLength(15)
        self.mask_input.setAlignment(Qt.AlignCenter)
        self.mask_input.setPlaceholderText(
            self.ml.get_tr_text("tab_ip_information_mask_ptext"))
        prefix_mask_box_layout.addWidget(self.mask_input, 0, 1)

        self.convert_btn = QPushButton(
            self.ml.get_tr_text("tab_ip_information_conv_btn"))
        self.convert_btn.setIcon(QIcon("static/images/exchange.png"))
        self.convert_btn.clicked.connect(self.convert_action)
        self.prefix_input.returnPressed.connect(self.convert_action)
        self.mask_input.returnPressed.connect(self.convert_action)
        prefix_mask_box_layout.addWidget(self.convert_btn,
                                         0,
                                         2,
                                         alignment=Qt.AlignLeft)

        # IP information group box
        self.ip_information_box = QGroupBox(
            self.ml.get_tr_text("tab_ip_information_ipinfo_gbox"))
        main_layout.addWidget(self.ip_information_box, 1, 0)
        ip_information_box_layout = QGridLayout()
        ip_information_box_layout.setContentsMargins(80, 80, 80, 80)
        ip_information_box_layout.setHorizontalSpacing(30)
        ip_information_box_layout.setVerticalSpacing(15)
        self.ip_information_box.setLayout(ip_information_box_layout)

        self.ip_address_label = QLabel(
            self.ml.get_tr_text("tab_ip_information_ipadd_lab"))
        ip_information_box_layout.addWidget(self.ip_address_label,
                                            0,
                                            0,
                                            alignment=Qt.AlignCenter)
        self.ip_address_textfield = QLineEdit()
        self.ip_address_textfield.setPlaceholderText("192.168.1.100/24")
        self.ip_address_textfield.setAlignment(Qt.AlignCenter)
        self.ip_address_textfield.setMaxLength(18)
        ip_information_box_layout.addWidget(self.ip_address_textfield, 0, 1)

        self.get_info_btn = QPushButton(
            self.ml.get_tr_text("tab_ip_information_getinfo_btn"))
        self.get_info_btn.setIcon(QIcon("static/images/get_info.png"))
        self.get_info_btn.clicked.connect(self.get_info_action)
        self.ip_address_textfield.returnPressed.connect(self.get_info_action)
        ip_information_box_layout.addWidget(self.get_info_btn, 0, 2)

        self.ip_class_label = QLabel(
            self.ml.get_tr_text("tab_ip_information_ipclass_lab"))
        ip_information_box_layout.addWidget(self.ip_class_label,
                                            1,
                                            0,
                                            alignment=Qt.AlignCenter)
        self.ip_class_textfield = QLineEdit()
        self.ip_class_textfield.setReadOnly(True)
        self.ip_class_textfield.setAlignment(Qt.AlignCenter)
        ip_information_box_layout.addWidget(self.ip_class_textfield, 1, 1)
        self.ip_class_copy_btn = QPushButton(
            self.ml.get_tr_text("tab_ip_information_copy_btn"))
        self.ip_class_copy_btn.setIcon(
            QIcon("static/images/copy_clipboard.png"))
        self.ip_class_copy_btn.clicked.connect(
            lambda: copy_action(self.ip_class_textfield.text()))
        ip_information_box_layout.addWidget(self.ip_class_copy_btn, 1, 2)

        self.ip_type_label = QLabel(
            self.ml.get_tr_text("tab_ip_information_iptype_lab"))
        ip_information_box_layout.addWidget(self.ip_type_label,
                                            2,
                                            0,
                                            alignment=Qt.AlignCenter)
        self.ip_type_textfield = QLineEdit()
        self.ip_type_textfield.setReadOnly(True)
        self.ip_type_textfield.setAlignment(Qt.AlignCenter)
        ip_information_box_layout.addWidget(self.ip_type_textfield, 2, 1)
        self.ip_type_copy_btn = QPushButton(
            self.ml.get_tr_text("tab_ip_information_copy_btn"))
        self.ip_type_copy_btn.setIcon(
            QIcon("static/images/copy_clipboard.png"))
        self.ip_type_copy_btn.clicked.connect(
            lambda: copy_action(self.ip_type_textfield.text()))
        ip_information_box_layout.addWidget(self.ip_type_copy_btn, 2, 2)

        self.network_address_label = QLabel(
            self.ml.get_tr_text("tab_ip_information_netadd_lab"))
        ip_information_box_layout.addWidget(self.network_address_label,
                                            3,
                                            0,
                                            alignment=Qt.AlignCenter)
        self.network_address_textfield = QLineEdit()
        self.network_address_textfield.setReadOnly(True)
        self.network_address_textfield.setAlignment(Qt.AlignCenter)
        ip_information_box_layout.addWidget(self.network_address_textfield, 3,
                                            1)
        self.network_address_copy_btn = QPushButton(
            self.ml.get_tr_text("tab_ip_information_copy_btn"))
        self.network_address_copy_btn.setIcon(
            QIcon("static/images/copy_clipboard.png"))
        self.network_address_copy_btn.clicked.connect(
            lambda: copy_action(self.network_address_textfield.text()))
        ip_information_box_layout.addWidget(self.network_address_copy_btn, 3,
                                            2)

        self.subnet_mask_label = QLabel(
            self.ml.get_tr_text("tab_ip_information_mask_lab"))
        ip_information_box_layout.addWidget(self.subnet_mask_label,
                                            4,
                                            0,
                                            alignment=Qt.AlignCenter)
        self.subnet_mask_textfield = QLineEdit()
        self.subnet_mask_textfield.setReadOnly(True)
        self.subnet_mask_textfield.setAlignment(Qt.AlignCenter)
        ip_information_box_layout.addWidget(self.subnet_mask_textfield, 4, 1)
        self.subnet_mask_copy_btn = QPushButton(
            self.ml.get_tr_text("tab_ip_information_copy_btn"))
        self.subnet_mask_copy_btn.setIcon(
            QIcon("static/images/copy_clipboard.png"))
        self.subnet_mask_copy_btn.clicked.connect(
            lambda: copy_action(self.subnet_mask_textfield.text()))
        ip_information_box_layout.addWidget(self.subnet_mask_copy_btn, 4, 2)

        self.first_addressable_ip_label = QLabel(
            self.ml.get_tr_text("tab_ip_information_firstip_lab"))
        ip_information_box_layout.addWidget(self.first_addressable_ip_label,
                                            5,
                                            0,
                                            alignment=Qt.AlignCenter)
        self.first_addressable_ip_textfield = QLineEdit()
        self.first_addressable_ip_textfield.setReadOnly(True)
        self.first_addressable_ip_textfield.setAlignment(Qt.AlignCenter)
        ip_information_box_layout.addWidget(
            self.first_addressable_ip_textfield, 5, 1)
        self.first_addressable_ip_copy_btn = QPushButton(
            self.ml.get_tr_text("tab_ip_information_copy_btn"))
        self.first_addressable_ip_copy_btn.setIcon(
            QIcon("static/images/copy_clipboard.png"))
        self.first_addressable_ip_copy_btn.clicked.connect(
            lambda: copy_action(self.first_addressable_ip_textfield.text()))
        ip_information_box_layout.addWidget(self.first_addressable_ip_copy_btn,
                                            5, 2)

        self.last_addressable_ip_label = QLabel(
            self.ml.get_tr_text("tab_ip_information_lastip_lab"))
        ip_information_box_layout.addWidget(self.last_addressable_ip_label,
                                            6,
                                            0,
                                            alignment=Qt.AlignCenter)
        self.last_addressable_ip_textfield = QLineEdit()
        self.last_addressable_ip_textfield.setReadOnly(True)
        self.last_addressable_ip_textfield.setAlignment(Qt.AlignCenter)
        ip_information_box_layout.addWidget(self.last_addressable_ip_textfield,
                                            6, 1)
        self.last_addressable_ip_copy_btn = QPushButton(
            self.ml.get_tr_text("tab_ip_information_copy_btn"))
        self.last_addressable_ip_copy_btn.setIcon(
            QIcon("static/images/copy_clipboard.png"))
        self.last_addressable_ip_copy_btn.clicked.connect(
            lambda: copy_action(self.last_addressable_ip_textfield.text()))
        ip_information_box_layout.addWidget(self.last_addressable_ip_copy_btn,
                                            6, 2)

        self.broadcast_address_label = QLabel(
            self.ml.get_tr_text("tab_ip_information_bcastip_lab"))
        ip_information_box_layout.addWidget(self.broadcast_address_label,
                                            7,
                                            0,
                                            alignment=Qt.AlignCenter)
        self.broadcast_address_textfield = QLineEdit()
        self.broadcast_address_textfield.setReadOnly(True)
        self.broadcast_address_textfield.setAlignment(Qt.AlignCenter)
        ip_information_box_layout.addWidget(self.broadcast_address_textfield,
                                            7, 1)
        self.broadcast_address_copy_btn = QPushButton(
            self.ml.get_tr_text("tab_ip_information_copy_btn"))
        self.broadcast_address_copy_btn.setIcon(
            QIcon("static/images/copy_clipboard.png"))
        self.broadcast_address_copy_btn.clicked.connect(
            lambda: copy_action(self.broadcast_address_textfield.text()))
        ip_information_box_layout.addWidget(self.broadcast_address_copy_btn, 7,
                                            2)

        self.next_network_address_label = QLabel(
            self.ml.get_tr_text("tab_ip_information_nextnetip_lab"))
        ip_information_box_layout.addWidget(self.next_network_address_label,
                                            8,
                                            0,
                                            alignment=Qt.AlignCenter)
        self.next_network_address_textfield = QLineEdit()
        self.next_network_address_textfield.setReadOnly(True)
        self.next_network_address_textfield.setAlignment(Qt.AlignCenter)
        ip_information_box_layout.addWidget(
            self.next_network_address_textfield, 8, 1)
        self.next_network_address_copy_btn = QPushButton(
            self.ml.get_tr_text("tab_ip_information_copy_btn"))
        self.next_network_address_copy_btn.setIcon(
            QIcon("static/images/copy_clipboard.png"))
        self.next_network_address_copy_btn.clicked.connect(
            lambda: copy_action(self.next_network_address_textfield.text()))
        ip_information_box_layout.addWidget(self.next_network_address_copy_btn,
                                            8, 2)

        self.max_endpoint_label = QLabel(
            self.ml.get_tr_text("tab_ip_information_maxend_lab"))
        ip_information_box_layout.addWidget(self.max_endpoint_label,
                                            9,
                                            0,
                                            alignment=Qt.AlignCenter)
        self.max_endpoint_textfield = QLineEdit()
        self.max_endpoint_textfield.setReadOnly(True)
        self.max_endpoint_textfield.setAlignment(Qt.AlignCenter)
        ip_information_box_layout.addWidget(self.max_endpoint_textfield, 9, 1)
        self.max_endpoint_copy_btn = QPushButton(
            self.ml.get_tr_text("tab_ip_information_copy_btn"))
        self.max_endpoint_copy_btn.setIcon(
            QIcon("static/images/copy_clipboard.png"))
        self.max_endpoint_copy_btn.clicked.connect(
            lambda: copy_action(self.max_endpoint_textfield.text()))
        ip_information_box_layout.addWidget(self.max_endpoint_copy_btn, 9, 2)
Example #22
0
    def __init__(self):
        super(NumberConversion, self).__init__()

        # App attributes
        self.bin_format_base = None
        self.bin_format_base_byte = None

        # Use language settings
        self.ml = ManageLng()

        main_layout = QGridLayout()
        self.setLayout(main_layout)

        # Input
        self.inputbox = QGroupBox(
            self.ml.get_tr_text("tab_num_conv_inputbox_gbox_name"))
        self.inputbox.setMaximumWidth(400)

        main_layout.addWidget(self.inputbox, 0, 0)

        inputbox_layout = QGridLayout()
        inputbox_layout.setHorizontalSpacing(25)
        inputbox_layout.setVerticalSpacing(35)
        inputbox_layout.setAlignment(Qt.AlignCenter)

        self.inputbox.setLayout(inputbox_layout)

        self.input_number_label = QLabel(
            self.ml.get_tr_text("tab_num_conv_inputbox_in_number_lab"))
        self.input_number_textfield = QLineEdit()
        self.input_number_textfield.setPlaceholderText("192")
        self.input_number_textfield.setAlignment(Qt.AlignCenter)
        self.input_number_textfield.returnPressed.connect(self.convert_action)

        inputbox_layout.addWidget(self.input_number_label,
                                  0,
                                  0,
                                  alignment=Qt.AlignCenter)
        inputbox_layout.addWidget(self.input_number_textfield, 0, 1)

        button_layout = QVBoxLayout()
        self.bin_button = QRadioButton(
            self.ml.get_tr_text("tab_num_conv_inputbox_bin_chkbox"))
        self.bin_button.clicked.connect(
            lambda: self.input_number_textfield.setPlaceholderText("11100010"))
        self.dec_button = QRadioButton(
            self.ml.get_tr_text("tab_num_conv_inputbox_dec_chkbox"))
        self.dec_button.clicked.connect(
            lambda: self.input_number_textfield.setPlaceholderText("192"))
        self.hex_button = QRadioButton(
            self.ml.get_tr_text("tab_num_conv_inputbox_hex_chkbox"))
        self.hex_button.clicked.connect(
            lambda: self.input_number_textfield.setPlaceholderText("FF"))
        self.dec_button.setChecked(True)
        button_layout.addWidget(self.bin_button)
        button_layout.addWidget(self.dec_button)
        button_layout.addWidget(self.hex_button)
        inputbox_layout.addLayout(button_layout, 0, 3, 1, 2)

        self.convert_button = QPushButton(
            self.ml.get_tr_text("tab_num_conv_inputbox_conv_btn"))
        self.convert_button.clicked.connect(self.convert_action)
        self.convert_button.setIcon(QIcon("static/images/exchange.png"))
        inputbox_layout.addWidget(self.convert_button,
                                  1,
                                  1,
                                  alignment=Qt.AlignCenter)

        # Output
        self.outputbox = QGroupBox(
            self.ml.get_tr_text("tab_num_conv_outputbox_gbox_name"))
        main_layout.addWidget(self.outputbox, 0, 1)
        outputbox_layout = QGridLayout()
        outputbox_layout.setHorizontalSpacing(25)
        self.outputbox.setLayout(outputbox_layout)

        self.bin_label = QLabel(
            self.ml.get_tr_text("tab_num_conv_outputbox_bin_lab"))
        self.bin_label.setAlignment(Qt.AlignCenter)

        self.dec_label = QLabel(
            self.ml.get_tr_text("tab_num_conv_outputbox_dec_lab"))
        self.dec_label.setAlignment(Qt.AlignCenter)

        self.hex_label = QLabel(
            self.ml.get_tr_text("tab_num_conv_outputbox_hex_lab"))
        self.hex_label.setAlignment(Qt.AlignCenter)

        self.bin_output = QLineEdit()
        self.bin_output.setReadOnly(True)
        self.bin_output.setAlignment(Qt.AlignCenter)

        self.dec_output = QLineEdit()
        self.dec_output.setReadOnly(True)
        self.dec_output.setAlignment(Qt.AlignCenter)

        self.hex_output = QLineEdit()
        self.hex_output.setReadOnly(True)
        self.hex_output.setAlignment(Qt.AlignCenter)

        self.bin_output_copy_button = QPushButton(
            self.ml.get_tr_text("tab_num_conv_outputbox_copy_btn"))
        self.bin_output_copy_button.setIcon(
            QIcon("static/images/copy_clipboard.png"))
        self.bin_output_copy_button.clicked.connect(
            lambda: copy_action(self.bin_output.text()))

        self.dec_output_copy_button = QPushButton(
            self.ml.get_tr_text("tab_num_conv_outputbox_copy_btn"))
        self.dec_output_copy_button.setIcon(
            QIcon("static/images/copy_clipboard.png"))
        self.dec_output_copy_button.clicked.connect(
            lambda: copy_action(self.dec_output.text()))

        self.hex_output_copy_button = QPushButton(
            self.ml.get_tr_text("tab_num_conv_outputbox_copy_btn"))
        self.hex_output_copy_button.setIcon(
            QIcon("static/images/copy_clipboard.png"))
        self.hex_output_copy_button.clicked.connect(
            lambda: copy_action(self.hex_output.text()))

        outputbox_layout.addWidget(self.bin_label, 0, 0)
        outputbox_layout.addWidget(self.bin_output, 0, 1)
        outputbox_layout.addWidget(self.bin_output_copy_button, 0, 2)

        outputbox_layout.addWidget(self.dec_label, 1, 0)
        outputbox_layout.addWidget(self.dec_output, 1, 1)
        outputbox_layout.addWidget(self.dec_output_copy_button, 1, 2)

        outputbox_layout.addWidget(self.hex_label, 2, 0)
        outputbox_layout.addWidget(self.hex_output, 2, 1)
        outputbox_layout.addWidget(self.hex_output_copy_button, 2, 2)

        # IP address/mask number conversion
        self.ip_address_number_conversion_box = QGroupBox(
            self.ml.get_tr_text("tab_num_conv_ip_mask_conv_gbox_name"))
        main_layout.addWidget(self.ip_address_number_conversion_box, 1, 0, 1,
                              2)

        ip_address_number_conversion_layout = QGridLayout()
        ip_address_number_conversion_layout.setAlignment(Qt.AlignCenter)
        ip_address_number_conversion_layout.setHorizontalSpacing(25)
        ip_address_number_conversion_layout.setVerticalSpacing(24)
        self.ip_address_number_conversion_box.setLayout(
            ip_address_number_conversion_layout)

        self.input_label = QLabel(
            self.ml.get_tr_text("tab_num_conv_ip_mask_conv_in_lab"))
        self.input_label.setAlignment(Qt.AlignCenter)
        self.input_label.setMaximumWidth(150)
        self.input_textfield = QLineEdit()
        self.input_textfield.setPlaceholderText("192.168.1.1")
        self.input_textfield.setAlignment(Qt.AlignLeft)
        self.input_textfield.setMaximumWidth(300)
        self.input_textfield.setAlignment(Qt.AlignCenter)
        self.input_textfield.returnPressed.connect(self.convert_action_2)
        ip_address_number_conversion_layout.addWidget(self.input_label, 0, 0)
        ip_address_number_conversion_layout.addWidget(self.input_textfield, 0,
                                                      1)

        button_layout_2 = QVBoxLayout()
        self.dec_to_bin_button = QRadioButton(
            self.ml.get_tr_text("tab_num_conv_ip_mask_conv_dectobin"))
        self.dec_to_bin_button.clicked.connect(
            lambda: self.input_textfield.setPlaceholderText("192.168.1.1"))
        self.dec_to_bin_button.setMaximumWidth(150)

        self.bin_to_dec_button = QRadioButton(
            self.ml.get_tr_text("tab_num_conv_ip_mask_conv_bintodec"))
        self.bin_to_dec_button.clicked.connect(
            lambda: self.input_textfield.setPlaceholderText(
                "11000000.10101000.00000001.00000001"))
        self.bin_to_dec_button.setMaximumWidth(150)
        self.dec_to_bin_button.setChecked(True)
        button_layout_2.addWidget(self.dec_to_bin_button)
        button_layout_2.addWidget(self.bin_to_dec_button)
        ip_address_number_conversion_layout.addLayout(button_layout_2, 0, 2)

        self.output_label = QLabel(
            self.ml.get_tr_text("tab_num_conv_ip_mask_conv_out_lab"))
        self.output_label.setAlignment(Qt.AlignCenter)
        self.output_textfield = QLineEdit()
        self.output_textfield.setMaximumWidth(300)
        self.output_textfield.setReadOnly(True)
        self.output_textfield.setAlignment(Qt.AlignCenter)
        ip_address_number_conversion_layout.addWidget(self.output_label, 1, 0)
        ip_address_number_conversion_layout.addWidget(self.output_textfield, 1,
                                                      1)

        self.output_textfield_copy_button = QPushButton(
            self.ml.get_tr_text("tab_num_conv_ip_mask_conv_copy_btn"))
        self.output_textfield_copy_button.setIcon(
            QIcon("static/images/copy_clipboard.png"))
        self.output_textfield_copy_button.clicked.connect(
            lambda: copy_action(self.output_textfield.text()))
        ip_address_number_conversion_layout.addWidget(
            self.output_textfield_copy_button, 1, 2, alignment=Qt.AlignLeft)

        self.convert_button_2 = QPushButton(
            self.ml.get_tr_text("tab_num_conv_ip_mask_conv_convert_btn"))
        self.convert_button_2.clicked.connect(self.convert_action_2)
        self.convert_button_2.setIcon(QIcon("static/images/exchange.png"))
        ip_address_number_conversion_layout.addWidget(
            self.convert_button_2, 2, 0, 1, 3, alignment=Qt.AlignHCenter)
Example #23
0
class StatComponent(QGroupBox):
    def __init__(self):
        super().__init__()

        self._series = {}
        self._legend_items = {}

        self.setTitle("Statistiques")
        self.setProperty("qss-var", "pb-0")

        self._total_label = QLabel()

        self._legend_layout = QGridLayout()
        self._legend_layout.setVerticalSpacing(0)
        self._legend_layout.setHorizontalSpacing(50)

        main_layout = QVBoxLayout()
        main_layout.addWidget(self._total_label)
        main_layout.addLayout(self._legend_layout)
        main_layout.addSpacing(5)
        main_layout.addWidget(self._createLineChart(), 1)

        self.setLayout(main_layout)

    def reset(self, parameters: Parameters):
        self._parameters = parameters

        self._total_label.setText("Éponges détectées : 0")

        for i in reversed(range(self._legend_layout.count())):
            self._legend_layout.itemAt(i).widget().setParent(None)

        self._chart.removeAllSeries()
        self._legend_items = {}
        self._series = {}
        for i, m in parameters.selectedMorphotypes().items():
            self._series[i] = QtCharts.QLineSeries(self)
            self._series[i].setName(m.name())
            self._series[i].setColor(m.color())

            pen = QPen(m.color(), 3)
            pen.setCapStyle(Qt.RoundCap)
            self._series[i].setPen(pen)

            self._series[i].append(0, 0)
            self._chart.addSeries(self._series[i])

            self._legend_items[i] = ChartLegendItem(m.name(), m.color(), self)
            self._legend_items[i].toggled.connect(self._legendItemToggled)

        for i, k in enumerate(self._legend_items.keys()):
            row = i % 2 + 1
            col = i // 2 + 1

            self._legend_layout.addWidget(self._legend_items[k], row, col)

        axis_pen = QPen(Loader.QSSColor("@dark"))
        axis_pen.setWidth(2)

        grid_line_pen = QPen(Loader.QSSColor("@light-gray"))

        labels_font = QFont(Loader.QSSVariable("@font"))
        labels_font.setPointSize(10)

        self._chart.createDefaultAxes()

        for axis in (self._chart.axisX(), self._chart.axisY()):
            axis.setRange(0, 4)
            axis.setLinePen(axis_pen)
            axis.setGridLinePen(grid_line_pen)
            axis.setLabelFormat("%d")
            axis.setLabelsFont(labels_font)

    def _createLineChart(self) -> QtCharts.QChartView:
        self._chart = QtCharts.QChart()

        self._chart.setAnimationOptions(QtCharts.QChart.SeriesAnimations)

        self._chart.setTitle("Détections cumulées")
        self._chart.legend().setVisible(False)
        self._chart.setBackgroundBrush(QBrush(QColor("transparent")))
        self._chart.setMargins(QMargins(0, 0, 0, 0))

        title_font = QFont(Loader.QSSVariable("@font"))
        title_font.setPointSize(14)
        self._chart.setTitleFont(title_font)
        self._chart.setTitleBrush(QBrush(Loader.QSSColor("@dark")))

        chart_view = QtCharts.QChartView(self._chart)
        chart_view.setRenderHint(QPainter.Antialiasing)

        return chart_view

    def update(self, analysis: Analysis):
        self._analysis = analysis

        for class_id in self._parameters.selectedMorphotypes():
            last_idx = self._series[class_id].count() - 1

            new_x = self._series[class_id].at(last_idx).x() + 1
            new_y = analysis.cumulativeDetectionsFor(class_id)

            if last_idx > 1:
                if self._series[class_id].at(last_idx - 1).y(
                ) == new_y and self._series[class_id].at(
                        last_idx).y() == new_y:
                    self._series[class_id].replace(last_idx, new_x, new_y)
                    continue

            self._series[class_id].append(new_x, new_y)
            self._legend_items[class_id].setValue(str(new_y))

        self._total_label.setText("Éponges détectées : %d" %
                                  analysis.totalDetections())

        self._recalculateAxis()

    def _recalculateAxis(self):
        base_series = list(self._series.values())[0]

        last_idx = base_series.count() - 1
        x = base_series.at(last_idx).x()

        self._chart.axisX().setRange(0, max(x, 4))

        maxY = 0
        for k in self._series:
            if not self._legend_items[k].isChecked():
                continue

            maxY = max(maxY, self._analysis.cumulativeDetectionsFor(k))

        maxY = max(maxY, 4)

        # Add 5% to show the top series below the top line
        maxY = round(1.05 * maxY)

        self._chart.axisY().setRange(0, maxY)

    @Slot(bool)
    def _legendItemToggled(self, state: bool):
        for k, v in self._legend_items.items():
            if v == self.sender():
                self._series[k].setVisible(state)
                break

        self._recalculateAxis()
    def __init__(self):
        super(IpSubnetCalculation, self).__init__()

        # Use language settings
        self.ml = ManageLng()

        # App attributes
        self.network_ip = None
        self.needed_networks = None
        self.subnet_bits = None
        self.default_networkbits = None
        self.calculation_worker = None

        main_layout = QVBoxLayout()
        main_layout.setSpacing(10)
        main_layout.setAlignment(Qt.AlignTop)
        self.setLayout(main_layout)

        top_bar = QGridLayout()

        # Left, top, right and bottom margins
        top_bar.setContentsMargins(40, 15, 40, 15)
        top_bar.setHorizontalSpacing(40)
        main_layout.addLayout(top_bar)

        self.starting_network_address_label = QLabel(self.ml.get_tr_text("tab_ipsubnet_starting_net"))
        self.number_of_subnets_label = QLabel(self.ml.get_tr_text("tab_ipsubnet_required_subnet_num"))

        self.starting_network_address_input = QLineEdit()
        self.starting_network_address_input.returnPressed.connect(self.calculation_action)
        self.number_of_subnets_input = QLineEdit()
        self.number_of_subnets_input.returnPressed.connect(self.calculation_action)

        top_bar.addWidget(self.starting_network_address_label, 0, 0)
        top_bar.addWidget(self.starting_network_address_input, 0, 1)
        top_bar.addWidget(self.number_of_subnets_label, 1, 0)
        top_bar.addWidget(self.number_of_subnets_input, 1, 1)

        self.calculation_button = QPushButton(self.ml.get_tr_text("tab_ipsubnet_calc_btn"))
        self.calculation_button.clicked.connect(self.calculation_action)
        self.calculation_button.setIcon(QIcon("static/images/get_info.png"))
        main_layout.addWidget(self.calculation_button, alignment=Qt.AlignCenter)

        self.table = QTableWidget()
        self.table.itemDoubleClicked.connect(copy_text_action)
        self.table.setColumnCount(6)

        self.table_column_names = [self.ml.get_tr_text("table_column_network_add"),
                                   self.ml.get_tr_text("table_column_ip_range"),
                                   self.ml.get_tr_text("table_column_broadcast_add"),
                                   self.ml.get_tr_text("table_column_subnet_mask"),
                                   self.ml.get_tr_text("table_column_prefix"),
                                   self.ml.get_tr_text("table_column_addressable_host")]

        self.table.setHorizontalHeaderLabels(self.table_column_names)

        # Automatic resizing of the columns to the content
        self.table.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch)
        self.table.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch)
        self.table.horizontalHeader().setSectionResizeMode(2, QHeaderView.Stretch)

        # Set table text align of vertical header
        self.table.verticalHeader().setDefaultAlignment(Qt.AlignCenter)

        # Fixed height of table rows
        self.table.verticalHeader().setSectionResizeMode(QHeaderView.Fixed)

        main_layout.addWidget(self.table)

        # Bottom bar
        bottom_bar = QHBoxLayout()

        # Create progressbar
        self.progressbar = QProgressBar()
        self.progressbar.setVisible(False)

        # Create cancel button
        self.cancel_btn = QPushButton(self.ml.get_tr_text("tab_ipsubnet_cancel_btn"))
        self.cancel_btn.setVisible(False)
        self.cancel_btn.clicked.connect(self.terminate_calculation)

        bottom_bar.addWidget(self.progressbar)
        bottom_bar.addWidget(self.cancel_btn)
        main_layout.addLayout(bottom_bar)
Example #25
0
    def __init__(self):
        super().__init__()

        # Main Layout
        main_layout = QHBoxLayout(self)
        main_layout.setContentsMargins(0, 0, 0, 0)

        title = QLabel(
            "Sp<font color='#419DD1'>o</font>ng<font color='#F4D05C'>o</font>")
        title.setObjectName("title")

        subtitle = QLabel(
            "Outil de classification et de reconnaissance de morphotypes d’éponges marines"
        )
        subtitle.setObjectName("subtitle")

        start_button = StylizedButton("Commencer une analyse", "blue")
        self._history_button = StylizedButton("Historique des analyses",
                                              "blue")
        about_button = StylizedButton("À propos", "blue")
        exit_button = StylizedButton("Quitter", "yellow")

        buttons_layout = QGridLayout()
        buttons_layout.setAlignment(Qt.AlignCenter)
        buttons_layout.setVerticalSpacing(24)
        buttons_layout.setHorizontalSpacing(30)

        buttons_layout.addWidget(start_button, 0, 0, 1, 2)
        buttons_layout.addWidget(self._history_button, 1, 0, 1, 2)
        buttons_layout.addWidget(about_button, 2, 0)
        buttons_layout.addWidget(exit_button, 2, 1)

        version_label = QLabel(AppInfo.version())
        version_label.setAlignment(Qt.AlignCenter)
        version_label.setObjectName("version")

        center_layout = QVBoxLayout()
        center_layout.setAlignment(Qt.AlignCenter)
        center_layout.setContentsMargins(15, 15, 15, 15)
        center_layout.addStretch(4)
        center_layout.addWidget(title)
        center_layout.addWidget(subtitle)
        center_layout.addLayout(buttons_layout)
        center_layout.addStretch(5)
        center_layout.addWidget(version_label)

        isen_logo = QLabel()
        isen_logo.setPixmap(
            QPixmap(":/img/isen_logo.png").scaledToWidth(
                180, Qt.SmoothTransformation))

        left_layout = QVBoxLayout()
        left_layout.setContentsMargins(0, 0, 0, 0)
        left_layout.addWidget(isen_logo, alignment=Qt.AlignBottom)

        ifremer_logo = QLabel()
        ifremer_logo.setAlignment(Qt.AlignRight)
        ifremer_logo.setPixmap(
            QPixmap(":/img/ifremer_logo.png").scaledToWidth(
                180, Qt.SmoothTransformation))

        right_layout = QVBoxLayout()
        right_layout.setContentsMargins(0, 0, 0, 0)
        right_layout.addWidget(ifremer_logo, alignment=Qt.AlignBottom)

        main_layout.addLayout(left_layout, 1)
        main_layout.addLayout(center_layout, 3)
        main_layout.addLayout(right_layout, 1)

        self.setLayout(main_layout)

        # Button slots
        start_button.clicked.connect(self._startButtonClicked)
        self._history_button.clicked.connect(self._historyButtonClicked)
        about_button.clicked.connect(self._aboutButtonClicked)
        exit_button.clicked.connect(self._exitButtonClicked)
Example #26
0
    def setupUI(self):
        _translate = QtCore.QCoreApplication.translate
        self.setWindowTitle(_translate("MainWindow", "Function"))
        self.setFixedSize(350, 220)

        self.function_label = QtWidgets.QLabel()
        font = QtGui.QFont()
        font.setFamily("Helvetica")
        font.setPointSize(22)
        font.setBold(True)
        font.setWeight(75)
        self.function_label.setFont(font)
        self.function_label.setStyleSheet("color: rgb(255, 24, 128);")
        self.function_label.setAlignment(QtCore.Qt.AlignCenter)
        self.function_label.setObjectName("function_label")
        self.function_label.setText(_translate("MainWindow", "FUNCTION"))

        font = QtGui.QFont()
        font.setFamily("Helvetica")
        font.setPointSize(11)
        style = "background-color: rgb(224, 237, 255)"

        self.process_pack = RequestButtonPack(
            self, "PROCESS",
            self.MakeButton(font, style, "process_button",
                            _translate("MainWindow", "Xem Process")))

        self.application_pack = RequestButtonPack(
            self, "APPLICATION",
            self.MakeButton(font, style, "application_button",
                            _translate("MainWindow", "Xem Ứng dụng")))

        self.input_pack = RequestButtonPack(
            self, "KEYLOG",
            self.MakeButton(font, style, "input_button",
                            _translate("MainWindow", "Bàn phím")))

        self.screenshot_pack = RequestButtonPack(
            self, "SCREENSHOT",
            self.MakeButton(font, style, "screenshot_button",
                            _translate("MainWindow", "Chụp màn hình")))

        self.streaming_pack = RequestButtonPack(
            self, "LIVESTREAM",
            self.MakeButton(font, style, "streaming_button",
                            _translate("MainWindow", "Xem live màn hình")))

        self.directory_pack = RequestButtonPack(
            self, "DIRECTORY",
            self.MakeButton(font, style, "directory_button",
                            _translate("MainWindow", "Cây thư mục")))

        self.registry_pack = RequestButtonPack(
            self, "REGISTRY",
            self.MakeButton(font, style, "directory_button",
                            _translate("MainWindow", "Registry")))

        self.shutdown_button = self.MakeButton(
            font, style, "shutdown_button", _translate("MainWindow",
                                                       "Shutdown"))
        self.logout_button = self.MakeButton(
            font, style, "logout_button", _translate("MainWindow", "Logout"))
        self.info_button = self.MakeButton(
            font, style, "info_button", _translate("MainWindow",
                                                   "MAC Address"))

        self.info_button.clicked.connect(self.onShowMACAdress)
        self.shutdown_button.clicked.connect(self.onShutdown)
        self.logout_button.clicked.connect(self.onLogOut)

        layout1 = QVBoxLayout()
        layout1.addWidget(self.screenshot_pack.button)
        layout1.addSpacing(5)
        layout1.addWidget(self.streaming_pack.button)
        layout1.addSpacing(5)

        layout2 = QVBoxLayout()
        layout2.addWidget(self.input_pack.button)
        layout2.addSpacing(5)
        layout2.addWidget(self.directory_pack.button)
        layout2.addSpacing(5)

        layout3 = QVBoxLayout()
        layout3.addWidget(self.process_pack.button)
        layout3.addSpacing(5)
        layout3.addWidget(self.application_pack.button)
        layout3.addSpacing(5)
        layout3.addWidget(self.registry_pack.button)

        layout4t = QGridLayout()
        layout4t.setHorizontalSpacing(5)
        layout4t.addWidget(self.logout_button, 0, 0)
        layout4t.addWidget(self.shutdown_button, 0, 1)

        layout4 = QVBoxLayout()
        layout4.addWidget(self.info_button)
        layout4.addSpacing(5)
        layout4.addItem(layout4t)

        buttonLayout = QGridLayout()
        buttonLayout.setHorizontalSpacing(15)
        buttonLayout.setVerticalSpacing(10)
        buttonLayout.addItem(layout1, 0, 0)
        buttonLayout.addItem(layout2, 0, 1)
        buttonLayout.addItem(layout3, 1, 0)
        buttonLayout.addItem(layout4, 1, 1)

        tmp = QtWidgets.QWidget(self)
        tmp.setFixedSize(320, 210)
        # tmp.setStyleSheet("background-color: rgb(60, 60, 180)")

        mainLayout = QVBoxLayout(tmp)
        mainLayout.addWidget(self.function_label)
        mainLayout.addItem(buttonLayout)

        self.setLayout(mainLayout)
Example #27
0
class _JoinEditor(AbsOperationEditor):
    def editorBody(self) -> QWidget:
        self.__g = RadioButtonGroup('Select join type:', self)
        for j in Join.JoinType:
            self.__g.addRadioButton(j.name, j, False)

        self.__onIndex = QCheckBox('Join on index?', self)

        self.__jpl = _JoinPanel('Left', None, None, self)
        self.__jpr = _JoinPanel('Right', None, None, self)

        w = QWidget(self)
        self.layout = QGridLayout()
        self.layout.addLayout(self.__g.glayout, 0, 0, 1, -1)
        self.layout.addWidget(self.__onIndex, 1, 0, 1, -1)
        self.layout.addWidget(self.__jpl, 2, 0, 1, 1)
        self.layout.addWidget(self.__jpr, 2, 1, 1, 1)
        self.errorLabel = QLabel(self)
        self.errorLabel.setWordWrap(True)
        self.layout.addWidget(self.errorLabel, 3, 0, 1, -1)
        self.layout.setHorizontalSpacing(15)
        self.layout.setVerticalSpacing(10)
        w.setLayout(self.layout)

        # Clear errors when something change
        self.__onIndex.stateChanged.connect(self.__onStateChange)
        self.__onIndex.stateChanged.connect(self.errorLabel.hide)

        return w

    def refresh(self) -> None:
        oldl = self.__jpl
        oldr = self.__jpr
        self.__jpl = _JoinPanel('Left', self.inputShapes[0], self.acceptedTypes, self)
        self.__jpr = _JoinPanel('Right', self.inputShapes[1], self.acceptedTypes, self)
        self.layout.replaceWidget(oldl, self.__jpl)
        self.layout.replaceWidget(oldr, self.__jpr)
        # Delete old widgets
        oldl.deleteLater()
        oldr.deleteLater()
        # Reconnect
        self.__jpl.box.widget.currentIndexChanged.connect(self.errorLabel.hide)
        self.__jpl.suffix.widget.textEdited.connect(self.errorLabel.hide)
        self.__jpr.box.widget.currentIndexChanged.connect(self.errorLabel.hide)
        self.__jpr.suffix.widget.textEdited.connect(self.errorLabel.hide)

    def showErrors(self, msg: str) -> None:
        text = self.errorLabel.text()
        if text:
            text += '<br>' + msg
        self.errorLabel.setText(text)

    def getOptions(self) -> Iterable:
        attrL, suffL = self.__jpl.getData()
        attrR, suffR = self.__jpr.getData()
        jtype = self.__g.getData()
        onIndex = self.__onIndex.isChecked()
        return suffL, suffR, onIndex, attrL, attrR, jtype

    def setOptions(self, lsuffix: str, rsuffix: str, on_index: bool, left_on: int, right_on: int,
                   type: Join.JoinType) -> None:
        self.__jpl.setData(left_on, lsuffix)
        self.__jpr.setData(right_on, rsuffix)
        self.__onIndex.setChecked(on_index)
        self.__g.setData(type)

    @Slot(Qt.CheckState)
    def __onStateChange(self, state: Qt.CheckState) -> None:
        if state == Qt.Checked:
            self.__jpl.box.widget.setDisabled(True)
            self.__jpr.box.widget.setDisabled(True)
        else:
            self.__jpl.box.widget.setEnabled(True)
            self.__jpr.box.widget.setEnabled(True)