def __init__(self, *args, **kwargs): super(Calculator, self).__init__(*args, **kwargs) # Single-inheritence approach: http://goo.gl/WNiHc # Calculator class only inherits from QWidget # A specific member attribute self.ui contains all # widgets set up in the designer. self.ui = Ui_Calculator() self.ui.setupUi(self) self.ui.calcButton = QtGui.QPushButton("Calculate") self.ui.horizontalLayout_2.addWidget(self.ui.calcButton) # Create a validator for each QLineEdit that only # allows a user to enter floats: 123.123 self.ui.inputA.setValidator(QtGui.QDoubleValidator()) self.ui.inputB.setValidator(QtGui.QDoubleValidator()) # instead of using the stock operator values set in the # ui file, lets set the box to match our class attribute self.ui.operatorBox.clear() self.ui.operatorBox.addItems(self.OPS.keys()) self.ui.clearButton.clicked.connect(self.clear) self.ui.calcButton.clicked.connect(self.calc)
def initialize_content(self): # Constraints dv = QtGui.QDoubleValidator(self._content.ei_guess_edit) dv.setBottom(0.0) self._content.ei_guess_edit.setValidator(dv) if "SNS" != self._facility_name: util.set_valid(self._content.ei_guess_edit, False) self._content.tzero_guess_edit.setValidator(QtGui.QDoubleValidator(self._content.tzero_guess_edit)) self._content.etr_low_edit.setValidator(QtGui.QDoubleValidator(self._content.etr_low_edit)) self._content.etr_width_edit.setValidator(QtGui.QDoubleValidator(self._content.etr_width_edit)) self._content.etr_high_edit.setValidator(QtGui.QDoubleValidator(self._content.etr_high_edit)) self._content.monitor1_specid_edit.setValidator(QtGui.QIntValidator(self._content.monitor1_specid_edit)) self._content.monitor2_specid_edit.setValidator(QtGui.QIntValidator(self._content.monitor2_specid_edit)) # Default states self._handle_tzero_guess(self._content.use_ei_guess_chkbox.isChecked()) # Connections self.connect(self._content.sample_browse, QtCore.SIGNAL("clicked()"), self._sample_browse) self.connect(self._content.detcal_browse, QtCore.SIGNAL("clicked()"), self._detcal_browse) self.connect(self._content.hardmask_browse, QtCore.SIGNAL("clicked()"), self._hardmask_browse) self.connect(self._content.grouping_browse, QtCore.SIGNAL("clicked()"), self._grouping_browse) self.connect(self._content.use_ei_guess_chkbox, QtCore.SIGNAL("stateChanged(int)"), self._handle_tzero_guess) self.connect(self._content.savedir_browse, QtCore.SIGNAL("clicked()"), self._savedir_browse) # Validated widgets self._connect_validated_lineedit(self._content.sample_edit) self._connect_validated_lineedit(self._content.ei_guess_edit) self._connect_validated_lineedit(self._content.savedir_edit)
def __init__(self, parent=None): QtGui.QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.InputVal.setValidator(QtGui.QDoubleValidator(self.ui.InputVal)) self.ui.totalFlightPathInput.setValidator( QtGui.QDoubleValidator(self.ui.totalFlightPathInput)) self.ui.scatteringAngleInput.setValidator( QtGui.QDoubleValidator(self.ui.scatteringAngleInput)) QtCore.QObject.connect(self.ui.convert, QtCore.SIGNAL("clicked()"), self.convert) QtCore.QObject.connect(self.ui.helpButton, QtCore.SIGNAL("clicked()"), self.helpClicked) QtCore.QObject.connect(self.ui.inputUnits, QtCore.SIGNAL("currentIndexChanged(QString)"), self.setInstrumentInputs) QtCore.QObject.connect(self.ui.outputUnits, QtCore.SIGNAL("currentIndexChanged(QString)"), self.setInstrumentInputs) self.setInstrumentInputs() ##defaults self.flightpath = -1.0 self.Theta = -1.0 self.output = 0.0
def _style_widgets(self): vcenter_hright = QtCore.Qt.AlignVCenter | QtCore.Qt.AlignRight vcenter_hcenter = QtCore.Qt.AlignVCenter | QtCore.Qt.AlignHCenter self._position_lbl.setAlignment(vcenter_hcenter) self._temperature_lbl.setAlignment(vcenter_hcenter) self._position_unit_lbl.setAlignment(vcenter_hcenter) self._temperature_unit_lbl.setAlignment(vcenter_hcenter) self._reference_lbl.setAlignment(vcenter_hright) self._sample_lbl.setAlignment(vcenter_hright) self._reference_position_txt.setAlignment(vcenter_hright) self._reference_temperature_txt.setAlignment(vcenter_hright) self._sample_position_txt.setAlignment(vcenter_hright) self._sample_temperature_txt.setAlignment(vcenter_hright) max_width_position = 70 max_width_temperature = 50 self._reference_position_txt.setMaximumWidth(max_width_position) self._sample_position_txt.setMaximumWidth(max_width_position) self._reference_temperature_txt.setMaximumWidth(max_width_temperature) self._sample_temperature_txt.setMaximumWidth(max_width_temperature) self._reference_position_txt.setValidator(QtGui.QDoubleValidator()) self._reference_temperature_txt.setValidator(QtGui.QDoubleValidator()) self._sample_position_txt.setValidator(QtGui.QDoubleValidator()) self._sample_temperature_txt.setValidator(QtGui.QDoubleValidator()) self._pressure_lbl.setAlignment(vcenter_hright) self._pressure_lbl.setStyleSheet("font:bold 20px") self._pressure_unit_lbl.setStyleSheet("font:bold 20px") cleanlooks = QtGui.QStyleFactory.create('plastique') self._ruby_scale_cb.setStyle(cleanlooks)
def initialize_content(self): """ Declare the validators and event connections for the widgets loaded through the .ui file. """ # Validators self._content.transmission_edit.setValidator( QtGui.QDoubleValidator(self._content.transmission_edit)) self._content.dtransmission_edit.setValidator( QtGui.QDoubleValidator(self._content.dtransmission_edit)) self._content.thickness_edit.setValidator( QtGui.QDoubleValidator(self._content.thickness_edit)) # Connections self.connect(self._content.data_file_browse_button, QtCore.SIGNAL("clicked()"), self._data_file_browse) self.connect(self._content.calculate_chk, QtCore.SIGNAL("clicked(bool)"), self._calculate_clicked) self.connect(self._content.direct_beam_chk, QtCore.SIGNAL("clicked()"), self._direct_beam) self.connect(self._content.beam_spreader_chk, QtCore.SIGNAL("clicked()"), self._beam_spreader) self.connect(self._content.dark_current_button, QtCore.SIGNAL("clicked()"), self._dark_current_browse) self.connect(self._content.data_file_plot_button, QtCore.SIGNAL("clicked()"), self._data_file_plot) self.connect(self._content.dark_current_plot_button, QtCore.SIGNAL("clicked()"), self._dark_plot_clicked) if not self._in_mantidplot: self._content.dark_current_plot_button.hide() self._content.data_file_plot_button.hide()
def __init__(self, *args, **kwargs): super(Calculator, self).__init__(*args, **kwargs) # Single-inheritence approach: http://goo.gl/WNiHc # Calculator class only inherits from QWidget # A specific member attribute self.ui contains all # widgets set up in the designer. self.ui = Ui_Calculator() self.ui.setupUi(self) # Create a validator for each QLineEdit that only # allows a user to enter floats: 123.123 self.ui.inputA.setValidator(QtGui.QDoubleValidator()) self.ui.inputB.setValidator(QtGui.QDoubleValidator()) # instead of using the stock operator values set in the # ui file, lets set the box to match our class attribute self.ui.operatorBox.clear() self.ui.operatorBox.addItems(self.OPS.keys()) self.ui.clearButton.clicked.connect(self.clear) # every time the text is edited in either input field, # calculate the result live self.ui.inputA.textEdited.connect(self.calc) self.ui.inputB.textEdited.connect(self.calc) # also when the operator box is changed self.ui.operatorBox.currentIndexChanged.connect(self.calc)
def __init__(self, parent=None): """Initialize the window.""" QtGui.QDialog.__init__(self, parent) min_label = QtGui.QLabel("min") max_label = QtGui.QLabel("max") min_text = QtGui.QLineEdit() max_text = QtGui.QLineEdit() min_text.setValidator(QtGui.QDoubleValidator()) max_text.setValidator(QtGui.QDoubleValidator()) buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel, Qt.Horizontal, parent=self) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) vbox = QtGui.QVBoxLayout() hbox = QtGui.QHBoxLayout() hbox.addWidget(min_label) hbox.addWidget(min_text) hbox.addWidget(max_label) hbox.addWidget(max_text) vbox.addLayout(hbox) vbox.addWidget(buttons) self.setLayout(vbox) self.setWindowTitle("Display range") min_text.setFocus() # Allow outside access to these self.min_text = min_text self.max_text = max_text
def __init__(self, parent=None): QtGui.QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.InputVal.setValidator(QtGui.QDoubleValidator(self.ui.InputVal)) self.ui.totalFlightPathInput.setValidator( QtGui.QDoubleValidator(self.ui.totalFlightPathInput)) self.ui.scatteringAngleInput.setValidator( QtGui.QDoubleValidator(self.ui.scatteringAngleInput)) QtCore.QObject.connect(self.ui.convert, QtCore.SIGNAL("clicked()"), self.convert) QtCore.QObject.connect(self.ui.helpButton, QtCore.SIGNAL("clicked()"), self.helpClicked) QtCore.QObject.connect(self.ui.inputUnits, QtCore.SIGNAL("currentIndexChanged(QString)"), self.setInstrumentInputs) QtCore.QObject.connect(self.ui.outputUnits, QtCore.SIGNAL("currentIndexChanged(QString)"), self.setInstrumentInputs) self.setInstrumentInputs() ##defaults self.flightpath = -1.0 self.Theta = -1.0 self.output = 0.0 try: import mantid #register startup mantid.UsageService.registerFeatureUsage("Interface", "TofConverter", False) except ImportError: pass
def _style_widgets(self): vcenter_hright = QtCore.Qt.AlignVCenter | QtCore.Qt.AlignRight self._laser_line_lbl.setAlignment(vcenter_hright) self._derivative_lbl.setAlignment(vcenter_hright) self._reference_pos_lbl.setAlignment(vcenter_hright) self._sample_pos_lbl.setAlignment(vcenter_hright) self._laser_line_txt.setAlignment(vcenter_hright) self._derivative_sb.setAlignment(vcenter_hright) self._reference_pos_txt.setAlignment(vcenter_hright) self._sample_pos_txt.setAlignment(vcenter_hright) self._pressure_lbl.setAlignment(vcenter_hright) max_width = 60 self._laser_line_txt.setMaximumWidth(max_width) self._reference_pos_txt.setMaximumWidth(max_width) self._sample_pos_txt.setMaximumWidth(max_width) self._laser_line_txt.setValidator(QtGui.QDoubleValidator()) self._reference_pos_txt.setValidator(QtGui.QDoubleValidator()) self._sample_pos_txt.setValidator(QtGui.QDoubleValidator()) self._pressure_lbl.setStyleSheet("font:bold 20px") self._pressure_unit_lbl.setStyleSheet("font:bold 20px")
def setupLayout(self): hbox = QtGui.QHBoxLayout() self.checkEngine = QtGui.QCheckBox(self.axis_name) self.LblStep = QtGui.QLabel('step') self.EngineStepSize = QtGui.QLineEdit() self.EngineStepSize.setValidator(QtGui.QDoubleValidator()) self.EngineStepSize.setText(str(0.5)) self.LblMin = QtGui.QLabel('from ') self.EngineMin = QtGui.QLineEdit() self.EngineMin.setValidator(QtGui.QDoubleValidator()) self.EngineMin.setText(str(0)) self.LblMax = QtGui.QLabel(' mm ') self.EngineMax = QtGui.QLineEdit() self.EngineMax.setValidator(QtGui.QDoubleValidator()) self.EngineMax.setText(str(1)) hbox.addWidget(self.checkEngine) hbox.addWidget(self.LblMin) hbox.addWidget(self.EngineMin) hbox.addWidget(self.LblStep) hbox.addWidget(self.EngineStepSize) hbox.addWidget(self.EngineMax) hbox.addWidget(self.LblMax) self.setLayout(hbox) self.EngineMin.editingFinished.connect(self.editMin)
def initialize_content(self): """ Declare the validators and event connections for the widgets loaded through the .ui file. """ # Validators self._content.spreader_trans_edit.setValidator(QtGui.QDoubleValidator(self._content.spreader_trans_edit)) self._content.spreader_trans_spread_edit.setValidator(QtGui.QDoubleValidator(self._content.spreader_trans_spread_edit)) # Connections self.connect(self._content.sample_scatt_browse, QtCore.SIGNAL("clicked()"), self._sample_scatt_browse) self.connect(self._content.sample_spread_browse, QtCore.SIGNAL("clicked()"), self._sample_spread_browse) self.connect(self._content.direct_scatt_browse, QtCore.SIGNAL("clicked()"), self._direct_scatt_browse) self.connect(self._content.direct_spread_browse, QtCore.SIGNAL("clicked()"), self._direct_spread_browse) self.connect(self._content.sample_scatt_plot, QtCore.SIGNAL("clicked()"), self._sample_scatt_plot_clicked) self.connect(self._content.sample_spread_plot, QtCore.SIGNAL("clicked()"), self._sample_spread_plot_clicked) self.connect(self._content.direct_scatt_plot, QtCore.SIGNAL("clicked()"), self._direct_scatt_plot_clicked) self.connect(self._content.direct_spread_plot, QtCore.SIGNAL("clicked()"), self._direct_spread_plot_clicked) if not self._in_mantidplot: self._content.sample_scatt_plot.hide() self._content.sample_spread_plot.hide() self._content.direct_scatt_plot.hide() self._content.direct_spread_plot.hide()
def set_input_validators(self): rx = QtCore.QRegExp( "(\d+.?\d+)(,\s*\d+.?\d+)*" ) validator = QtGui.QRegExpValidator(rx, self.valuesLineEdit); self.valuesLineEdit.setValidator(validator) self.firstValueLineEdit.setValidator(QtGui.QDoubleValidator(self.firstValueLineEdit)) self.lastValueLineEdit.setValidator(QtGui.QDoubleValidator(self.lastValueLineEdit)) self.stepValueLineEdit.setValidator(QtGui.QDoubleValidator(self.stepValueLineEdit))
def __init__(self, parent = None, name = None, fl = 0, acq_params = None, path_template = None, layout = None): """ Descript. : """ QtGui.QWidget.__init__(self, parent, QtCore.Qt.WindowFlags(fl)) if name is not None: self.setObjectName(name) # Hardware objects ---------------------------------------------------- self._beamline_setup_hwobj = None # Internal variables -------------------------------------------------- # Properties ---------------------------------------------------------- # Signals ------------------------------------------------------------- # Slots --------------------------------------------------------------- # Graphic elements ---------------------------------------------------- if acq_params is None: self._acquisition_parameters = queue_model_objects.AcquisitionParameters() else: self._acquisition_parameters = acq_params if path_template is None: self._path_template = queue_model_objects.PathTemplate() else: self._path_template = path_template self._acquisition_mib = DataModelInputBinder(self._acquisition_parameters) self.acq_widget = uic.loadUi(os.path.join(os.path.dirname(__file__), "ui_files/Qt4_acquisition_widget_vertical_simple_layout.ui")) # Layout -------------------------------------------------------------- main_layout = QtGui.QVBoxLayout(self) main_layout.addWidget(self.acq_widget) main_layout.setSpacing(0) main_layout.setContentsMargins(0, 0, 0, 0) self.setLayout(main_layout) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ self.acq_widget.num_images_cbox.activated.connect(self.update_num_images) self.acq_widget.detector_mode_combo.activated.connect(self.detector_mode_changed) self.acq_widget.osc_start_cbox.toggled.connect(self.osc_start_cbox_click) # Other --------------------------------------------------------------- self.energy_validator = QtGui.QDoubleValidator(0, 25, 5, self) self.resolution_validator = QtGui.QDoubleValidator(0, 15, 3, self) self.transmission_validator = QtGui.QDoubleValidator(0, 100, 3, self) self.exp_time_validator = QtGui.QDoubleValidator(0, 10000, 5, self) self.acq_widget.osc_start_ledit.setEnabled(False) self.acq_widget.kappa_ledit.setEnabled(False) self.acq_widget.kappa_phi_ledit.setEnabled(False) self.acq_widget.num_images_cbox.setCurrentIndex(1)
def _setup(self): self._ms_level.activated.connect(self._ms_level_chosen) self._precursor.activated.connect(self._precursor_chosen) self._precursor_min.editingFinished.connect( self._precursor_range_updated) self._precursor_max.editingFinished.connect( self._precursor_range_updated) self._precursor_min.setValidator(QtGui.QDoubleValidator()) self._precursor_max.setValidator(QtGui.QDoubleValidator())
def __init__(self, parent=None): """ Constructor. @param parent : The parent widget. """ ################ __init__ : Initialize base class QtGui.QWidget.__init__(self, parent) ################ __init__ : define the non-GUI variables: ################## __init__ : set up GUI: # Main layout self._layout = QtGui.QVBoxLayout() self.setLayout(self._layout) # Setup Groupbox group_box = QtGui.QGroupBox('Misc') self._layout.addWidget(group_box) form_layout = QtGui.QFormLayout() group_box.setLayout(form_layout) # Kohn Sham mgrid levels label = QtGui.QLabel('Kohn Sham MG level ') self._khlevel = QtGui.QSpinBox() self._khlevel.setValue(2) form_layout.addRow(label, self._khlevel) # poisson mgrid levels label = QtGui.QLabel('Poisson MG level ') self._poissonlevel = QtGui.QSpinBox() self._poissonlevel.setValue(2) form_layout.addRow(label, self._poissonlevel) # Kohn Sham time step label = QtGui.QLabel('Kohn Sham time step') self._khstep = QtGui.QLineEdit() validator = QtGui.QDoubleValidator(self._khstep) self._khstep.setValidator(validator) form_layout.addRow(label, self._khstep) self._khstep.setText('1.0') # Poisson time step label = QtGui.QLabel('Poisson time step') self._poissonstep = QtGui.QLineEdit() validator = QtGui.QDoubleValidator(self._poissonstep) self._poissonstep.setValidator(validator) form_layout.addRow(label, self._poissonstep) self._poissonstep.setText('1.35')
def setValidators(self): self.ui.startChannelInput.setValidator(CH_VALIDATOR) self.ui.stopChannelInput.setValidator(CH_VALIDATOR) self.ui.startFractionInput.setValidator(FRAC_VALIDATOR) self.ui.stopFractionInput.setValidator(FRAC_VALIDATOR) self.ui.passInput.setValidator(QtGui.QIntValidator()) self.ui.dwellTimeInput.setValidator(QtGui.QDoubleValidator()) self.ui.mcsBinInput.setValidator(QtGui.QDoubleValidator())
def addTabs(self, ipatch=None): for itab in range(self.tabWidget.count()): layout = self.tabWidget.widget(itab).findChildren( QtGui.QVBoxLayout)[0] self.clearLayout(layout, 0) self.tabWidget.clear() for ifield in self.fields: if ifield not in unknowns: continue widget = QtGui.QWidget() layout = QtGui.QVBoxLayout(widget) layout2 = QtGui.QHBoxLayout() cb = QtGui.QComboBox() cb.addItems(['uniform', 'nonuniform']) values = self.setInitialConditions(ifield) layout2.addWidget(cb) if types[ifield] == 'scalar': ledit = QtGui.QLineEdit() ledit.setValidator(QtGui.QDoubleValidator()) if type(values) != str: ledit.setText(str(values)) QtCore.QObject.connect( ledit, QtCore.SIGNAL(_fromUtf8("textEdited(QString)")), self.checkData) layout2.addWidget(ledit) else: for j in range(3): ledit = QtGui.QLineEdit() ledit.setValidator(QtGui.QDoubleValidator()) if type(values) != str: ledit.setText(str(values.vals[j])) layout2.addWidget(ledit) QtCore.QObject.connect( ledit, QtCore.SIGNAL(_fromUtf8("textEdited(QString)")), self.checkData) layout.addLayout(layout2) if ifield == 'U': qbutton = QtGui.QCheckBox() qbutton.setText('Initialize from potential flow') layout.addWidget(qbutton) QtCore.QObject.connect( qbutton, QtCore.SIGNAL(_fromUtf8("stateChanged(int)")), self.onPotentialFlow) QtCore.QObject.connect( qbutton, QtCore.SIGNAL(_fromUtf8("stateChanged(int)")), self.checkData) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) layout.addItem(spacerItem) self.tabWidget.addTab(widget, ifield) self.tabWidget.setTabText(self.tabWidget.count(), ifield)
def __init__(self, parent=None, dbops=None): if dbops == None: return super().__init__(parent) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setupUi(self) # Save database operations object self.db_ops = dbops # Add type options self.typeBox.clear() self.typeBox.addItems(constants.workout_types_list) # Define default date for calendar as system date self.dateEdit.setDate(QtCore.QDate.currentDate()) # Ensure sets input is int intValidator = QtGui.QIntValidator() self.setsEdit.setValidator(intValidator) self.setsEdit.setPlaceholderText("0") # Ensure reps input is float doubleValidator1 = QtGui.QDoubleValidator() self.repsEdit.setValidator(doubleValidator1) self.repsEdit.setPlaceholderText("0.0") # Ensure avWt input is float doubleValidator2 = QtGui.QDoubleValidator() self.avWtEdit.setValidator(doubleValidator2) self.avWtEdit.setPlaceholderText("0.0") # Add average weight units options self.avWtUnitsBox.clear() self.avWtUnitsBox.addItems(constants.weight_units_list) # Ensure hiWt input is float doubleValidator3 = QtGui.QDoubleValidator() self.hiWtEdit.setValidator(doubleValidator3) self.hiWtEdit.setPlaceholderText("0.0") # Add average weight units options self.hiWtUnitsBox.clear() self.hiWtUnitsBox.addItems(constants.weight_units_list) # Setup custom warning text self.warningLabel.setStyleSheet('QLabel#warningLabel {color: red}') self.warningLabel.hide() # Setup button connections self.setup_buttons()
def __init__(self, parent=None): """Constructor.""" super(ResumenFinalTramosDialog, self).__init__(parent) # Set up the user interface from Designer. # After setupUI you can access any designer object by doing # self.<objectname>, and you can use autoconnect slots - see # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html # #widgets-and-dialogs-with-auto-connect self.setupUi(self) self.cota_cano_inicio.setValidator(QtGui.QDoubleValidator()) self.cota_cano_final.setValidator(QtGui.QDoubleValidator()) self.diametro.setValidator(QtGui.QDoubleValidator())
def initialize_content(self): """ Declare the validators and event connections for the widgets loaded through the .ui file. """ # Validators self._content.transmission_edit.setValidator( QtGui.QDoubleValidator(self._content.transmission_edit)) self._content.dtransmission_edit.setValidator( QtGui.QDoubleValidator(self._content.dtransmission_edit)) #self._content.thickness_edit.setValidator(QtGui.QDoubleValidator(self._content.thickness_edit)) # Connections self.connect(self._content.calculate_trans_chk, QtCore.SIGNAL("clicked(bool)"), self._calculate_clicked) self.connect(self._content.trans_direct_chk, QtCore.SIGNAL("clicked()"), self._direct_beam) self.connect(self._content.trans_spreader_chk, QtCore.SIGNAL("clicked()"), self._beam_spreader) self.connect(self._content.background_chk, QtCore.SIGNAL("clicked(bool)"), self._background_clicked) self.connect(self._content.background_browse, QtCore.SIGNAL("clicked()"), self._background_browse) self.connect(self._content.trans_dark_current_button, QtCore.SIGNAL("clicked()"), self._trans_dark_current_browse) self.connect(self._content.background_plot_button, QtCore.SIGNAL("clicked()"), self._background_plot_clicked) self.connect(self._content.trans_dark_current_plot_button, QtCore.SIGNAL("clicked()"), self._trans_dark_current_plot_clicked) # Process transmission option if not self.show_transmission: self._content.calculate_trans_chk.hide() self._content.bck_trans_label.hide() self._content.bck_trans_err_label.hide() self._content.transmission_edit.hide() self._content.dtransmission_edit.hide() self._content.calculate_trans_chk.hide() self._content.theta_dep_chk.hide() self._content.trans_direct_chk.hide() self._content.trans_spreader_chk.hide() self._content.trans_dark_current_label.hide() self._content.trans_dark_current_edit.hide() self._content.trans_dark_current_button.hide() if not self._in_mantidplot: self._content.background_plot_button.hide() self._content.trans_dark_current_plot_button.hide()
def prepareUi(self): self.setWindowTitle('AutoDoc v1.1 - Karogis') self.mTop.setValidator(QtGui.QDoubleValidator(0, 10, 2, self)) self.mBottom.setValidator(QtGui.QDoubleValidator(0, 10, 2, self)) self.mLeft.setValidator(QtGui.QDoubleValidator(0, 10, 2, self)) self.mRight.setValidator(QtGui.QDoubleValidator(0, 10, 2, self)) self.logger('====================================') self.logger('|| ***** www.karogis.com ***** ||') self.logger('====================================\n\n') self.logVisible = False self.toggleLog() self.statusbar.showMessage('Siap')
def set_validator(self): self.theta_offset_txt.setValidator(QtGui.QDoubleValidator()) self.center_offset_txt.setValidator(QtGui.QDoubleValidator()) self.soller_x_pos_txt.setValidator(QtGui.QDoubleValidator()) self.soller_z_pos_txt.setValidator(QtGui.QDoubleValidator()) self.soller_theta_pos_txt.setValidator(QtGui.QDoubleValidator()) self.soller_x_step_txt.setValidator(QtGui.QDoubleValidator()) self.soller_z_step_txt.setValidator(QtGui.QDoubleValidator()) self.soller_theta_step_txt.setValidator(QtGui.QDoubleValidator()) self.collection_time_txt.setValidator(QtGui.QDoubleValidator()) self.collection_angle_txt.setValidator(QtGui.QDoubleValidator())
def add_distforce_clicked(): #Create the dialog dialog = QtGui.QDialog() dialog_ui = Ui_Dist_Force_Dialog() dialog_ui.setupUi(dialog) #Initially, hide the ok button ok = dialog_ui.buttonBox.button(QtGui.QDialogButtonBox.Ok) ok.setEnabled(False) #Setup input validators start_validator = QtGui.QDoubleValidator() start_validator.setRange(0, beam.length, 5) end_validator = QtGui.QDoubleValidator() end_validator.setRange(0, beam.length, 5) magnitude_validator = QtGui.QDoubleValidator() magnitude_validator.setDecimals(5) #Apply the input validators dialog_ui.lineEdit_start.setValidator(start_validator) dialog_ui.lineEdit_end.setValidator(end_validator) dialog_ui.lineEdit_magnitude.setValidator(magnitude_validator) #Adjust the visibility of the ok button if the input is changed dialog_ui.lineEdit_start.textChanged.connect( lambda: adjust_ok_buttons_state_dist(dialog_ui, ok, end_validator)) dialog_ui.lineEdit_end.textChanged.connect( lambda: adjust_ok_buttons_state_dist(dialog_ui, ok, end_validator)) dialog_ui.lineEdit_magnitude.textChanged.connect( lambda: adjust_ok_buttons_state_dist(dialog_ui, ok, end_validator)) #Set the focus dialog_ui.lineEdit_start.setFocus() #Show the dialog dialog.exec_() #If ok is pressed, create the new distributed force if dialog.result(): interaction = Dist_Force(float(dialog_ui.lineEdit_start.text()), float(dialog_ui.lineEdit_magnitude.text()), float(dialog_ui.lineEdit_end.text())) beam.add_interaction(interaction) update_tree(beam)
def __init__(self, group_item, parent=None): """ Constructor """ super(BodyWidget, self).__init__(parent=parent) self._parent = parent self.ui = Ui_Form() self.ui.setupUi(self) # self.setFocusPolicy(QtCore.Qt.NoFocus)#self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) #self.setFocusPolicy(QtCore.Qt.NoFocus) # self.setFocusPolicy(QtCore.Qt.StrongFocus) # self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.FramelessWindowHint) self.setWindowFlags(self.windowFlags() | QtCore.Qt.Window) self.setParent(self._parent) self.setWindowModality(QtCore.Qt.WindowModal) # widget.show() self.group_item = group_item self.item = None self.ui.save_pushButton.setAutoDefault(True) # set validators to limit user input __validator_dbl = QtGui.QDoubleValidator() __validator_int = QtGui.QIntValidator() self.ui.R_lineEdit.setValidator(QtGui.QDoubleValidator()) # body id self.ui.bodyID_lineEdit.setValidator(__validator_int) # signals self.ui.cancel_pushButton.clicked.connect(self._cancel) self.ui.save_pushButton.clicked.connect(self._save) self.ui.save_pushButton.setFocus() self.ui.load_geometry_pushButton.clicked.connect(self._load_stl_file) self.ui.load_data_pushButton.clicked.connect(self._load_dat_file) self.ui.bodyID_lineEdit.setText(str(len(self.group_item._children))) self._move() # show first tab in qtabwidget self.ui.tabWidget.setCurrentIndex(0) # show widget self.raise_() self.show()
def __init__(self, user, parent=None): super(NewDepo, self).__init__(parent=parent) self.setWindowTitle(u'同业存款') self.user = user layout = QtGui.QGridLayout() layout.addWidget(QtGui.QLabel(u'交易日'), 0, 0, 1, 1) self.tradeDateTime = QtGui.QDateTimeEdit(datetime.datetime.now()) self.tradeDateTime.setCalendarPopup(True) layout.addWidget(self.tradeDateTime, 0, 1, 1, 1) layout.addWidget(QtGui.QLabel(u'账簿'), 1, 0, 1, 1) q = QtSql.QSqlQuery('SELECT NAME_CN FROM BOOKS ORDER BY ID') books = [] while q.next(): books.append(q.value(0).toString()) self.books = QtGui.QComboBox() self.books.addItems(books) layout.addWidget(self.books, 1, 1, 1, 1) layout.addWidget(QtGui.QLabel(u'金额'), 2, 0, 1, 1) self.amount = QtGui.QLineEdit() self.amount.setValidator(QtGui.QDoubleValidator()) self.amount.textChanged.connect(self.update_total) layout.addWidget(self.amount, 2, 1, 1, 1) layout.addWidget(QtGui.QLabel(u'收益率(%)'), 3, 0, 1, 1) self.rtn = QtGui.QLineEdit() self.rtn.setValidator(QtGui.QDoubleValidator()) self.rtn.textChanged.connect(self.update_total) layout.addWidget(self.rtn, 3, 1, 1, 1) layout.addWidget(QtGui.QLabel(u'到期日'), 4, 0, 1, 1) self.expdate = QtGui.QDateEdit(datetime.date.today()) self.expdate.setCalendarPopup(True) self.expdate.dateChanged.connect(self.update_total) layout.addWidget(self.expdate, 4, 1, 1, 1) layout.addWidget(QtGui.QLabel(u'计息方式'), 5, 0, 1, 1) self.dcc = QtGui.QComboBox() self.dcc.addItems(['Act/360']) layout.addWidget(self.dcc, 5, 1, 1, 1) layout.addWidget(QtGui.QLabel(u'到期金额'), 6, 0, 1, 1) self.total = QtGui.QLineEdit() self.total.setReadOnly(True) self.total.setValidator(QtGui.QDoubleValidator()) layout.addWidget(self.total, 6, 1, 1, 1) layout.addWidget(QtGui.QLabel(u'交易对手'), 7, 0, 1, 1) self.comment = QtGui.QLineEdit() layout.addWidget(self.comment, 7, 1, 1, 1) btnLayout = QtGui.QHBoxLayout() btnLayout.addWidget(self.ok) btnLayout.addWidget(self.cancel) layout.addLayout(btnLayout, 8, 0, 1, 2) self.setLayout(layout)
def addStation(self): #print(type(add_dialog),dir(add_dialog)) transformneeded = True X_coord = 0 Y_coord = 0 Z_coord = 0 lam_coord = 0 fi_coord = 0 height_coord = 0 Name = 'station' if (self.add_dialog.exec_() == QtGui.QDialog.Accepted): reg_ex = QRegExp("[a-z-A-Z_]+") rgx = QtGui.QRegExpValidator(reg_ex) x_v = QtGui.QDoubleValidator(-1e7, 1e7, 15) y_v = QtGui.QDoubleValidator(-1e7, 1e7, 15) z_v = QtGui.QDoubleValidator(-1e7, 1e7, 15) self.add_dialog.name_station.setValidator(rgx) self.add_dialog.lineEdit_x_coord.setValidator(x_v) self.add_dialog.lineEdit_y_coord.setValidator(y_v) self.add_dialog.lineEdit_y_coord.setValidator(z_v) Name = self.add_dialog.name_station.text() if (self.add_dialog.Geocentric.isChecked()): transformneeded = True X_coord = self.add_dialog.lineEdit_x_coord.text() Y_coord = add_dialog.lineEdit_y_coord.text() Z_coord = self.add_dialog.lineEdit_z_coord.text() X_coord = np.double(X_coord) Y_coord = np.double(Y_coord) Z_coord = np.double(Z_coord) elif (self.add_dialog.Geographic.isChecked()): transformneeded = False lam_coord = self.add_dialog.lineEdit_x_coord.text() fi_coord = self.add_dialog.lineEdit_y_coord.text() height_coord = self.add_dialog.lineEdit_z_coord.text() lam_coord = np.double(lam_coord) fi_coord = np.double(fi_coord) height_coord = np.double(height_coord) else: print("not checked") if (transformneeded): trans = Transform.transform() lam_coord,fi_coord,height_coord=trans.transform2geog(X_coord,Y_coord,Z_coord,\ e1_terrestre,f,a_terrestre) lam_coord = lam_coord * 180.0 / np.pi fi_coord = fi_coord * 180.0 / np.pi height_coord = height_coord * 180.0 / np.pi self.gnss_plugin.saveStation(Name, lam_coord, fi_coord, height_coord) self.add_dialog.done(QtGui.QDialog.Accepted)
def __init__(self, text='', width=70, height=20, font_size=default_font_size, val_range=None, enabled=True, highlight_nonvalid=False, int_validator=False, read_only=False): super(UiQLineEditDouble, self).__init__() self.font_size = font_size self.highlight_nonvalid = highlight_nonvalid if val_range: if int_validator: validator = QtGui.QIntValidator(val_range[0], val_range[1], self) validator.setNotation(QtGui.QIntValidator.StandardNotation) else: validator = QtGui.QDoubleValidator(val_range[0], val_range[1], 5, self) validator.setNotation(QtGui.QDoubleValidator.StandardNotation) else: if int_validator: validator = QtGui.QIntValidator() else: validator = QtGui.QDoubleValidator() if read_only: self.setReadOnly(True) self.setValidator(validator) if width: self.setFixedWidth(width) if height: self.setFixedHeight(height) self.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.setStyleSheet( 'QLineEdit { font:' + str(self.font_size) + 'px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);}') self.setText(text) self.setEnabled(enabled) if self.highlight_nonvalid: self.textChanged.connect(self.highlightNonValid) self.highlightNonValid()
def __init__(self, parentWindow): QtGui.QDialog.__init__(self, parentWindow) layout = QtGui.QVBoxLayout(self) self.setWindowTitle("Log transform") layout.addWidget(QtGui.QLabel("Function: c * Log(i+1)")) self.center = QtGui.QWidget(self) self.layout1 = QtGui.QHBoxLayout(self.center) self.center.setLayout(self.layout1) self.layout1.addWidget(QtGui.QLabel("c =")) self.textfieldC = QtGui.QLineEdit(self.center) self.textfieldC.setValidator( QtGui.QDoubleValidator(self.textfieldC)) self.layout1.addWidget(self.textfieldC) layout.addWidget(self.center) self.buttons = QtGui.QWidget(self) self.layout2 = QtGui.QHBoxLayout(self.buttons) self.buttons.setLayout(self.layout2) self.buttonOk = QtGui.QPushButton("OK") self.buttonOk.clicked.connect(self.ok) self.buttonCancel = QtGui.QPushButton("Cancel") self.buttonCancel.clicked.connect(self.close) self.layout2.addWidget(self.buttonOk) self.layout2.addWidget(self.buttonCancel) layout.addWidget(self.buttons) self.resize(300, self.size().height())
def initialize_content(self): # Constraints for widget in [ self._content.median_test_high_edit, self._content.median_test_low_edit, self._content.median_test_out_high_edit, self._content.median_test_out_low_edit, self._content.errorbar_crit_edit, self._content.ratio_var_crit_edit, self._content.sambkg_median_test_high_edit, self._content.sambkg_median_test_low_edit, self._content.sambkg_errorbar_crit_edit ]: dvp = QtGui.QDoubleValidator(widget) dvp.setBottom(0.0) widget.setValidator(dvp) for widget in [ self._content.tof_start_edit, self._content.tof_end_edit ]: ivp = QtGui.QIntValidator(widget) ivp.setBottom(0) widget.setValidator(ivp) # Connections self.connect(self._content.det_van2_browse, QtCore.SIGNAL("clicked()"), self._det_van2_browse)
def entry(self): box = QtGui.QLineEdit(self) box.setValidator(QtGui.QDoubleValidator()) box.setMaxLength(10) box.move(200, 2 + self.info.frameRect().height()) box.setFont(QtGui.QFont("Arial", 20)) return box