예제 #1
0
    def __getProfileLimitsGroupbox( self ):
        " Creates the profile limits groupbox "
        limitsGroupbox = QGroupBox( self )
        limitsGroupbox.setTitle( "Profiler diagram limits" )
        sizePolicy = QSizePolicy( QSizePolicy.Expanding, QSizePolicy.Preferred )
        sizePolicy.setHorizontalStretch( 0 )
        sizePolicy.setVerticalStretch( 0 )
        sizePolicy.setHeightForWidth(
                limitsGroupbox.sizePolicy().hasHeightForWidth() )
        limitsGroupbox.setSizePolicy( sizePolicy )

        layoutLimits = QGridLayout( limitsGroupbox )
        self.__nodeLimitEdit = QLineEdit()
        self.__nodeLimitEdit.textEdited.connect( self.__setRunButtonProps )
        self.__nodeLimitValidator = QDoubleValidator( 0.0, 100.0, 2, self )
        self.__nodeLimitValidator.setNotation( QDoubleValidator.StandardNotation )
        self.__nodeLimitEdit.setValidator( self.__nodeLimitValidator )
        nodeLimitLabel = QLabel( "Hide nodes below" )
        self.__edgeLimitEdit = QLineEdit()
        self.__edgeLimitEdit.textEdited.connect( self.__setRunButtonProps )
        self.__edgeLimitValidator = QDoubleValidator( 0.0, 100.0, 2, self )
        self.__edgeLimitValidator.setNotation( QDoubleValidator.StandardNotation )
        self.__edgeLimitEdit.setValidator( self.__edgeLimitValidator )
        edgeLimitLabel = QLabel( "Hide edges below" )
        layoutLimits.addWidget( nodeLimitLabel, 0, 0 )
        layoutLimits.addWidget( self.__nodeLimitEdit, 0, 1 )
        layoutLimits.addWidget( QLabel( "%" ), 0, 2 )
        layoutLimits.addWidget( edgeLimitLabel, 1, 0 )
        layoutLimits.addWidget( self.__edgeLimitEdit, 1, 1 )
        layoutLimits.addWidget( QLabel( "%" ), 1, 2 )
        return limitsGroupbox
예제 #2
0
    def __getProfileLimitsGroupbox(self):
        " Creates the profile limits groupbox "
        limitsGroupbox = QGroupBox(self)
        limitsGroupbox.setTitle("Profiler diagram limits")
        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            limitsGroupbox.sizePolicy().hasHeightForWidth())
        limitsGroupbox.setSizePolicy(sizePolicy)

        layoutLimits = QGridLayout(limitsGroupbox)
        self.__nodeLimitEdit = QLineEdit()
        self.__nodeLimitEdit.textEdited.connect(self.__setRunButtonProps)
        self.__nodeLimitValidator = QDoubleValidator(0.0, 100.0, 2, self)
        self.__nodeLimitValidator.setNotation(
            QDoubleValidator.StandardNotation)
        self.__nodeLimitEdit.setValidator(self.__nodeLimitValidator)
        nodeLimitLabel = QLabel("Hide nodes below")
        self.__edgeLimitEdit = QLineEdit()
        self.__edgeLimitEdit.textEdited.connect(self.__setRunButtonProps)
        self.__edgeLimitValidator = QDoubleValidator(0.0, 100.0, 2, self)
        self.__edgeLimitValidator.setNotation(
            QDoubleValidator.StandardNotation)
        self.__edgeLimitEdit.setValidator(self.__edgeLimitValidator)
        edgeLimitLabel = QLabel("Hide edges below")
        layoutLimits.addWidget(nodeLimitLabel, 0, 0)
        layoutLimits.addWidget(self.__nodeLimitEdit, 0, 1)
        layoutLimits.addWidget(QLabel("%"), 0, 2)
        layoutLimits.addWidget(edgeLimitLabel, 1, 0)
        layoutLimits.addWidget(self.__edgeLimitEdit, 1, 1)
        layoutLimits.addWidget(QLabel("%"), 1, 2)
        return limitsGroupbox
예제 #3
0
    def createDialog (self):
        """
        Create qt dialog
        """
                
        self.TIMEOUT_ACTION = Settings.instance().readValue( key = 'TestGenerator/timeout-framework-action' )

        self.timeoutLine = QLineEdit()
        self.timeoutLine.setText(str(self.TIMEOUT_ACTION))
        validatorTimeout = QDoubleValidator(self)
        validatorTimeout.setNotation(QDoubleValidator.StandardNotation)
        self.timeoutLine.setValidator(validatorTimeout)
        self.timeoutLine.installEventFilter(self)

        optionLayout = QHBoxLayout()
        optionLayout.addWidget(QLabel( self.tr("Max time to run action (in seconds):") ) )
        optionLayout.addWidget(self.timeoutLine)

        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setStyleSheet( """QDialogButtonBox { 
            dialogbuttonbox-buttons-have-icons: 1;
            dialog-ok-icon: url(:/ok.png);
            dialog-cancel-icon: url(:/ko.png);
        }""")
        self.buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)

        mainLayout = QVBoxLayout()
        mainLayout.addLayout(optionLayout)
        mainLayout.addWidget(self.buttonBox)
        self.setLayout(mainLayout)

        self.setWindowTitle(self.tr("Framework Options"))
예제 #4
0
 def __init__(self, module, parent=None ):
     """Constructor."""
     super(fdtmSettingsDialog, self).__init__(parent)
     self.iface = module.iface
     self.setupUi(self)
     self.DEMLayer.setFilters(QgsMapLayerProxyModel.RasterLayer)
     self.isValidated = None
     self.newProjectIsNotYetSaved = None
     self.buttonBox.accepted.connect(self.datasetValidation)
     self.exportProjectButton.clicked.connect(self.export_action)
     self.exportProjectButton.setEnabled(False)
     self.averagePrecipitation.setText('10')
     self.defaultRoadsWidth.setText('8')
     self.averagePrecipitation.setValidator(QDoubleValidator(0, 1000, 2, self.averagePrecipitation) )
     self.defaultRoadsWidth.setValidator(QDoubleValidator(0, 100, 2, self.defaultRoadsWidth) )
     self.defaultRoadsWidth.hide()
     self.defaultRoadsWidthLabel.hide()
     self.projectFolderPath.hide()
     self.projectFolderLabel.hide()
     #self.projection.setOptionVisible(QgsProjectionSelectionWidget.ProjectCrs,True)
     self.updateDataset = None
     self.averagePrecipitationChanged = None
     self.setNullProjectFiles()
     self.setOptionalSupportFiles()
     self.validated.connect(self.handleUpdateSignals)
     self.debugCheck.stateChanged.connect(self.toggleDebug)
     self.qgis_stdout = sys.stdout
     self.debugCheck.setChecked(False)
     self.debugCheck.hide()
     self.debugLabel.hide()
     self.allowValidationLabel.show()
     self.adjustSize()
     self.loadRCCombo()
     self.activate()
    def createAdditionalControlWidgets(self):
        self.windowChooser = QComboBox()
        self.windowChooser.addItems(self.prm['data']['available_windows'])
        self.windowChooser.setCurrentIndex(self.windowChooser.findText(self.prm['pref']['smoothingWindow']))
        self.windowChooserLabel = QLabel(self.tr('Window:'))
        self.gridBox.addWidget(self.windowChooserLabel, 0, 4)
        self.gridBox.addWidget(self.windowChooser, 0, 5)
        self.windowChooser.currentIndexChanged[int].connect(self.onChangeWindowFunction)

        self.winLengthLabel= QLabel(self.tr('Window Length (s)'))
        self.winLengthWidget = QLineEdit(self.currLocale.toString(0)) 
        self.winLengthWidget.setValidator(QDoubleValidator(self))
        self.gridBox.addWidget(self.winLengthLabel, 2, 0)
        self.gridBox.addWidget(self.winLengthWidget, 2, 1)

        self.winOverlapLabel= QLabel(self.tr('Overlap (%)'))
        self.winOverlapWidget = QLineEdit(self.currLocale.toString(0)) 
        self.winOverlapWidget.setValidator(QDoubleValidator(self))
        self.gridBox.addWidget(self.winOverlapLabel, 2, 2)
        self.gridBox.addWidget(self.winOverlapWidget, 2, 3)

        self.cmapChooserLabel = QLabel(self.tr('Color Map:'))
        self.gridBox.addWidget(self.cmapChooserLabel, 1, 4)
        self.cmapChooser = QComboBox()
        self.cmapChooser.addItems(self.prm['data']['available_colormaps'])
        self.cmapChooser.setCurrentIndex(self.cmapChooser.findText(self.prm['pref']['colormap']))
        self.gridBox.addWidget(self.cmapChooser, 1, 5)

        self.windowChooser.currentIndexChanged[int].connect(self.onChangeWindowFunction)
        self.cmapChooser.currentIndexChanged[int].connect(self.onChangeWindowFunction)
        self.winLengthWidget.editingFinished.connect(self.onChangeWindowFunction)
        self.winOverlapWidget.editingFinished.connect(self.onChangeWindowFunction)
예제 #6
0
	def __init__(self, *args, **kwargs):
		abstractCustomMinMaxLineEdit.__init__(self, *args, **kwargs)
		
		self._setType(self.FLOAT)
		validator = QDoubleValidator()
		validator.setNotation(QDoubleValidator.StandardNotation)
		self.setValidator(validator)
예제 #7
0
def double_validator(widget,
                     min=0,
                     max=999999,
                     decimals=3,
                     notation=QDoubleValidator().StandardNotation):
    validator = QDoubleValidator(min, max, decimals)
    validator.setNotation(notation)
    widget.setValidator(validator)
    def __init__(self):
        super().__init__()

        box0 = gui.widgetBox(self.controlArea, " ",orientation="horizontal") 
        #widget buttons: compute, set defaults, help
        gui.button(box0, self, "Compute", callback=self.calculate_IdealPhaseRetarder)
        gui.button(box0, self, "Defaults", callback=self.defaults)
        gui.button(box0, self, "Help", callback=self.get_doc)
        self.process_showers()
        box = gui.widgetBox(self.controlArea, " ",orientation="vertical") 
        
        
        idx = -1 
        
        # widget index 0 
        idx += 1 
        box1 = gui.widgetBox(box) 
        gui.comboBox(box1, self, "TYPE",
                     label=self.unitLabels()[idx], addSpace=True,
                     items=['general', 'Quarter Wave Plate (fast-axis horizontal)', 'Quarter Wave Plate (fast-axis vertical)', 'Half Wave Plate (also Ideal Mirror)'],
                     valueType=int, orientation="horizontal")
        self.show_at(self.unitFlags()[idx], box1) 
        
        # widget index 1 
        idx += 1 
        box1 = gui.widgetBox(box) 
        gui.lineEdit(box1, self, "THETA",
                     label=self.unitLabels()[idx], addSpace=True,
                     valueType=float, validator=QDoubleValidator())
        self.show_at(self.unitFlags()[idx], box1) 
        
        # widget index 2 
        idx += 1 
        box1 = gui.widgetBox(box) 
        gui.lineEdit(box1, self, "DELTA",
                     label=self.unitLabels()[idx], addSpace=True,
                     valueType=float, validator=QDoubleValidator())
        self.show_at(self.unitFlags()[idx], box1) 

        # widget index 3
        idx += 1
        box1 = gui.widgetBox(box)
        gui.comboBox(box1, self, "DUMP_TO_FILE",
                     label=self.unitLabels()[idx], addSpace=True,
                     items=["No","Yes"],
                     orientation="horizontal")
        self.show_at(self.unitFlags()[idx], box1)

        # widget index 4
        idx += 1
        box1 = gui.widgetBox(box)
        gui.lineEdit(box1, self, "FILE_NAME",
                     label=self.unitLabels()[idx], addSpace=True)
        self.show_at(self.unitFlags()[idx], box1)

        gui.rubber(self.controlArea)
예제 #9
0
    def __init__(self, parent=None):
        super(NumberWidgetConfig, self).__init__(parent)
        self.setupUi(self)
        self.minEdit.setValidator(QDoubleValidator())
        self.maxEdit.setValidator(QDoubleValidator())

        self.minEdit.textChanged.connect(self.widgetchanged)
        self.maxEdit.textChanged.connect(self.widgetchanged)
        self.prefixEdit.textChanged.connect(self.widgetchanged)
        self.suffixEdit.textChanged.connect(self.widgetchanged)
예제 #10
0
 def __init__(self, value, decimals=1):
     super(QTrapProperty, self).__init__()
     self.setAlignment(Qt.AlignRight)
     self.setMaximumWidth(50)
     self.setMaxLength(7)
     self.fmt = '%' + '.%df' % decimals
     v = QDoubleValidator(decimals=decimals)
     v.setNotation(QDoubleValidator.StandardNotation)
     self.setValidator(v)
     self.value = value
     self.returnPressed.connect(self.updateValue)
예제 #11
0
 def __init__(self, bottom=float_info.min, top=float_info.max, decimals=float_info.dig, parent=None):
     """Initiates the class.
     
     Args:
         bottom: Float minimum value.
         top: Float maximum value.
         decimals: Integer representing decimals.
         parent: Parent object.
     """
     QDoubleValidator.__init__(self, bottom, top, decimals, parent)
     self.setNotation(QDoubleValidator.ScientificNotation)
예제 #12
0
    def createDoubleLineEdit(self, minimum=None, maximum=None, placeholder=""):
        line_edit = ClearableLineEdit(placeholder=placeholder)
        validator = QDoubleValidator()

        if minimum is not None:
            validator.setBottom(minimum)

        if maximum is not None:
            validator.setTop(maximum)

        line_edit.setValidator(validator)
        return line_edit
예제 #13
0
 def set_coords_limits(self):
     """
     sets min and max X and Y coords for user input validation
     :return: void
     """
     self.coords_line_edit_list = self.coords_dlg.findChildren(QLineEdit)
     x_coords_validator = QDoubleValidator(-100000.00, 600000.00, 2, None)
     y_coords_validator = QDoubleValidator(100000.00, 1300000.00, 2, None)
     for coords_line_edit in self.coords_line_edit_list:
         if "X" in coords_line_edit.objectName():
             coords_line_edit.setValidator(x_coords_validator)
         else:
             coords_line_edit.setValidator(y_coords_validator)
예제 #14
0
    def ud_options(self):
        """ Dialog ud_options.ui """

        # Create dialog
        dlg_udoptions = UDoptions()
        utils_giswater.setDialog(dlg_udoptions)

        dlg_udoptions.min_slope.setValidator(QDoubleValidator())
        dlg_udoptions.lengthening_step.setValidator(QDoubleValidator())
        dlg_udoptions.max_trials.setValidator(QIntValidator())
        dlg_udoptions.sys_flow_tol.setValidator(QIntValidator())
        dlg_udoptions.variable_step.setValidator(QIntValidator())
        dlg_udoptions.min_surfarea.setValidator(QIntValidator())
        dlg_udoptions.head_tolerance.setValidator(QDoubleValidator())
        dlg_udoptions.lat_flow_tol.setValidator(QIntValidator())

        # Set values from widgets of type QComboBox
        sql = "SELECT DISTINCT(id) FROM " + self.schema_name + ".inp_value_options_fu ORDER BY id"
        rows = self.dao.get_rows(sql)
        utils_giswater.fillComboBox("flow_units", rows, False)
        sql = "SELECT DISTINCT(id) FROM " + self.schema_name + ".inp_value_options_fr ORDER BY id"
        rows = self.dao.get_rows(sql)
        utils_giswater.fillComboBox("flow_routing", rows, False)
        sql = "SELECT DISTINCT(id) FROM " + self.schema_name + ".inp_value_options_lo ORDER BY id"
        rows = self.dao.get_rows(sql)
        utils_giswater.fillComboBox("link_offsets", rows, False)
        sql = "SELECT DISTINCT(id) FROM " + self.schema_name + ".inp_value_options_fme ORDER BY id"
        rows = self.dao.get_rows(sql)
        utils_giswater.fillComboBox("force_main_equation", rows, False)
        sql = "SELECT DISTINCT(id) FROM " + self.schema_name + ".inp_value_options_nfl ORDER BY id"
        rows = self.dao.get_rows(sql)
        utils_giswater.fillComboBox("normal_flow_limited", rows, False)
        sql = "SELECT DISTINCT(id) FROM " + self.schema_name + ".inp_value_options_id ORDER BY id"
        rows = self.dao.get_rows(sql)
        utils_giswater.fillComboBox("inertial_damping", rows, False)
        sql = "SELECT DISTINCT(id) FROM " + self.schema_name + ".value_yesno ORDER BY id"
        rows = self.dao.get_rows(sql)
        utils_giswater.fillComboBox("allow_ponding", rows, False)
        utils_giswater.fillComboBox("skip_steady_state", rows, False)
        utils_giswater.fillComboBox("ignore_rainfall", rows, False)
        utils_giswater.fillComboBox("ignore_snowmelt", rows, False)
        utils_giswater.fillComboBox("ignore_groundwater", rows, False)
        utils_giswater.fillComboBox("ignore_routing", rows, False)
        utils_giswater.fillComboBox("ignore_quality", rows, False)
        update = True
        dlg_udoptions.btn_accept.pressed.connect(
            partial(self.insert_or_update, update, 'inp_options',
                    dlg_udoptions))
        dlg_udoptions.btn_cancel.pressed.connect(dlg_udoptions.close)
        self.go2epa_options_get_data('inp_options')
        dlg_udoptions.exec_()
예제 #15
0
 def __init__(self, iface):
     QDialog.__init__(self, iface.mainWindow())
     self.iface = iface
     self.setupUi(self)
     self.xMin.setValidator(QDoubleValidator(self.xMin))
     self.xMax.setValidator(QDoubleValidator(self.xMax))
     self.yMin.setValidator(QDoubleValidator(self.yMin))
     self.yMax.setValidator(QDoubleValidator(self.yMax))
     QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
     self.setWindowTitle(self.tr("Regular points"))
     self.buttonOk = self.buttonBox_2.button(QDialogButtonBox.Ok)
     self.progressBar.setValue(0)
     self.mapCanvas = self.iface.mapCanvas()
     self.populateLayers()
예제 #16
0
    def __init__(self, parent):
        QDialog.__init__(self, parent)
        self.prm = parent.prm
        self.currLocale = self.parent().prm['data']['currentLocale']
        self.currLocale.setNumberOptions(
            self.currLocale.OmitGroupSeparator
            | self.currLocale.RejectGroupSeparator)
        vbl = QVBoxLayout()
        self.grid = QGridLayout()

        filterTypeLabel = QLabel(self.tr('Filter Type: '))
        self.filterChooser = QComboBox()
        self.filterChooser.addItems([
            self.tr('lowpass'),
            self.tr('highpass'),
            self.tr('bandpass'),
            self.tr('bandstop')
        ])
        self.filterChooser.setCurrentIndex(0)
        self.grid.addWidget(self.filterChooser, 0, 1)
        self.filterChooser.currentIndexChanged[int].connect(
            self.onChangeFilterType)
        self.filterOrderLabel = QLabel(self.tr('Filter Order: '))
        self.filterOrderWidget = QLineEdit('256')
        self.filterOrderWidget.setValidator(QIntValidator(self))
        self.grid.addWidget(self.filterOrderLabel, 0, 2)
        self.grid.addWidget(self.filterOrderWidget, 0, 3)

        self.currFilterType = self.tr('lowpass')
        self.cutoffLabel = QLabel(self.tr('Cutoff: '))
        self.endCutoffLabel = QLabel(self.tr('End Transition Band = Cutoff *'))
        self.cutoffWidget = QLineEdit('')
        self.cutoffWidget.setValidator(QDoubleValidator(self))
        endCutoff = 1.2
        self.endCutoffWidget = QLineEdit(self.currLocale.toString(endCutoff))
        self.endCutoffWidget.setValidator(QDoubleValidator(self))
        self.grid.addWidget(self.cutoffLabel, 2, 1)
        self.grid.addWidget(self.cutoffWidget, 2, 2)
        self.grid.addWidget(self.endCutoffLabel, 2, 3)
        self.grid.addWidget(self.endCutoffWidget, 2, 4)

        buttonBox = QDialogButtonBox(QDialogButtonBox.Ok
                                     | QDialogButtonBox.Cancel)
        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)

        vbl.addLayout(self.grid)
        vbl.addWidget(buttonBox)
        self.setLayout(vbl)
        self.setWindowTitle(self.tr("Apply Filter"))
예제 #17
0
    def build_gui(self):

        box = oasysgui.widgetBox(self.controlArea,
                                 self.name + " Input Parameters",
                                 orientation="vertical",
                                 width=self.CONTROL_AREA_WIDTH - 5)

        idx = -1

        #widget index 0
        idx += 1
        box1 = gui.widgetBox(box)
        oasysgui.lineEdit(box1,
                          self,
                          "VOLTAGE",
                          label=self.unitLabels()[idx],
                          addSpace=False,
                          valueType=float,
                          validator=QDoubleValidator(),
                          orientation="horizontal",
                          labelWidth=250)
        self.show_at(self.unitFlags()[idx], box1)

        #widget index 1
        idx += 1
        box1 = gui.widgetBox(box)
        oasysgui.lineEdit(box1,
                          self,
                          "RIPPLE",
                          label=self.unitLabels()[idx],
                          addSpace=False,
                          valueType=float,
                          validator=QDoubleValidator(),
                          orientation="horizontal",
                          labelWidth=250)
        self.show_at(self.unitFlags()[idx], box1)

        #widget index 2
        idx += 1
        box1 = gui.widgetBox(box)
        oasysgui.lineEdit(box1,
                          self,
                          "AL_FILTER",
                          label=self.unitLabels()[idx],
                          addSpace=False,
                          valueType=float,
                          validator=QDoubleValidator(),
                          orientation="horizontal",
                          labelWidth=250)
        self.show_at(self.unitFlags()[idx], box1)
예제 #18
0
파일: BC_Mirror.py 프로젝트: hlp2002/XOPPY
    def __init__(self):
        super().__init__()

        box0 = gui.widgetBox(self.controlArea, " ", orientation="horizontal")
        #widget buttons: compute, set defaults, help
        gui.button(box0, self, "Compute", callback=self.compute)
        gui.button(box0, self, "Defaults", callback=self.defaults)
        gui.button(box0, self, "Help", callback=self.help1)
        self.process_showers()
        box = gui.widgetBox(self.controlArea, " ", orientation="vertical")

        idx = -1

        #widget index 0
        idx += 1
        box1 = gui.widgetBox(box)
        gui.lineEdit(box1,
                     self,
                     "coating",
                     label=self.unitLabels()[idx],
                     addSpace=True)
        self.show_at(self.unitFlags()[idx], box1)

        #widget index 1
        idx += 1
        box1 = gui.widgetBox(box)
        gui.lineEdit(box1,
                     self,
                     "thickness",
                     label=self.unitLabels()[idx],
                     addSpace=True,
                     valueType=float,
                     validator=QDoubleValidator())
        self.show_at(self.unitFlags()[idx], box1)

        #widget index 2
        idx += 1
        box1 = gui.widgetBox(box)
        gui.lineEdit(box1,
                     self,
                     "density",
                     label=self.unitLabels()[idx],
                     addSpace=True,
                     valueType=float,
                     validator=QDoubleValidator())
        self.show_at(self.unitFlags()[idx], box1)

        self.process_showers()
        gui.rubber(self.controlArea)
예제 #19
0
    def ud_options(self):
        """ Dialog ud_options.ui """
        
        # Create dialog
        dlg_udoptions = UDoptions()
        self.load_settings(dlg_udoptions)

        dlg_udoptions.min_slope.setValidator(QDoubleValidator())
        dlg_udoptions.lengthening_step.setValidator(QDoubleValidator())
        dlg_udoptions.max_trials.setValidator(QIntValidator())
        dlg_udoptions.sys_flow_tol.setValidator(QIntValidator())
        dlg_udoptions.variable_step.setValidator(QIntValidator())
        dlg_udoptions.min_surfarea.setValidator(QIntValidator())
        dlg_udoptions.head_tolerance.setValidator(QDoubleValidator())
        dlg_udoptions.lat_flow_tol.setValidator(QIntValidator())

        # Set values from widgets of type QComboBox
        sql = "SELECT DISTINCT(id) FROM "+self.schema_name+".inp_value_options_fu ORDER BY id"
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox(dlg_udoptions, dlg_udoptions.flow_units, rows, False)
        sql = "SELECT DISTINCT(id) FROM "+self.schema_name+".inp_value_options_fr ORDER BY id"
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox(dlg_udoptions, dlg_udoptions.flow_routing, rows, False)
        sql = "SELECT DISTINCT(id) FROM "+self.schema_name+".inp_value_options_lo ORDER BY id"
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox(dlg_udoptions, dlg_udoptions.link_offsets, rows, False)
        sql = "SELECT DISTINCT(id) FROM "+self.schema_name+".inp_value_options_fme ORDER BY id"
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox(dlg_udoptions, dlg_udoptions.force_main_equation, rows, False)
        sql = "SELECT DISTINCT(id) FROM "+self.schema_name+".inp_value_options_nfl ORDER BY id"
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox(dlg_udoptions, dlg_udoptions.normal_flow_limited, rows, False)
        sql = "SELECT DISTINCT(id) FROM "+self.schema_name+".inp_value_options_id ORDER BY id"
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox(dlg_udoptions, dlg_udoptions.inertial_damping, rows, False)
        sql = "SELECT DISTINCT(id) FROM "+self.schema_name+".value_yesno ORDER BY id"
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox(dlg_udoptions, dlg_udoptions.allow_ponding, rows, False)
        utils_giswater.fillComboBox(dlg_udoptions, dlg_udoptions.skip_steady_state, rows, False)
        utils_giswater.fillComboBox(dlg_udoptions, dlg_udoptions.ignore_rainfall, rows, False)
        utils_giswater.fillComboBox(dlg_udoptions, dlg_udoptions.ignore_snowmelt, rows, False)
        utils_giswater.fillComboBox(dlg_udoptions, dlg_udoptions.ignore_groundwater, rows, False)
        utils_giswater.fillComboBox(dlg_udoptions, dlg_udoptions.ignore_routing, rows, False)
        utils_giswater.fillComboBox(dlg_udoptions, dlg_udoptions.ignore_quality, rows, False)
        dlg_udoptions.btn_accept.clicked.connect(partial(self.update_table, 'inp_options', dlg_udoptions))
        dlg_udoptions.btn_cancel.clicked.connect(dlg_udoptions.close)
        self.go2epa_options_get_data('inp_options', dlg_udoptions)
        dlg_udoptions.setWindowFlags(Qt.WindowStaysOnTopHint)
        dlg_udoptions.exec_()
예제 #20
0
    def get_point(self, virtual_layer_name):
    
        validator = QDoubleValidator(0.00, 999.00, 3)
        validator.setNotation(QDoubleValidator().StandardNotation)

        self.dlg_create_circle.radius.setValidator(validator)
        self.dlg_create_circle.btn_accept.pressed.connect(self.get_radius)
        self.dlg_create_circle.btn_cancel.pressed.connect(self.cancel)
        self.dlg_create_circle.radius.setFocus()

        self.active_layer = self.iface.mapCanvas().currentLayer()
        self.virtual_layer_polygon = self.controller.get_layer_by_layername(virtual_layer_name, True)
        
        # Open dialog
        self.open_dialog(self.dlg_create_circle, maximize_button=False)
예제 #21
0
    def __init__(self, parent=None):
        super(NumberWidgetConfig, self).__init__(parent)
        self.setupUi(self)
        self.minEdit.setValidator(QDoubleValidator())
        self.maxEdit.setValidator(QDoubleValidator())

        self.minEdit.textChanged.connect(self.widgetchanged)
        self.maxEdit.textChanged.connect(self.widgetchanged)
        self.prefixEdit.textChanged.connect(self.widgetchanged)
        self.suffixEdit.textChanged.connect(self.widgetchanged)
        self.places_spin.valueChanged.connect(self.widgetchanged)
        self.step_spin.valueChanged.connect(self.widgetchanged)

        self.places_spin.setVisible(False)
        self.places_label.setVisible(False)
예제 #22
0
    def __init__(self, edge, line_name, proc_ev):
        super(Dialog_edge, self).__init__()

        # Entry window name
        self.setWindowTitle("Line {}-{}".format(line_name[0], line_name[1]))

        # Entry forms
        self.entry_susceptance = QLineEdit()
        self.entry_susceptance.setText(str(edge["susceptance"]))
        self.entry_susceptance.setValidator(QDoubleValidator(0.01, 10, 2))

        self.entry_status = QCheckBox()
        self.entry_status.setChecked(edge["status"])

        self.layout = QFormLayout()
        self.layout.addRow("Susceptance", self.entry_susceptance)
        self.layout.addRow("Connected", self.entry_status)

        # Entry window set button
        self.button = QPushButton()
        self.button.setText("Set")
        self.button.clicked.connect(partial(self.button_click, edge))
        self.layout.addWidget(self.button)

        # Set entry window layout
        self.setLayout(self.layout)

        self.proc_ev = proc_ev
        self.show()
예제 #23
0
 def __init__(self, iface):
     QDialog.__init__(self, iface.mainWindow())
     self.iface = iface
     self.setupUi(self)
     QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
     QObject.connect(self.spnX, SIGNAL("valueChanged(double)"), self.offset)
     QObject.connect(self.btnUpdate, SIGNAL("clicked()"), self.updateLayer)
     QObject.connect(self.btnCanvas, SIGNAL("clicked()"), self.updateCanvas)
     QObject.connect(self.chkAlign, SIGNAL("toggled(bool)"), self.chkAlignToggled)
     self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
     self.setWindowTitle(self.tr("Vector grid"))
     self.xMin.setValidator(QDoubleValidator(self.xMin))
     self.xMax.setValidator(QDoubleValidator(self.xMax))
     self.yMin.setValidator(QDoubleValidator(self.yMin))
     self.yMax.setValidator(QDoubleValidator(self.yMax))
     self.populateLayers()
예제 #24
0
 def createEditor(self, parent, option, index):
     editor = QLineEdit(parent)
     if index.column() == 0:
         editor.setValidator(QDoubleValidator(0, 1, 6, editor))
     else:
         editor.setInputMask(r"\#HHHHHHHH")
     return editor
예제 #25
0
 def setDefaultParameters(self):
 
     self.field = list(range(self.sndPrm['nFields']))
     self.fieldLabel = list(range(self.sndPrm['nFields']))
     fieldLabelColumn = 0
     fieldColumn = 1
     chooserLabelColumn = 2
     chooserColumn = 3
     fshift = self.nrows
     for f in range(self.sndPrm['nFields']):
         self.fieldLabel[f] = QLabel(self.tr(self.sndPrm['fieldLabel'][f]))
         self.grid_0.addWidget(self.fieldLabel[f], f+fshift, fieldLabelColumn)
         self.field[f] = QLineEdit()
         self.field[f].setText(str(self.sndPrm['field'][f]))
         self.field[f].setValidator(QDoubleValidator(self))
         self.grid_0.addWidget(self.field[f], f+fshift, fieldColumn)
      
     self.chooser = list(range(self.sndPrm['nChoosers']))
     self.chooserLabel = list(range(self.sndPrm['nChoosers']))
     self.chooserOptions = list(range(self.sndPrm['nChoosers']))
     for c in range(self.sndPrm['nChoosers']):
         self.chooserLabel[c] = QLabel(self.tr(self.sndPrm['chooserLabel'][c]))
         self.grid_1.addWidget(self.chooserLabel[c], c, chooserLabelColumn)
         self.chooserOptions[c] = self.sndPrm['chooserOptions'][c]
         self.chooser[c] = QComboBox()  
         self.chooser[c].addItems(self.chooserOptions[c])
         self.chooser[c].setCurrentIndex(self.chooserOptions[c].index(self.sndPrm['chooser'][c]))
         self.grid_1.addWidget(self.chooser[c], c, chooserColumn)
     for c in range(len(self.chooser)):
         self.chooser[c].activated[str].connect(self.onChooserChange)
         self.onChooserChange()
     self.sndPrm['nFields'] = len(self.field)
     self.sndPrm['nChoosers'] = len(self.chooser)
예제 #26
0
    def init_create_circle_form(self, point):

        # Create the dialog and signals
        self.dlg_create_circle = Cad_add_circle()
        self.load_settings(self.dlg_create_circle)
        self.cancel_circle = False
        validator = QDoubleValidator(0.00, 999.00, 3)
        validator.setNotation(QDoubleValidator().StandardNotation)
        self.dlg_create_circle.radius.setValidator(validator)

        self.dlg_create_circle.btn_accept.clicked.connect(
            partial(self.get_radius, point))
        self.dlg_create_circle.btn_cancel.clicked.connect(self.cancel)
        self.dlg_create_circle.radius.setFocus()

        self.dlg_create_circle.exec_()
예제 #27
0
    def master_estimate_result_new(self,
                                   tablename=None,
                                   result_id=None,
                                   index=0):
        """ Button 38: New estimate result """

        # Create dialog
        dlg_estimate_result_new = EstimateResultNew()
        self.load_settings(dlg_estimate_result_new)

        # Set signals
        dlg_estimate_result_new.btn_close.clicked.connect(
            partial(self.close_dialog, dlg_estimate_result_new))
        dlg_estimate_result_new.prices_coefficient.setValidator(
            QDoubleValidator())

        self.populate_cmb_result_type(dlg_estimate_result_new.cmb_result_type,
                                      'plan_result_type', False)

        if result_id != 0 and result_id:
            sql = ("SELECT * FROM " + self.schema_name + "." + tablename + " "
                   " WHERE result_id = '" + str(result_id) +
                   "' AND current_user = cur_user")
            row = self.controller.get_row(sql)
            if row is None:
                message = "Any record found for current user in table"
                self.controller.show_warning(message,
                                             parameter='plan_result_cat')
                return

            utils_giswater.setWidgetText(dlg_estimate_result_new,
                                         dlg_estimate_result_new.result_name,
                                         row['result_id'])
            dlg_estimate_result_new.cmb_result_type.setCurrentIndex(index)
            utils_giswater.setWidgetText(
                dlg_estimate_result_new,
                dlg_estimate_result_new.prices_coefficient,
                row['network_price_coeff'])
            utils_giswater.setWidgetText(dlg_estimate_result_new,
                                         dlg_estimate_result_new.observ,
                                         row['descript'])
            dlg_estimate_result_new.result_name.setEnabled(False)
            dlg_estimate_result_new.cmb_result_type.setEnabled(False)
            dlg_estimate_result_new.prices_coefficient.setEnabled(False)
            dlg_estimate_result_new.observ.setEnabled(False)
            dlg_estimate_result_new.btn_calculate.setText("Close")
            dlg_estimate_result_new.btn_calculate.clicked.connect(
                partial(self.close_dialog))
        else:
            dlg_estimate_result_new.btn_calculate.clicked.connect(
                partial(self.master_estimate_result_new_calculate,
                        dlg_estimate_result_new))
        # TODO pending translation
        # Manage i18n of the form and open it
        # self.controller.translate_form(dlg_estimate_result_new, 'estimate_result_new')

        self.open_dialog(dlg_estimate_result_new,
                         dlg_name="plan_estimate_result_new",
                         maximize_button=False)
예제 #28
0
    def get_point(self, virtual_layer_name):
        validator = QDoubleValidator(-99999.99, 99999.999, 3)
        validator.setNotation(QDoubleValidator().StandardNotation)
        self.dlg_create_point.dist_x.setValidator(validator)
        validator = QDoubleValidator(-99999.99, 99999.999, 3)
        validator.setNotation(QDoubleValidator().StandardNotation)
        self.dlg_create_point.dist_y.setValidator(validator)
        self.dlg_create_point.btn_accept.pressed.connect(self.get_values)
        self.dlg_create_point.btn_cancel.pressed.connect(self.cancel)
        self.dlg_create_point.dist_x.setFocus()

        self.active_layer = self.iface.mapCanvas().currentLayer()
        self.virtual_layer_point = self.controller.get_layer_by_layername(
            virtual_layer_name, True)

        # Open dialog
        self.open_dialog(self.dlg_create_point, maximize_button=False)
예제 #29
0
 def check_slice_duration(self, newtxt):
     """If the acquisition duration is changed, make sure the slices can't
     use times beyond this."""
     self.check_settings() # update DAQ acquisition settings first
     for i in range(self.slices.rowCount()):
         for j in [1,2]: # force slice to be within max duration
             validator = QDoubleValidator(0.,float(self.stats['Duration (ms)']),3)
             self.slices.cellWidget(i, j).setValidator(validator)
예제 #30
0
 def createBaseControlWidgets(self):
     self.xminLabel = QLabel(self.tr('xmin'))
     self.xminWidget = QLineEdit(self.currLocale.toString(self.axes.get_xlim()[0]))               
     self.xminWidget.setValidator(QDoubleValidator(self))
     self.xmaxLabel = QLabel(self.tr('xmax'))
     self.xmaxWidget = QLineEdit(self.currLocale.toString(self.axes.get_xlim()[1]))
     self.xmaxWidget.setValidator(QDoubleValidator(self))
     self.yminLabel = QLabel(self.tr('ymin'))
     self.yminWidget = QLineEdit(self.currLocale.toString(self.axes.get_ylim()[0])) 
     self.yminWidget.setValidator(QDoubleValidator(self))
     self.ymaxLabel = QLabel(self.tr('ymax'))
     self.ymaxWidget = QLineEdit(self.currLocale.toString(self.axes.get_ylim()[1])) 
     self.ymaxWidget.setValidator(QDoubleValidator(self))
     self.xminWidget.editingFinished.connect(self.onAxesChange)
     self.xmaxWidget.editingFinished.connect(self.onAxesChange)
     self.yminWidget.editingFinished.connect(self.onAxesChange)
     self.ymaxWidget.editingFinished.connect(self.onAxesChange)
예제 #31
0
    def createDialog(self):
        """
        Create qt dialog
        """

        self.TIMEOUT_ANDROID_ACTION = Settings.instance().readValue(
            key='TestGenerator/timeout-android-action')

        self.timeoutAndroidLine = QLineEdit()
        self.timeoutAndroidLine.setText(str(self.TIMEOUT_ANDROID_ACTION))
        validatorAndroid = QDoubleValidator(self)
        validatorAndroid.setNotation(QDoubleValidator.StandardNotation)
        self.timeoutAndroidLine.setValidator(validatorAndroid)
        self.timeoutAndroidLine.installEventFilter(self)

        self.agentNameLineAndroid = QLineEdit("AGENT_ANDROID")

        self.agentsAndroidList = QComboBox()
        self.agentsAndroidList.setMinimumWidth(300)

        optionAndroidLayout = QGridLayout()
        optionAndroidLayout.addWidget(
            QLabel(self.tr("Max time to run action:")), 1, 0)
        optionAndroidLayout.addWidget(self.timeoutAndroidLine, 1, 1)

        optionAndroidLayout.addWidget(QLabel(self.tr("Agent Key Name:")), 3, 0)
        optionAndroidLayout.addWidget(self.agentNameLineAndroid, 3, 1)

        optionAndroidLayout.addWidget(QLabel(self.tr("Agent:")), 4, 0)
        optionAndroidLayout.addWidget(self.agentsAndroidList, 4, 1)

        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setStyleSheet("""QDialogButtonBox { 
            dialogbuttonbox-buttons-have-icons: 1;
            dialog-ok-icon: url(:/ok.png);
            dialog-cancel-icon: url(:/ko.png);
        }""")
        self.buttonBox.setStandardButtons(QDialogButtonBox.Ok
                                          | QDialogButtonBox.Cancel)

        mainLayout = QVBoxLayout()
        mainLayout.addLayout(optionAndroidLayout)
        mainLayout.addWidget(self.buttonBox)
        self.setLayout(mainLayout)

        self.setWindowTitle(self.tr("Android Options"))
예제 #32
0
    def widget(self, parent):
        config = createForm("plot_param_dir_fct.ui", parent)
        self._config = config
        config.selectDataFile.clicked.connect(self._selectDataFile)
        config.changeColorMap.clicked.connect(self._changeColorMap)
        config.dataFile.textChanged.connect(self._checkAndLoad)
        config.orthogonal.toggled.connect(self._set_orthogonal)
        config.symetricColoring.toggled[bool].connect(
            self._set_symetric_coloring)
        config.capping.toggled[bool].connect(self._cappingChanged)
        config.minCap.setValidator(QDoubleValidator(config.minCap))
        config.maxCap.setValidator(QDoubleValidator(config.minCap))
        config.minCap.textChanged['QString'].connect(self._minCapStringChanged)
        config.maxCap.textChanged['QString'].connect(self._maxCapStringChanged)
        config.point1.currentIndexChanged['QString'].connect(
            self._changePoint1)
        config.point2.currentIndexChanged['QString'].connect(
            self._changePoint2)
        config.drawLine.toggled.connect(self._set_draw_line)
        config.lineWidth.valueChanged.connect(self._set_line_width)
        config.selectLineColor.clicked.connect(self._changeLineColor)

        config.dataFile.setText(self.data_file)
        value = self.minmax_values
        self.resetMinMax(value)
        config.orthogonal.setChecked(self.orthogonal)
        config.symetricColoring.setChecked(self._symetric_coloring)
        config.drawLine.setChecked(self.draw_line)
        config.lineWidth.setValue(self.line_width)
        setColor(config.lineColor, self.line_color)
        if self._value_capping is not None:
            config.capping.setChecked(True)
            config.minCap.setText(u"{:.5g}".format(self._value_capping[0]))
            config.maxCap.setText(u"{:.5g}".format(self._value_capping[1]))
        if self.data is not None:
            config = self._config
            config.point1.clear()
            config.point2.clear()
            for i in self.points:
                config.point1.addItem(str(i))
                config.point2.addItem(str(i))
            config.point1.setCurrentIndex(0)
            config.point2.setCurrentIndex(1)
        self.addScaleBarWidget(config)
        return self._config
예제 #33
0
    def setupUi(self):
        super().setupUi(self)
        # self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowContextHelpButtonHint)

        self.ui_normal_handler.setChecked(True)
        self.ui_composed_handler.setChecked(False)
        self.ui_normal_handler.toggled.connect(self.on_composite_view_changed)
        self.ui_composed_handler.toggled.connect(
            self.on_composite_view_changed)
        self.ui_composite_ranges.hide()

        self.ui_handler_selector.currentIndexChanged.connect(
            self.on_range_handler_changed)
        self.ui_span_mode.stateChanged.connect(self.on_span_mode_changed)

        self.ui_span_mode.setChecked(False)
        self.ui_span_mode.hide()
        self.on_span_mode_changed(0)

        self.ui_view_range_dock.hide()

        self.rangeMode = HandlersEnum.normal
        self.adjustSize()

        self.ui_start_val.setValidator(QDoubleValidator())
        self.ui_stop_val.setValidator(QDoubleValidator())
        self.ui_step_val.setValidator(QDoubleValidator())
        self.ui_center_val.setValidator(QDoubleValidator())
        self.ui_span_val.setValidator(QDoubleValidator())

        self.plot = self.ui_range_plot.addPlot()
        self.range_curve = self.plot.plot(
            pen=pg.mkPen(color="r", width=2),
            symbolPen=pg.mkPen(color="r", width=1),
            symbolBrush="r",
            symbol='o',
            size=0,
            pxMode=True)  #pg.ScatterPlotItem()#size=10, pen=pg.mkPen('r'))
        # self.plot.setLabel("left", "<font size=\"5\">Value</font>")#, units="<font size=\"15\">V^2Hz-1</font>")
        # self.plot.setLabel("bottom", "<font size=\"5\">Index</font>")#, units="Hz")
        self.plot.getAxis("left").setWidth(20)
        self.plot.showAxis("right", show=True)
        self.plot.showAxis("top", show=True)
        self.plot.getAxis("right").setStyle(showValues=False)
        self.plot.getAxis("top").setStyle(showValues=False)
예제 #34
0
 def createFloatingPointEditor(self,
                               value=0.0,
                               minValue=float("-inf"),
                               maxValue=float("+inf"),
                               decimals=1000):
     floatingPointEditor = QLineEdit(str(value))
     floatingPointEditor.setValidator(
         QDoubleValidator(minValue, maxValue, decimals))
     return floatingPointEditor
예제 #35
0
class FloatColumnValidator(QValidator):
    def __init__(self):
        QValidator.__init__(self)
        self._qvalidator = QDoubleValidator()

    def validate(self, text, cursor_pos):
        adjusted_cursor_pos = cursor_pos - (len(text) - len(text.lstrip()))
        status, text, new_cursor_pos = self._qvalidator.validate(text.strip(), adjusted_cursor_pos)
        return status
예제 #36
0
    def validate(self, input_value, pos):

        if input_value in ('', '.', '-'):
            return QValidator.Intermediate, input_value, pos

        state, value, pos = QDoubleValidator.validate(self, input_value, pos)

        if state != QValidator.Acceptable:
            return QValidator.Invalid, value, pos

        return QValidator.Acceptable, value, pos
예제 #37
0
 def validate(self, input_value, pos):
     """Validates the given input. Overrides the QDoubleValidator's validate 
     function.
     
     Args:
         input_value: User given string to be validated.
         pos: Cursor position (if required).
     """
     input_value = input_value.replace(",", ".")
     state, pos, a = QDoubleValidator.validate(self, input_value, pos)
     if input_value == "" or input_value == ".":
         pos = "0.0"
         return QValidator.Intermediate, pos, a
     if state != QValidator.Acceptable:
         return QValidator.Invalid, pos, a
     return QValidator.Acceptable, pos, a
예제 #38
0
 def __init__(self):
     QValidator.__init__(self)
     self._qvalidator = QDoubleValidator()
예제 #39
0
파일: mav_gui.py 프로젝트: cstefanovic/mav
    def __init__(self,
      # .. _numMavs:
      #
      # The number of MAVs in the simulation.
      numMavs,
      # See _flyTimeSec.
      flyTimeSec,
      # See _chargeTimeSec.
      chargeTimeSec):

        # First, let the QDialog initialize itself.
        super(MavDialog, self).__init__()

        # Create a ChargingStation to manage the MAVs.
        self._chargingStation = ChargingStation(self, numMavs, flyTimeSec,
                                                chargeTimeSec)

        # `Load <http://pyqt.sourceforge.net/Docs/PyQt4/designer.html#PyQt4.uic.loadUi>`_
        # in our UI. The secord parameter lods the resulting UI directly into
        # this class.
        uic.loadUi(join(dirname(__file__), 'mav_gui.ui'), self)

        # Only allow numbers between 0 and 99 for the line edits.
        flyTimeValidator = QDoubleValidator(0.0, 9.9, 1, self)
        flyTimeValidator.setNotation(QDoubleValidator.StandardNotation)
        self.leFlyTime.setValidator(flyTimeValidator)
        chargeTimeValidator = QDoubleValidator(0.0, 9.9, 1, self)
        chargeTimeValidator.setNotation(QDoubleValidator.StandardNotation)
        self.leChargeTime.setValidator(chargeTimeValidator)

        # Example: create a separate thread
        self._thread = QThread(self)
        #self._thread.start()
        # Create a worker.
        self._worker = DummyWorker(self)

        # Timer examples
        # ^^^^^^^^^^^^^^
        # A single-shot timer. It can't be canceled.
        QTimer.singleShot(1500, self._onTimeout)
        # Another single-shot timer. Because it has a name, it can be canceled.
        self._timer = QTimer(self)
        self._timer.timeout.connect(self._onTimeout)
        self._timer.setSingleShot(True)
        self._timer.start(3000)

        # Add in status info GUI for numMavs MAVs.
        hl = QHBoxLayout()
        self.wMavStatus.setLayout(hl)
        assert numMavs > 0
        self.numMavs = numMavs
        self.mavStatus = []
        self.electrodeStatus = []
        self._chargeTimeSec = [chargeTimeSec]*self.numMavs
        self._flyTimeSec = [flyTimeSec]*self.numMavs
        for index in range(self.numMavs):
            e = UncheckableRadioButton(self)
            self.electrodeStatus.append(e)
            hl.addWidget(e)

            # Add in a group box.
            smw = SingleMavWidget()
            mavName = 'MAV {}'.format(index + 1)
            smw.gb = QGroupBox(mavName, self.wMavStatus)
            vl = QVBoxLayout()
            smw.gb.setLayout(vl)
            smw.rbFlying = UncheckableRadioButton('Flying', smw.gb)
            smw.rbWaiting = UncheckableRadioButton('Waiting', smw.gb)
            smw.rbCharging = UncheckableRadioButton('Charging', smw.gb)
            vl.addWidget(smw.rbFlying)
            vl.addWidget(smw.rbWaiting)
            vl.addWidget(smw.rbCharging)
            self.mavStatus.append(smw)
            hl.addWidget(smw.gb)

            # Update the combo box.
            self.cbSelectedMav.insertItem(index, mavName)

        # Update GUI with parameters.
        self.on_cbSelectedMav_currentIndexChanged(0)

        self.updateMavState.connect(self._on_updateMavState)
예제 #40
0
class RunDialog( QDialog ):
    """ Run parameters dialog implementation """

    # See utils.run for runParameters
    def __init__( self, path, runParameters, termType,
                  profilerParams, debuggerParams,
                  action = "", parent = None ):
        QDialog.__init__( self, parent )

        # Used as a return value
        self.termType = termType
        self.profilerParams = copy.deepcopy( profilerParams )
        self.debuggerParams = copy.deepcopy( debuggerParams )

        self.__action = action.lower()

        # Avoid pylint complains
        self.__argsEdit = None
        self.__scriptWDRButton = None
        self.__dirRButton = None
        self.__dirEdit = None
        self.__dirSelectButton = None
        self.__inheritParentRButton = None
        self.__inheritParentPlusRButton = None
        self.__inhPlusEnvTable = None
        self.__addInhButton = None
        self.__delInhButton = None
        self.__editInhButton = None
        self.__specificRButton = None
        self.__specEnvTable = None
        self.__addSpecButton = None
        self.__delSpecButton = None
        self.__editSpecButton = None
        self.__runButton = None
        self.__nodeLimitEdit = None
        self.__edgeLimitEdit = None

        self.__createLayout( action )
        self.setWindowTitle( action + " parameters for " + path )

        # Restore the values
        self.runParams = copy.deepcopy( runParameters )
        self.__argsEdit.setText( self.runParams.arguments )

        # Working dir
        if self.runParams.useScriptLocation:
            self.__scriptWDRButton.setChecked( True )
            self.__dirEdit.setEnabled( False )
            self.__dirSelectButton.setEnabled( False )
        else:
            self.__dirRButton.setChecked( True )
            self.__dirEdit.setEnabled( True )
            self.__dirSelectButton.setEnabled( True )

        self.__dirEdit.setText( self.runParams.specificDir )

        # Environment
        self.__populateTable( self.__inhPlusEnvTable,
                              self.runParams.additionToParentEnv )
        self.__populateTable( self.__specEnvTable,
                              self.runParams.specificEnv )

        if self.runParams.envType == RunParameters.InheritParentEnv:
            self.__inheritParentRButton.setChecked( True )
            self.__setEnabledInheritedPlusEnv( False )
            self.__setEnabledSpecificEnv( False )
        elif self.runParams.envType == RunParameters.InheritParentEnvPlus:
            self.__inheritParentPlusRButton.setChecked( True )
            self.__setEnabledSpecificEnv( False )
        else:
            self.__specificRButton.setChecked( True )
            self.__setEnabledInheritedPlusEnv( False )

        # Terminal
        if self.termType == TERM_REDIRECT:
            self.__redirectRButton.setChecked( True )
        elif self.termType == TERM_AUTO:
            self.__autoRButton.setChecked( True )
        elif self.termType == TERM_KONSOLE:
            self.__konsoleRButton.setChecked( True )
        elif self.termType == TERM_GNOME:
            self.__gnomeRButton.setChecked( True )
        else:
            self.__xtermRButton.setChecked( True )

        # Close checkbox
        self.__closeCheckBox.setChecked( self.runParams.closeTerminal )
        if self.termType == TERM_REDIRECT:
            self.__closeCheckBox.setEnabled( False )

        # Profile limits if so
        if self.__action == "profile":
            if self.profilerParams.nodeLimit < 0.0 or \
               self.profilerParams.nodeLimit > 100.0:
                self.profilerParams.nodeLimit = 1.0
            self.__nodeLimitEdit.setText( str( self.profilerParams.nodeLimit ) )
            if self.profilerParams.edgeLimit < 0.0 or \
               self.profilerParams.edgeLimit > 100.0:
                self.profilerParams.edgeLimit = 1.0
            self.__edgeLimitEdit.setText( str( self.profilerParams.edgeLimit ) )
        elif self.__action == "debug":
            self.__reportExceptionCheckBox.setChecked(
                                    self.debuggerParams.reportExceptions )
            self.__traceInterpreterCheckBox.setChecked(
                                    self.debuggerParams.traceInterpreter )
            self.__stopAtFirstCheckBox.setChecked(
                                    self.debuggerParams.stopAtFirstLine )
            self.__autoforkCheckBox.setChecked(
                                    self.debuggerParams.autofork )
            self.__debugChildCheckBox.setChecked(
                                    self.debuggerParams.followChild )
            self.__debugChildCheckBox.setEnabled( self.debuggerParams.autofork )

        self.__setRunButtonProps()
        return

    @staticmethod
    def __populateTable( table, dictionary ):
        " Populates the given table "
        for key, value in dictionary.iteritems():
            item = QTreeWidgetItem( [ key, value ] )
            table.addTopLevelItem( item )
        if dictionary:
            table.setCurrentItem( table.topLevelItem( 0 ) )
        return

    def __setEnabledInheritedPlusEnv( self, value ):
        " Disables/enables 'inherited and add' section controls "
        self.__inhPlusEnvTable.setEnabled( value )
        self.__addInhButton.setEnabled( value )
        self.__delInhButton.setEnabled( value )
        self.__editInhButton.setEnabled( value )
        return

    def __setEnabledSpecificEnv( self, value ):
        " Disables/enables 'specific env' section controls "
        self.__specEnvTable.setEnabled( value )
        self.__addSpecButton.setEnabled( value )
        self.__delSpecButton.setEnabled( value )
        self.__editSpecButton.setEnabled( value )
        return

    def __createLayout( self, action ):
        """ Creates the dialog layout """

        self.resize( 650, 300 )
        self.setSizeGripEnabled( True )

        # Top level layout
        layout = QVBoxLayout( self )

        # Cmd line arguments
        argsLabel = QLabel( "Command line arguments" )
        self.__argsEdit = QLineEdit()
        self.__argsEdit.textChanged.connect( self.__argsChanged )
        argsLayout = QHBoxLayout()
        argsLayout.addWidget( argsLabel )
        argsLayout.addWidget( self.__argsEdit )
        layout.addLayout( argsLayout )

        # Working directory
        workDirGroupbox = QGroupBox( self )
        workDirGroupbox.setTitle( "Working directory" )
        sizePolicy = QSizePolicy( QSizePolicy.Expanding, QSizePolicy.Preferred )
        sizePolicy.setHorizontalStretch( 0 )
        sizePolicy.setVerticalStretch( 0 )
        sizePolicy.setHeightForWidth( \
                        workDirGroupbox.sizePolicy().hasHeightForWidth() )
        workDirGroupbox.setSizePolicy( sizePolicy )

        gridLayoutWD = QGridLayout( workDirGroupbox )
        self.__scriptWDRButton = QRadioButton( workDirGroupbox )
        self.__scriptWDRButton.setText( "&Use script location" )
        gridLayoutWD.addWidget( self.__scriptWDRButton, 0, 0 )
        self.__scriptWDRButton.clicked.connect( self.__scriptWDirClicked )

        self.__dirRButton = QRadioButton( workDirGroupbox )
        self.__dirRButton.setText( "Select &directory" )
        gridLayoutWD.addWidget( self.__dirRButton, 1, 0 )
        self.__dirRButton.clicked.connect( self.__dirClicked )

        self.__dirEdit = QLineEdit( workDirGroupbox )
        gridLayoutWD.addWidget( self.__dirEdit, 1, 1 )
        self.__dirEdit.textChanged.connect( self.__workingDirChanged )

        self.__dirSelectButton = QPushButton( workDirGroupbox )
        self.__dirSelectButton.setText( "..." )
        gridLayoutWD.addWidget( self.__dirSelectButton, 1, 2 )
        self.__dirSelectButton.clicked.connect( self.__selectDirClicked )

        layout.addWidget( workDirGroupbox )

        # Environment
        envGroupbox = QGroupBox( self )
        envGroupbox.setTitle( "Environment" )
        sizePolicy = QSizePolicy( QSizePolicy.Expanding, QSizePolicy.Preferred )
        sizePolicy.setHorizontalStretch( 0 )
        sizePolicy.setVerticalStretch( 0 )
        sizePolicy.setHeightForWidth( \
                        envGroupbox.sizePolicy().hasHeightForWidth() )
        envGroupbox.setSizePolicy( sizePolicy )

        layoutEnv = QVBoxLayout( envGroupbox )
        self.__inheritParentRButton = QRadioButton( envGroupbox )
        self.__inheritParentRButton.setText( "Inherit &parent" )
        self.__inheritParentRButton.clicked.connect( self.__inhClicked )
        layoutEnv.addWidget( self.__inheritParentRButton )

        self.__inheritParentPlusRButton = QRadioButton( envGroupbox )
        self.__inheritParentPlusRButton.setText( "Inherit parent and add/&modify" )
        self.__inheritParentPlusRButton.clicked.connect( self.__inhPlusClicked )
        layoutEnv.addWidget( self.__inheritParentPlusRButton )
        hInhPlusLayout = QHBoxLayout()
        self.__inhPlusEnvTable = QTreeWidget()
        self.__inhPlusEnvTable.itemActivated.connect( self.__inhPlusItemActivated )
        self.__tuneTable( self.__inhPlusEnvTable )
        hInhPlusLayout.addWidget( self.__inhPlusEnvTable )
        vInhPlusLayout = QVBoxLayout()
        self.__addInhButton = QPushButton()
        self.__addInhButton.clicked.connect( self.__addInhClicked )
        self.__addInhButton.setText( 'Add' )
        vInhPlusLayout.addWidget( self.__addInhButton )
        self.__delInhButton = QPushButton()
        self.__delInhButton.clicked.connect( self.__delInhClicked )
        self.__delInhButton.setText( 'Delete' )
        vInhPlusLayout.addWidget( self.__delInhButton )
        self.__editInhButton = QPushButton()
        self.__editInhButton.clicked.connect( self.__editInhClicked )
        self.__editInhButton.setText( "Edit" )
        vInhPlusLayout.addWidget( self.__editInhButton )
        hInhPlusLayout.addLayout( vInhPlusLayout )
        layoutEnv.addLayout( hInhPlusLayout )

        self.__specificRButton = QRadioButton( envGroupbox )
        self.__specificRButton.setText( "&Specific" )
        self.__specificRButton.clicked.connect( self.__specClicked )
        layoutEnv.addWidget( self.__specificRButton )
        hSpecLayout = QHBoxLayout()
        self.__specEnvTable = QTreeWidget()
        self.__specEnvTable.itemActivated.connect( self.__specItemActivated )
        self.__tuneTable( self.__specEnvTable )
        hSpecLayout.addWidget( self.__specEnvTable )
        vSpecLayout = QVBoxLayout()
        self.__addSpecButton = QPushButton()
        self.__addSpecButton.clicked.connect( self.__addSpecClicked )
        self.__addSpecButton.setText( 'Add' )
        vSpecLayout.addWidget( self.__addSpecButton )
        self.__delSpecButton = QPushButton()
        self.__delSpecButton.clicked.connect( self.__delSpecClicked )
        self.__delSpecButton.setText( 'Delete' )
        vSpecLayout.addWidget( self.__delSpecButton )
        self.__editSpecButton = QPushButton()
        self.__editSpecButton.clicked.connect( self.__editSpecClicked )
        self.__editSpecButton.setText( "Edit" )
        vSpecLayout.addWidget( self.__editSpecButton )
        hSpecLayout.addLayout( vSpecLayout )
        layoutEnv.addLayout( hSpecLayout )
        layout.addWidget( envGroupbox )

        # Terminal and profile limits
        if self.__action in [ "profile", "debug" ]:
            layout.addWidget( self.__getIDEWideGroupbox() )
        else:
            termGroupbox = self.__getTermGroupbox()
            termGroupbox.setTitle( "Terminal to run in (IDE wide setting)" )
            layout.addWidget( termGroupbox )

        # Close checkbox
        self.__closeCheckBox = QCheckBox( "&Close terminal upon "
                                          "successful completion" )
        self.__closeCheckBox.stateChanged.connect( self.__onCloseChanged )
        layout.addWidget( self.__closeCheckBox )

        # Buttons at the bottom
        buttonBox = QDialogButtonBox( self )
        buttonBox.setOrientation( Qt.Horizontal )
        buttonBox.setStandardButtons( QDialogButtonBox.Cancel )
        self.__runButton = buttonBox.addButton( action,
                                                QDialogButtonBox.AcceptRole )
        self.__runButton.setDefault( True )
        self.__runButton.clicked.connect( self.onAccept )
        layout.addWidget( buttonBox )

        buttonBox.rejected.connect( self.close )
        return

    def __getTermGroupbox( self ):
        " Creates the term groupbox "
        termGroupbox = QGroupBox( self )
        sizePolicy = QSizePolicy( QSizePolicy.Expanding, QSizePolicy.Preferred )
        sizePolicy.setHorizontalStretch( 0 )
        sizePolicy.setVerticalStretch( 0 )
        sizePolicy.setHeightForWidth(
                        termGroupbox.sizePolicy().hasHeightForWidth() )
        termGroupbox.setSizePolicy( sizePolicy )

        layoutTerm = QVBoxLayout( termGroupbox )
        self.__redirectRButton = QRadioButton( termGroupbox )
        self.__redirectRButton.setText( "&Redirect to IDE" )
        self.__redirectRButton.toggled.connect( self.__redirectedChanged )
        layoutTerm.addWidget( self.__redirectRButton )
        self.__autoRButton = QRadioButton( termGroupbox )
        self.__autoRButton.setText( "Aut&o detection" )
        layoutTerm.addWidget( self.__autoRButton )
        self.__konsoleRButton = QRadioButton( termGroupbox )
        self.__konsoleRButton.setText( "Default &KDE konsole" )
        layoutTerm.addWidget( self.__konsoleRButton )
        self.__gnomeRButton = QRadioButton( termGroupbox )
        self.__gnomeRButton.setText( "gnome-&terminal" )
        layoutTerm.addWidget( self.__gnomeRButton )
        self.__xtermRButton = QRadioButton( termGroupbox )
        self.__xtermRButton.setText( "&xterm" )
        layoutTerm.addWidget( self.__xtermRButton )
        return termGroupbox

    def __redirectedChanged( self, checked ):
        " Triggered when the redirected radio button changes its state "
        self.__closeCheckBox.setEnabled( not checked )
        return

    def __getIDEWideGroupbox( self ):
        " Creates the IDE wide groupbox "
        ideGroupbox = QGroupBox( self )
        ideGroupbox.setTitle( "IDE Wide Settings" )
        sizePolicy = QSizePolicy( QSizePolicy.Expanding, QSizePolicy.Preferred )
        sizePolicy.setHorizontalStretch( 0 )
        sizePolicy.setVerticalStretch( 0 )
        sizePolicy.setHeightForWidth(
                        ideGroupbox.sizePolicy().hasHeightForWidth() )
        ideGroupbox.setSizePolicy( sizePolicy )

        layoutIDE = QHBoxLayout( ideGroupbox )

        termGroupbox = self.__getTermGroupbox()
        termGroupbox.setTitle( "Terminal to run in" )
        layoutIDE.addWidget( termGroupbox )

        if self.__action == "profile":
            # Profile version of the dialog
            limitsGroupbox = self.__getProfileLimitsGroupbox()
            layoutIDE.addWidget( limitsGroupbox )
        else:
            # Debug version of the dialog
            dbgGroupbox = self.__getDebugGroupbox()
            layoutIDE.addWidget( dbgGroupbox )
        return ideGroupbox

    def __getProfileLimitsGroupbox( self ):
        " Creates the profile limits groupbox "
        limitsGroupbox = QGroupBox( self )
        limitsGroupbox.setTitle( "Profiler diagram limits" )
        sizePolicy = QSizePolicy( QSizePolicy.Expanding, QSizePolicy.Preferred )
        sizePolicy.setHorizontalStretch( 0 )
        sizePolicy.setVerticalStretch( 0 )
        sizePolicy.setHeightForWidth(
                limitsGroupbox.sizePolicy().hasHeightForWidth() )
        limitsGroupbox.setSizePolicy( sizePolicy )

        layoutLimits = QGridLayout( limitsGroupbox )
        self.__nodeLimitEdit = QLineEdit()
        self.__nodeLimitEdit.textEdited.connect( self.__setRunButtonProps )
        self.__nodeLimitValidator = QDoubleValidator( 0.0, 100.0, 2, self )
        self.__nodeLimitValidator.setNotation( QDoubleValidator.StandardNotation )
        self.__nodeLimitEdit.setValidator( self.__nodeLimitValidator )
        nodeLimitLabel = QLabel( "Hide nodes below" )
        self.__edgeLimitEdit = QLineEdit()
        self.__edgeLimitEdit.textEdited.connect( self.__setRunButtonProps )
        self.__edgeLimitValidator = QDoubleValidator( 0.0, 100.0, 2, self )
        self.__edgeLimitValidator.setNotation( QDoubleValidator.StandardNotation )
        self.__edgeLimitEdit.setValidator( self.__edgeLimitValidator )
        edgeLimitLabel = QLabel( "Hide edges below" )
        layoutLimits.addWidget( nodeLimitLabel, 0, 0 )
        layoutLimits.addWidget( self.__nodeLimitEdit, 0, 1 )
        layoutLimits.addWidget( QLabel( "%" ), 0, 2 )
        layoutLimits.addWidget( edgeLimitLabel, 1, 0 )
        layoutLimits.addWidget( self.__edgeLimitEdit, 1, 1 )
        layoutLimits.addWidget( QLabel( "%" ), 1, 2 )
        return limitsGroupbox

    def __getDebugGroupbox( self ):
        " Creates the debug settings groupbox "
        dbgGroupbox = QGroupBox( self )
        dbgGroupbox.setTitle( "Debugger" )
        sizePolicy = QSizePolicy( QSizePolicy.Expanding, QSizePolicy.Preferred )
        sizePolicy.setHorizontalStretch( 0 )
        sizePolicy.setVerticalStretch( 0 )
        sizePolicy.setHeightForWidth(
                    dbgGroupbox.sizePolicy().hasHeightForWidth() )
        dbgGroupbox.setSizePolicy( sizePolicy )

        dbgLayout = QVBoxLayout( dbgGroupbox )
        self.__reportExceptionCheckBox = QCheckBox( "Report &exceptions" )
        self.__reportExceptionCheckBox.stateChanged.connect(
                                            self.__onReportExceptionChanged )
        self.__traceInterpreterCheckBox = QCheckBox( "T&race interpreter libs" )
        self.__traceInterpreterCheckBox.stateChanged.connect(
                                            self.__onTraceInterpreterChanged )
        self.__stopAtFirstCheckBox = QCheckBox( "Stop at first &line" )
        self.__stopAtFirstCheckBox.stateChanged.connect(
                                            self.__onStopAtFirstChanged )
        self.__autoforkCheckBox = QCheckBox( "&Fork without asking" )
        self.__autoforkCheckBox.stateChanged.connect(self.__onAutoforkChanged )
        self.__debugChildCheckBox = QCheckBox( "Debu&g child process" )
        self.__debugChildCheckBox.stateChanged.connect( self.__onDebugChild )

        dbgLayout.addWidget( self.__reportExceptionCheckBox )
        dbgLayout.addWidget( self.__traceInterpreterCheckBox )
        dbgLayout.addWidget( self.__stopAtFirstCheckBox )
        dbgLayout.addWidget( self.__autoforkCheckBox )
        dbgLayout.addWidget( self.__debugChildCheckBox )
        return dbgGroupbox


    @staticmethod
    def __tuneTable( table ):
        " Sets the common settings for a table "

        table.setAlternatingRowColors( True )
        table.setRootIsDecorated( False )
        table.setItemsExpandable( False )
        table.setUniformRowHeights( True )
        table.setSelectionMode( QAbstractItemView.SingleSelection )
        table.setSelectionBehavior( QAbstractItemView.SelectRows )
        table.setItemDelegate( NoOutlineHeightDelegate( 4 ) )
        table.setHeaderLabels( [ "Variable", "Value" ] )

        header = table.header()
        header.setSortIndicator( 0, Qt.AscendingOrder )
        header.setSortIndicatorShown( True )
        header.setClickable( True )
        table.setSortingEnabled( True )
        return

    def __scriptWDirClicked( self ):
        " The script working dir button is clicked "
        self.__dirEdit.setEnabled( False )
        self.__dirSelectButton.setEnabled( False )
        self.runParams.useScriptLocation = True

        self.__setRunButtonProps()
        return

    def __dirClicked( self ):
        " The script specific working dir button is clicked "
        self.__dirEdit.setEnabled( True )
        self.__dirSelectButton.setEnabled( True )
        self.runParams.useScriptLocation = False

        self.__setRunButtonProps()
        return

    def __argsChanged( self, value ):
        " Triggered when cmd line args are changed "
        value = str( value ).strip()
        self.runParams.arguments = value
        self.__setRunButtonProps()
        return

    def __workingDirChanged( self, value ):
        " Triggered when a working dir value is changed "
        value = str( value )
        self.runParams.specificDir = value
        self.__setRunButtonProps()
        return

    def __onCloseChanged( self, state ):
        " Triggered when the close terminal check box changed "
        self.runParams.closeTerminal = state != 0
        return

    def __onReportExceptionChanged( self, state ):
        " Triggered when exception report check box changed "
        self.debuggerParams.reportExceptions = state != 0
        return

    def __onTraceInterpreterChanged( self, state ):
        " Triggered when trace interpreter changed "
        self.debuggerParams.traceInterpreter = state != 0
        return

    def __onStopAtFirstChanged( self, state ):
        " Triggered when stop at first changed "
        self.debuggerParams.stopAtFirstLine = state != 0
        return

    def __onAutoforkChanged( self, state ):
        " Triggered when autofork changed "
        self.debuggerParams.autofork = state != 0
        self.__debugChildCheckBox.setEnabled( self.debuggerParams.autofork )
        return

    def __onDebugChild( self, state ):
        " Triggered when debug child changed "
        self.debuggerParams.followChild = state != 0
        return

    def __argumentsOK( self ):
        " Returns True if the arguments are OK "
        try:
            parseCommandLineArguments( self.runParams.arguments )
            return True
        except:
            return False

    def __dirOK( self ):
        " Returns True if the working dir is OK "
        if self.__scriptWDRButton.isChecked():
            return True
        return os.path.isdir( self.__dirEdit.text() )

    def __setRunButtonProps( self, newText = None ):
        " Enable/disable run button and set its tooltip "
        if not self.__argumentsOK():
            self.__runButton.setEnabled( False )
            self.__runButton.setToolTip( "No closing quotation in arguments" )
            return

        if not self.__dirOK():
            self.__runButton.setEnabled( False )
            self.__runButton.setToolTip( "The given working "
                                         "dir is not found" )
            return

        if self.__nodeLimitEdit is not None:
            txt = self.__nodeLimitEdit.text().strip()
            try:
                value = float( txt )
                if value < 0.0 or value > 100.0:
                    raise Exception( "Out of range" )
            except:
                self.__runButton.setEnabled( False )
                self.__runButton.setToolTip( "The given node limit "
                                             "is out of range" )
                return

        if self.__edgeLimitEdit is not None:
            txt = self.__edgeLimitEdit.text().strip()
            try:
                value = float( txt )
                if value < 0.0 or value > 100.0:
                    raise Exception( "Out of range" )
            except:
                self.__runButton.setEnabled( False )
                self.__runButton.setToolTip( "The given edge limit "
                                             "is out of range" )
                return

        self.__runButton.setEnabled( True )
        self.__runButton.setToolTip( "Save parameters and " +
                                     self.__action + " script" )
        return

    def __selectDirClicked( self ):
        " Selects the script working dir "
        dirName = QFileDialog.getExistingDirectory( self,
                    "Select the script working directory",
                    self.__dirEdit.text(),
                    QFileDialog.Options( QFileDialog.ShowDirsOnly ) )

        if dirName:
            self.__dirEdit.setText( os.path.normpath( dirName ) )
        return

    def __inhClicked( self ):
        " Inerit parent env radio button clicked "
        self.__setEnabledInheritedPlusEnv( False )
        self.__setEnabledSpecificEnv( False )
        self.runParams.envType = RunParameters.InheritParentEnv
        return

    def __inhPlusClicked( self ):
        " Inherit parent and add radio button clicked "
        self.__setEnabledInheritedPlusEnv( True )
        self.__setEnabledSpecificEnv( False )
        self.runParams.envType = RunParameters.InheritParentEnvPlus

        if self.__inhPlusEnvTable.selectedIndexes():
            self.__delInhButton.setEnabled( True )
            self.__editInhButton.setEnabled( True )
        else:
            self.__delInhButton.setEnabled( False )
            self.__editInhButton.setEnabled( False )
        return

    def __specClicked( self ):
        " Specific env radio button clicked "
        self.__setEnabledInheritedPlusEnv( False )
        self.__setEnabledSpecificEnv( True )
        self.runParams.envType = RunParameters.SpecificEnvironment

        if self.__specEnvTable.selectedIndexes():
            self.__delSpecButton.setEnabled( True )
            self.__editSpecButton.setEnabled( True )
        else:
            self.__delSpecButton.setEnabled( False )
            self.__editSpecButton.setEnabled( False )
        return

    @staticmethod
    def __delAndInsert( table, name, value ):
        " Deletes an item by name if so; insert new; highlight it "
        for index in xrange( table.topLevelItemCount() ):
            item = table.topLevelItem( index )
            if str( item.text( 0 ) ) == name:
                table.takeTopLevelItem( index )
                break

        item = QTreeWidgetItem( [ name, value ] )
        table.addTopLevelItem( item )
        table.setCurrentItem( item )
        return item

    def __addInhClicked( self ):
        " Add env var button clicked "
        dlg = EnvVarDialog()
        if dlg.exec_() == QDialog.Accepted:
            name = str( dlg.name )
            value = str( dlg.value )
            self.__delAndInsert( self.__inhPlusEnvTable, name, value )
            self.runParams.additionToParentEnv[ name ] = value
            self.__delInhButton.setEnabled( True )
            self.__editInhButton.setEnabled( True )
        return

    def __addSpecClicked( self ):
        " Add env var button clicked "
        dlg = EnvVarDialog()
        if dlg.exec_() == QDialog.Accepted:
            name = str( dlg.name )
            value = str( dlg.value )
            self.__delAndInsert( self.__specEnvTable, name, value )
            self.runParams.specificEnv[ name ] = value
            self.__delSpecButton.setEnabled( True )
            self.__editSpecButton.setEnabled( True )
        return

    def __delInhClicked( self ):
        " Delete the highlighted variable "
        if self.__inhPlusEnvTable.topLevelItemCount() == 0:
            return

        name = self.__inhPlusEnvTable.currentItem().text( 0 )
        for index in xrange( self.__inhPlusEnvTable.topLevelItemCount() ):
            item = self.__inhPlusEnvTable.topLevelItem( index )
            if name == item.text( 0 ):
                self.__inhPlusEnvTable.takeTopLevelItem( index )
                break

        del self.runParams.additionToParentEnv[ str( name ) ]
        if self.__inhPlusEnvTable.topLevelItemCount() == 0:
            self.__delInhButton.setEnabled( False )
            self.__editInhButton.setEnabled( False )
        else:
            self.__inhPlusEnvTable.setCurrentItem( \
                                self.__inhPlusEnvTable.topLevelItem( 0 ) )
        return

    def __delSpecClicked( self ):
        " Delete the highlighted variable "
        if self.__specEnvTable.topLevelItemCount() == 0:
            return

        name = self.__specEnvTable.currentItem().text( 0 )
        for index in xrange( self.__specEnvTable.topLevelItemCount() ):
            item = self.__specEnvTable.topLevelItem( index )
            if name == item.text( 0 ):
                self.__specEnvTable.takeTopLevelItem( index )
                break

        del self.runParams.specificEnv[ str( name ) ]
        if self.__specEnvTable.topLevelItemCount() == 0:
            self.__delSpecButton.setEnabled( False )
            self.__editSpecButton.setEnabled( False )
        else:
            self.__specEnvTable.setCurrentItem( \
                            self.__specEnvTable.topLevelItem( 0 ) )
        return

    def __editInhClicked( self ):
        " Edits the highlighted variable "
        if self.__inhPlusEnvTable.topLevelItemCount() == 0:
            return

        item = self.__inhPlusEnvTable.currentItem()
        dlg = EnvVarDialog( str( item.text( 0 ) ), str( item.text( 1 ) ), self )
        if dlg.exec_() == QDialog.Accepted:
            name = str( dlg.name )
            value = str( dlg.value )
            self.__delAndInsert( self.__inhPlusEnvTable, name, value )
            self.runParams.additionToParentEnv[ name ] = value
        return

    def __inhPlusItemActivated( self, item, column ):
        " Triggered when a table item is activated "
        self.__editInhClicked()
        return

    def __editSpecClicked( self ):
        " Edits the highlighted variable "
        if self.__specEnvTable.topLevelItemCount() == 0:
            return

        item = self.__specEnvTable.currentItem()
        dlg = EnvVarDialog( str( item.text( 0 ) ), str( item.text( 1 ) ), self )
        if dlg.exec_() == QDialog.Accepted:
            name = str( dlg.name )
            value = str( dlg.value )
            self.__delAndInsert( self.__specEnvTable, name, value )
            self.runParams.specificEnv[ name ] = value
        return

    def __specItemActivated( self, item, column ):
        " Triggered when a table item is activated "
        self.__editSpecClicked()
        return

    def onAccept( self ):
        " Saves the selected terminal and profiling values "
        if self.__redirectRButton.isChecked():
            self.termType = TERM_REDIRECT
        elif self.__autoRButton.isChecked():
            self.termType = TERM_AUTO
        elif self.__konsoleRButton.isChecked():
            self.termType = TERM_KONSOLE
        elif self.__gnomeRButton.isChecked():
            self.termType = TERM_GNOME
        else:
            self.termType = TERM_XTERM

        if self.__action == "profile":
            self.profilerParams.nodeLimit = float(
                                    self.__nodeLimitEdit.text() )
            self.profilerParams.edgeLimit = float(
                                    self.__edgeLimitEdit.text() )

        self.accept()
        return