def __init__(self, *args): COMCUPluginBase.__init__(self, BrickletLoadCellV2, *args) self.lc = self.device self.cbe_weight = CallbackEmulator(self.lc.get_weight, self.cb_weight, self.increase_error_count) self.current_weight = None # int, g self.calibration = None plots = [('Weight', Qt.red, lambda: self.current_weight, format_weight) ] self.plot_widget = PlotWidget('Weight [g]', plots) self.button_calibration = QPushButton("Calibration...") self.button_calibration.clicked.connect( self.button_calibration_clicked) self.button_tare = QPushButton("Tare") self.button_tare.clicked.connect(self.button_tare_clicked) self.cbox_info_led_config = QComboBox() self.cbox_info_led_config.addItem("Off") self.cbox_info_led_config.addItem("On") self.cbox_info_led_config.addItem("Heartbeat") self.cbox_info_led_config.currentIndexChanged.connect( self.cbox_info_led_config_changed) self.label_info_led_config = QLabel('Info LED:') #self.enable_led = QCheckBox("Enable LED") #self.enable_led.stateChanged.connect(self.enable_led_changed) self.spin_average = QSpinBox() self.spin_average.setMinimum(0) self.spin_average.setMaximum(40) self.spin_average.setSingleStep(1) self.spin_average.setValue(5) self.spin_average.editingFinished.connect(self.spin_average_finished) self.label_average = QLabel('Moving Average Length:') self.rate_label = QLabel('Rate:') self.rate_combo = QComboBox() self.rate_combo.addItem("10 Hz") self.rate_combo.addItem("80 Hz") self.rate_combo.currentIndexChanged.connect(self.new_config) self.gain_label = QLabel('Gain:') self.gain_combo = QComboBox() self.gain_combo.addItem("128x") self.gain_combo.addItem("64x") self.gain_combo.addItem("32x") self.gain_combo.currentIndexChanged.connect(self.new_config) hlayout = QHBoxLayout() hlayout.addWidget(self.label_average) hlayout.addWidget(self.spin_average) hlayout.addWidget(self.rate_label) hlayout.addWidget(self.rate_combo) hlayout.addWidget(self.gain_label) hlayout.addWidget(self.gain_combo) hlayout.addStretch() hlayout.addWidget(self.button_calibration) hlayout.addWidget(self.button_tare) hlayout.addWidget(self.label_info_led_config) hlayout.addWidget(self.cbox_info_led_config) line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout)
def __init__(self, parent=None): QWidget.__init__(self, parent) icon = QIcon() icon.addPixmap(QPixmap(":/freeseer/logo.png"), QIcon.Normal, QIcon.Off) self.setWindowIcon(icon) self.resize(400, 400) self.mainLayout = QVBoxLayout() self.setLayout(self.mainLayout) self.setStyleSheet(""" QToolButton { background-color: #D1D1D1; border-style: solid; border-width: 1px; border-radius: 10px; border-color: #969696; padding: 6px; } QToolButton:pressed { background-color: #A3A2A2; border-width: 2px; border-color: #707070; } QToolButton:checked { background-color: #A3A2A2; border-width: 2px; border-color: #707070; } QToolButton:disabled { background-color: #EDEDED; border-color: #BFBDBD; } QToolButton:hover { border-width: 2px; } """) boldFont = QFont() boldFont.setBold(True) fontSize = self.font().pixelSize() fontUnit = "px" if fontSize == -1: # Font is set as points, not pixels. fontUnit = "pt" fontSize = self.font().pointSize() # Control bar self.controlRow = QHBoxLayout() self.mainLayout.addLayout(self.controlRow) self.recordIcon = QIcon(":/multimedia/record.png") self.stopIcon = QIcon(":/multimedia/stop.png") pauseIcon = QIcon(":/multimedia/pause.png") playIcon = QIcon(":/multimedia/play.png") self.headphoneIcon = QIcon() self.headphoneIcon.addPixmap(QPixmap(":/multimedia/headphones.png"), QIcon.Normal, QIcon.Off) self.is_recording = False self.recordButton = QToolButton() self.recordButton.setToolTip("Record") self.recordButton.setFixedSize(QSize(60, 40)) self.recordButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.recordButton.setIcon(self.recordIcon) self.recordButton.setEnabled(False) self.recordButton.setObjectName("recordButton") self.controlRow.addWidget(self.recordButton, 0, Qt.AlignLeft) self.connect(self.recordButton, SIGNAL("clicked()"), self.setRecordIcon) self.playButton = QToolButton() self.playButton.setToolTip("Play last recorded Video") self.playButton.setFixedSize(QSize(60, 40)) self.playButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.playButton.setIcon(playIcon) self.playButton.setEnabled(False) self.controlRow.addWidget(self.playButton, 0, Qt.AlignLeft) self.pauseButton = QToolButton() self.pauseButton.setToolTip("Pause") self.pauseButton.setIcon(pauseIcon) self.pauseButton.setFixedSize(QSize(60, 40)) self.pauseButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.pauseButton.setEnabled(False) self.pauseButton.setCheckable(True) self.controlRow.addWidget(self.pauseButton, 0, Qt.AlignLeft) self.controlRow.addSpacerItem(QSpacerItem(30, 40)) self.controlRow.addStretch(1) self.standbyButton = QPushButton("Standby") self.standbyButton.setStyleSheet(""" QPushButton {{ color: white; background-color: #47a447; border-style: solid; border-width: 0px; border-radius: 10px; border-color: #398439; font: bold {}{}; padding: 6px; }} QPushButton:pressed {{ background-color: #3E8A3E; border-color: #327532; }} QPushButton:hover {{ border-width: 2px; }} """.format(fontSize + 3, fontUnit)) self.standbyButton.setToolTip("Standby") self.standbyButton.setFixedSize(QSize(180, 40)) self.standbyButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.standbyButton.setCheckable(True) self.standbyButton.setObjectName("standbyButton") self.controlRow.addWidget(self.standbyButton) self.disengageButton = QPushButton("Leave record-mode") self.disengageButton.setStyleSheet(""" QPushButton {{ color: white; background-color: #D14343; border-style: solid; border-width: 0px; border-radius: 10px; border-color: #B02C2C; font: bold {}{}; padding: 6px; }} QPushButton:pressed {{ background-color: #AD2B2B; border-color: #8C2929; }} QPushButton:hover {{ border-width: 2px; }} QPushButton:disabled {{ background-color: #B89E9E; }} """.format(fontSize + 3, fontUnit)) self.disengageButton.setToolTip("Leave record-mode") self.disengageButton.setFixedSize(QSize(180, 40)) self.disengageButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.disengageButton.setHidden(True) self.disengageButton.setObjectName("disengageButton") self.controlRow.addWidget(self.disengageButton) # Filter bar self.filterBarLayout = QVBoxLayout() self.mainLayout.addLayout(self.filterBarLayout) self.filterBarLayoutRow_1 = QHBoxLayout() self.filterBarLayout.addLayout(self.filterBarLayoutRow_1) self.eventLabel = QLabel("Event") self.eventLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.eventComboBox = QComboBox() self.eventLabel.setBuddy(self.eventComboBox) self.roomLabel = QLabel("Room") self.roomLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.roomComboBox = QComboBox() self.roomLabel.setBuddy(self.roomComboBox) self.dateLabel = QLabel("Date") self.dateLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.dateComboBox = QComboBox() self.dateLabel.setBuddy(self.dateComboBox) self.filterBarLayoutRow_1.addWidget(self.eventLabel) self.filterBarLayoutRow_1.addWidget(self.eventComboBox) self.filterBarLayoutRow_1.addWidget(self.roomLabel) self.filterBarLayoutRow_1.addWidget(self.roomComboBox) self.filterBarLayoutRow_1.addWidget(self.dateLabel) self.filterBarLayoutRow_1.addWidget(self.dateComboBox) self.filterBarLayoutRow_2 = QHBoxLayout() self.filterBarLayout.addLayout(self.filterBarLayoutRow_2) self.talkLabel = QLabel("Talk ") self.talkLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.talkComboBox = QComboBox() self.talkComboBox.setFont(boldFont) self.talkComboBox.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum) self.talkComboBox.setSizeAdjustPolicy( QComboBox.AdjustToMinimumContentsLength) self.filterBarLayoutRow_2.addWidget(self.talkLabel) self.filterBarLayoutRow_2.addWidget(self.talkComboBox) # Preview Layout self.previewLayout = QHBoxLayout() self.mainLayout.addLayout(self.previewLayout) self.previewWidget = QWidget() self.audioSlider = QSlider() self.audioSlider.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) self.audioSlider.setEnabled(False) self.previewLayout.addWidget(self.previewWidget) self.previewLayout.addWidget(self.audioSlider) self.statusLabel = QLabel() self.mainLayout.addWidget(self.statusLabel) # Audio Feedback Checkbox self.audioFeedbackCheckbox = QCheckBox() self.audioFeedbackCheckbox.setLayoutDirection(Qt.RightToLeft) self.audioFeedbackCheckbox.setIcon(self.headphoneIcon) self.audioFeedbackCheckbox.setToolTip("Enable Audio Feedback") self.mainLayout.addWidget(self.audioFeedbackCheckbox)
def createWidgets(self, filename): """ Create qt widgets @param filename: @type filename: """ self.setFixedWidth(450) self.setFixedHeight(500) self.warningLabel = QLabel('') font = QFont() font.setItalic(True) self.warningLabel.setFont(font) if self.typeMode == MODE_SAVE: self.selectedFilenames = [] self.setWindowTitle('Save to local repository as ...') self.acceptButton = QPushButton("Save") self.warningLabel.setText('') withFile = False elif self.typeMode == MODE_OPEN: self.acceptButton = QPushButton("Open") self.setWindowTitle('Open from repository') withFile = True if self.multipleSelection: self.warningLabel.setText('Multiple selection files available.') else: self.warningLabel.setText('') else: raise Exception( 'local repo mode not supported: %s' % self.typeMode) layout = QVBoxLayout() self.widgetRepo = Repository( parent= self, withFile = withFile ) self.widgetRepo.active() self.repo = self.widgetRepo.wrepository layout.addWidget( self.widgetRepo ) if self.typeMode == MODE_OPEN: if self.multipleSelection: self.repo.setSelectionMode(QAbstractItemView.ExtendedSelection) # save mode if self.typeMode == MODE_SAVE: fileLayout = QHBoxLayout() fileLayout.addWidget(QLabel('File name:')) self.filenameLineEdit = QLineEdit(filename) fileLayout.addWidget( self.filenameLineEdit ) layout.addLayout(fileLayout) # Buttons self.cancelButton = QPushButton("Cancel") buttonLayout = QHBoxLayout() buttonLayout.addStretch() buttonLayout.addWidget(self.acceptButton) buttonLayout.addWidget(self.cancelButton) layout.addWidget( self.warningLabel ) layout.addLayout(buttonLayout) # set the layout self.setLayout(layout)
def __init__(self): self.techniquesClass = { 'caesar cipher': caesarCipher, 'mono alphabetic cipher': monoAlphabeticCipher, 'vigenere cipher': vigenereCipher, 'vernan cipher': vernanCipher, 'one time pad': oneTimePad } self.rowsview = [] self.filesview = [] self.techniques = [] QDialog.__init__(self) self.setWindowTitle("CryptoSystems") self.resize(1024, 600) self.setMinimumSize(QSize(1024, 600)) self.setMaximumSize(QSize(1024, 600)) self.checkBox_2 = QCheckBox(self) self.checkBox_2.setGeometry(QRect(620, 10, 130, 20)) self.checkBox_2.setText('Select All') self.checkBox_2.clicked.connect(self.__selectAllFiles) self.treeView = QTreeView(self) self.treeView.setGeometry(QRect(10, 10, 230, 580)) self.treeView.setObjectName("treeView") self.fileSystemModel = QFileSystemModel(self.treeView) self.fileSystemModel.setReadOnly(False) self.fileSystemModel.setFilter(QDir.AllDirs | QDir.NoDotAndDotDot) root = self.fileSystemModel.setRootPath("/") self.treeView.setModel(self.fileSystemModel) self.treeView.setRootIndex(root) self.treeView.hideColumn(1) self.treeView.hideColumn(2) self.treeView.hideColumn(3) self.treeView.clicked.connect(self.__eventDirectoryChanged) self.mygroupbox = QGroupBox(self) self.mygroupbox.setGeometry(QRect(0, 0, 1000, 1000)) self.myform = QFormLayout() for j in list(range(100)): horizontalLayout = QHBoxLayout() self.myform.addRow(horizontalLayout) self.rowsview.append(horizontalLayout) self.mygroupbox.setLayout(self.myform) scroll = QScrollArea(self) scroll.setWidget(self.mygroupbox) scroll.setWidgetResizable(True) scroll.setGeometry(QRect(250, 30, 500, 580)) scroll.setWidgetResizable(True) self.label_4 = QLabel(self) self.label_4.setGeometry(QRect(780, 30, 31, 16)) self.label_4.setPixmap(QPixmap("images/key.png")) self.label_4.setScaledContents(True) self.lineEdit = QLineEdit(self) self.lineEdit.setGeometry(QRect(820, 30, 180, 20)) self.lineEdit.setObjectName("lineEdit") self.lineEdit.setPlaceholderText(_fromUtf8('write your password')) self.lineEdit.setEchoMode(QLineEdit.Password) self.techniquesGroup = QGroupBox(self) self.tecniquesform = QFormLayout() self.techniquesGroup.setLayout(self.tecniquesform) self.techniquesScroll = QScrollArea(self) self.techniquesScroll.setGeometry(QRect(770, 100, 230, 300)) self.techniquesScroll.setWidget(self.techniquesGroup) self.techniquesScroll.setWidgetResizable(True) self.rowsTechiques = [] for i in list(range(8)): horizontalLayout = QHBoxLayout() self.tecniquesform.addRow(horizontalLayout) self.rowsTechiques.append(horizontalLayout) techniquesCombo = QComboBox() techniquesCombo.setGeometry(QRect(10, 50, 171, 22)) techniquesCombo.addItems(self.techniquesClass.keys()) self.techniques.append(techniquesCombo) self.rowsTechiques[0].addWidget(techniquesCombo) self.techniquesNumber = 1 self.addTechnique = QPushButton() self.addTechnique.setGeometry(QRect(90, 90, 31, 21)) self.addTechnique.setFixedSize(31, 21) self.addTechnique.setText('+') self.connect(self.addTechnique, SIGNAL("clicked()"), self.__eventAddTechnique) self.rowsTechiques[len(self.rowsTechiques) - 1].addWidget( self.addTechnique) self.okButton = QPushButton(self) self.okButton.setGeometry(QRect(920, 560, 80, 20)) self.okButton.setText('Start...') self.connect(self.okButton, SIGNAL("clicked()"), self.__eventInitEncryption)
def main(): """Main function""" app = QApplication([]) def validate_min_max(parent_container): """ :param parent_container: The container that use this validator. :type parent_container: ParameterContainer :return: """ min_value_parameter = parent_container.get_parameter_by_guid( min_integer_parameter.guid) max_value_parameter = parent_container.get_parameter_by_guid( max_integer_parameter.guid) min_value = min_value_parameter.value max_value = max_value_parameter.value print 'min', min_value print 'max', max_value if min_value > max_value: print 'Not valid' return { 'valid': False, 'message': ('Your minimum value (%d) should be less than your maximum ' 'value (%d)' % (min_value, max_value)) } print 'Valid' return {'valid': True, 'message': ''} unit_feet = Unit('130790') unit_feet.load_dictionary(unit_feet_depth) unit_metres = Unit('900713') unit_metres.load_dictionary(unit_metres_depth) string_parameter = StringParameter('28082014') string_parameter.name = 'Province Name' string_parameter.description = 'Name of province.' string_parameter.help_text = ( 'A <b>test help</b> that is very long so that you need to ' 'read it for one minute and you will be tired after read this ' 'description. You are the best user so far. Even better if you read ' 'this description loudly so that all of your friends will be able ' 'to hear you') string_parameter.is_required = True string_parameter.value = 'Daerah Istimewa Yogyakarta' boolean_parameter = BooleanParameter('1231231') boolean_parameter.name = 'Post processor' boolean_parameter.description = 'This is post processor parameter.' boolean_parameter.help_text = ( 'A <b>test help text</b> that is very long so that you need to ' 'read it for one minute and you will be tired after read this ' 'description. You are the best user so far. Even better if you read ' 'this description loudly so that all of your friends will be able ' 'to hear you') boolean_parameter.is_required = True boolean_parameter.value = True float_parameter = FloatParameter() float_parameter.name = 'Flood Depth' float_parameter.is_required = True float_parameter.precision = 3 float_parameter.minimum_allowed_value = 1.0 float_parameter.maximum_allowed_value = 2.0 float_parameter.description = 'The depth of flood.' float_parameter.help_text = ( 'A <b>test _description</b> that is very long so that you need to ' 'read it for one minute and you will be tired after read this ' 'description. You are the best user so far. Even better if you read ' 'this description loudly so that all of your friends will be able ' 'to hear you') float_parameter.unit = unit_feet float_parameter.allowed_units = [unit_metres, unit_feet] float_parameter.value = 1.12 integer_parameter = IntegerParameter() integer_parameter.name = 'Paper' integer_parameter.is_required = True integer_parameter.minimum_allowed_value = 1 integer_parameter.maximum_allowed_value = 5 integer_parameter.description = 'Number of paper' integer_parameter.help_text = ( 'A <b>test _description</b> that is very long so that you need to ' 'read it for one minute and you will be tired after read this ' 'description. You are the best user so far. Even better if you read ' 'this description loudly so that all of your friends will be able ' 'to hear you') integer_parameter.unit = unit_feet integer_parameter.allowed_units = [unit_feet] integer_parameter.value = 3 point_parameter = PointParameter() point_parameter.name = 'Point Parameter' point_parameter.is_required = True point_parameter.description = 'Short help.' point_parameter.help_text = 'Long description for parameter.' point_parameter.value = (0, 1) min_integer_parameter = IntegerParameter() min_integer_parameter.name = 'Minimal Stick Length' min_integer_parameter.is_required = True min_integer_parameter.minimum_allowed_value = 1 min_integer_parameter.maximum_allowed_value = 50 min_integer_parameter.description = 'Minimum length of a stick' min_integer_parameter.help_text = ( 'Minimum length of a stick that are allowed') min_integer_parameter.unit = unit_metres min_integer_parameter.allowed_units = [unit_metres] min_integer_parameter.value = 3 max_integer_parameter = IntegerParameter() max_integer_parameter.name = 'Maximum Stick Length' max_integer_parameter.is_required = True max_integer_parameter.minimum_allowed_value = 1 max_integer_parameter.maximum_allowed_value = 50 max_integer_parameter.description = 'Maximum length of a stick' max_integer_parameter.help_text = ( 'Maximum length of a stick that are allowed') max_integer_parameter.unit = unit_metres max_integer_parameter.allowed_units = [unit_metres] max_integer_parameter.value = 4 list_parameter = ListParameter() list_parameter.name = 'Affected Field' list_parameter.is_required = True list_parameter.maximum_item_count = 3 list_parameter.minimum_item_count = 1 list_parameter.description = 'Column used for affected field' list_parameter.help_text = 'Column used for affected field in the vector' list_parameter.element_type = str list_parameter.options_list = [ 'FLOODPRONE', 'affected', 'floodprone', 'yes/no', '\xddounicode test' ] list_parameter.value = ['FLOODPRONE', 'affected', 'floodprone'] select_parameter = SelectParameter() select_parameter.name = 'Select Affected Field' select_parameter.is_required = True select_parameter.description = 'Column used for affected field' select_parameter.help_text = ( 'Column used for affected field in the vector') select_parameter.element_type = str select_parameter.options_list = [ 'FLOODPRONE', 'affected', 'floodprone', 'yes/no', '\xddounicode test' ] select_parameter.value = 'affected' input_list_parameter = InputListParameter() input_list_parameter.name = 'Thresholds' input_list_parameter.is_required = True input_list_parameter.maximum_item_count = 3 input_list_parameter.minimum_item_count = 1 input_list_parameter.description = 'Specified List of thresholds' input_list_parameter.help_text = 'Some help text' input_list_parameter.element_type = int input_list_parameter.ordering = InputListParameter.DescendingOrder input_list_parameter.value = [1] dict_parameter = DictParameter() dict_parameter.name = 'Dict Parameter' dict_parameter.is_required = True dict_parameter.maximum_item_count = 5 dict_parameter.minimum_item_count = 1 dict_parameter.description = 'Dict Parameter example' dict_parameter.help_text = 'Dict Parameter help text.' dict_parameter.element_type = str dict_parameter.value = { 'foo': 'True', 'bar': '10', 'woo': 'False', 'sub_dict_sample': { 'key1': 'val1', 'key2': 'val2' } } group_parameter = GroupParameter() group_parameter.name = 'Age ratios' group_parameter.is_required = True group_parameter.value = [ string_parameter, integer_parameter, boolean_parameter ] def _custom_validator(value): valid = True if string_parameter.value == 'foo' and integer_parameter.value == \ 3 and boolean_parameter.value is True: valid = False if not valid: raise Exception('Parameter not valid') group_parameter.custom_validator = _custom_validator parameters = [ string_parameter, integer_parameter, boolean_parameter, float_parameter, float_parameter, boolean_parameter, integer_parameter, point_parameter, list_parameter, input_list_parameter, dict_parameter, group_parameter, select_parameter ] extra_parameters = [(PointParameter, PointParameterWidget)] min_max_parameters = [min_integer_parameter, max_integer_parameter] description_text = ( 'These parameters are merely created for showing example only') # description_text = '' parameter_container = ParameterContainer(parameters, extra_parameters=extra_parameters, description_text=description_text) parameter_container.setup_ui() # create error handler parameter_widget = parameter_container.get_parameter_widgets() try: input_list_widget = [ w.widget() for w in parameter_widget if isinstance(w.widget(), InputListParameterWidget) ][0] def add_row_handler(exception): box = QMessageBox() box.critical(input_list_widget, 'Add Row Error', exception.message) input_list_widget.add_row_error_handler = add_row_handler except IndexError: pass parameter_container2 = ParameterContainer( extra_parameters=extra_parameters, description_text='Empty Parameter Container Description') parameter_container2.setup_ui() parameter_container3 = ParameterContainer( parameters=min_max_parameters, extra_parameters=extra_parameters, description_text='Minimum Maximum Parameter') parameter_container3.add_validator(validate_min_max) parameter_container3.setup_ui() def show_error_message(parent, exception): """Generate error message to handle parameter errors :param parent: The widget as a parent of message box :type parent: QWidget :param exception: python Exception or Error :type exception: Exception """ box = QMessageBox() box.critical(parent, 'Error occured', exception.message) def show_parameter(the_parameter_container): """Print the value of parameter. :param the_parameter_container: A parameter container :type the_parameter_container: ParameterContainer """ def show_parameter_value(a_parameter): if isinstance(a_parameter, GroupParameter): for param in a_parameter.value: show_parameter_value(param) else: print a_parameter.guid, a_parameter.name, a_parameter.value try: the_parameters = the_parameter_container.get_parameters() if the_parameters: for parameter in the_parameters: show_parameter_value(parameter) except Exception as inst: show_error_message(parameter_container, inst) button = QPushButton('Show parameters') # noinspection PyUnresolvedReferences button.clicked.connect( partial(show_parameter, the_parameter_container=parameter_container)) validate_button = QPushButton('Validate parameters') # noinspection PyUnresolvedReferences validate_button.clicked.connect( partial(show_parameter, the_parameter_container=parameter_container3)) widget = QWidget() layout = QGridLayout() layout.addWidget(parameter_container) layout.addWidget(button) layout.addWidget(parameter_container2) layout.addWidget(parameter_container3) layout.addWidget(validate_button) widget.setLayout(layout) widget.setGeometry(0, 0, 500, 500) widget.show() sys.exit(app.exec_())
def __init__(self, parent=None): QDialog.__init__(self, parent) self.setObjectName("ui_SubProjectMngForm") self.resize(200, 200) font = QFont() font.setFamily("Arial") font.setBold(False) font.setWeight(50) self.setFont(font) self.vlForm = QVBoxLayout(self) self.vlForm.setObjectName("vl_ProjectMngForm") self.vlForm.setSpacing(9) self.vlForm.setMargin(9) self.setWindowTitle("SubProject Manage Dialog") self.basicFrame = Frame(self) self.vlForm.addWidget(self.basicFrame) self.frameName = Frame(self.basicFrame, "HL") self.basicFrame.Add = self.frameName self.frame = Frame(self.frameName) self.frameName.Add = self.frame self.comboProjectSubproject = ComboBoxPanel(self.frame) self.comboProjectSubproject.Caption = "Project" self.comboProjectSubproject.LabelWidth = 120 self.frame.Add = self.comboProjectSubproject self.textNameSubproject = TextBoxPanel(self.frame) self.textNameSubproject.Caption = "Sub-Project Name" self.textNameSubproject.LabelWidth = 120 self.textNameSubproject.Width = 120 self.frame.Add = self.textNameSubproject self.textFullName = TextBoxPanel(self.frame) self.textFullName.Caption = "Full Name" self.textFullName.LabelWidth = 120 self.textFullName.Width = 120 self.textFullName.Visible = False self.frame.Add = self.textFullName self.groubox = GroupBox(self.frameName) self.groubox.Caption = "Sub-Projects" self.frameName.Add = self.groubox self.listBoxSubproject = ListBox(self.groubox) self.groubox.Add = self.listBoxSubproject self.textPathSubproject = TextBoxPanel(self.basicFrame) self.textPathSubproject.Caption = "Sub-Project Path" self.textPathSubproject.imageButton.setIcon(QIcon()) self.textPathSubproject.Button = "opens.png" self.textPathSubproject.LabelWidth = 120 self.textPathSubproject.textBox.setMaximumWidth(10000) self.textPathSubproject.textBox.setMinimumWidth(100) self.basicFrame.Add = self.textPathSubproject self.btnFrame = Frame(self.basicFrame, "HL") self.basicFrame.Add = self.btnFrame self.buttonAddSubproject = QPushButton(self.btnFrame) self.buttonAddSubproject.setObjectName("buttonAddSubproject") self.buttonAddSubproject.setText("Add") self.btnFrame.Add = self.buttonAddSubproject self.buttonModifySubproject = QPushButton(self.btnFrame) self.buttonModifySubproject.setObjectName("buttonModifySubproject") self.buttonModifySubproject.setText("Modify") self.btnFrame.Add = self.buttonModifySubproject self.buttonDeleteSubproject = QPushButton(self.btnFrame) self.buttonDeleteSubproject.setObjectName("buttonDeleteSubproject") self.buttonDeleteSubproject.setText("Delete") self.btnFrame.Add = self.buttonDeleteSubproject self.buttonCloseSubproject = QPushButton(self.btnFrame) self.buttonCloseSubproject.setObjectName("buttonCloseSubproject") self.buttonCloseSubproject.setText("Close") self.btnFrame.Add = self.buttonCloseSubproject self.connect(self.listBoxSubproject, SIGNAL("Event_0"), self.listBoxSubproject_SelectedIndexChanged) self.connect(self.textPathSubproject, SIGNAL("Event_1"), self.buttonBrowseSubproject_Click) self.connect(self.textNameSubproject, SIGNAL("Event_0"), self.setFullName) self.connect(self.comboProjectSubproject, SIGNAL("Event_0"), self.setFullNameProjectNameChanged) self.buttonCloseSubproject.clicked.connect( self.buttonCloseSubproject_Click) self.buttonDeleteSubproject.clicked.connect( self.buttonDeleteSubproject_Click) self.buttonModifySubproject.clicked.connect( self.buttonModifySubproject_Click) self.buttonAddSubproject.clicked.connect( self.buttonAddSubproject_Click) self.editFlag = True for pi in AirCraftOperation.g_projectList.ProjectsList: if pi.Pt == enumProjectType.ptSubProject: self.listBoxSubproject.Add(pi.Name) elif pi.Pt == enumProjectType.ptProject: self.comboProjectSubproject.Add(pi.Name) self.editFlag = False self.setFullNameProjectNameChanged()
def __init__(self, parent=None, iface=None, dock=None): """Constructor for the dialog. :param parent: Widget to use as parent. :type parent: PyQt4.QtGui.QWidget :param iface: A QGisAppInterface instance we use to access QGIS via. :type iface: QgsAppInterface :param dock: A Dock widget needed to run the scenarios with. On our road map is to figure out how to get rid of this parameter. :type dock: Dock """ QDialog.__init__(self, parent) self.setupUi(self) self.setWindowModality(Qt.ApplicationModal) self.iface = iface self.dock = dock self.legend = iface.legendInterface() header_view = self.table.horizontalHeader() header_view.setResizeMode(0, QtGui.QHeaderView.Stretch) header_view.setResizeMode(1, QtGui.QHeaderView.Interactive) self.table.setColumnWidth(0, 200) self.table.setColumnWidth(1, 125) # select the whole row instead of one cell self.table.setSelectionBehavior(QAbstractItemView.SelectRows) # initiate layer group creation self.root = QgsProject.instance().layerTreeRoot() # container for all layer group self.layer_group_container = [] # preventing error if the user delete the directory self.default_directory = temp_dir() if not os.path.exists(self.source_directory.text()): self.source_directory.setText(self.default_directory) if not os.path.exists(self.output_directory.text()): self.output_directory.setText(self.default_directory) self.populate_table(self.source_directory.text()) # Setting this to False will suppress the popup of the results table self.show_results_popup = True # connect signal to slot # noinspection PyUnresolvedReferences self.output_directory.textChanged.connect(self.save_state) # noinspection PyUnresolvedReferences self.source_directory.textChanged.connect(self.save_state) # noinspection PyUnresolvedReferences self.source_directory.textChanged.connect(self.populate_table) # noinspection PyUnresolvedReferences self.source_directory.textChanged.connect( self.update_default_output_dir) # Setup run all button in button box self.run_all_button = QPushButton('Run all') self.run_all_button.clicked.connect(self.run_all_clicked) self.button_box.addButton( self.run_all_button, QDialogButtonBox.ActionRole) # Setup run selected button in button box self.run_selected_button = QPushButton('Run selected') self.run_selected_button.clicked.connect(self.run_selected_clicked) self.button_box.addButton( self.run_selected_button, QDialogButtonBox.ActionRole) # Set up new project settings self.start_in_new_project = False # Set up context help self.help_button = self.button_box.button(QtGui.QDialogButtonBox.Help) # Allow toggling the help button self.help_button.setCheckable(True) self.help_button.toggled.connect(self.help_toggled) self.main_stacked_widget.setCurrentIndex(1) self.restore_state()
def transaction_dialog(self, d): self.wallet = d.wallet self.verify_button = b = QPushButton(self.button_label) b.clicked.connect(lambda: self.do_verify(d.tx)) d.buttons.insert(0, b) self.transaction_dialog_update(d)
import signal import sys #from PyMata.pymata import PyMata from PyQt4.QtGui import QApplication, QMainWindow, QPushButton, QVBoxLayout, QWidget, QTextEdit app = QApplication([]) button_convert = QPushButton("Convert order") mainwindow = QMainWindow() mainwindow.resize(230, 400) mainwindow.setWindowTitle("Puuri abi") vbox = QVBoxLayout() vbox.addStretch(1) textedit = QTextEdit("First part") textedit2 = QTextEdit("Second part") textedit3 = QTextEdit(" ") vbox.addWidget(textedit) vbox.addWidget(textedit2) vbox.addWidget(textedit3) vbox.addWidget(button_convert) container = QWidget() container.setLayout(vbox) mainwindow.setCentralWidget(container) mainwindow.show() def convert_handler(): value = textedit2.toPlainText() #print(value)
def create_account_dialog(self): def coinapult_signup(): try: self.client.createAccount(createLocalKeys=True, changeAuthMethod=True, tag="electrum-gfk36") self.client.activateAccount(agree=True) except (CoinapultError, CoinapultErrorECC) as ce: QMessageBox.warning(None, _("Unable to create Coinapult account because %s" % str(ce), QString(_("OK")))) def signup_done(result): self.ca_ok_button.setDisabled(False) self.wallet.storage.put("coinapult_ecc_public", str(self.client.ecc_pub_pem)) self.ecc_pub_key_edit.setText(self.client.ecc_pub_pem) self.wallet.storage.put("coinapult_ecc_private", str(self.client.ecc['privkey'].to_pem())) self.ecc_priv_key_edit.setText(str(self.client.ecc['privkey'].to_pem())) self.config.set_key('coinapult_auth_method', 'ECC', True) ecc_pub = self.wallet.storage.get("coinapult_ecc_public", '') ecc_priv = self.wallet.storage.get("coinapult_ecc_private", '') try: self.client = CoinapultClient(ecc={'pubkey': ecc_pub, 'privkey': ecc_priv}, authmethod='ecc') except (CoinapultError, CoinapultErrorECC): self.client = None QMessageBox.warning(None, _('Coinapult Connection failed'), _('Failed to connect to Coinapult. Locks disabled for this session.'), _('OK')) d.accept() def on_change_tos(checked): if checked: self.config.set_key('plugin_coinapult_locks_tos', 'checked') else: self.config.set_key('plugin_coinapult_locks_tos', 'unchecked') def ok_clicked(): if self.agreed_tos(): self.ca_ok_button.setDisabled(True) self.waiting_dialog = WaitingDialog(d, 'Creating your Coinapult account. One moment please...', coinapult_signup, signup_done) self.waiting_dialog.start() d = QDialog() d.setWindowTitle("Create Coinapult Account") layout = QGridLayout(d) # lable = None text_edit = QPlainTextEdit() text = open(os.path.dirname(__file__) + '/lib/TERMS.txt').read() text_edit.setPlainText(text) layout.addWidget(text_edit, 0, 0) layout.setRowStretch(0, 8) layout.addWidget(QLabel(_("Do you agree to Coinapult's Terms of Service (https://coinapult.com/terms)?: ")), 3, 0) tos_checkbox = QCheckBox() tos_checkbox.setEnabled(True) tos_checkbox.setChecked(self.config.get('plugin_coinapult_locks_tos', 'unchecked') != 'unchecked') tos_checkbox.stateChanged.connect(on_change_tos) layout.addWidget(tos_checkbox, 3, 1) layout.addWidget( QLabel(_("<font color='red'>This will overwrite any Coinapult API keys in your wallet.<br>" "If you do not have backups of your API keys, this will lock you out of your " # TODO This isn't actually stored in the wallet yet... "account!</font>")), 4, 0) self.ca_ok_button = QPushButton(_("OK")) self.ca_ok_button.clicked.connect(ok_clicked) layout.addWidget(self.ca_ok_button, 5, 1) if d.exec_(): return True else: return False
def _init_gui(self): # Setup base elements self.gridLayout = QGridLayout(self) self.gridLayout.setObjectName('glMain') self.gridLayout.addLayout( self.vlNotification, 0, 0, 1, 1 ) QApplication.processEvents() column_widget_area = self._setup_columns_content_area() self.gridLayout.addWidget( column_widget_area, 1, 0, 1, 1 ) QApplication.processEvents() # Add notification for mandatory columns if applicable next_row = 2 if self.has_mandatory: self.required_fields_lbl = QLabel(self) msg = self.tr( 'Please fill out all required (*) fields.' ) msg = self._highlight_asterisk(msg) self.required_fields_lbl.setText(msg) self.gridLayout.addWidget( self.required_fields_lbl, next_row, 0, 1, 2 ) # Bump up row reference next_row += 1 self.buttonBox = QDialogButtonBox(self) self.buttonBox.setObjectName('buttonBox') self.gridLayout.addWidget( self.buttonBox, next_row, 0, 1, 1 ) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons( QDialogButtonBox.Cancel|QDialogButtonBox.Save ) if self.edit_model is None: if not self.collect_model: self.save_new_button = QPushButton( QApplication.translate( 'EntityEditorDialog', 'Save and New' ) ) self.buttonBox.addButton( self.save_new_button, QDialogButtonBox.ActionRole ) # edit model, collect model # adding new record for child # Saving in parent editor if not isinstance(self._parent._parent, EntityEditorDialog): # adding a new record if self.edit_model is None: # saving when digitizing. if self.collect_model: self.buttonBox.accepted.connect(self.on_model_added) # saving parent editor else: self.buttonBox.accepted.connect(self.save_parent_editor) self.save_new_button.clicked.connect(self.save_and_new) # updating existing record else: if not self.collect_model: # updating existing record of the parent editor self.buttonBox.accepted.connect(self.save_parent_editor) # Saving in child editor else: # save and new record if self.edit_model is None: self.buttonBox.accepted.connect(self.on_child_saved) self.save_new_button.clicked.connect( lambda: self.on_child_saved(True) ) else: # When updating an existing child editor save to the db self.buttonBox.accepted.connect( self.on_child_saved ) #self.buttonBox.accepted.connect(self.submit) self.buttonBox.rejected.connect(self.cancel)
def settings_dialog(self): def check_for_api_key(api_key): if api_key and len(api_key) > 12: self.config.set_key("plugin_coinapult_locks_api_key", str(api_key)) def check_for_api_secret(api_secret): if api_secret and len(api_secret) > 12: self.config.set_key("plugin_coinapult_locks_api_secret", str(api_secret)) def check_for_ecc_pub_key(pub_key): if pub_key and len(pub_key) > 12: self.wallet.storage.put("coinapult_ecc_public", str(pub_key)) def check_for_ecc_priv_key(priv_key): if priv_key and len(priv_key) > 12: self.wallet.storage.put("coinapult_ecc_private", str(priv_key)) def ok_clicked(): # check_for_api_key(self.api_key_edit.text()) # check_for_api_secret(self.api_secret_edit.text()) check_for_ecc_pub_key(self.ecc_pub_key_edit.toPlainText()) check_for_ecc_priv_key(self.ecc_priv_key_edit.toPlainText()) if self.agreed_tos(): d.accept() else: self.disable() return False def on_change_auth_method(method): if method == 'REST': self.config.set_key('coinapult_auth_method', 'REST', True) else: self.config.set_key('coinapult_auth_method', 'ECC', True) d = QDialog() d.setMaximumWidth(600) d.setWindowTitle("Settings") layout = QGridLayout(d) layout.setColumnMinimumWidth(1, 200) layout.setHorizontalSpacing(20) about_locks_label = QLabel(ABOUT_LOCKS) about_locks_label.setWordWrap(True) about_locks_label.setOpenExternalLinks(True) layout.addWidget(about_locks_label, 0, 1, 5, 1, Qt.AlignRight) create_account_label = QLabel(_("If you wish to use Locks, and do not already have an account, " "click here to generate your ECC keys:")) create_account_label.setWordWrap(True) create_account_label.setOpenExternalLinks(True) layout.addWidget(create_account_label, 0, 0) create_account_button = QPushButton(_('Create Account')) create_account_button.setMaximumWidth(120) create_account_button.clicked.connect(self.create_account_dialog) layout.addWidget(create_account_button, 1, 0, Qt.AlignTop) warning_label = QLabel(_("If you already have a Coinapult account, simply paste your ECC credentials below." "<br><br>" "<font color='red'>WARNING Back up the keys below somewhere safe! If you overwrite " "them here, you could lose access to your Coinapult account.</font><br><br>" "ECC public key")) warning_label.setWordWrap(True) layout.addWidget(warning_label, 3, 0, Qt.AlignBottom) self.ecc_pub_key_edit = QTextEdit(self.wallet.storage.get("coinapult_ecc_public", '')) # self.ecc_pub_key_edit.textChanged.connect(check_for_ecc_pub_key) layout.addWidget(self.ecc_pub_key_edit, 4, 0, Qt.AlignTop) # layout.setRowStretch(2, 3) layout.addWidget(QLabel(_('ECC private key')), 5, 0, Qt.AlignBottom) self.ecc_priv_key_edit = QTextEdit("hidden") # self.ecc_priv_key_edit.textChanged.connect(check_for_ecc_priv_key) layout.addWidget(self.ecc_priv_key_edit, 6, 0, Qt.AlignTop) # layout.setRowStretch(2, 3) ## Rest Layout # layout.addWidget(QLabel(_('Coinapult API key: ')), 0, 0) # self.api_key_edit = QLineEdit(self.api_key()) # self.api_key_edit.textChanged.connect(check_for_api_key) # layout.addWidget(self.api_key_edit, 0, 1, 1, 2) # # layout.addWidget(QLabel(_('Coinapult API secret: ')), 1, 0) # self.api_secret_edit = QLineEdit("hidden") # self.api_key_edit.textChanged.connect(check_for_api_secret) # layout.addWidget(self.api_secret_edit, 1, 1, 1, 2) ok_button = QPushButton(_("OK")) ok_button.setMaximumWidth(50) ok_button.clicked.connect(lambda: ok_clicked()) layout.addWidget(ok_button, 7, 0) if d.exec_(): return True else: return False
def create_locks_tab(self): self.specify_by_currency = QComboBox() def on_change_currency(currency): if currency != self.Locks_currency: self.Locks_currency = LOCKS_CURRENCIES[currency] self.specify_by_currency.clear() otheri = 0 if self.specify_by_currency.findText('BTC') > 0 else 1 self.specify_by_currency.removeItem(otheri) self.specify_by_currency.addItem(str(LOCKS_CURRENCIES[currency])) self.specify_by_currency.addItem('BTC') self.specify_by_currency.setMaximumWidth(60) def on_btc_amount_change(amount): if amount != self.Locks_amount: self.Locks_amount = amount def on_change_action(act): action = LOCK_ACTIONS[act] if action != self.Locks_action: self.Locks_action = action def get_quote(): specifiedCurrency = self.specify_by_currency.currentText() def get_lock(): if specifiedCurrency == 'BTC': amount = float(self.Locks_amount) outAmount = 0 else: amount = 0 outAmount = float(self.Locks_amount) try: lock = self.client.lock(amount=amount, outAmount=outAmount, currency=self.Locks_currency) # print json.dumps(lock, indent=4) pending_locks = self.config.get('pending_locks', []) pending_locks.append(lock) self.config.set_key('pending_locks', pending_locks, True) return lock except (CoinapultError, CoinapultErrorECC) as ce: QMessageBox.warning(None, _('Lock Failed'), _('Lock action failed due to reason: %s') % ce, _('OK')) def get_unlock(): if specifiedCurrency == 'BTC': amount = 0 outAmount = float(self.Locks_amount) else: amount = float(self.Locks_amount) outAmount = 0 for addr in self.wallet.addresses(): u, used = self.wallet.is_used(addr) if not used and u == 0: self.unlock_address = addr break try: unlock = self.client.unlock(amount=amount, outAmount=outAmount, currency=str(self.Locks_currency), address=str(self.unlock_address)) # print json.dumps(unlock, indent=4) pending_unlocks = self.config.get('pending_unlocks', []) pending_unlocks.append(unlock) self.config.set_key('pending_unlocks', pending_unlocks, True) return unlock except (CoinapultError, CoinapultErrorECC) as ce: QMessageBox.warning(None, _('Unlock Failed'), _('Unlock action failed due to reason: %s') % ce, _('OK')) self.quote_button.setDisabled(True) if self.Locks_action == 'Lock': self.waiting_dialog = WaitingDialog(w, 'Requesting Lock Quote', get_lock, self.lock_confirm_dialog) self.waiting_dialog.start() else: self.waiting_dialog = WaitingDialog(w, 'Requesting Unlock Quote', get_unlock, self.unlock_confirm_dialog) self.waiting_dialog.start() w = QWidget() self.tabLayout = QGridLayout(w) self.tabLayout.setColumnMinimumWidth(3, 400) self.tabLayout.setColumnStretch(0, 5) self.tabLayout.setHorizontalSpacing(10) about_locks_label = QLabel(ABOUT_LOCKS) about_locks_label.setWordWrap(True) about_locks_label.setOpenExternalLinks(True) self.tabLayout.addWidget(about_locks_label, 0, 2, 2, 3, Qt.AlignTop) self.balsLayout = QGridLayout(w) self.balsLayout.setColumnMinimumWidth(35, 400) self.balsLayout.setHorizontalSpacing(10) # self.balsLayout.setFrameStyle(QFrame.VLine) row = 0 balw = QLabel(_("<font size='5' style='bold'>Current Locks Balances</font>")) # balw.setBackgroundRole(QPalette_ColorRole=QPalette_ColorRole) balw.setBackgroundRole(QPalette.Midlight) balw.setAutoFillBackground(True) balw.setMinimumWidth(250) self.balsLayout.addWidget(balw, row, 0) row += 1 for cur in LOCKS_CURRENCIES: if cur == 'XAU': disp_cur = "Gold oz" elif cur == 'XAG': disp_cur = "Silver oz" else: disp_cur = cur curw = QLabel(_("<font size='5'>- %s</font>" % disp_cur)) curw.setBackgroundRole(QPalette.Light) curw.setAutoFillBackground(True) curw.setMinimumWidth(250) self.balsLayout.addWidget(curw, row, 0) row += 1 self.tabLayout.addLayout(self.balsLayout, 0, 0, 2, 3, Qt.AlignTop) # self.tabLayout.addWidget(QLabel(_('Estimated Total BTC Value')), row, 0) # self.tabLayout.addWidget(QLabel(_('- BTC')), row, 1) # row += 1 self.tabLayout.addWidget(QLabel(_('What do you want to do?')), 2, 0, Qt.AlignBottom) # row += 1 self.tabLayout.addWidget(QLabel(_('Which Locks asset?')), 2, 1, Qt.AlignBottom) # row += 1 # row += 1 self.tabLayout.addWidget(QLabel(_('Amount')), 2, 2, 1, 2, Qt.AlignBottom) # self.tabLayout.addWidget(QLabel(_('')), row, 0) # self.tabLayout.addWidget(QLabel(_('How much of which?')), 2, 3, Qt.AlignBottom) row += 1 combo_action = QComboBox() combo_action.currentIndexChanged.connect(on_change_action) combo_action.addItems(LOCK_ACTIONS) combo_action.setMaximumWidth(100) self.tabLayout.addWidget(combo_action, 3, 0, Qt.AlignTop) combo_currency = QComboBox() combo_currency.currentIndexChanged.connect(on_change_currency) combo_currency.addItems(LOCKS_CURRENCIES) combo_currency.setMaximumWidth(60) self.tabLayout.addWidget(combo_currency, 3, 1, Qt.AlignTop) btc_amount_edit = QLineEdit('0') btc_amount_edit.textChanged.connect(on_btc_amount_change) btc_amount_edit.setMaximumWidth(100) self.tabLayout.addWidget(btc_amount_edit, 3, 2, Qt.AlignRight) # self.specify_by_currency.currentIndexChanged.connect(on_change_specify_currency) self.specify_by_currency.addItems(['']) self.specify_by_currency.setMaximumWidth(60) self.tabLayout.addWidget(self.specify_by_currency, 3, 3, Qt.AlignLeft) # row += 1 self.quote_button = QPushButton(_('Get Quote')) self.quote_button.clicked.connect(get_quote) self.quote_button.setMaximumWidth(100) self.tabLayout.addWidget(self.quote_button, 5, 0, Qt.AlignBottom) return w
def __init__(self, *args): PluginBase.__init__(self, BrickletBarometer, *args) self.barometer = self.device has_calibrate = self.firmware_version == (1, 0, 0) has_averaging = self.firmware_version >= (2, 0, 1) self.moving_average_pressure = 25 self.average_pressure = 10 self.average_temperature = 10 self.cbe_air_pressure = CallbackEmulator( self.barometer.get_air_pressure, self.cb_air_pressure, self.increase_error_count) self.cbe_altitude = CallbackEmulator(self.barometer.get_altitude, self.cb_altitude, self.increase_error_count) self.air_pressure_label = AirPressureLabel() self.altitude_label = AltitudeLabel() self.chip_temperature_label = ChipTemperatureLabel() if has_calibrate: self.chip_temperature_label.setAlignment(Qt.AlignCenter) self.current_air_pressure = None self.current_altitude = None plot_list = [['', Qt.red, self.get_current_air_pressure]] self.air_pressure_plot_widget = PlotWidget('Air Pressure [mbar]', plot_list) plot_list = [['', Qt.darkGreen, self.get_current_altitude]] self.altitude_plot_widget = PlotWidget('Altitude [m]', plot_list) if has_calibrate: self.calibrate_button = QPushButton('Calibrate Altitude') self.calibrate_button.clicked.connect(self.calibrate_clicked) else: self.get_reference_button = QPushButton('Get') self.get_reference_button.clicked.connect( self.get_reference_clicked) self.set_reference_button = QPushButton('Set') self.set_reference_button.clicked.connect( self.set_reference_clicked) self.reference_label = QLabel('Reference Air Pressure [mbar]:') self.reference_edit = QLineEdit() self.get_reference_clicked() if has_averaging: self.avg_pressure_box = QSpinBox() self.avg_pressure_box.setMinimum(0) self.avg_pressure_box.setMaximum(10) self.avg_pressure_box.setSingleStep(1) self.avg_pressure_box.setValue(10) self.avg_temperature_box = QSpinBox() self.avg_temperature_box.setMinimum(0) self.avg_temperature_box.setMaximum(255) self.avg_temperature_box.setSingleStep(1) self.avg_temperature_box.setValue(10) self.avg_moving_pressure_box = QSpinBox() self.avg_moving_pressure_box.setMinimum(0) self.avg_moving_pressure_box.setMaximum(25) self.avg_moving_pressure_box.setSingleStep(1) self.avg_moving_pressure_box.setValue(25) self.avg_pressure_box.editingFinished.connect( self.avg_pressure_box_finished) self.avg_temperature_box.editingFinished.connect( self.avg_temperature_box_finished) self.avg_moving_pressure_box.editingFinished.connect( self.avg_moving_pressure_box_finished) layout_h1 = QHBoxLayout() layout_h1.addStretch() layout_h1.addWidget(self.air_pressure_label) layout_h1.addStretch() layout_v1 = QVBoxLayout() layout_v1.addLayout(layout_h1) layout_v1.addWidget(self.air_pressure_plot_widget) layout_h2 = QHBoxLayout() layout_h2.addStretch() layout_h2.addWidget(self.altitude_label) layout_h2.addStretch() layout_v2 = QVBoxLayout() layout_v2.addLayout(layout_h2) layout_v2.addWidget(self.altitude_plot_widget) if has_calibrate: layout_h3 = QHBoxLayout() layout_h3.addWidget(self.chip_temperature_label) layout_h3.addWidget(self.calibrate_button) else: layout_h3 = QHBoxLayout() layout_h3.addWidget(self.reference_label) layout_h3.addWidget(self.reference_edit) layout_h3.addWidget(self.get_reference_button) layout_h3.addWidget(self.set_reference_button) layout_v3 = QVBoxLayout() layout_v3.addWidget(self.chip_temperature_label) layout_v3.addLayout(layout_h3) if has_averaging: line1 = QFrame() line1.setFrameShape(QFrame.VLine) line1.setFrameShadow(QFrame.Sunken) line2 = QFrame() line2.setFrameShape(QFrame.VLine) line2.setFrameShadow(QFrame.Sunken) layout_h4 = QHBoxLayout() layout_h4.addWidget(QLabel('Air Pressure Moving Average Length:')) layout_h4.addWidget(self.avg_moving_pressure_box) layout_h4.addWidget(line1) layout_h4.addWidget(QLabel('Air Pressure Average Length:')) layout_h4.addWidget(self.avg_pressure_box) layout_h4.addWidget(line2) layout_h4.addWidget(QLabel('Temperate Average Length:')) layout_h4.addWidget(self.avg_temperature_box) layout_h1 = QHBoxLayout() layout_h1.addLayout(layout_v1) layout_h1.addLayout(layout_v2) layout = QVBoxLayout(self) layout.addLayout(layout_h1) if has_calibrate: layout.addLayout(layout_h3) else: layout.addLayout(layout_v3) if has_averaging: lineh = QFrame() lineh.setFrameShape(QFrame.HLine) lineh.setFrameShadow(QFrame.Sunken) layout.addWidget(lineh) layout.addLayout(layout_h4) self.chip_temp_timer = QTimer() self.chip_temp_timer.timeout.connect(self.update_chip_temp) self.chip_temp_timer.setInterval(100)
from PyQt4.QtGui import QApplication app = QApplication(sys.argv) red = QColor(255, 0, 0) green = QColor(0, 255, 0) blue = QColor(0, 0, 255) #model = LabelListModel([Label("Label 1", red), # Label("Label 2", green), # Label("Label 3", blue)]) model = LabelListModel() l = QVBoxLayout() w = QWidget(None) w.setLayout(l) addButton = QPushButton( "Add random label\n note: \n the first added is permanent") l.addWidget(addButton) def addRandomLabel(): model.insertRow( model.rowCount(), Label( "Label {}".format(model.rowCount() + 1), QColor(numpy.random.randint(0, 255), numpy.random.randint(0, 255), numpy.random.randint(0, 255)))) addButton.clicked.connect(addRandomLabel) model.makeRowPermanent(0)
def __init__(self, parent): QDialog.__init__(self, parent) self.prm = self.parent().parent().prm self.audioManager = audioManager(self) self.currLocale = self.parent().parent().prm['currentLocale'] self.currLocale.setNumberOptions( self.currLocale.OmitGroupSeparator | self.currLocale.RejectGroupSeparator) self.isPlaying = False self.sizer = QGridLayout() self.v1Sizer = QVBoxLayout() self.wavsTableWidget = QTableWidget() self.wavsTableWidget.setColumnCount(4) self.wavsTableWidget.setSelectionBehavior(QAbstractItemView.SelectRows) self.wavsTableWidget.setSelectionMode( QAbstractItemView.ExtendedSelection) self.wavsTableWidget.setHorizontalHeaderLabels( [self.tr("File"), self.tr('Use'), self.tr("RMS Level"), 'id']) self.quidColumn = 3 self.wavsTableWidget.hideColumn(self.quidColumn) self.wavsTableWidget.cellDoubleClicked[int, int].connect( self.onCellDoubleClicked) #ADD wav BUTTON self.addWavButton = QPushButton(self.tr("Add Wav"), self) self.addWavButton.clicked.connect(self.onClickAddWavButton) #REMOVE wav BUTTON self.removeWavButton = QPushButton(self.tr("Remove Wav"), self) self.removeWavButton.clicked.connect(self.onClickRemoveWavButton) #PLAY wav BUTTON self.playWavButton = QPushButton(self.tr("Play Wav"), self) self.playWavButton.clicked.connect(self.onClickPlayWavButton) #STOP wav BUTTON self.stopWavButton = QPushButton(self.tr("Stop Playing"), self) self.stopWavButton.clicked.connect(self.onClickStopWavButton) self.v1Sizer.addWidget(self.addWavButton) self.v1Sizer.addWidget(self.removeWavButton) self.v1Sizer.addWidget(self.playWavButton) self.v1Sizer.addWidget(self.stopWavButton) self.v1Sizer.addStretch() self.wavsList = {} for i in range(len(self.parent().wavsPref['endMessageFiles'])): currCount = i + 1 thisID = self.parent().wavsPref['endMessageFilesID'][i] self.wavsList[thisID] = {} self.wavsList[thisID]['file'] = self.parent( ).wavsPref['endMessageFiles'][i] self.wavsList[thisID]['use'] = self.parent( ).wavsPref['endMessageFilesUse'][i] self.wavsList[thisID]['level'] = self.parent( ).wavsPref['endMessageLevels'][i] self.wavsTableWidget.setRowCount(currCount) n = 0 newItem = QTableWidgetItem(self.wavsList[thisID]['file']) newItem.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) self.wavsTableWidget.setItem(currCount - 1, n, newItem) n = n + 1 newItem = QTableWidgetItem(self.wavsList[thisID]['use']) newItem.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) self.wavsTableWidget.setItem(currCount - 1, n, newItem) n = n + 1 newItem = QTableWidgetItem( self.currLocale.toString(self.wavsList[thisID]['level'])) newItem.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) self.wavsTableWidget.setItem(currCount - 1, n, newItem) n = n + 1 self.wavsList[thisID]['qid'] = QTableWidgetItem(thisID) self.wavsTableWidget.setItem(currCount - 1, n, self.wavsList[thisID]['qid']) buttonBox = QDialogButtonBox(QDialogButtonBox.Apply | QDialogButtonBox.Ok | QDialogButtonBox.Cancel) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject) self.sizer.addLayout(self.v1Sizer, 0, 0) self.sizer.addWidget(self.wavsTableWidget, 0, 1) self.sizer.addWidget(buttonBox, 1, 1) self.setLayout(self.sizer) self.setWindowTitle(self.tr("Edit Wavs")) self.show()
def __init__(self, run_model, parent): QDialog.__init__(self, parent) self.setWindowFlags(Qt.Window) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) self.setModal(True) self.setWindowModality(Qt.WindowModal) self.setWindowTitle("Simulations") assert isinstance(run_model, BaseRunModel) self._run_model = run_model ert = None if isinstance(run_model, BaseRunModel): ert = run_model.ert() self.simulations_tracker = SimulationsTracker() states = self.simulations_tracker.getStates() self.state_colors = {state.name: state.color for state in states} self.state_colors['Success'] = self.state_colors["Finished"] self.state_colors['Failure'] = self.state_colors["Failed"] self.total_progress = SimpleProgress() status_layout = QHBoxLayout() status_layout.addStretch() self.__status_label = QLabel() status_layout.addWidget(self.__status_label) status_layout.addStretch() status_widget_container = QWidget() status_widget_container.setLayout(status_layout) self.progress = Progress() self.progress.setIndeterminateColor(self.total_progress.color) for state in states: self.progress.addState(state.state, QColor(*state.color), 100.0 * state.count / state.total_count) legend_layout = QHBoxLayout() self.legends = {} for state in states: self.legends[state] = Legend("%s (%d/%d)", QColor(*state.color)) self.legends[state].updateLegend(state.name, 0, 0) legend_layout.addWidget(self.legends[state]) legend_widget_container = QWidget() legend_widget_container.setLayout(legend_layout) self.running_time = QLabel("") self.plot_tool = PlotTool() self.plot_tool.setParent(None) self.plot_button = QPushButton(self.plot_tool.getName()) self.plot_button.clicked.connect(self.plot_tool.trigger) self.plot_button.setEnabled(ert is not None) self.kill_button = QPushButton("Kill simulations") self.done_button = QPushButton("Done") self.done_button.setHidden(True) self.restart_button = QPushButton("Restart") self.restart_button.setHidden(True) self.show_details_button = QPushButton("Details") self.show_details_button.setCheckable(True) size = 20 spin_movie = resourceMovie("ide/loading.gif") spin_movie.setSpeed(60) spin_movie.setScaledSize(QSize(size, size)) spin_movie.start() self.processing_animation = QLabel() self.processing_animation.setMaximumSize(QSize(size, size)) self.processing_animation.setMinimumSize(QSize(size, size)) self.processing_animation.setMovie(spin_movie) button_layout = QHBoxLayout() button_layout.addWidget(self.processing_animation) button_layout.addWidget(self.running_time) button_layout.addStretch() button_layout.addWidget(self.show_details_button) button_layout.addWidget(self.plot_button) button_layout.addWidget(self.kill_button) button_layout.addWidget(self.done_button) button_layout.addWidget(self.restart_button) button_widget_container = QWidget() button_widget_container.setLayout(button_layout) self.detailed_progress = DetailedProgressWidget( self, self.state_colors) self.detailed_progress.setVisible(False) self.dummy_widget_container = QWidget( ) #Used to keep the other widgets from stretching layout = QVBoxLayout() layout.addWidget(self.total_progress) layout.addWidget(status_widget_container) layout.addWidget(self.progress) layout.addWidget(legend_widget_container) layout.addWidget(self.detailed_progress) layout.addWidget(self.dummy_widget_container) layout.addWidget(button_widget_container) layout.setStretch(0, 0) layout.setStretch(1, 0) layout.setStretch(2, 0) layout.setStretch(3, 0) layout.setStretch(4, 1) layout.setStretch(5, 1) layout.setStretch(6, 0) self.setLayout(layout) self.kill_button.clicked.connect(self.killJobs) self.done_button.clicked.connect(self.accept) self.restart_button.clicked.connect(self.restart_failed_realizations) self.show_details_button.clicked.connect(self.toggle_detailed_progress) self.__updating = False self.__update_queued = False self.__simulation_started = False self.__update_timer = QTimer(self) self.__update_timer.setInterval(500) self.__update_timer.timeout.connect(self.updateRunStatus) self._simulations_argments = {}
def __init__(self, parent=None): super(StudentForm, self).__init__(parent) #self.setGeometry(50, 50, 820, 530) self.resize(530, 430) self.tabz = QTabWidget(self) self.tab1 = QWidget(self) self.tab2 = QWidget(self) self.tab3 = QWidget(self) self.tab4 = QWidget(self) #main form self.schno = QLabel("School Number") self.schnoData = QLineEdit() self.schnoData.setObjectName("schno") self.schnoData.setPlaceholderText("00000000") self.surname = QLabel("Surname") self.surnameData = QLineEdit() self.surnameData.setObjectName("surname") self.surnameData.setPlaceholderText("Surname") self.firstname = QLabel("Firstname") self.firstnameData = QLineEdit() self.firstnameData.setObjectName("firstname") self.firstnameData.setPlaceholderText("Firstname") self.middlename = QLabel("Middlename") self.middlenameData = QLineEdit() self.middlenameData.setObjectName("middlename") self.middlenameData.setPlaceholderText("middlename") self.soo = QLabel("State/Region of Origin") self.sooData = QLineEdit() self.sooData.setObjectName("soo") self.sooData.setPlaceholderText("Lagos") self.lga = QLabel("LGA/District") self.lgaData = QLineEdit() self.lgaData.setObjectName("lga") self.lgaData.setPlaceholderText("Ikeja") self.addr = QLabel("House Address") self.addrData = QTextEdit() self.addrData.setObjectName("addr") #self.addrData.setPlaceholderText("No. 12 Harrrison For Str., Ney York") self.dob = QLabel("Date of Birth") self.dobData = QDateEdit() self.dobData.setObjectName("dob") self.admit = QLabel("Date Admitted") self.admitData = QDateEdit() self.admitData.setObjectName("admit") self.pb = QPushButton() self.pb.setObjectName("Submit") self.pb.setText("Submit") self.pb1 = QPushButton() self.pb1.setObjectName("Cancel") self.pb1.setText("Cancel") hbo = QHBoxLayout() self.gender = QLabel('Gender') self.r1 = QRadioButton('Male') self.r2 = QRadioButton('Female') hbo.addWidget(self.r1) hbo.addWidget(self.r2) Formlayout = QFormLayout() Formlayout.addRow(self.schno, self.schnoData) Formlayout.addRow(self.surname, self.surnameData) Formlayout.addRow(self.firstname, self.firstnameData) Formlayout.addRow(self.middlename, self.middlenameData) Formlayout.addRow(self.gender, hbo) Formlayout.addRow(self.dob, self.dobData) Formlayout.addRow(self.admit, self.admitData) Formlayout.addRow(self.soo, self.sooData) Formlayout.addRow(self.lga, self.lgaData) Formlayout.addRow(self.addr, self.addrData) grid = QGridLayout() grid.addWidget(self.pb1, 0, 1) grid.addWidget(self.pb, 0, 0) groupBox = QGroupBox('BIODATA') groupBox.setLayout(Formlayout) vbox = QVBoxLayout() vbox.addWidget(groupBox) vbox.addStretch() vbox.addLayout(grid) #self.setLayout(vbox) self.connect(self.pb, SIGNAL("clicked()"), lambda: self.button_click(1)) self.connect(self.pb1, SIGNAL("clicked()"), self.close) self.setWindowTitle("Student Data") #self.setTabText(0, 'BioData') self.tab1.setLayout(vbox) #guardian data relations = [ 'Father', 'Mother', 'Aunt', 'Uncle', 'Grand Parent', 'Guardian', 'Others' ] #first guardian details self.g1name = QLabel("First Guardian") self.g1Data = QLineEdit() self.g1Data.setObjectName("g1name") self.g1Data.setPlaceholderText("Fullname") self.g1rel = QLabel('Relationship') self.g1relData = QComboBox() self.g1relData.addItems(relations) self.g1p1 = QLabel("Phone Number") self.g1p1Data = QLineEdit() self.g1p1Data.setObjectName("g1p1") self.g1p1Data.setPlaceholderText("08000000000") self.g1p2 = QLabel("Alt. Phone Number") self.g1p2Data = QLineEdit() self.g1p2Data.setObjectName("g1p2") self.g1p2Data.setPlaceholderText("08000000000") self.g1email = QLabel("Email") self.g1emailData = QLineEdit() self.g1emailData.setObjectName("g1email") self.g1emailData.setPlaceholderText("*****@*****.**") self.g1addr = QLabel("Address") self.g1addrData = QTextEdit() self.g1addrData.setObjectName("g1add") #self.g1addrData.setPlaceholderText("No. 12 Harrrison For Str., Ney York") #second guardian details self.g2name = QLabel("Second Guardian") self.g2Data = QLineEdit() self.g2Data.setObjectName("g2name") self.g2Data.setPlaceholderText("Mr. Surname Lastname") self.g2rel = QLabel('Relationship') self.g2relData = QComboBox() self.g2relData.addItems(relations) self.g2p1 = QLabel("Phone Number") self.g2p1Data = QLineEdit() self.g2p1Data.setObjectName("g2p1") self.g2p1Data.setPlaceholderText("08000000000") self.g2p2 = QLabel("Alt. Phone Number") self.g2p2Data = QLineEdit() self.g2p2Data.setObjectName("g2p2") self.g2p2Data.setPlaceholderText("08000000000") self.g2email = QLabel("Email") self.g2emailData = QLineEdit() self.g2emailData.setObjectName("g2email") self.g2emailData.setPlaceholderText("*****@*****.**") self.g2addr = QLabel("Address") self.g2addrData = QTextEdit() self.g2addrData.setObjectName("g2add") #self.g2addrData.setPlaceholderText("No. 12 Harrrison For Str., Ney York") self.pb = QPushButton() self.pb.setObjectName("Submit") self.pb.setText("Submit") self.pb1 = QPushButton() self.pb1.setObjectName("Cancel") self.pb1.setText("Cancel") hbo = QHBoxLayout() self.gender = QLabel('Gender') self.r1 = QRadioButton('Male') self.r2 = QRadioButton('Female') hbo.addWidget(self.r1) hbo.addWidget(self.r2) Formlayout1 = QFormLayout() Formlayout1.addRow(self.g1name, self.g1Data) Formlayout1.addRow(self.g1rel, self.g1relData) Formlayout1.addRow(self.g1p1, self.g1p1Data) Formlayout1.addRow(self.g1p2, self.g1p2Data) Formlayout1.addRow(self.g1email, self.g1emailData) Formlayout1.addRow(self.g1addr, self.g1addrData) Formlayout2 = QFormLayout() Formlayout2.addRow(self.g2name, self.g2Data) Formlayout2.addRow(self.g2rel, self.g2relData) Formlayout2.addRow(self.g2p1, self.g2p1Data) Formlayout2.addRow(self.g2p2, self.g2p2Data) Formlayout2.addRow(self.g2email, self.g2emailData) Formlayout2.addRow(self.g2addr, self.g2addrData) grid1 = QGridLayout() grid1.addWidget(self.pb, 0, 0) grid1.addWidget(self.pb1, 0, 1) hbox1 = QHBoxLayout() hbox1.addLayout(Formlayout1) hbox1.addLayout(Formlayout2) groupBox2 = QGroupBox('GUARDIAN') groupBox2.setLayout(hbox1) vbox1 = QVBoxLayout() vbox1.addWidget(groupBox2) vbox1.addStretch() vbox1.addLayout(grid1) #photo self.pic1 = QLabel() image1 = Image.open('img/studentz.png') self.pic1.resize(100, 150) self.pic1.setLabel(image1) self.pic2 = QLabel() image2 = Image.open('img/studentz.png') self.pic2.resize(100, 150) self.pic2.setPixmap(image2) self.pic3 = QLabel() image3 = Image.open('img/studentz.png') self.pic3.resize(100, 150) self.pic3.setPixmap(image3) self.picBtn1 = QPushButton('Select Image') self.picBtn1.clicked.connect(self.getFilez) self.picBtn2 = QPushButton('Select Image') self.picBtn2.clicked.connect(self.getFilez) self.picBtn3 = QPushButton('Select Image') self.picBtn3.clicked.connect(self.getFilez) picGrid = QGridLayout() picGrid.addWidget(self.pic1, 0, 1) picGrid.addWidget(self.pic2, 0, 2) picGrid.addWidget(self.pic3, 0, 3) picGrid.addWidget(self.picBtn1, 1, 1) picGrid.addWidget(self.picBtn2, 2, 2) picGrid.addWidget(self.picBtn3, 3, 3) self.tabz.addTab(self.tab1, 'Bio-Data') self.tabz.addTab(self.tab2, 'Contact Details') self.tabz.addTab(self.tab3, 'Passports') #self.tabz.setTabEnabled(1, False) #self.tabz.setTabEnabled(2, False) self.setWindowTitle("Add Student Data") self.show()
def __init__(self, panel): super(Widget, self).__init__(panel) layout = QVBoxLayout() self.setLayout(layout) layout.setSpacing(0) self.searchEntry = SearchLineEdit() self.treeView = QTreeView(contextMenuPolicy=Qt.CustomContextMenu) self.textView = QTextBrowser() applyButton = QToolButton(autoRaise=True) editButton = QToolButton(autoRaise=True) addButton = QToolButton(autoRaise=True) self.menuButton = QPushButton(flat=True) menu = QMenu(self.menuButton) self.menuButton.setMenu(menu) splitter = QSplitter(Qt.Vertical) top = QHBoxLayout() layout.addLayout(top) splitter.addWidget(self.treeView) splitter.addWidget(self.textView) layout.addWidget(splitter) splitter.setSizes([200, 100]) splitter.setCollapsible(0, False) top.addWidget(self.searchEntry) top.addWidget(applyButton) top.addSpacing(10) top.addWidget(addButton) top.addWidget(editButton) top.addWidget(self.menuButton) # action generator for actions added to search entry def act(slot, icon=None): a = QAction(self, triggered=slot) self.addAction(a) a.setShortcutContext(Qt.WidgetWithChildrenShortcut) icon and a.setIcon(icons.get(icon)) return a # hide if ESC pressed in lineedit a = act(self.slotEscapePressed) a.setShortcut(QKeySequence(Qt.Key_Escape)) # import action a = self.importAction = act(self.slotImport, 'document-open') menu.addAction(a) # export action a = self.exportAction = act(self.slotExport, 'document-save-as') menu.addAction(a) # apply button a = self.applyAction = act(self.slotApply, 'edit-paste') applyButton.setDefaultAction(a) menu.addSeparator() menu.addAction(a) # add button a = self.addAction_ = act(self.slotAdd, 'list-add') a.setShortcut(QKeySequence(Qt.Key_Insert)) addButton.setDefaultAction(a) menu.addSeparator() menu.addAction(a) # edit button a = self.editAction = act(self.slotEdit, 'document-edit') a.setShortcut(QKeySequence(Qt.Key_F2)) editButton.setDefaultAction(a) menu.addAction(a) # set shortcut action a = self.shortcutAction = act(self.slotShortcut, 'preferences-desktop-keyboard-shortcuts') menu.addAction(a) # delete action a = self.deleteAction = act(self.slotDelete, 'list-remove') a.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_Delete)) menu.addAction(a) # restore action a = self.restoreAction = act(self.slotRestore) menu.addSeparator() menu.addAction(a) # help button a = self.helpAction = act(self.slotHelp, 'help-contents') menu.addSeparator() menu.addAction(a) self.treeView.setSelectionBehavior(QTreeView.SelectRows) self.treeView.setSelectionMode(QTreeView.ExtendedSelection) self.treeView.setRootIsDecorated(False) self.treeView.setAllColumnsShowFocus(True) self.treeView.setModel(model.model()) self.treeView.setCurrentIndex(QModelIndex()) # signals self.searchEntry.returnPressed.connect(self.slotReturnPressed) self.searchEntry.textChanged.connect(self.updateFilter) self.treeView.doubleClicked.connect(self.slotDoubleClicked) self.treeView.customContextMenuRequested.connect(self.showContextMenu) self.treeView.selectionModel().currentChanged.connect(self.updateText) self.treeView.model().dataChanged.connect(self.updateFilter) # highlight text self.highlighter = highlight.Highlighter(self.textView.document()) # complete on snippet variables self.searchEntry.setCompleter(QCompleter([ ':icon', ':indent', ':menu', ':name', ':python', ':selection', ':set', ':symbol', ':template', ':template-run'], self.searchEntry)) self.readSettings() app.settingsChanged.connect(self.readSettings) app.translateUI(self) self.updateColumnSizes() self.setAcceptDrops(True)
def eContFill(self, a): sid = 23 data = self.pullStudents(a) self.resize(430, 530) #self.tabz = QTabWidget(self) self.tabz.clear() self.tab1 = QWidget(self) self.tab2 = QWidget(self) self.tab3 = QWidget(self) self.schno = QLabel("School Number") self.schnoData = QLineEdit() self.schnoData.setObjectName("schno") if (data['schno'] and len(data['schno']) > 1): self.schnoData.setText(data['schno']) else: self.schnoData.setPlaceholderText("00000000") self.surname = QLabel("Surname") self.surnameData = QLineEdit() self.surnameData.setObjectName("surname") if (data['surname'] and len(data['surname']) > 1): tx = data['surname'] self.surnameData.setText(tx.title()) else: self.surnameData.setPlaceholderText("Surname") self.firstname = QLabel("Firstname") self.firstnameData = QLineEdit() self.firstnameData.setObjectName("firstname") if (data['firstname'] and len(data['firstname'])): tx = data['firstname'] self.firstnameData.setText(tx.title()) else: self.firstnameData.setPlaceholderText("Firstname") self.middlename = QLabel("Middlename") self.middlenameData = QLineEdit() self.middlenameData.setObjectName("middlename") if (data['othername'] and len(data['othername']) > 1): tx = data['othername'] self.middlenameData.setText(tx.title()) else: self.middlenameData.setPlaceholderText("othername") self.soo = QLabel("State/Region of Origin") self.sooData = QLineEdit() self.sooData.setObjectName("soo") if (data['soo'] and len(data['soo']) > 1): tx = data['soo'] self.sooData.setText(tx.title()) else: self.sooData.setPlaceholderText("Lagos") self.lga = QLabel("LGA/District") self.lgaData = QLineEdit() self.lgaData.setObjectName("lga") if (data['lga'] and len(data['lga'])): tx = data['lga'] self.lgaData.setText(tx.title()) else: self.lgaData.setPlaceholderText("Ikeja") self.addr = QLabel("House Address") self.addrData = QTextEdit() self.addrData.setObjectName("addr") if (data['addr'] and len(data['addr'])): tx = data['addr'] self.addrData.setText(tx) else: pass self.dob = QLabel("Date of Birth") self.dobData = QDateEdit() self.dobData.setObjectName("dob") tx = QDate.fromString(data['dob'], 'yyyy-MM-dd') self.dobData.setDate(QDate(tx.year(), tx.month(), tx.day())) self.admit = QLabel("Date Admitted") self.admitData = QDateEdit() self.admitData.setObjectName("admit") tx = QDate.fromString(data['admit'], 'yyyy-MM-dd') self.admitData.setDate(QDate(tx.year(), tx.month(), tx.day())) self.pb4 = QPushButton() self.pb4.setObjectName("Submit") self.pb4.setText("Submit") self.pb5 = QPushButton() self.pb5.setObjectName("Cancel") self.pb5.setText("Cancel") hbo = QHBoxLayout() self.gender = QLabel('Gender') self.r1 = QRadioButton('Male') self.r2 = QRadioButton('Female') if (data['gender'] == 'Male'): self.r1.setChecked(True) elif (data['gender'] == 'Female'): self.r2.setChecked(True) hbo.addWidget(self.r1) hbo.addWidget(self.r2) Formlayout = QFormLayout() Formlayout.addRow(self.schno, self.schnoData) Formlayout.addRow(self.surname, self.surnameData) Formlayout.addRow(self.firstname, self.firstnameData) Formlayout.addRow(self.middlename, self.middlenameData) Formlayout.addRow(self.gender, hbo) Formlayout.addRow(self.dob, self.dobData) Formlayout.addRow(self.admit, self.admitData) Formlayout.addRow(self.soo, self.sooData) Formlayout.addRow(self.lga, self.lgaData) Formlayout.addRow(self.addr, self.addrData) grid = QGridLayout() grid.addWidget(self.pb1, 0, 1) grid.addWidget(self.pb, 0, 0) groupBox = QGroupBox('BIODATA') groupBox.setLayout(Formlayout) vbox = QVBoxLayout() vbox.addWidget(groupBox) vbox.addStretch() vbox.addLayout(grid) #self.setLayout(vbox) self.connect(self.pb4, SIGNAL("clicked()"), lambda: self.button1_click(sid)) self.connect(self.pb5, SIGNAL("clicked()"), self.close) self.tab1.setLayout(vbox) relations = [ 'Father', 'Mother', 'Aunt', 'Uncle', 'Grand Parent', 'Guardian', 'Others' ] #first guardian details self.g1name = QLabel("First Guardian") self.g1Data = QLineEdit() self.g1Data.setObjectName("g1name") if (data['g1'] and len(data['g1']) > 1): tx = data['g1'] self.g1Data.setText(tx.title()) else: self.g1Data.setPlaceholderText("Mr. Surname Lastname") self.g1rel = QLabel('Relationship') self.g1relData = QComboBox() self.g1relData.addItems(relations) if data['g1rel'] and len(data['g1rel']) > 0: index1 = self.g1relData.findText(data['g1rel'], Qt.QtMatchFixedString) if index1 >= 0: self.g1relData.setCurrentIndex(index1) self.g1p1 = QLabel("Phone Number") self.g1p1Data = QLineEdit() self.g1p1Data.setObjectName("g1p1") if (data['g1p1'] and len(data['g1p1']) > 1): tx = data['g1p1'] self.g1p1Data.setText(tx.title()) else: self.g1p1Data.setPlaceholderText("08000000000") self.g1p2 = QLabel("Alt. Phone Number") self.g1p2Data = QLineEdit() self.g1p2Data.setObjectName("g1p2") if (data['g1p2'] and len(data['g1p2']) > 1): tx = data['g1p2'] self.g1p2Data.setText(tx.title()) else: self.g1p2Data.setPlaceholderText("08000000000") self.g1email = QLabel("Email") self.g1emailData = QLineEdit() self.g1emailData.setObjectName("g1email") if (data['g1email'] and len(data['g1email']) > 1): tx = data['g1email'] self.g1Data.setText(tx.title()) else: self.g1Data.setPlaceholderText("*****@*****.**") self.g1addr = QLabel("Address") self.g1addrData = QTextEdit() self.g1addrData.setObjectName("g1add") if (data['g1addr'] and len(data['g1addr']) > 1): tx = data['g1addr'] self.g1Data.setText(tx.title()) else: pass #second guardian details self.g2name = QLabel("Second Guardian") self.g2Data = QLineEdit() self.g2Data.setObjectName("g2name") if (data['g2'] and len(data['g2']) > 1): tx = data['g2'] self.g2Data.setText(tx.title()) else: self.g2Data.setPlaceholderText("Title. Surname Lastname") self.g2rel = QLabel('Relationship') self.g2relData = QComboBox() self.g2relData.addItems(relations) if data['g2rel'] and len(data['g2rel']) > 0: index2 = self.g2relData.findText(data['g2rel'], Qt.QtMatchFixedString) if index2 >= 0: self.g2relData.setCurrentIndex(index2) self.g2p1 = QLabel("Phone Number") self.g2p1Data = QLineEdit() self.g2p1Data.setObjectName("g2p1") if (data['g2p1'] and len(data['g2p1']) > 1): tx = data['g2p1'] self.g2p1Data.setText(tx.title()) else: self.g2p1Data.setPlaceholderText("08000000000") self.g2p2 = QLabel("Alt. Phone Number") self.g2p2Data = QLineEdit() self.g2p2Data.setObjectName("g2p2") if (data['g2p2'] and len(data['g2p2']) > 1): tx = data['g2p2'] self.g2p2Data.setText(tx.title()) else: self.g2p2Data.setPlaceholderText("0800000000") self.g2email = QLabel("Email") self.g2emailData = QLineEdit() self.g2emailData.setObjectName("g2email") if (data['g2email'] and len(data['g2email']) > 1): tx = data['g2email'] self.g2emailData.setText(tx.title()) else: self.g2emailData.setPlaceholderText("*****@*****.**") self.g2addr = QLabel("Address") self.g2addrData = QTextEdit() self.g2addrData.setObjectName("g2add") if (data['g2addr'] and len(data['g2addr']) > 1): tx = data['g2addr'] self.g2Data.setText(tx.title()) else: pass self.pb = QPushButton() self.pb.setObjectName("Submit") self.pb.setText("Submit") self.pb1 = QPushButton() self.pb1.setObjectName("Cancel") self.pb1.setText("Cancel") hbo = QHBoxLayout() self.gender = QLabel('Gender') self.r1 = QRadioButton('Male') self.r2 = QRadioButton('Female') hbo.addWidget(self.r1) hbo.addWidget(self.r2) Formlayout1 = QFormLayout() Formlayout1.addRow(self.g1name, self.g1Data) Formlayout1.addRow(self.g1rel, self.g1relData) Formlayout1.addRow(self.g1p1, self.g1p1Data) Formlayout1.addRow(self.g1p2, self.g1p2Data) Formlayout1.addRow(self.g1email, self.g1emailData) Formlayout1.addRow(self.g1addr, self.g1addrData) Formlayout2 = QFormLayout() Formlayout2.addRow(self.g2name, self.g2Data) Formlayout2.addRow(self.g2rel, self.g2relData) Formlayout2.addRow(self.g2p1, self.g2p1Data) Formlayout2.addRow(self.g2p2, self.g2p2Data) Formlayout2.addRow(self.g2email, self.g2emailData) Formlayout2.addRow(self.g2addr, self.g2addrData) grid1 = QGridLayout() grid1.addWidget(self.pb, 0, 0) grid1.addWidget(self.pb1, 0, 1) hbox1 = QHBoxLayout() hbox1.addLayout(Formlayout1) hbox1.addStretch() hbox1.addLayout(Formlayout2) groupBox2 = QGroupBox('GUARDIAN') groupBox2.setLayout(hbox1) vbox1 = QVBoxLayout() vbox1.addWidget(groupBox2) vbox1.addStretch() vbox1.addLayout(grid1) self.tab2.setLayout(vbox1) #photo picstyle = QSize(120, 180) picstyle1 = Qt.KeepAspectRatio self.pic1Lbl = QLabel('YEAR 1 & 2') self.pic2Lbl = QLabel('YEAR 3 & 4') self.pic3Lbl = QLabel('YEAR 5 & 6') self.pic1 = QLabel() pixmap1 = QPixmap('img/studentz.png').scaled(picstyle, picstyle1) self.pic1.setPixmap(pixmap1) self.pic2 = QLabel() pixmap2 = QPixmap('img/studentz.png').scaled(picstyle, picstyle1) self.pic2.setPixmap(pixmap2) self.pic3 = QLabel() pixmap3 = QPixmap('img/studentz.png').scaled(picstyle, picstyle1) self.pic3.setPixmap(pixmap3) self.picBtn1 = QPushButton('Select Image') self.picBtn1.clicked.connect(self.getFilez) self.picBtn2 = QPushButton('Select Image') self.picBtn2.clicked.connect(self.getFilez) self.picBtn3 = QPushButton('Select Image') self.picBtn3.clicked.connect(self.getFilez) self.pic1Lbl.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) self.pic2Lbl.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) self.pic3Lbl.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) self.picBtn1.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) self.picBtn2.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) self.picBtn3.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) h1pic = QVBoxLayout() h2pic = QVBoxLayout() h3pic = QVBoxLayout() vpic = QHBoxLayout() h1pic.addWidget(self.pic1Lbl) h1pic.addStretch(0) h1pic.addWidget(self.pic1) h1pic.addStretch(0) h1pic.addWidget(self.picBtn1) h1pic.setContentsMargins(0, 0, 0, 0) h1pic.setSpacing(0) h1pic.setMargin(0) h2pic.addWidget(self.pic2Lbl) h2pic.addStretch(0) h2pic.addWidget(self.pic2) h2pic.addStretch(0) h2pic.addWidget(self.picBtn2) h2pic.setContentsMargins(0, 0, 0, 0) h2pic.setSpacing(0) h2pic.setMargin(0) h3pic.addWidget(self.pic3Lbl) h3pic.addStretch(0) h3pic.addWidget(self.pic3) h3pic.addStretch(0) h3pic.addWidget(self.picBtn3) h3pic.setContentsMargins(0, 0, 0, 0) h3pic.setSpacing(0) h3pic.setMargin(0) vpic.addLayout(h1pic) vpic.addStretch(0) vpic.addLayout(h2pic) vpic.addStretch(0) vpic.addLayout(h3pic) vpic.setSpacing(0) vpic.setMargin(0) vpic.setContentsMargins(0, 0, 0, 0) self.tab3.setLayout(vpic) self.tab3.resize(100, 100) self.tab3.setStyleSheet( "background-color: red; margin:5px; border:1px solid red;") self.tabz.addTab(self.tab1, 'Bio-Data') self.tabz.addTab(self.tab2, 'Contact Details') self.tabz.addTab(self.tab3, 'Passports') self.setWindowTitle("Add Student Data") self.show()
def __init__(self): self.techniquesClass = { 'caesar cipher': caesarCipher, 'mono alphabetic cipher': monoAlphabeticCipher, 'vigenere cipher': vigenereCipher, 'vernan cipher': vernanCipher, 'one time pad': oneTimePad } self.rowsview = [] self.filesview = [] #self.techniques = [] QDialog.__init__(self) self.setWindowTitle("Desencriptador de Cryogenesis Systems.") self.resize(1024, 600) self.setMinimumSize(QSize(1024, 600)) self.setMaximumSize(QSize(1024, 600)) self.checkBox_2 = QCheckBox(self) self.checkBox_2.setGeometry(QRect(620, 10, 130, 20)) self.checkBox_2.setText('seleccionar todos') self.checkBox_2.clicked.connect(self.__selectAllFiles) self.treeView = QTreeView(self) self.treeView.setGeometry(QRect(10, 10, 230, 580)) self.treeView.setObjectName("treeView") self.fileSystemModel = QFileSystemModel(self.treeView) self.fileSystemModel.setReadOnly(False) self.fileSystemModel.setFilter(QDir.AllDirs | QDir.NoDotAndDotDot) root = self.fileSystemModel.setRootPath("/") self.treeView.setModel(self.fileSystemModel) self.treeView.setRootIndex(root) self.treeView.hideColumn(1) self.treeView.hideColumn(2) self.treeView.hideColumn(3) self.treeView.clicked.connect(self.__eventDirectoryChanged) self.mygroupbox = QGroupBox(self) self.mygroupbox.setGeometry(QRect(0, 0, 1000, 1000)) self.myform = QFormLayout() for j in list(range(100)): horizontalLayout = QHBoxLayout() self.myform.addRow(horizontalLayout) self.rowsview.append(horizontalLayout) self.mygroupbox.setLayout(self.myform) scroll = QScrollArea(self) scroll.setWidget(self.mygroupbox) scroll.setWidgetResizable(True) scroll.setGeometry(QRect(250, 30, 500, 580)) scroll.setWidgetResizable(True) self.label_4 = QLabel(self) self.label_4.setGeometry(QRect(780, 30, 31, 16)) self.label_4.setPixmap(QPixmap("images/key.png")) self.label_4.setScaledContents(True) self.lineEdit = QLineEdit(self) self.lineEdit.setGeometry(QRect(820, 30, 180, 20)) self.lineEdit.setObjectName("lineEdit") self.lineEdit.setPlaceholderText(_fromUtf8('escriba su contraseña')) self.lineEdit.setEchoMode(QLineEdit.Password) self.okButton = QPushButton(self) self.okButton.setGeometry(QRect(920, 560, 80, 20)) self.okButton.setText('Iniciar...') self.connect(self.okButton, SIGNAL("clicked()"), self.__eventInitDecryption)
"programming, with high-quality technical articles " "written by Qt experts.") textWindow = mdiArea.addSubWindow(textEdit) textWindow.setWindowTitle("A Text Editor") label = QLabel() label.setPixmap(QPixmap("../../images/qt-logo.png")) labelWindow = mdiArea.addSubWindow(label) labelWindow.setWindowTitle("A Label") items = (("Henry", 23), ("Bill", 56), ("Susan", 19), ("Jane", 47)) table = QTableWidget(len(items), 2) for i in range(len(items)): name, age = items[i] item = QTableWidgetItem(name) table.setItem(i, 0, item) item = QTableWidgetItem(str(age)) table.setItem(i, 1, item) tableWindow = mdiArea.addSubWindow(table) tableWindow.setWindowTitle("A Table Widget") mdiArea.show() changer = Changer(mdiArea) button = QPushButton("Cascade") button.connect(button, SIGNAL("clicked()"), changer.change) button.show() sys.exit(app.exec_())
def __init__(self, parent, resoution="0.0000"): QWidget.__init__(self, parent) while not isinstance(parent, QDialog): parent = parent.parent() self.setObjectName("NumberBoxPanel" + str(len(parent.findChildren(NumberBoxPanel)))) self.hLayoutBoxPanel = QHBoxLayout(self) self.hLayoutBoxPanel.setSpacing(0) self.hLayoutBoxPanel.setContentsMargins(0, 0, 0, 0) self.hLayoutBoxPanel.setObjectName(("hLayoutBoxPanel")) self.frameBoxPanel = QFrame(self) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.frameBoxPanel.sizePolicy().hasHeightForWidth()) self.frameBoxPanel.setSizePolicy(sizePolicy) self.frameBoxPanel.setFrameShape(QFrame.NoFrame) self.frameBoxPanel.setFrameShadow(QFrame.Raised) self.frameBoxPanel.setObjectName(("frameBoxPanel")) self.hLayoutframeBoxPanel = QHBoxLayout(self.frameBoxPanel) self.hLayoutframeBoxPanel.setSpacing(0) self.hLayoutframeBoxPanel.setMargin(0) self.hLayoutframeBoxPanel.setObjectName(("hLayoutframeBoxPanel")) self.captionLabel = QLabel(self.frameBoxPanel) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.captionLabel.sizePolicy().hasHeightForWidth()) self.captionLabel.setSizePolicy(sizePolicy) self.captionLabel.setMinimumSize(QSize(200, 0)) self.captionLabel.setMaximumSize(QSize(200, 16777215)) font = QFont() font.setBold(False) font.setWeight(50) self.captionLabel.setFont(font) self.captionLabel.setObjectName(("captionLabel")) self.hLayoutframeBoxPanel.addWidget(self.captionLabel) if resoution != None: self.numberBox = QLineEdit(self.frameBoxPanel) self.numberBox.setEnabled(True) font = QFont() font.setBold(False) font.setWeight(50) self.numberBox.setFont(font) self.numberBox.setObjectName(self.objectName() + "_numberBox") self.numberBox.setText("0.0") self.numberBox.setMinimumWidth(70) self.numberBox.setMaximumWidth(70) self.hLayoutframeBoxPanel.addWidget(self.numberBox) self.numberBox.textChanged.connect(self.numberBoxChanged) self.numberBox.editingFinished.connect( self.numberBoxEditingFinished) else: self.numberBox = QSpinBox(self.frameBoxPanel) self.numberBox.setObjectName(self.objectName() + "_numberBox") self.numberBox.setMinimumWidth(70) self.numberBox.setMaximumWidth(70) self.numberBox.setMinimum(-100000000) self.numberBox.setMaximum(100000000) self.numberBox.setValue(1) self.hLayoutframeBoxPanel.addWidget(self.numberBox) self.imageButton = QPushButton(self.frameBoxPanel) self.imageButton.setText(("")) icon = QIcon() icon.addPixmap(QPixmap(("Resource/convex_hull.png")), QIcon.Normal, QIcon.Off) self.imageButton.setIcon(icon) self.imageButton.setObjectName(("imageButton")) self.imageButton.setVisible(False) self.hLayoutframeBoxPanel.addWidget(self.imageButton) self.hLayoutBoxPanel.addWidget(self.frameBoxPanel) spacerItem = QSpacerItem(10, 10, QSizePolicy.Expanding, QSizePolicy.Minimum) self.hLayoutBoxPanel.addItem(spacerItem) self.imageButton.clicked.connect(self.imageButtonClicked) self.numberResolution = resoution str0 = String.Number2String(6.6788, "0.0000") self.Value = 0 self.captionUnits = ""
def __init__(self, controller): QMainWindow.__init__(self) # set controller self.controller = controller # set position & size self.setGeometry(750, 200, 500, 10) # set title self.setWindowTitle("Crops") # create main widget self.main_widget = QWidget(self) # create main layout self.main_layout = QVBoxLayout(self.main_widget) self.main_layout.setAlignment(Qt.AlignTop) self.main_layout.addStretch(1) self.main_layout.setSpacing(5) # initialize list of dicts used for accessing all crop parameter controls self.crop_param_controls = [] # create tabs widget self.crop_tabs_widget = QTabWidget() self.crop_tabs_widget.setUsesScrollButtons(True) self.crop_tabs_widget.tabCloseRequested.connect( self.controller.remove_crop) self.crop_tabs_widget.currentChanged.connect( self.controller.change_crop) self.crop_tabs_widget.setElideMode(Qt.ElideLeft) self.crop_tabs_widget.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.crop_tabs_widget.setMinimumSize(276, 300) self.main_layout.addWidget(self.crop_tabs_widget) # create tabs layout crop_tabs_layout = QHBoxLayout(self.crop_tabs_widget) # create lists for storing all crop tab widgets & layouts self.crop_tab_layouts = [] self.crop_tab_widgets = [] # add crop button layout crop_button_layout = QHBoxLayout() crop_button_layout.setSpacing(5) crop_button_layout.addStretch(1) self.main_layout.addLayout(crop_button_layout) # add delete crop button self.remove_crop_button = QPushButton(u'\u2717 Remove Crop', self) self.remove_crop_button.setMaximumWidth(120) self.remove_crop_button.clicked.connect( lambda: self.controller.remove_crop(self.controller.current_crop)) self.remove_crop_button.setDisabled(True) crop_button_layout.addWidget(self.remove_crop_button) # add new crop button self.create_crop_button = QPushButton(u'\u270E New Crop', self) self.create_crop_button.setMaximumWidth(100) self.create_crop_button.clicked.connect( lambda: self.controller.create_crop()) crop_button_layout.addWidget(self.create_crop_button) # set main widget self.setCentralWidget(self.main_widget) # set window buttons self.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowMinimizeButtonHint | Qt.WindowMaximizeButtonHint) self.show()
def __init__(self, parent, item): QWidget.__init__(self, parent) self.gridLayout_2 = QGridLayout(self) self.gridLayout_2.setObjectName(("gridLayout_2")) self.mMapPositionFixedCheckBox = QCheckBox(self) self.mMapPositionFixedCheckBox.setObjectName(("mMapPositionFixedCheckBox")) self.gridLayout_2.addWidget(self.mMapPositionFixedCheckBox, 0, 0, 1, 1) self.gridLayout = QGridLayout() self.gridLayout.setObjectName(("gridLayout")) self.mFrameColorButton = QgsColorButton(self) self.mFrameColorButton.setText(("")) self.mFrameColorButton.setObjectName(("mFrameColorButton")) self.gridLayout.addWidget(self.mFrameColorButton, 3, 1, 1, 1) self.mFrameColorButton.colorChanged.connect(self.on_mFrameColorButton_colorChanged) self.mBackgroundColorLabel = QLabel(self) self.mBackgroundColorLabel.setObjectName(("mBackgroundColorLabel")) self.gridLayout.addWidget(self.mBackgroundColorLabel, 2, 0, 1, 1) self.mMapMarkerLabel = QLabel(self) self.mMapMarkerLabel.setObjectName(("mMapMarkerLabel")) self.gridLayout.addWidget(self.mMapMarkerLabel, 0, 0, 1, 1) self.mBackgroundColorButton = QgsColorButton(self) self.mBackgroundColorButton.setText(("")) self.mBackgroundColorButton.setObjectName(("mBackgroundColorButton")) self.gridLayout.addWidget(self.mBackgroundColorButton, 2, 1, 1, 1) self.mBackgroundColorButton.colorChanged.connect(self.on_mBackgroundColorButton_colorChanged) self.mMapMarkerButton = QPushButton(self) self.mMapMarkerButton.setText(("")) self.mMapMarkerButton.setObjectName(("mMapMarkerButton")) self.gridLayout.addWidget(self.mMapMarkerButton, 0, 1, 1, 1) self.mMapMarkerButton.clicked.connect(self.on_mMapMarkerButton_clicked) self.mFrameWidthLabel = QLabel(self) self.mFrameWidthLabel.setObjectName(("mFrameWidthLabel")) self.gridLayout.addWidget(self.mFrameWidthLabel, 1, 0, 1, 1) self.mFrameWidthSpinBox = QDoubleSpinBox(self) self.mFrameWidthSpinBox.setObjectName(("mFrameWidthSpinBox")) self.gridLayout.addWidget(self.mFrameWidthSpinBox, 1, 1, 1, 1) self.mFrameColorLabel = QLabel(self) self.mFrameColorLabel.setObjectName(("mFrameColorLabel")) self.gridLayout.addWidget(self.mFrameColorLabel, 3, 0, 1, 1) self.gridLayout_2.addLayout(self.gridLayout, 1, 0, 1, 1) self.mMapMarkerLabel.setBuddy(self.mMapMarkerButton) self.mFrameWidthLabel.setBuddy(self.mFrameWidthSpinBox) self.setWindowTitle("QgsAnnotationWidgetBase") self.mMapPositionFixedCheckBox.setText("Fixed map position") self.mBackgroundColorLabel.setText("Background color") self.mMapMarkerLabel.setText("Map marker") self.mFrameWidthLabel.setText( "Frame width") self.mFrameColorLabel.setText( "Frame color") self.setLayout(self.gridLayout_2) self.mItem = item if ( self.mItem != None ): self.blockAllSignals( True ) if ( self.mItem.mapPositionFixed() ): self.mMapPositionFixedCheckBox.setCheckState( Qt.Checked ) else: self.mMapPositionFixedCheckBox.setCheckState( Qt.Unchecked ) self.mFrameWidthSpinBox.setValue( self.mItem.frameBorderWidth() ) self.mFrameColorButton.setColor( self.mItem.frameColor() ) self.mFrameColorButton.setColorDialogTitle( "Select frame color" ) self.mFrameColorButton.setColorDialogOptions( QColorDialog.ShowAlphaChannel ) self.mBackgroundColorButton.setColor( self.mItem.frameBackgroundColor() ) self.mBackgroundColorButton.setColorDialogTitle( "Select background color" ) self.mBackgroundColorButton.setColorDialogOptions( QColorDialog.ShowAlphaChannel ) self.symbol = self.mItem.markerSymbol() if ( self.symbol != None ): self.mMarkerSymbol = self.symbol.clone() self.updateCenterIcon() self.blockAllSignals( False )
def setup_ui(self, dock_widget): """ initiate main Qt building blocks of interface :param dock_widget: QDockWidget instance """ dock_widget.setObjectName("dock_widget") dock_widget.setAttribute(Qt.WA_DeleteOnClose) self.dock_widget_content = QWidget(self) self.dock_widget_content.setObjectName("dockWidgetContent") self.main_vlayout = QVBoxLayout(self) self.dock_widget_content.setLayout(self.main_vlayout) # add button to add objects to graphs self.button_bar_hlayout = QHBoxLayout(self) self.show_manual_input_button = QPushButton(self) self.button_bar_hlayout.addWidget(self.show_manual_input_button) self.show_manual_input_button.setDisabled(True) self.button_bar_hlayout.addWidget(QLabel("filter t/m categorie:")) self.category_combo = QComboBox(self) self.button_bar_hlayout.addWidget(self.category_combo) self.next_endpoint_button = QPushButton(self) self.button_bar_hlayout.addWidget(self.next_endpoint_button) self.next_endpoint_button.setDisabled(True) self.child_selection_strategy_combo = QComboBox(self) self.button_bar_hlayout.addWidget(QLabel("doortrekken tot:")) self.button_bar_hlayout.addWidget(self.child_selection_strategy_combo) spacer_item = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.button_bar_hlayout.addItem(spacer_item) # self.button_bar_hlayout.addItem(QLabel("doortrekken tot:")) # self.button_bar_hlayout.addItem(self.begroeiings_strategy_combo) self.main_vlayout.addLayout(self.button_bar_hlayout) # add tabWidget for graphWidgets self.contentLayout = QHBoxLayout(self) self.tree_table_tab = QTabWidget(self) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.tree_table_tab.sizePolicy().hasHeightForWidth()) self.tree_table_tab.setSizePolicy(sizePolicy) self.tree_table_tab.setMinimumSize(QSize(850, 0)) self.contentLayout.addWidget(self.tree_table_tab) # startpointTree self.startpoint_tree_widget = StartpointTreeWidget(self, self.area_model) # sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) # sizePolicy.setHorizontalStretch(0) # sizePolicy.setVerticalStretch(0) # sizePolicy.setHeightForWidth( # self.legger_tree_widget.sizePolicy().hasHeightForWidth()) # self.legger_tree_widget.setSizePolicy(sizePolicy) # self.legger_tree_widget.setMinimumSize(QSize(750, 0)) self.tree_table_tab.addTab(self.startpoint_tree_widget, 'startpunten') # LeggerTree self.legger_tree_widget = LeggerTreeWidget(self, self.legger_model) # sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) # sizePolicy.setHorizontalStretch(0) # sizePolicy.setVerticalStretch(0) # sizePolicy.setHeightForWidth( # self.legger_tree_widget.sizePolicy().hasHeightForWidth()) # self.legger_tree_widget.setSizePolicy(sizePolicy) # self.legger_tree_widget.setMinimumSize(QSize(750, 0)) self.tree_table_tab.addTab(self.legger_tree_widget, 'hydrovakken') # graphs self.graph_vlayout = QVBoxLayout(self) # Graph self.plot_widget = LeggerPlotWidget( self, session=self.session, legger_model=self.legger_model, variant_model=self.variant_model) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth( self.plot_widget.sizePolicy().hasHeightForWidth()) self.plot_widget.setSizePolicy(sizePolicy) self.plot_widget.setMinimumSize(QSize(250, 150)) self.graph_vlayout.addWidget(self.plot_widget, 2) # Sideview Graph self.sideview_widget = LeggerSideViewPlotWidget( self, session=self.session, legger_model=self.legger_model) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth( self.sideview_widget.sizePolicy().hasHeightForWidth()) self.sideview_widget.setSizePolicy(sizePolicy) self.sideview_widget.setMinimumSize(QSize(250, 150)) self.graph_vlayout.addWidget(self.sideview_widget) self.contentLayout.addLayout(self.graph_vlayout, 2) self.rightVstack = QVBoxLayout(self) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) self.begroeiings_combo = QComboBox(self) self.begroeiings_strategy_combo = QComboBox(self) self.groupBox_begroeiings = QGroupBox(self) self.groupBox_begroeiings.setTitle("begroeiingsfilter en voor welk deel") vbox_strat = QVBoxLayout() vbox_strat.addWidget(self.begroeiings_combo) vbox_strat.addWidget(self.begroeiings_strategy_combo) self.groupBox_begroeiings.setLayout(vbox_strat) self.rightVstack.addWidget(self.groupBox_begroeiings) # variantentable self.plot_item_table = VariantenTable(self, variant_model=self.variant_model) self.plot_item_table.setMinimumWidth(380) self.rightVstack.addWidget(self.plot_item_table) self.selected_variant_remark = QPlainTextEdit(self) self.selected_variant_remark.setFixedHeight(100) self.selected_variant_remark.setDisabled(True) self.rightVstack.addWidget(self.selected_variant_remark) self.contentLayout.addLayout(self.rightVstack, 0) self.main_vlayout.addLayout(self.contentLayout) # add dockwidget dock_widget.setWidget(self.dock_widget_content) self.retranslate_ui(dock_widget) QMetaObject.connectSlotsByName(dock_widget)
def get_value(self): return self.password.text() if __name__ == '__main__': ''' Demo application showing PinMatrix widget in action ''' a = QApplication(sys.argv) matrix = PinMatrixWidget() def clicked(): print "PinMatrix value is", matrix.get_value() print "Possible button combinations:", matrix.get_strength() sys.exit() ok = QPushButton('OK') QObject.connect(ok, SIGNAL('clicked()'), clicked) vbox = QVBoxLayout() vbox.addWidget(matrix) vbox.addWidget(ok) w = QWidget() w.setLayout(vbox) w.move(100, 100) w.show() a.exec_()
from PyQt4.QtGui import QApplication, QPushButton, QWidget app = QApplication([]) mainWindow = QWidget() def showShortcuts(): mgrDlg = ShortcutManagerDlg(mainWindow) for group, shortcutDict in mgr.shortcuts.items(): print group + ":" for i, (shortcut, (desc, obj)) in enumerate(shortcutDict.items()): print desc + " : " + str(shortcut.key().toString()) mainLayout = QVBoxLayout() btn = QPushButton("Show shortcuts") btn.clicked.connect(showShortcuts) mainLayout.addWidget(btn) mainWindow.setLayout(mainLayout) mainWindow.show() def trigger(name): print "Shortcut triggered:", name def registerShortcuts(mgr): scA = QShortcut(QKeySequence("1"), mainWindow, member=partial(trigger, "A")) mgr.register("Group 1", "Shortcut 1A", scA, None) scB = QShortcut(QKeySequence("2"),
def __init__(self, ipcon, uid): PluginBase.__init__(self, ipcon, uid) self.lcd = bricklet_lcd_20x4.LCD20x4(self.uid) self.ipcon.add_device(self.lcd) self.version = '.'.join(map(str, self.lcd.get_version()[1])) self.qtcb_pressed.connect(self.cb_pressed) self.lcd.register_callback(self.lcd.CALLBACK_BUTTON_PRESSED, self.qtcb_pressed.emit) self.qtcb_released.connect(self.cb_released) self.lcd.register_callback(self.lcd.CALLBACK_BUTTON_RELEASED, self.qtcb_released.emit) self.line_label = QLabel('Line: ') self.line_combo = QComboBox() for i in range(LCD20x4.MAX_LINE): self.line_combo.addItem(str(i)) self.pos_label = QLabel('Position: ') self.pos_combo = QComboBox() for i in range(LCD20x4.MAX_POSITION): self.pos_combo.addItem(str(i)) self.pos_layout = QHBoxLayout() self.pos_layout.addWidget(self.pos_label) self.pos_layout.addWidget(self.pos_combo) self.pos_layout.addStretch() self.line_layout = QHBoxLayout() self.line_layout.addWidget(self.line_label) self.line_layout.addWidget(self.line_combo) self.line_layout.addStretch() self.text_label = QLabel('Text: ') self.text_edit = QLineEdit() self.text_edit.setMaxLength(LCD20x4.MAX_POSITION) self.text_button = QPushButton('Send Text') self.text_layout = QHBoxLayout() self.text_layout.addWidget(self.text_label) self.text_layout.addWidget(self.text_edit) self.text_layout.addWidget(self.text_button) self.clear_button = QPushButton("Clear Display") self.bl_button = QPushButton() self.cursor_button = QPushButton() self.blink_button = QPushButton() try: if self.lcd.is_backlight_on(): self.bl_button.setText('Backlight Off') else: self.bl_button.setText('Backlight On') cursor, blink = self.lcd.get_config() if cursor: self.cursor_button.setText('Cursor Off') else: self.cursor_button.setText('Cursor On') if blink: self.blink_button.setText('Blink Off') else: self.blink_button.setText('Blink On') except ip_connection.Error: pass self.onofflayout = QHBoxLayout() self.onofflayout.addWidget(self.bl_button) self.onofflayout.addWidget(self.cursor_button) self.onofflayout.addWidget(self.blink_button) self.b0_label = QLabel('Button 0: Released') self.b1_label = QLabel('Button 1: Released') self.b2_label = QLabel('Button 2: Released') self.cursor_button.pressed.connect(self.cursor_pressed) self.blink_button.pressed.connect(self.blink_pressed) self.clear_button.pressed.connect(self.clear_pressed) self.bl_button.pressed.connect(self.bl_pressed) self.text_button.pressed.connect(self.text_pressed) layout = QVBoxLayout(self) layout.addLayout(self.line_layout) layout.addLayout(self.pos_layout) layout.addLayout(self.text_layout) layout.addWidget(self.clear_button) layout.addLayout(self.onofflayout) layout.addWidget(self.b0_label) layout.addWidget(self.b1_label) layout.addWidget(self.b2_label) layout.addStretch()
def init_UI(self): """Produce the widgets and buttons.""" self.centre_widget = QWidget() self.tabs = QTabWidget() # make tabs for each main display self.centre_widget.layout = QVBoxLayout() self.centre_widget.layout.addWidget(self.tabs) self.centre_widget.setLayout(self.centre_widget.layout) self.setCentralWidget(self.centre_widget) # change font size font = QFont() font.setPixelSize(18) #### menubar at top gives options #### menubar = self.menuBar() # file menubar allows you to save/load data file_menu = menubar.addMenu('File') for label, function in [['Load Config', self.load_config], ['Save Config', self.save_config], ['Load Trace', self.load_trace], ['Save Trace', self.save_trace], ['Save Graph', self.save_graph]]: action = QAction(label, self) action.triggered.connect(function) file_menu.addAction(action) #### tab for settings #### settings_tab = QWidget() settings_grid = QGridLayout() settings_tab.setLayout(settings_grid) self.tabs.addTab(settings_tab, "Settings") self.settings = QTableWidget(1, 6) self.settings.setHorizontalHeaderLabels([ 'Duration (ms)', 'Sample Rate (kS/s)', 'Trigger Channel', 'Trigger Level (V)', 'Trigger Edge', 'Use Trigger?' ]) settings_grid.addWidget(self.settings, 0, 0, 1, 1) defaults = [ str(self.stats['Duration (ms)']), str(self.stats['Sample Rate (kS/s)']), self.stats['Trigger Channel'], str(self.stats['Trigger Level (V)']), self.stats['Trigger Edge'], '1' ] validators = [ double_validator, double_validator, None, double_validator, None, bool_validator ] for i in range(6): table_item = QLineEdit( defaults[i]) # user can edit text to change the setting if defaults[i] == 'Sample Rate (kS/s)': table_item.setEnabled(False) table_item.setValidator( validators[i] ) # validator limits the values that can be entered self.settings.setCellWidget(0, i, table_item) self.settings.resizeColumnToContents(1) self.settings.setFixedHeight(70) # make it take up less space self.settings.cellWidget(0, 0).textChanged.connect( self.check_slice_duration) # start/stop: start waiting for a trigger or taking an acquisition self.toggle = QPushButton('Start', self) self.toggle.setCheckable(True) self.toggle.clicked.connect(self.activate) settings_grid.addWidget(self.toggle, 1, 0, 1, 1) # channels self.channels = QTableWidget(8, 7) # make table self.channels.setHorizontalHeaderLabels([ 'Channel', 'Label', 'Scale (X/V)', 'Offset (V)', 'Range', 'Acquire?', 'Plot?' ]) settings_grid.addWidget(self.channels, 2, 0, 1, 1) validators = [ None, double_validator, double_validator, None, bool_validator, bool_validator ] for i in range(8): chan = 'Dev4/ai' + str(i) # name of virtual channel table_item = QLabel(chan) self.channels.setCellWidget(i, 0, table_item) if chan in self.stats['channels']: # load values from previous defaults = self.stats['channels'][chan] else: # default values when none are loaded defaults = channel_stats("[dummy, " + str(i) + ", 1.0, 0.0, 5.0, 0, 0]")['dummy'] for j, key in zip([0, 1, 2, 4, 5], ['label', 'scale', 'offset', 'acquire', 'plot']): table_item = QLineEdit(str(defaults[key])) if 'acquire' in key: table_item.textChanged.connect(self.check_slice_channels) elif 'plot' in key: table_item.textChanged.connect(self.set_acquire) table_item.setValidator(validators[j]) self.channels.setCellWidget(i, j + 1, table_item) vrange = QComboBox() # only allow certain values for voltage range vrange.text = vrange.currentText # overload function so it's same as QLabel vrange.addItems(['%.1f' % x for x in worker.vrs]) try: vrange.setCurrentIndex(worker.vrs.index(defaults['range'])) except Exception as e: error('Invalid channel voltage range\n' + str(e)) self.channels.setCellWidget(i, 4, vrange) #### Plot for most recently acquired trace #### trace_tab = QWidget() trace_grid = QGridLayout() trace_tab.setLayout(trace_grid) self.tabs.addTab(trace_tab, "Trace") # button activates horizontal line self.hline_toggle = QPushButton('Horizontal line', self, checkable=True) self.hline_toggle.clicked.connect(self.add_horizontal) trace_grid.addWidget(self.hline_toggle, 0, 0, 1, 1) self.hline_label = QLabel() trace_grid.addWidget(self.hline_label, 0, 1, 1, 1) fadeline_button = QPushButton('Persist', self) fadeline_button.clicked.connect(self.set_fadelines) trace_grid.addWidget(fadeline_button, 0, 2, 1, 1) # plot the trace self.trace_canvas = pg.PlotWidget() self.trace_legend = self.trace_canvas.addLegend() self.trace_canvas.getAxis('bottom').tickFont = font self.trace_canvas.getAxis('left').tickFont = font self.trace_canvas.setLabel('bottom', 'Time', 's', **{'font-size': '18pt'}) self.trace_canvas.setLabel('left', 'Voltage', 'V', **{'font-size': '18pt'}) self.lines = [] # handles for lines plotting the last measurement self.fadelines = [] # handles for previous measurement lines for i in range(8): chan = self.channels.cellWidget(i, 1).text() self.lines.append( self.trace_canvas.plot([1], name=chan, pen=pg.mkPen(pg.intColor(i), width=3))) self.lines[i].hide() self.fadelines.append( self.trace_canvas.plot([1], pen=pg.mkPen(pg.intColor(i, alpha=50), width=2))) self.fadelines[i].hide() self.hline = pg.InfiniteLine(1., angle=0, pen='k', movable=True) self.trace_canvas.addItem(self.hline) self.hline.sigPositionChanged.connect(self.update_hline) self.hline.hide() trace_grid.addWidget(self.trace_canvas, 1, 0, 1, 3) #### Settings for slices of the trace accumulating into the graph #### slice_tab = QWidget() slice_grid = QGridLayout() slice_tab.setLayout(slice_grid) self.tabs.addTab(slice_tab, "Slice") # Buttons to add/remove slices and reset graph for i, (label, func) in enumerate([['Add slice', self.add_slice], ['Remove slice', self.del_slice], ['Reset graph', self.reset_graph]]): button = QPushButton(label, self) button.clicked.connect(func) slice_grid.addWidget(button, 0, i, 1, 1) # parameters for slices self.slices = QTableWidget(0, 4) # make table self.slices.setHorizontalHeaderLabels( ['Slice name', 'Start (ms)', 'End (ms)', 'Channels']) slice_grid.addWidget(self.slices, 1, 0, 1, 3) #### Plot for graph of accumulated data #### graph_tab = QWidget() graph_grid = QGridLayout() graph_tab.setLayout(graph_grid) self.tabs.addTab(graph_tab, "Graph") self.mean_graph = pg.PlotWidget() # for plotting means self.stdv_graph = pg.PlotWidget() # for plotting standard deviations self.graph_legends = [] for i, g in enumerate([self.mean_graph, self.stdv_graph]): g.getAxis('bottom').tickFont = font g.getAxis('bottom').setFont(font) g.getAxis('left').tickFont = font g.getAxis('left').setFont(font) graph_grid.addWidget(g, i, 0, 1, 1) self.reset_lines() # make a line for every slice channel self.stdv_graph.setLabel('bottom', 'Shot', '', **{'font-size': '18pt'}) self.stdv_graph.setLabel('left', 'Standard Deviation', 'V', **{'font-size': '18pt'}) self.mean_graph.setLabel('left', 'Mean', 'V', **{'font-size': '18pt'}) #### tab for TCP message settings #### tcp_tab = QWidget() tcp_grid = QGridLayout() tcp_tab.setLayout(tcp_grid) self.tabs.addTab(tcp_tab, "Sync") label = QLabel('Run number: ') tcp_grid.addWidget(label, 0, 0, 1, 1) self.n_edit = QLineEdit(str(self.stats['n'])) self.n_edit.setValidator(int_validator) self.n_edit.textEdited[str].connect(self.set_n) tcp_grid.addWidget(self.n_edit, 0, 1, 1, 1) label = QLabel('Save directory: ') tcp_grid.addWidget(label, 1, 0, 1, 1) self.save_edit = QLineEdit(self.stats['save_dir']) self.save_edit.textEdited[str].connect(self.set_save_dir) tcp_grid.addWidget(self.save_edit, 1, 1, 1, 1) label = QLabel('Trace file name: ') tcp_grid.addWidget(label, 2, 0, 1, 1) self.trace_edit = QLineEdit(self.stats['trace_file']) self.trace_edit.textEdited[str].connect(self.set_trace_file) tcp_grid.addWidget(self.trace_edit, 2, 1, 1, 1) label = QLabel('Graph file name: ') tcp_grid.addWidget(label, 3, 0, 1, 1) self.graph_edit = QLineEdit(self.stats['graph_file']) self.graph_edit.textEdited[str].connect(self.set_graph_file) tcp_grid.addWidget(self.graph_edit, 3, 1, 1, 1) reset = QPushButton('Stop TCP client', self, checkable=True, checked=False) reset.clicked.connect(self.reset_client) tcp_grid.addWidget(reset, 4, 0, 1, 1) self.unsync_toggle = QPushButton('Unsync run number', checkable=True, checked=False) tcp_grid.addWidget(self.unsync_toggle, 4, 1, 1, 1) self.send_data = QPushButton('Send data to influxdb', checkable=True, checked=False) tcp_grid.addWidget(self.send_data, 5, 0, 1, 1) #### Title and icon #### self.setWindowTitle('- NI DAQ Controller -') self.setWindowIcon(QIcon('docs/daqicon.png')) self.setGeometry(200, 200, 800, 600)