Пример #1
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)
Пример #2
0
 def _do_layout_(self):
     lt = QVBoxLayout()
     lt.setContentsMargins(0, 0, 0, 0)
     lt.addLayout(self._build_buttons_layout_())
     lt.addWidget(self.editor)
     self.setLayout(lt)