def addProgressBar(self, stages=1): progressBar = MultistageProgressBar(self, stages) progressBar.setTextVisible(False) # hide a default % completion text load_css_for_widget(progressBar, os.path.join(css_path, 'progressbar.css')) self.widgets.append(progressBar) return progressBar
def addAnimation(self, gifPath): gifAnimation = QtGui.QLabel(self) gifAnimation.setObjectName('animation') load_css_for_widget(gifAnimation, os.path.join(css_path, 'label.css')) gif = QtGui.QMovie(gifPath) gifAnimation.setMovie(gif) gif.start() self.widgets.append(gifAnimation) return gifAnimation
def addComboBox(self, onClick, defaultItem=None): comboBox = ComboBox(self, defaultItem) comboBox.clicked.connect(onClick) comboBox.resized.connect(self.centerWidgets) # the resizing policy will allow the combobox to resize depending on its contents comboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents) load_css_for_widget(comboBox, os.path.join(css_path, 'combobox.css'), images_path) self.widgets.append(comboBox) return comboBox
def addTextEdit(self): textEdit = QtGui.QTextEdit() load_css_for_widget(textEdit, os.path.join(css_path, 'textedit.css')) disclaimer_path = os.path.join(base_path, "DISCLAIMER") disclaimer_text = read_file_contents(disclaimer_path) textEdit.setText(disclaimer_text) textEdit.setReadOnly(True) textEdit.setGeometry(100, 100, 800, 600) return textEdit
def __init__(self, parent, logtext): super(LogReportDialog, self).__init__(parent) self.log = logtext palette = self.palette() palette.setColor(self.backgroundRole(), QtGui.QColor(255, 255, 255)) self.setPalette(palette) self.setWindowTitle( "Sorry we didn't get to finish burning your SD card") heading = QtGui.QLabel( "Want to send us the logs to allow us to improve?") heading.setObjectName("dialogTitle") load_css_for_widget(heading, os.path.join(css_path, 'label.css')) self.emailMessage = "Optionally enter email address" emailentry = self.addTextEdit(text=self.emailMessage, readOnly=False, oneLine=True) textview = self.addTextEdit(self.log, startsVisible=False) self.textview = textview self.emailentry = emailentry self.logButton = QtGui.QPushButton("View Log") self.logButton.clicked.connect(self.toggleLog) self.logButton.setObjectName("dialogOk") load_css_for_widget(self.logButton, os.path.join(css_path, 'button.css')) self.okButton = QtGui.QPushButton("OK") self.okButton.clicked.connect(self.accept) self.okButton.setObjectName("dialogOk") load_css_for_widget(self.okButton, os.path.join(css_path, 'button.css')) cancelButton = QtGui.QPushButton("CANCEL") cancelButton.clicked.connect(self.reject) cancelButton.setObjectName("dialogCancel") load_css_for_widget(cancelButton, os.path.join(css_path, 'button.css')) mainLayout = QtGui.QVBoxLayout() hbox = QtGui.QHBoxLayout() hbox.addSpacing(20) hbox.addWidget(self.logButton) hbox.addSpacing(80) hbox.addWidget(self.okButton) hbox.addSpacing(20) hbox.addWidget(cancelButton) hbox.addSpacing(80) mainLayout.setSpacing(20) mainLayout.addWidget(heading) mainLayout.addWidget(emailentry) mainLayout.addWidget(textview) mainLayout.addLayout(hbox) self.setLayout(mainLayout) cancelButton.setFocus()
def setTheme(self): # the application window only has a vertical container which contains # exactly 3 items: a header image, a spacer for the active screen, and a footer self.container = VerticalContainer(self) self.container.setGeometry(0, 0, APP_WIDTH, APP_HEIGHT) # changing the background color of the main window palette = self.palette() palette.setColor(self.backgroundRole(), QtGui.QColor(255, 132, 42)) # FF842A self.setPalette(palette) # adding the 3 items to the application container self.container.addImage(os.path.join(images_path, 'header.png')) self.container.addSpacer(CONTAINER_HEIGHT) footer = self.container.addLabel("Questions? Visit help.kano.me", objectName=LABEL_CSS_FOOTER) load_css_for_widget(footer, os.path.join(css_path, 'label.css'))
def addTextEdit(self, text, readOnly=True, startsVisible=True, oneLine=False): if oneLine: textEdit = QtGui.QLineEdit() else: textEdit = QtGui.QTextEdit() load_css_for_widget(textEdit, os.path.join(css_path, 'textedit.css')) if readOnly: textEdit.setText(text) else: textEdit.setPlaceholderText(text) textEdit.setReadOnly(readOnly) textEdit.setGeometry(100, 100, 800, 600) textEdit.setVisible(startsVisible) return textEdit
def __init__(self, parent, logtext): super(LogReportDialog, self).__init__(parent) self.log = logtext palette = self.palette() palette.setColor(self.backgroundRole(), QtGui.QColor(255, 255, 255)) self.setPalette(palette) self.setWindowTitle("Sorry we didn't get to finish burning your SD card") heading = QtGui.QLabel("Want to send us the logs to allow us to improve?") heading.setObjectName("dialogTitle") load_css_for_widget(heading, os.path.join(css_path, 'label.css')) self.emailMessage = "Optionally enter email address" emailentry = self.addTextEdit(text=self.emailMessage, readOnly=False, oneLine=True) textview = self.addTextEdit(self.log, startsVisible=False) self.textview = textview self.emailentry = emailentry self.logButton = QtGui.QPushButton("View Log") self.logButton.clicked.connect(self.toggleLog) self.logButton.setObjectName("dialogOk") load_css_for_widget(self.logButton, os.path.join(css_path, 'button.css')) self.okButton = QtGui.QPushButton("OK") self.okButton.clicked.connect(self.accept) self.okButton.setObjectName("dialogOk") load_css_for_widget(self.okButton, os.path.join(css_path, 'button.css')) cancelButton = QtGui.QPushButton("CANCEL") cancelButton.clicked.connect(self.reject) cancelButton.setObjectName("dialogCancel") load_css_for_widget(cancelButton, os.path.join(css_path, 'button.css')) mainLayout = QtGui.QVBoxLayout() hbox = QtGui.QHBoxLayout() hbox.addSpacing(20) hbox.addWidget(self.logButton) hbox.addSpacing(80) hbox.addWidget(self.okButton) hbox.addSpacing(20) hbox.addWidget(cancelButton) hbox.addSpacing(80) mainLayout.setSpacing(20) mainLayout.addWidget(heading) mainLayout.addWidget(emailentry) mainLayout.addWidget(textview) mainLayout.addLayout(hbox) self.setLayout(mainLayout) cancelButton.setFocus()
def __init__(self, parent): super(DisclaimerDialog, self).__init__(parent) palette = self.palette() palette.setColor(self.backgroundRole(), QtGui.QColor(255, 255, 255)) self.setPalette(palette) self.setWindowTitle("Are you sure?") heading = QtGui.QLabel("Hey! Are you sure?") heading.setObjectName("dialogTitle") load_css_for_widget(heading, os.path.join(css_path, 'label.css')) textview = self.addTextEdit() self.checkbox = QtGui.QCheckBox('I still want to do this', self) self.checkbox.clicked.connect(self.enableButton) load_css_for_widget(self.checkbox, os.path.join(css_path, 'checkbox.css')) self.okButton = QtGui.QPushButton("OK") self.okButton.clicked.connect(self.accept) self.okButton.setEnabled(False) self.okButton.setObjectName("dialogOk") load_css_for_widget(self.okButton, os.path.join(css_path, 'button.css')) cancelButton = QtGui.QPushButton("CANCEL") cancelButton.clicked.connect(self.reject) cancelButton.setObjectName("dialogCancel") load_css_for_widget(cancelButton, os.path.join(css_path, 'button.css')) mainLayout = QtGui.QVBoxLayout() hbox = QtGui.QHBoxLayout() hbox.addSpacing(80) hbox.addWidget(self.okButton) hbox.addSpacing(20) hbox.addWidget(cancelButton) hbox.addSpacing(80) mainLayout.setSpacing(20) mainLayout.addWidget(heading) mainLayout.addWidget(textview) mainLayout.addWidget(self.checkbox, alignment=QtCore.Qt.AlignHCenter) mainLayout.addLayout(hbox) self.setLayout(mainLayout)
def addButton(self, text, onClick): button = HoverButton(text, self) button.clicked.connect(onClick) load_css_for_widget(button, os.path.join(css_path, 'button.css')) self.widgets.append(button) return button
def addLabel(self, text, objectName=""): label = QtGui.QLabel(text, self) label.setObjectName(objectName) # set a class ID for CSS styling load_css_for_widget(label, os.path.join(css_path, 'label.css')) self.widgets.append(label) return label