예제 #1
0
 def __init__(self, propertiesRepo, propertyName, gap=10, editWidth=100):
     QWidget.__init__(self)
     lt = QHBoxLayout()
     self.label = QLabel(propertyName)
     self.edit = PropertyLineEdit(propertiesRepo, propertyName)
     self.edit.setFixedWidth(editWidth)
     lt.addWidget(self.label)
     lt.addStretch(gap)
     lt.addWidget(self.edit)
     self.setLayout(lt)
예제 #2
0
    def showProperties(self, item):

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

        self.leftPanel.setVisible(item is not None)

        if item is None:
            return

        # close = QPushButton('x')
        # close.clicked.connect(lambda: self.scene.emptyPress())
        # l = QHBoxLayout()
        # l.addStretch(1)
        # l.addWidget(close)
        # w = QWidget()
        # w.setLayout(l)
        # self.editLayout.addWidget(w)

        from properties import PropertyWidget
        from widgets import horizontalSeparator, hoverActiveButton

        for p in item.properties():
            rowW = PropertyWidget(item.properties(), p.name)
            rowW.edit.setStyleSheet(EditImageWindow.editStyle)
            rowW.edit.setMaximumWidth(80)
            self.editLayout.addWidget(rowW)

        if isinstance(item, RectSelectionItem):
            insetInput = QLineEdit()
            insetInput.setStyleSheet(EditImageWindow.editStyle)
            insetInput.setValidator(QIntValidator())
            insetInput.setMaximumWidth(40)
            insetInput.setText('1')
            insetInput.setTextMargins(6, 0, 0, 0)
            rowLt = QHBoxLayout()
            bt = hoverActiveButton("Insert Insets")
            bt.clicked.connect(
                lambda: self.appendInsets(int(insetInput.text()), item))

            rowLt.addWidget(insetInput)
            rowLt.addStretch(10)
            rowLt.addWidget(bt)
            panel = QWidget()
            panel.setLayout(rowLt)

            self.editLayout.addWidget(horizontalSeparator())
            self.editLayout.addWidget(panel)
예제 #3
0
    def init_ui(self):
        """Initialize the gui"""
        # Define layout
        hbox = {}
        vbox = QVBoxLayout()
        self.setLayout(vbox)

        # Create layout box
        for i in range(1, 16):
            hbox[i] = QHBoxLayout()
            vbox.addLayout(hbox[i], 0)

        # Create store entry
        hbox[1].addWidget(self.create_label('Codigo', width=45))
        self.info_labels['Codigo'] = self.create_entry()
        hbox[1].addWidget(self.info_labels['Codigo'])

        # Create labels
        for lb in self.lbs:
            hbox[lb[0]].addWidget(self.create_label(lb[1], width=lb[2]))
            self.info_labels[lb[1]] = self.create_label(info=True, width=lb[3])
            hbox[lb[0]].addWidget(self.info_labels[lb[1]])

        # Search button
        self.btn_search = self.create_btn('Busca', width=570, func=self.search)
        hbox[7].addWidget(self.btn_search)

        # Create terminal entry
        for name in (('IP1', 8), ('IP2', 10)):
            self.entry[name[0]] = self.create_entry(True)
            hbox[name[1]].addWidget(self.entry[name[0]])

        # Create SSH and VNC buttons
        for name in (8, 10):
            hbox[name].addWidget(self.create_btn('SSH', func=self.search))
            hbox[name].addWidget(self.create_btn('VNC', func=self.search))

        # Create ping box
        for box in (('ip1', 9), ('ip2', 11), ('router', 13), ('sw', 15)):
            self.box[box[0]] = self.create_term()
            hbox[box[1]].addWidget(self.box[box[0]])
예제 #4
0
    def __init__(self, centeralWidget):
        QDialog.__init__(self)

        ok = QPushButton()
        ok.setIcon(self.style().standardIcon(QStyle.SP_DialogOkButton))
        ok.setText('Ok')
        ok.clicked.connect(self.on_ok.emit)
        ok.clicked.connect(lambda: self.close())

        cancel = QPushButton()
        cancel.setIcon(self.style().standardIcon(QStyle.SP_DialogCancelButton))
        cancel.setText('Cancel')
        cancel.clicked.connect(lambda: self.close())

        buttonsLt = QHBoxLayout()
        buttonsLt.addStretch()
        buttonsLt.addWidget(ok)
        buttonsLt.addWidget(cancel)

        mainLt = QVBoxLayout()
        mainLt.addWidget(centeralWidget, Qt.AlignCenter)
        mainLt.addLayout(buttonsLt)

        self.setLayout(mainLt)
예제 #5
0
    def do_layout(self):
        panel = QWidget()

        bar = self.layout_buttons()

        topBottom = QVBoxLayout()
        leftToRight = QHBoxLayout()
        leftToRight.addWidget(self.leftPanel)
        leftToRight.addStretch(10)
        topBottom.addStretch(1)
        topBottom.addLayout(leftToRight)
        topBottom.addStretch(1)
        self.view.setLayout(topBottom)

        lt = QVBoxLayout()
        lt.addWidget(bar)
        #lt.addLayout(leftToRight)
        lt.addWidget(self.view)
        panel.setLayout(lt)

        self.setCentralWidget(panel)
예제 #6
0
    def _layout_buttons_(self):
        box = QHBoxLayout()
        box.setContentsMargins(5, 5, 5, 5)
        box.addWidget(self.add_files_button)
        box.addWidget(self.screenshot_button)
        box.addWidget(self.edit_image)
        box.addWidget(self.delete_button)
        box.addStretch(20)
        box.addWidget(self.insert_button)
        self.buttons_bar.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
        self.buttons_bar.setLayout(box)

        # self.buttons_bar.setObjectName('buttons_bar')
        self.buttons_bar.setObjectName('buttons')
        self.buttons_bar.setStyleSheet("""
        QFrame#buttons{
            border-top:1px solid gray;
            border-left:1px solid gray; border-right:1px solid gray;
            border-top-left-radius:3px; border-top-right-radius:3px
        }
        """)
예제 #7
0
    def __init__(self, parent, session):
        QDialog.__init__(self, parent)
        self.setStyleSheet('''
        QToolButton { 
            border: 1px solid rgb(51, 122, 183); 
            border-radius:5px; 
            background:rgb(222, 222, 222); 
            outline:0px;
            padding:10px;
            width: 80px;
        } 
        QToolButton:hover { background:transparent; background:rgb(51, 122, 183); color:white}
        QToolButton:pressed { background:rgb(41, 100, 153); color:white }
        QToolButton:checked { background:rgb(41, 100, 153); color:white }
        ''')

        self.setWindowTitle('Choose Template')

        self.boxLt = QHBoxLayout()
        self.boxLt.setSpacing(20)
        self.buttons = {}
        self.selected = None

        nameLt = QHBoxLayout()
        self.nameInput = QLineEdit()
        self.nameInput.setValidator(FileExistValidator(session))
        nameLt.addWidget(QLabel('File Name'))
        nameLt.addSpacing(10)
        nameLt.addWidget(self.nameInput)
        self.errorLabel = QLabel('File already exists, change name')
        self.errorLabel.setStyleSheet('color:red; font-size:8pt')
        self.errorLabel.hide()

        self.create = QPushButton('Create')
        self.create.setEnabled(False)
        self.create.clicked.connect(self.processCreation)
        blt = QHBoxLayout()
        blt.addStretch(0)
        blt.addWidget(self.create)

        lt = QVBoxLayout()
        lt.addLayout(nameLt)
        lt.addWidget(self.errorLabel)
        lt.addSpacing(20)
        lt.addLayout(self.boxLt)
        lt.addSpacing(20)
        lt.addLayout(blt)
        lt.setContentsMargins(50, 50, 50, 50)
        self.setLayout(lt)

        self.template_selected.connect(self.validateCreate)
        self.nameInput.textChanged.connect(self.validateCreate)
예제 #8
0
class AddNewTemplatePanel(QDialog):
    template_selected = Signal(str)
    on_file_create = Signal(str, str)

    def __init__(self, parent, session):
        QDialog.__init__(self, parent)
        self.setStyleSheet('''
        QToolButton { 
            border: 1px solid rgb(51, 122, 183); 
            border-radius:5px; 
            background:rgb(222, 222, 222); 
            outline:0px;
            padding:10px;
            width: 80px;
        } 
        QToolButton:hover { background:transparent; background:rgb(51, 122, 183); color:white}
        QToolButton:pressed { background:rgb(41, 100, 153); color:white }
        QToolButton:checked { background:rgb(41, 100, 153); color:white }
        ''')

        self.setWindowTitle('Choose Template')

        self.boxLt = QHBoxLayout()
        self.boxLt.setSpacing(20)
        self.buttons = {}
        self.selected = None

        nameLt = QHBoxLayout()
        self.nameInput = QLineEdit()
        self.nameInput.setValidator(FileExistValidator(session))
        nameLt.addWidget(QLabel('File Name'))
        nameLt.addSpacing(10)
        nameLt.addWidget(self.nameInput)
        self.errorLabel = QLabel('File already exists, change name')
        self.errorLabel.setStyleSheet('color:red; font-size:8pt')
        self.errorLabel.hide()

        self.create = QPushButton('Create')
        self.create.setEnabled(False)
        self.create.clicked.connect(self.processCreation)
        blt = QHBoxLayout()
        blt.addStretch(0)
        blt.addWidget(self.create)

        lt = QVBoxLayout()
        lt.addLayout(nameLt)
        lt.addWidget(self.errorLabel)
        lt.addSpacing(20)
        lt.addLayout(self.boxLt)
        lt.addSpacing(20)
        lt.addLayout(blt)
        lt.setContentsMargins(50, 50, 50, 50)
        self.setLayout(lt)

        self.template_selected.connect(self.validateCreate)
        self.nameInput.textChanged.connect(self.validateCreate)

    def populateButtons(self, names):
        self.buttons = {}
        for name in names:
            b = QToolButton()
            b.setText(name)
            b.setGraphicsEffect(_create_shadow_())
            b.setIcon(self.style().standardIcon(QStyle.SP_FileIcon))
            b.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
            b.clicked.connect(self.processTemplateClick)
            b.setCheckable(True)
            self.buttons[name] = b
            self.boxLt.addWidget(b)

    def validateCreate(self):
        correct_name = self.nameInput.hasAcceptableInput()
        enabled = sum([
            int(self.buttons[b].isChecked()) for b in self.buttons
        ]) == 1 and len(self.nameInput.text()) > 0 and correct_name
        self.create.setEnabled(enabled)
        self.errorLabel.setVisible(not correct_name)

    def processTemplateClick(self):
        bname = self.sender().text()
        for name in self.buttons:
            if name != bname:
                self.buttons[name].setChecked(False)
        self.selected = bname
        self.template_selected.emit(self.sender().text())

    def processCreation(self):
        self.on_file_create.emit(self.nameInput.text().strip(), self.selected)
예제 #9
0
 def _layout_buttons_(self):
     box = QHBoxLayout()
     box.addWidget(self.delete_button)
     box.addStretch(20)
     box.addWidget(self.add_folder)
     box.addWidget(self.add_page)
     box.setContentsMargins(5, 5, 5, 5)
     self.buttons_bar.setLayout(box)
     self.buttons_bar.setSizePolicy(
         QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
     self.buttons_bar.setObjectName('buttons')
     self.buttons_bar.setStyleSheet(
         'QFrame#buttons{background:transparent; border-top:1px solid gray; '
         'border-left:1px solid gray; border-right:1px solid gray; '
         'border-top-left-radius:3px; border-top-right-radius:3px}')
예제 #10
0
    def layout_buttons(self):
        import icons

        panel = QWidget()
        panel.setObjectName('buttons-bar')

        add_rect = QPushButton()
        add_rect.setIcon(icons.get('rectangle'))
        add_rect.setToolTip('Add Rectangle')
        add_rect.clicked.connect(self.scene.addRectElement)

        add_ellipse = QPushButton()
        add_ellipse.setIcon(icons.get('ellipse'))
        add_ellipse.setToolTip('Add Ellipse')
        add_ellipse.clicked.connect(self.scene.addEllipseElement)

        add_number = QPushButton()
        add_number.setToolTip('Add number')
        add_number.setIcon(icons.get('add_number'))
        add_number.clicked.connect(lambda: self.scene.addNumberElement(self))

        add_numbered_rect = QPushButton()
        add_numbered_rect.setToolTip('Add numbered rectangle')
        add_numbered_rect.setIcon(icons.get('add_numbered_rect'))
        add_numbered_rect.clicked.connect(
            lambda: self.scene.addNumberedRectElement(self))

        duplicate_button = QPushButton()
        duplicate_button.setToolTip('Duplicate')
        duplicate_button.setIcon(icons.get('duplicate'))
        duplicate_button.setEnabled(False)
        duplicate_button.clicked.connect(
            lambda: self.scene.duplicateSelection())
        self.enabledOnSelection.append(duplicate_button)

        delete_button = QPushButton()
        delete_button.setToolTip('Delete')
        delete_button.setIcon(self.style().standardIcon(QStyle.SP_TrashIcon))
        delete_button.setEnabled(False)
        delete_button.clicked.connect(lambda: self.scene.deleteSelected())
        self.enabledOnSelection.append(delete_button)

        spacing = QLineEdit()
        spacing.setText(str(self.scene.posConstraint.spacing))
        spacing.setValidator(QIntValidator(bottom=0))
        spacing.returnPressed.connect(
            lambda: self.scene.setSpacing(int(spacing.text())))
        spacing.setMaximumWidth(30)

        xshift = QSpinBox()
        xshift.setValue(self.scene.posConstraint.xShift)
        xshift.valueChanged.connect(lambda v: self.scene.setXGridShift(v))

        yshift = QSpinBox()
        yshift.setValue(self.scene.posConstraint.yShift)
        yshift.valueChanged.connect(lambda v: self.scene.setYGridShift(v))

        lt = QHBoxLayout()
        lt.addWidget(add_rect)
        lt.addWidget(add_ellipse)
        lt.addWidget(add_number)
        lt.addWidget(add_numbered_rect)
        lt.addSpacing(20)
        lt.addWidget(duplicate_button)
        lt.addSpacing(20)
        lt.addWidget(delete_button)
        lt.addStretch()
        lt.addWidget(QLabel('Grid Spacing'))
        lt.addWidget(spacing)
        lt.addWidget(QLabel('X Grid Shift'))
        lt.addWidget(xshift)
        lt.addWidget(QLabel('Y Grid Shift'))
        lt.addWidget(yshift)

        panel.setLayout(lt)

        return panel
예제 #11
0
 def _build_buttons_layout_(self):
     lt = QHBoxLayout()
     return lt