Exemplo n.º 1
0
    def addOverlayWidget(self, w, line, col=None, offset=0, minX=0):
        line -= 1

        if line not in self.__overlayWidgets:
            cont = QFrame()
            cont.setStyleSheet("QFrame { background-color : transparent; }")
            cont.setLayout(QHBoxLayout())
            cont.layout().setSpacing(20)
            cont.layout().setMargin(0)
            cont.layout().setSizeConstraint(QLayout.SetMinAndMaxSize)
            cont.setParent(self.viewport())

            if col is None:
                col = self.lineLength(line) - 1
            else:
                col = min(col, self.lineLength(line) - 1)

            self.__moveOverlayToLine(cont, line)
            pos = self.positionFromLineIndex(int(line), col)
            x = self.SendScintilla(Qsci.QsciScintilla.SCI_POINTXFROMPOSITION, 0, pos)
            cont.move(max(x + offset, minX), cont.y())

            cont.resize(10, self.textHeight(line))
            cont.show()

            self.__overlayWidgets[line] = cont

        w.setParent(self.__overlayWidgets[line])
        w.resize(w.size().width(), self.textHeight(line))
        self.__overlayWidgets[line].layout().addWidget(w)
Exemplo n.º 2
0
    def addOverlayWidget(self, w, line, col=None, offset=0, minX=0):
        line -= 1

        if line not in self.__overlayWidgets:
            cont = QFrame()
            cont.setStyleSheet("QFrame { background-color : transparent; }")
            cont.setLayout(QHBoxLayout())
            cont.layout().setSpacing(20)
            cont.layout().setMargin(0)
            cont.layout().setSizeConstraint(QLayout.SetMinAndMaxSize)
            cont.setParent(self.viewport())

            if col is None:
                col = self.lineLength(line) - 1
            else:
                col = min(col, self.lineLength(line) - 1)

            self.__moveOverlayToLine(cont, line)
            pos = self.positionFromLineIndex(int(line), col)
            x = self.SendScintilla(Qsci.QsciScintilla.SCI_POINTXFROMPOSITION,
                                   0, pos)
            cont.move(max(x + offset, minX), cont.y())

            cont.resize(10, self.textHeight(line))
            cont.show()

            self.__overlayWidgets[line] = cont

        w.setParent(self.__overlayWidgets[line])
        w.resize(w.size().width(), self.textHeight(line))
        self.__overlayWidgets[line].layout().addWidget(w)
Exemplo n.º 3
0
class Example(QWidget):
    def __init__(self):
        super(Example, self).__init__()
        self.init()

    def init(self):
        self.setLayout(QBoxLayout(0, self))
        self.setWindowModality(Qt.WindowModal)

        self.frame = QFrame(self)
        self.frame.setStyleSheet("background: black;")
        self.frame.move(0, 0)
        self.frame.resize(self.size().width(), self.size().height())
        self.frame.setAttribute( Qt.WA_OpaquePaintEvent )

        self.button = QPushButton('Test', self)
        self.button.clicked.connect(self.handleButton)
        layout = QVBoxLayout(self)
        layout.addWidget(self.button)

    def handleButton(self):
        self.emit(SIGNAL("clicked"))
Exemplo n.º 4
0
    def _init_ui(self):

        # Styles
        self.setStyleSheet("""QRadioButton {
                max-width: 40px;
            }""")

        bold_font = QFont()
        bold_font.setBold(True)

        title_label = QLabel(self)
        title_label.setText("PyPass3")
        title_label.move(10, 0)
        title_label.setMinimumSize(300, 20)
        title_label.setFont(bold_font)

        length_label = QLabel(self)
        length_label.setText("Length")
        length_label.move(192, 185)
        length_label.setMinimumSize(200, 20)
        length_label.setFont(bold_font)

        main_label = QLabel(self)
        main_label.setText("Make robust secrets with random characters,\n"
                           "words, or numbers. Or choose number of dice\n"
                           "and rolls for words type passphrase. Defaults\n"
                           "to 5 dice and 5 rolls.\n")
        main_label.setMinimumSize(280, 100)
        main_label.move(10, 15)

        type_label = QLabel(self)
        type_label.setText("Secret type")
        type_label.move(10, 87)
        type_label.setFont(bold_font)

        dice_label = QLabel(self)
        dice_label.setText("Number of dice")
        dice_label.move(10, 138)
        dice_label.setMinimumSize(280, 20)
        dice_label.setFont(bold_font)

        rolls_label = QLabel(self)
        rolls_label.setText("Number of rolls")
        rolls_label.move(10, 190)
        rolls_label.setMinimumSize(280, 20)
        rolls_label.setFont(bold_font)

        self.textbox = QTextEdit(self)
        self.textbox.setMinimumSize(280, 100)
        self.textbox.move(10, 245)
        self.textbox.setFontFamily("Courier New")

        self.length_textline = QLineEdit(self)
        self.length_textline.setMinimumSize(100, 20)
        self.length_textline.move(190, 210)

        min_width = 125
        # max_width = 150

        # Add Generate button
        generate_btn = QPushButton('Generate', self)
        generate_btn.setToolTip('Click to generate secret')
        # generate_btn.clicked.connect(on_click)
        generate_btn.clicked.connect(self._on_click)
        generate_btn.move(10, 355)
        generate_btn.setMinimumWidth(min_width)

        # Add Quit button
        quit_btn = QPushButton('Quit', self)
        quit_btn.setToolTip('Quit this application')
        quit_btn.clicked.connect(exit)
        quit_btn.move(165, 355)
        quit_btn.setMinimumWidth(min_width)

        # Add Copy button
        copy_btn = QPushButton('Copy', self)
        copy_btn.setToolTip('Copy your secret')
        copy_btn.clicked.connect(self._copy_textbox)
        copy_btn.move(250, 320)
        copy_btn.setMaximumWidth(35)
        copy_btn.setMaximumHeight(20)
        copy_btn.setStyleSheet('font-size: 11px;')

        # Add Help button
        help_btn = QPushButton('Help', self)
        help_btn.setToolTip('Get help about this application')
        help_btn.clicked.connect(self._open_help)
        help_btn.move(240, 80)
        help_btn.setMaximumWidth(35)
        help_btn.setMaximumHeight(20)
        help_btn.setStyleSheet('font-size: 11px;')

        hr1 = QFrame(self)
        hr1.setFrameShape(QFrame.HLine)
        hr1.move(10, 125)
        hr1.setMinimumWidth(280)
        hr1.setStyleSheet("color: #d0d0d0;")

        hr2 = QFrame(self)
        hr2.setFrameShape(QFrame.HLine)
        hr2.move(10, 175)
        hr2.setMinimumWidth(100)
        hr2.setStyleSheet("color: #d0d0d0;")

        # Add secret type radio buttons
        self.words_radio_btn = QRadioButton('words', self)
        self.words_radio_btn.move(10, 110)
        self.words_radio_btn.clicked.connect(self._set_word_defaults)
        self.words_radio_btn.setStyleSheet('max-width: 80px;')

        self.mixed_radio_btn = QRadioButton('mixed', self)
        self.mixed_radio_btn.move(90, 110)
        self.mixed_radio_btn.clicked.connect(self._disabled_unused)
        self.mixed_radio_btn.setStyleSheet('max-width: 80px;')

        self.numbers_radio_btn = QRadioButton('numbers', self)
        self.numbers_radio_btn.move(170, 110)
        self.numbers_radio_btn.clicked.connect(self._disabled_unused)
        self.numbers_radio_btn.setStyleSheet('max-width: 100px;')

        # Add dice roll radio buttons
        self.num_dice4 = QRadioButton('4', self)
        self.num_dice4.move(10, 160)

        self.num_dice5 = QRadioButton('5', self)
        self.num_dice5.move(60, 160)

        self.num_rolls3 = QRadioButton('3', self)
        self.num_rolls3.move(10, 212)

        self.num_rolls4 = QRadioButton('4', self)
        self.num_rolls4.move(60, 212)

        self.num_rolls5 = QRadioButton('5', self)
        self.num_rolls5.move(110, 212)

        self.radio_type_group = QButtonGroup(self)
        self.radio_type_group.addButton(self.words_radio_btn)
        self.radio_type_group.addButton(self.mixed_radio_btn)
        self.radio_type_group.addButton(self.numbers_radio_btn)

        self.radio_dice_group = QButtonGroup(self)
        self.radio_dice_group.addButton(self.num_dice4)
        self.radio_dice_group.addButton(self.num_dice5)

        self.radio_rolls_group = QButtonGroup(self)
        self.radio_rolls_group.addButton(self.num_rolls3)
        self.radio_rolls_group.addButton(self.num_rolls4)
        self.radio_rolls_group.addButton(self.num_rolls5)

        self.setGeometry(100, 100, 300, 400)
        self.setWindowTitle('Password Generator')
        self.setWindowIcon(QIcon('../images/lock_icon_bkgrd.png'))