Esempio n. 1
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.current_radio = None
        self.dedicated_radio = None
        self.systerm_radio = None

        self.runconf = RunConfiguration()

        firstrun_o = CONF.get('run', ALWAYS_OPEN_FIRST_RUN_OPTION, False)

        # --- General settings ----
        common_group = QGroupBox(_("General settings"))
        common_layout = QGridLayout()
        common_group.setLayout(common_layout)
        self.clo_cb = QCheckBox(_("Command line options:"))
        common_layout.addWidget(self.clo_cb, 0, 0)
        self.clo_edit = QLineEdit()
        self.connect(self.clo_cb, SIGNAL("toggled(bool)"),
                     self.clo_edit.setEnabled)
        self.clo_edit.setEnabled(False)
        common_layout.addWidget(self.clo_edit, 0, 1)
        self.wd_cb = QCheckBox(_("Working directory:"))
        common_layout.addWidget(self.wd_cb, 1, 0)
        wd_layout = QHBoxLayout()
        self.wd_edit = QLineEdit()
        self.connect(self.wd_cb, SIGNAL("toggled(bool)"),
                     self.wd_edit.setEnabled)
        self.wd_edit.setEnabled(False)
        wd_layout.addWidget(self.wd_edit)
        browse_btn = QPushButton(get_std_icon('DirOpenIcon'), "", self)
        browse_btn.setToolTip(_("Select directory"))
        self.connect(browse_btn, SIGNAL("clicked()"), self.select_directory)
        wd_layout.addWidget(browse_btn)
        common_layout.addLayout(wd_layout, 1, 1)

        # --- Interpreter ---
        interpreter_group = QGroupBox(_("Interpreter"))
        interpreter_layout = QVBoxLayout()
        interpreter_group.setLayout(interpreter_layout)
        self.current_radio = QRadioButton(CURRENT_INTERPRETER)
        interpreter_layout.addWidget(self.current_radio)
        self.dedicated_radio = QRadioButton(DEDICATED_INTERPRETER)
        interpreter_layout.addWidget(self.dedicated_radio)
        self.systerm_radio = QRadioButton(SYSTERM_INTERPRETER)
        interpreter_layout.addWidget(self.systerm_radio)

        # --- Dedicated interpreter ---
        new_group = QGroupBox(_("Dedicated Python interpreter"))
        self.connect(self.current_radio, SIGNAL("toggled(bool)"),
                     new_group.setDisabled)
        new_layout = QGridLayout()
        new_group.setLayout(new_layout)
        self.interact_cb = QCheckBox(
            _("Interact with the Python "
              "interpreter after execution"))
        new_layout.addWidget(self.interact_cb, 1, 0, 1, -1)
        self.pclo_cb = QCheckBox(_("Command line options:"))
        new_layout.addWidget(self.pclo_cb, 2, 0)
        self.pclo_edit = QLineEdit()
        self.connect(self.pclo_cb, SIGNAL("toggled(bool)"),
                     self.pclo_edit.setEnabled)
        self.pclo_edit.setEnabled(False)
        self.pclo_edit.setToolTip(
            _("<b>-u</b> is added to the "
              "other options you set here"))
        new_layout.addWidget(self.pclo_edit, 2, 1)

        #TODO: Add option for "Post-mortem debugging"

        # Checkbox to preserve the old behavior, i.e. always open the dialog
        # on first run
        hline = QFrame()
        hline.setFrameShape(QFrame.HLine)
        hline.setFrameShadow(QFrame.Sunken)
        self.firstrun_cb = QCheckBox(ALWAYS_OPEN_FIRST_RUN % _("this dialog"))
        self.connect(self.firstrun_cb, SIGNAL("clicked(bool)"),
                     self.set_firstrun_o)
        self.firstrun_cb.setChecked(firstrun_o)

        layout = QVBoxLayout()
        layout.addWidget(interpreter_group)
        layout.addWidget(common_group)
        layout.addWidget(new_group)
        layout.addWidget(hline)
        layout.addWidget(self.firstrun_cb)
        self.setLayout(layout)
Esempio n. 2
0
    def __init__(self, parent):
        QFrame.__init__(self, parent)
        self.setContentsMargins(0, 0, 0, 0)
        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(1)
        self._setNameLineEdit = QLineEdit(self)
        layout.addWidget(self._setNameLineEdit)

        self._setListView = QListView(self)
        self._listModel = QStandardItemModel(self)
        self._proxyModel = QSortFilterProxyModel(self)
        self._proxyModel.setSourceModel(self._listModel)

        self._setListView.setModel(self._proxyModel)
        self._setListView.setItemDelegate(ListItemDelegate(self))

        self._setNameLineEdit.textChanged.connect(
            self._proxyModel.setFilterFixedString)

        self._completer = QCompleter(self._listModel, self)

        self._setNameLineEdit.setCompleter(self._completer)

        self._listModel.itemChanged.connect(self._onSetNameChange)
        layout.addWidget(self._setListView)
        buttonLayout = QHBoxLayout()

        self._addAction = QAction("+", self, toolTip="Add a new sort key")
        self._updateAction = QAction("Update",
                                     self,
                                     toolTip="Update/save current selection")
        self._removeAction = QAction("\u2212",
                                     self,
                                     toolTip="Remove selected sort key.")

        self._addToolButton = QToolButton(self)
        self._updateToolButton = QToolButton(self)
        self._removeToolButton = QToolButton(self)
        self._updateToolButton.setSizePolicy(QSizePolicy.MinimumExpanding,
                                             QSizePolicy.Minimum)

        self._addToolButton.setDefaultAction(self._addAction)
        self._updateToolButton.setDefaultAction(self._updateAction)
        self._removeToolButton.setDefaultAction(self._removeAction)

        buttonLayout.addWidget(self._addToolButton)
        buttonLayout.addWidget(self._updateToolButton)
        buttonLayout.addWidget(self._removeToolButton)

        layout.addLayout(buttonLayout)
        self.setLayout(layout)

        self._addAction.triggered.connect(self.addCurrentSelection)
        self._updateAction.triggered.connect(self.updateSelectedSelection)
        self._removeAction.triggered.connect(self.removeSelectedSelection)

        self._setListView.selectionModel().selectionChanged.connect(
            self._onListViewSelectionChanged)
        self.selectionModel = None
        self._selections = []
Esempio n. 3
0
 def createWidget(self, parent):
     return QLineEdit(parent)
Esempio n. 4
0
    def __init__(self, parent):
        QDialog.__init__(self, parent)
        self.tmpPref = {}
        self.tmpPref['pref'] = copy.deepcopy(self.parent().prm['pref'])
        self.currLocale = self.parent().prm['data']['currentLocale']
        self.currLocale.setNumberOptions(self.currLocale.OmitGroupSeparator | self.currLocale.RejectGroupSeparator)
        
        self.tabWidget = QTabWidget()
        self.tabWidget.currentChanged.connect(self.tabChanged)
        self.appPrefWidget = QWidget()
        self.plotPrefWidget = QWidget()
        self.signalPrefWidget = QWidget()
        self.soundPrefWidget = QWidget()

        
        #APP PREF
        appPrefGrid = QGridLayout()
        n = 0
        self.languageChooserLabel = QLabel(self.tr('Language (requires restart):'))
        appPrefGrid.addWidget(self.languageChooserLabel, n, 0)
        self.languageChooser = QComboBox()
        self.languageChooser.addItems(self.parent().prm['data']['available_languages'])
        self.languageChooser.setCurrentIndex(self.languageChooser.findText(self.tmpPref['pref']['language']))
        self.languageChooser.currentIndexChanged[int].connect(self.onLanguageChooserChange)
        appPrefGrid.addWidget(self.languageChooser, n, 1)
        n = n+1
        self.countryChooserLabel = QLabel(self.tr('Country (requires restart):'))
        appPrefGrid.addWidget(self.countryChooserLabel, n, 0)
        self.countryChooser = QComboBox()
        self.countryChooser.addItems(self.parent().prm['data']['available_countries'][self.tmpPref['pref']['language']])
        self.countryChooser.setCurrentIndex(self.countryChooser.findText(self.tmpPref['pref']['country']))
        appPrefGrid.addWidget(self.countryChooser, n, 1)

        self.appPrefWidget.setLayout(appPrefGrid)
        
        #PLOT PREF
        plotPrefGrid = QGridLayout()
        n = 0


        #LINE COLOUR
        self.lineColor1 = self.tmpPref['pref']['lineColor1']
        self.lineColorButton = QPushButton(self.tr("Line Color"), self)
        self.lineColorButton.clicked.connect(self.onChangeLineColor)
        plotPrefGrid.addWidget(self.lineColorButton, n, 0)

        self.lineColorSquare = QWidget(self)
        self.lineColorSquare.setStyleSheet("QWidget { background-color: %s }" % self.lineColor1.name())
        plotPrefGrid.addWidget(self.lineColorSquare, n, 1)
       
        n = n+1
        
        self.backgroundColor = self.tmpPref['pref']['backgroundColor']
        self.backgroundColorButton = QPushButton(self.tr("Background Color"), self)
        self.backgroundColorButton.clicked.connect(self.onChangeBackgroundColor)
        plotPrefGrid.addWidget(self.backgroundColorButton, n, 0)

        self.backgroundColorSquare = QWidget(self)
        self.backgroundColorSquare.setStyleSheet("QWidget { background-color: %s }" % self.backgroundColor.name())
        plotPrefGrid.addWidget(self.backgroundColorSquare, n, 1)

        n = n+1
        self.canvasColor = self.tmpPref['pref']['canvasColor']
        self.canvasColorButton = QPushButton(self.tr("Canvas Color"), self)
        self.canvasColorButton.clicked.connect(self.onChangeCanvasColor)
        plotPrefGrid.addWidget(self.canvasColorButton, n, 0)

        self.canvasColorSquare = QWidget(self)
        self.canvasColorSquare.setStyleSheet("QWidget { background-color: %s }" % self.canvasColor.name())
        plotPrefGrid.addWidget(self.canvasColorSquare, n, 1)
        
        n = n+1
        self.dpiLabel = QLabel(self.tr('DPI - Resolution:'))
        plotPrefGrid.addWidget(self.dpiLabel, n, 0)
        self.dpiWidget = QLineEdit(str(self.tmpPref['pref']['dpi']))
        plotPrefGrid.addWidget(self.dpiWidget, n, 1)
        self.dpiWidget.setValidator(QIntValidator(self))
        self.dpiWidget.editingFinished.connect(self.ondpiChange)
        
        n = n+1
        self.cmapChooserLabel = QLabel(self.tr('Color Map:'))
        plotPrefGrid.addWidget(self.cmapChooserLabel, n, 0)
        self.cmapChooser = QComboBox()
        self.cmapChooser.addItems(self.parent().prm['data']['available_colormaps'])
        self.cmapChooser.setCurrentIndex(self.cmapChooser.findText(self.tmpPref['pref']['colormap']))
        plotPrefGrid.addWidget(self.cmapChooser, n, 1)
        n = n+1
        
        self.gridOn = QCheckBox(self.tr('Grid'))
        self.gridOn.setChecked(self.tmpPref['pref']['grid'])
        plotPrefGrid.addWidget(self.gridOn, n, 1)

        self.plotPrefWidget.setLayout(plotPrefGrid)
        
        #SIGNAL PREF
        signalPrefGrid = QGridLayout()
        n = 0
        self.windowChooser = QComboBox()
        self.windowChooser.addItems(self.parent().prm['data']['available_windows'])
        self.windowChooser.setCurrentIndex(self.windowChooser.findText(self.tmpPref['pref']['smoothingWindow']))
        self.windowChooserLabel = QLabel(self.tr('Window:'))
        signalPrefGrid.addWidget(self.windowChooserLabel, 0, 0)
        signalPrefGrid.addWidget(self.windowChooser, 0, 1)

        n = n+1
        self.signalPrefWidget.setLayout(signalPrefGrid)
        
        #SOUND PREF
        soundPrefGrid = QGridLayout()
        n = 0
        self.wavmanagerLabel = QLabel(self.tr('Wav Manager (requires restart):'))
        self.wavmanagerChooser = QComboBox()
        self.wavmanagerChooser.addItems(["scipy"])
        self.wavmanagerChooser.setCurrentIndex(self.wavmanagerChooser.findText(self.tmpPref['pref']['wavmanager']))
        soundPrefGrid.addWidget(self.wavmanagerLabel, n, 0)
        soundPrefGrid.addWidget(self.wavmanagerChooser, n, 1)

        n = n+1
        
        self.playChooser = QComboBox()
        self.playChooser.addItems(self.parent().prm['data']['available_play_commands'])
        self.playChooser.setCurrentIndex(self.playChooser.findText(self.tmpPref['pref']['playCommandType']))
        self.playChooser.currentIndexChanged[int].connect(self.onPlayChooserChange)
        self.playChooserLabel = QLabel(self.tr('Play Command:'))
        soundPrefGrid.addWidget(self.playChooserLabel, n, 0)
        soundPrefGrid.addWidget(self.playChooser, n, 1)

        n = n+1
        self.playCommandLabel = QLabel(self.tr('Command:'))
        soundPrefGrid.addWidget(self.playCommandLabel, n, 0)
        self.playCommandWidget = QLineEdit(str(self.tmpPref['pref']['playCommand']))
        self.playCommandWidget.setReadOnly(True)
        soundPrefGrid.addWidget(self.playCommandWidget, n, 1)

        n = n+1
        self.maxLevelLabel = QLabel(self.tr('Max Level:'))
        soundPrefGrid.addWidget(self.maxLevelLabel, n, 0)
        self.maxLevelWidget = QLineEdit(self.currLocale.toString(self.tmpPref['pref']['maxLevel']))
        self.maxLevelWidget.setValidator(QDoubleValidator(self))
        soundPrefGrid.addWidget(self.maxLevelWidget, n, 1)

        
        self.soundPrefWidget.setLayout(soundPrefGrid)

        self.tabWidget.addTab(self.appPrefWidget, self.tr("Applicatio&n"))
        self.tabWidget.addTab(self.plotPrefWidget, self.tr("Plot&s"))
        self.tabWidget.addTab(self.signalPrefWidget, self.tr("Signa&l"))
        self.tabWidget.addTab(self.soundPrefWidget, self.tr("Soun&d"))

        buttonBox = QDialogButtonBox(QDialogButtonBox.Apply|QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)
        buttonBox.button(QDialogButtonBox.Apply).clicked.connect(self.permanentApply)
        
        layout = QVBoxLayout()
        layout.addWidget(self.tabWidget)
        layout.addWidget(buttonBox)
        self.setLayout(layout)
Esempio n. 5
0
    def __init__(self):

        super(nuevousuario, self).__init__(None)
        self.foto = ''
        self.resize(400, 460)
        self.setWindowTitle('Datos de Usuario')
        
        self.imaje = QLabel(self)
        self.imaje.setGeometry(160,210,225,225)
        self.imaje.setPixmap(QPixmap("usuario.png"))
        
        self.n = QLabel('Nombre Completo:',self)
        self.n.move(10,10)
        
        self.u = QLabel('Nombre de Usuario:',self)
        self.u.move(10,50)
        
        self.failu = QLabel('Este Usuario ya Existe',self)
        self.failu.move(140,70)
        self.failu.hide()
        
        self.c = QLabel('Correo Electronico:',self)
        self.c.move(10,90)
        
        self.a = QLabel('Edad:',self)
        self.a.move(10,130)
  
        self.faila = QLabel('Ingrese una Edad',self)
        self.faila.move(140,150)
        self.faila.hide()
      
        self.p = QLabel('Clave:',self)
        self.p.move(10,170)
        
        self.failp = QLabel('Clave muy Debil',self)
        self.failp.move(140,190)
        self.failp.hide()

        self.f = QLabel('Foto:',self)
        self.f.move(10,210)
        
        self.Name = QLineEdit(self)
        self.Name.setGeometry(140, 10, 200, 20)
        
        self.User = QLineEdit(self)
        self.User.setGeometry(140, 50, 200, 20)
        
        self.Mail = QLineEdit(self)
        self.Mail.setGeometry(140, 90, 200, 20)
        
        self.Age = QLineEdit(self)
        self.Age.setGeometry(140, 130, 200, 20)
        
        self.Pass = QLineEdit(self)
        self.Pass.setGeometry(140, 170, 200, 20)

        key = self.Pass
        key.setEchoMode(self.Pass.Password)
        
        self.buscarfoto = QPushButton('Buscar Foto', self)
        self.buscarfoto.setGeometry(10, 250, 100, 30)
        
        self.guardar = QPushButton('Guardar', self)
        self.guardar.setGeometry(30, 300, 60, 30)

        self.failc = QLabel('Llenar Campos Vacios',self)
        self.failc.move(10,350)
        self.failc.hide()

        self.failf = QLabel('Elija Una Foto',self)
        self.failf.move(140,440)
        self.failf.hide()
                
        self.connect(self.buscarfoto, SIGNAL('clicked()'), lambda: self.buscar(self.ponfoto))
        self.connect(self.guardar, SIGNAL('clicked()'), lambda: self.nuevo(self.Name, self.User, self.Mail, self.Age, self.Pass))
Esempio n. 6
0
    def __init__(self):
        QWizardPage.__init__(self)
        self.setTitle(self.tr("New Project Data"))
        self.setSubTitle(
            self.tr(
                "Complete the following fields to create the Project Structure"
            ))

        gbox = QGridLayout(self)
        #Names of the fields to complete
        self.lblName = QLabel(self.tr("New Project Name (*):"))
        self.lblPlace = QLabel(self.tr("Project Location (*):"))
        self.lblDescription = QLabel(self.tr("Project Description:"))
        self.lblLicense = QLabel(self.tr("Project License:"))
        self.lblVenvFolder = QLabel(self.tr("Virtualenv Folder:"))
        gbox.addWidget(self.lblName, 0, 0, Qt.AlignRight)
        gbox.addWidget(self.lblPlace, 1, 0, Qt.AlignRight)
        gbox.addWidget(self.lblDescription, 2, 0, Qt.AlignTop)
        gbox.addWidget(self.lblLicense, 3, 0, Qt.AlignRight)
        gbox.addWidget(self.lblVenvFolder, 4, 0, Qt.AlignRight)

        #Fields on de right of the grid
        #Name
        self.txtName = QLineEdit()
        #Location
        hPlace = QHBoxLayout()
        self.txtPlace = QLineEdit()
        self.txtPlace.setReadOnly(True)
        self.btnExamine = QPushButton(self.tr("Browse..."))
        hPlace.addWidget(self.txtPlace)
        hPlace.addWidget(self.btnExamine)
        #Virtualenv
        vPlace = QHBoxLayout()
        self.vtxtPlace = QLineEdit()
        self.vtxtPlace.setReadOnly(True)
        self.vbtnExamine = QPushButton(self.tr("Browse..."))
        vPlace.addWidget(self.vtxtPlace)
        vPlace.addWidget(self.vbtnExamine)
        #Project Description
        self.txtDescription = QPlainTextEdit()
        #Project License
        self.cboLicense = QComboBox()
        self.cboLicense.setFixedWidth(250)
        self.cboLicense.addItem('Apache License 2.0')
        self.cboLicense.addItem('Artistic License/GPL')
        self.cboLicense.addItem('Eclipse Public License 1.0')
        self.cboLicense.addItem('GNU General Public License v2')
        self.cboLicense.addItem('GNU General Public License v3')
        self.cboLicense.addItem('GNU Lesser General Public License')
        self.cboLicense.addItem('MIT License')
        self.cboLicense.addItem('Mozilla Public License 1.1')
        self.cboLicense.addItem('New BSD License')
        self.cboLicense.addItem('Other Open Source')
        self.cboLicense.addItem('Other')
        self.cboLicense.setCurrentIndex(4)
        #Add to Grid
        gbox.addWidget(self.txtName, 0, 1)
        gbox.addLayout(hPlace, 1, 1)
        gbox.addWidget(self.txtDescription, 2, 1)
        gbox.addWidget(self.cboLicense, 3, 1)
        gbox.addLayout(vPlace, 4, 1)
        #Signal
        self.connect(self.btnExamine, SIGNAL('clicked()'), self.load_folder)
        self.connect(self.vbtnExamine, SIGNAL('clicked()'),
                     self.load_folder_venv)
        self.connect(self.txtName, SIGNAL('textChanged(const QString&)'),
                     lambda: self.emit(SIGNAL("completeChanged()")))
    def initUI(self):
        self.setMinimumSize(QSize(150, 450))
        self.setMaximumSize(QSize(150, 450))
        layout = QVBoxLayout(self)
        self.setLayout(layout)

        #Create widgets
        l_sprite = QLabel(self)
        i_sprite = QSpinBox(self)
        i_trainerclass = QComboBox(self)
        i_name = QLineEdit(self)
        i_gender = QComboBox(self)
        l_songid = QLabel("Song:", self)
        i_songid = QSpinBox(self)
        i_doublebattle = QCheckBox("Double battle", self)
        i_choosemoves = QCheckBox("Explicit movesets", self)
        l_items = QLabel("Items:")
        i_item1 = QComboBox(self)
        i_item2 = QComboBox(self)
        i_item3 = QComboBox(self)
        i_item4 = QComboBox(self)

        #fill lists, set ranges values
        i_sprite.setRange(0, 255)
        i_songid.setRange(0, 0b01111111)
        i_trainerclass.addItems(self.trainerclasses)
        l_sprite.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        l_sprite.setMinimumSize(120, 64)
        l_sprite.setAlignment(Qt.AlignCenter)
        i_gender.addItems(['Male', 'Female'])
        i_item1.addItems(self.itemslist)
        i_item2.addItems(self.itemslist)
        i_item3.addItems(self.itemslist)
        i_item4.addItems(self.itemslist)

        #Set fields according to the trainer object
        i_sprite.setValue(self.trainer.trainerspriteid)
        i_name.setText(self.trainer.getName().getText())
        i_songid.setValue(self.trainer.getSong())
        i_trainerclass.setCurrentIndex(self.trainer.trainerclass)
        i_doublebattle.setChecked(self.trainer.doublebattle)
        i_choosemoves.setChecked(self.trainer.customMoves())
        i_gender.setCurrentIndex(not self.trainer.isMale())
        i_item1.setCurrentIndex(self.trainer.item1)
        i_item2.setCurrentIndex(self.trainer.item2)
        i_item3.setCurrentIndex(self.trainer.item3)
        i_item4.setCurrentIndex(self.trainer.item4)

        #Add all to layout
        layout.addWidget(l_sprite)
        layout.addWidget(i_sprite)
        layout.addWidget(i_gender)
        layout.addWidget(i_trainerclass)
        layout.addWidget(i_name)
        layout.addWidget(i_name)
        layout.addWidget(l_songid)
        layout.addWidget(i_songid)
        layout.addWidget(i_doublebattle)
        layout.addWidget(i_choosemoves)
        layout.addWidget(l_items)
        layout.addWidget(i_item1)
        layout.addWidget(i_item2)
        layout.addWidget(i_item3)
        layout.addWidget(i_item4)

        #Connect to signals
        i_sprite.valueChanged.connect(self.updateSprite)
        i_choosemoves.stateChanged.connect(self.chooseMovesChanged)

        #Keep values for future refs
        self.l_sprite = l_sprite
        self.i_sprite = i_sprite
        self.i_trainerclass = i_trainerclass
        self.i_gender = i_gender
        self.i_name = i_name
        self.i_songid = i_songid
        self.i_item1 = i_item1
        self.i_item2 = i_item2
        self.i_item3 = i_item3
        self.i_item4 = i_item4
        self.i_doublebattle = i_doublebattle
        self.i_choosemoves = i_choosemoves

        self.updateSprite()
        self.chooseMovesChanged(i_choosemoves.checkState())
 def getWidgetFromParameter(self, param):
     if isinstance(param, ParameterRaster):
         item = QComboBox()
         layers = self.getAvailableValuesOfType(ParameterRaster,
                                                OutputRaster)
         if param.optional:
             item.addItem(self.NOT_SELECTED, None)
         for layer in layers:
             item.addItem(self.resolveValueDescription(layer), layer)
     elif isinstance(param, ParameterVector):
         item = QComboBox()
         layers = self.getAvailableValuesOfType(ParameterVector,
                                                OutputVector)
         if param.optional:
             item.addItem(self.NOT_SELECTED, None)
         for layer in layers:
             item.addItem(self.resolveValueDescription(layer), layer)
     elif isinstance(param, ParameterTable):
         item = QComboBox()
         tables = self.getAvailableValuesOfType(ParameterTable, OutputTable)
         layers = self.getAvailableValuesOfType(ParameterVector,
                                                OutputVector)
         if param.optional:
             item.addItem(self.NOT_SELECTED, None)
         for table in tables:
             item.addItem(self.resolveValueDescription(table), table)
         for layer in layers:
             item.addItem(self.resolveValueDescription(layer), layer)
     elif isinstance(param, ParameterBoolean):
         item = QComboBox()
         item.addItem('Yes')
         item.addItem('No')
         bools = self.getAvailableValuesOfType(ParameterBoolean, None)
         for b in bools:
             item.addItem(self.resolveValueDescription(b), b)
     elif isinstance(param, ParameterSelection):
         item = QComboBox()
         item.addItems(param.options)
     elif isinstance(param, ParameterFixedTable):
         item = FixedTablePanel(param)
     elif isinstance(param, ParameterRange):
         item = RangePanel(param)
     elif isinstance(param, ParameterMultipleInput):
         if param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
             options = self.getAvailableValuesOfType(
                 ParameterVector, OutputVector)
         else:
             options = self.getAvailableValuesOfType(
                 ParameterRaster, OutputRaster)
         opts = []
         for opt in options:
             opts.append(self.resolveValueDescription(opt))
         item = MultipleInputPanel(opts)
     elif isinstance(param, ParameterString):
         strings = self.getAvailableValuesOfType(ParameterString,
                                                 OutputString)
         options = [(self.resolveValueDescription(s), s) for s in strings]
         if param.multiline:
             item = MultilineTextPanel(options)
             item.setText(unicode(param.default))
         else:
             item = QComboBox()
             item.setEditable(True)
             for desc, val in options:
                 item.addItem(desc, val)
             item.setEditText(unicode(param.default))
     elif isinstance(param, ParameterTableField):
         item = QComboBox()
         item.setEditable(True)
         fields = self.getAvailableValuesOfType(ParameterTableField, None)
         for f in fields:
             item.addItem(self.resolveValueDescription(f), f)
     elif isinstance(param, ParameterNumber):
         item = QComboBox()
         item.setEditable(True)
         numbers = self.getAvailableValuesOfType(ParameterNumber,
                                                 OutputNumber)
         for n in numbers:
             item.addItem(self.resolveValueDescription(n), n)
         item.setEditText(str(param.default))
     elif isinstance(param, ParameterCrs):
         item = CrsSelectionPanel(param.default)
     elif isinstance(param, ParameterExtent):
         item = QComboBox()
         item.setEditable(True)
         extents = self.getAvailableValuesOfType(ParameterExtent,
                                                 OutputExtent)
         if self.canUseAutoExtent():
             item.addItem(self.USE_MIN_COVERING_EXTENT, None)
         for ex in extents:
             item.addItem(self.resolveValueDescription(ex), ex)
         if not self.canUseAutoExtent():
             item.setEditText(str(param.default))
     elif isinstance(param, ParameterFile):
         item = QComboBox()
         item.setEditable(True)
         files = self.getAvailableValuesOfType(ParameterFile, OutputFile)
         for f in files:
             item.addItem(self.resolveValueDescription(f), f)
     elif isinstance(param, ParameterGeometryPredicate):
         item = GeometryPredicateSelectionPanel(param.enabledPredicates)
     else:
         item = QLineEdit()
         try:
             item.setText(str(param.default))
         except:
             pass
     return item
    def setupUi(self):
        self.labels = {}
        self.widgets = {}
        self.checkBoxes = {}
        self.showAdvanced = False
        self.valueItems = {}
        self.dependentItems = {}
        self.resize(650, 450)
        self.buttonBox = QDialogButtonBox()
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel
                                          | QDialogButtonBox.Ok)
        tooltips = self._alg.getParameterDescriptions()
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.verticalLayout = QVBoxLayout()
        self.verticalLayout.setSpacing(5)
        self.verticalLayout.setMargin(20)

        hLayout = QHBoxLayout()
        hLayout.setSpacing(5)
        hLayout.setMargin(0)
        descriptionLabel = QLabel(self.tr("Description"))
        self.descriptionBox = QLineEdit()
        self.descriptionBox.setText(self._alg.name)
        hLayout.addWidget(descriptionLabel)
        hLayout.addWidget(self.descriptionBox)
        self.verticalLayout.addLayout(hLayout)
        line = QFrame()
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)
        self.verticalLayout.addWidget(line)

        for param in self._alg.parameters:
            if param.isAdvanced:
                self.advancedButton = QPushButton()
                self.advancedButton.setText(
                    self.tr('Show advanced parameters'))
                self.advancedButton.setMaximumWidth(150)
                self.advancedButton.clicked.connect(
                    self.showAdvancedParametersClicked)
                self.verticalLayout.addWidget(self.advancedButton)
                break
        for param in self._alg.parameters:
            if param.hidden:
                continue
            desc = param.description
            if isinstance(param, ParameterExtent):
                desc += '(xmin, xmax, ymin, ymax)'
            label = QLabel(desc)
            self.labels[param.name] = label
            widget = self.getWidgetFromParameter(param)
            self.valueItems[param.name] = widget
            if param.name in tooltips.keys():
                tooltip = tooltips[param.name]
            else:
                tooltip = param.description
            label.setToolTip(tooltip)
            widget.setToolTip(tooltip)
            if param.isAdvanced:
                label.setVisible(self.showAdvanced)
                widget.setVisible(self.showAdvanced)
                self.widgets[param.name] = widget
            self.verticalLayout.addWidget(label)
            self.verticalLayout.addWidget(widget)

        for output in self._alg.outputs:
            if output.hidden:
                continue
            if isinstance(output, (OutputRaster, OutputVector, OutputTable,
                                   OutputHTML, OutputFile, OutputDirectory)):
                label = QLabel(output.description + '<' +
                               output.__class__.__name__ + '>')
                item = QLineEdit()
                if hasattr(item, 'setPlaceholderText'):
                    item.setPlaceholderText(ModelerParametersDialog.ENTER_NAME)
                self.verticalLayout.addWidget(label)
                self.verticalLayout.addWidget(item)
                self.valueItems[output.name] = item

        label = QLabel(' ')
        self.verticalLayout.addWidget(label)
        label = QLabel(self.tr('Parent algorithms'))
        self.dependenciesPanel = self.getDependenciesPanel()
        self.verticalLayout.addWidget(label)
        self.verticalLayout.addWidget(self.dependenciesPanel)

        self.verticalLayout.addStretch(1000)
        self.setLayout(self.verticalLayout)

        self.setPreviousValues()
        self.setWindowTitle(self._alg.name)
        self.verticalLayout2 = QVBoxLayout()
        self.verticalLayout2.setSpacing(2)
        self.verticalLayout2.setMargin(0)
        self.tabWidget = QTabWidget()
        self.tabWidget.setMinimumWidth(300)
        self.paramPanel = QWidget()
        self.paramPanel.setLayout(self.verticalLayout)
        self.scrollArea = QScrollArea()
        self.scrollArea.setWidget(self.paramPanel)
        self.scrollArea.setWidgetResizable(True)
        self.tabWidget.addTab(self.scrollArea, self.tr('Parameters'))
        self.webView = QWebView()

        html = None
        url = None
        isText, help = self._alg.help()
        if help is not None:
            if isText:
                html = help
            else:
                url = QUrl(help)
        else:
            html = self.tr('<h2>Sorry, no help is available for this '
                           'algorithm.</h2>')
        try:
            if html:
                self.webView.setHtml(html)
            elif url:
                self.webView.load(url)
        except:
            self.webView.setHtml(
                self.tr('<h2>Could not open help file :-( </h2>'))
        self.tabWidget.addTab(self.webView, 'Help')
        self.verticalLayout2.addWidget(self.tabWidget)
        self.verticalLayout2.addWidget(self.buttonBox)
        self.setLayout(self.verticalLayout2)
        self.buttonBox.accepted.connect(self.okPressed)
        self.buttonBox.rejected.connect(self.cancelPressed)
        QMetaObject.connectSlotsByName(self)
Esempio n. 10
0
    def __init__(self, parent=None):
        super().__init__(parent=parent)

        # cost display
        self.cost = QGroupBox("National ideas")
        costLayout = QFormLayout()

        self.costRating = QLineEdit()
        self.costRating.setReadOnly(True)
        costLayout.addRow(QLabel("Rating:"), self.costRating)

        self.costDisplay = QLineEdit()
        self.costDisplay.setReadOnly(True)
        costLayout.addRow(QLabel("Cost:"), self.costDisplay)

        possibleRatings = QGroupBox("Possible ratings")
        possibleRatingsLayout = QFormLayout()
        for cost, rating in ideaRatings:
            if cost is not None:
                possibleRatingsLayout.addRow(QLabel("Up to %0.1f:" % (cost),), QLabel(rating))
            else:
                possibleRatingsLayout.addRow(QLabel("Above:"), QLabel(rating))
        possibleRatings.setLayout(possibleRatingsLayout)
        costLayout.addRow(possibleRatings)

        breakdown = QGroupBox("Breakdown")
        breakdownLayout = QFormLayout()
        self.breakdownLabels = []
        self.breakdownCosts = []
        for i in range(9):
            breakdownLabel = QLabel()
            self.breakdownLabels.append(breakdownLabel)
            
            breakdownCost = QLineEdit()
            breakdownCost.setReadOnly(True)
            
            self.breakdownCosts.append(breakdownCost)
            breakdownLayout.addRow(breakdownLabel, breakdownCost)

        breakdown.setLayout(breakdownLayout)

        costLayout.addRow(breakdown)

        self.cost.setLayout(costLayout)

        self.cost.setToolTip(costToolTipText)

        # penalty display
        self.penalties = QGroupBox("Penalties")
        penaltiesLayout = QFormLayout()

        # self.penaltiesRating = QLineEdit()
        # self.penaltiesRating.setReadOnly(True)
        # penaltiesLayout.addRow(QLabel("Rating:"), self.penaltiesRating)
        
        self.yellowCardCount = QLineEdit()
        self.yellowCardCount.setReadOnly(True)
        penaltiesLayout.addRow(QLabel("Yellow cards:"), self.yellowCardCount)

        self.yellowCardDisplay = QListView()
        self.yellowCardDisplay.setSelectionMode(QAbstractItemView.NoSelection)
        self.yellowCards = QStringListModel()
        self.yellowCardDisplay.setModel(self.yellowCards)
        penaltiesLayout.addRow(self.yellowCardDisplay)

        self.redCardCount = QLineEdit()
        self.redCardCount.setReadOnly(True)
        penaltiesLayout.addRow(QLabel("Red cards:"), self.redCardCount)

        self.redCardDisplay = QListView()
        self.redCardDisplay.setSelectionMode(QAbstractItemView.NoSelection)
        self.redCards = QStringListModel()
        self.redCardDisplay.setModel(self.redCards)
        penaltiesLayout.addRow(self.redCardDisplay)

        self.penalties.setLayout(penaltiesLayout)

        self.penalties.setToolTip(penaltiesToolTipText)

        layout = QHBoxLayout()

        layout.addWidget(self.cost)
        layout.addWidget(self.penalties)

        self.setLayout(layout)
Esempio n. 11
0
    def initUI(self):
        self.setGeometry(200, 200, 250, 200)
        self.setWindowTitle(u'查找')

        title = QLabel(u'请选择搜索模式:')

        self.type_site_id = QRadioButton(u"基站ID ")
        self.type_site_id.setChecked(True)  # 默认查找基站ID
        self.type_site_name = QRadioButton(u"基站名 ")
        self.type_cell_id = QRadioButton(u"小区ID ")
        self.type_cell_name = QRadioButton(u"小区名 ")
        self.type_pn = QRadioButton(u"PN ")
        self.type_psc = QRadioButton(u"PSC ")
        self.type_pci = QRadioButton(u"PCI ")
        self.type_bcch = QRadioButton(u"BCCH ")

        search_type = QButtonGroup()
        search_type.addButton(self.type_site_id)
        search_type.addButton(self.type_site_name)
        search_type.addButton(self.type_cell_id)
        search_type.addButton(self.type_cell_name)
        search_type.addButton(self.type_pn)
        search_type.addButton(self.type_psc)
        search_type.addButton(self.type_pci)
        search_type.addButton(self.type_bcch)

        search_grid = QGridLayout()
        search_grid.setSpacing(10)
        search_grid.addWidget(self.type_site_id, 0, 1)
        search_grid.addWidget(self.type_site_name, 0, 2)
        search_grid.addWidget(self.type_cell_id, 0, 3)
        search_grid.addWidget(self.type_cell_name, 0, 4)
        search_grid.addWidget(self.type_pn, 1, 1)
        search_grid.addWidget(self.type_psc, 1, 2)
        search_grid.addWidget(self.type_pci, 1, 3)
        search_grid.addWidget(self.type_bcch, 1, 4)

        search_hbox = QHBoxLayout()
        search_hbox.setSpacing(10)
        search_hbox.addStretch(1)
        search_hbox.addLayout(search_grid)
        search_hbox.addStretch(1)

        self.searchText = QLineEdit()
        ok = QPushButton(u'确定')
        self.connect(ok, SIGNAL('clicked()'), self.search)
        cancel = QPushButton(u'取消')
        self.connect(cancel, SIGNAL('clicked()'), self.cancel)

        btn_hbox = QHBoxLayout()
        btn_hbox.setSpacing(10)
        btn_hbox.addStretch(1)
        btn_hbox.addWidget(ok)
        btn_hbox.addWidget(cancel)
        btn_hbox.addStretch(1)

        vbox = QVBoxLayout()
        vbox.setSpacing(15)
        vbox.addWidget(title)
        vbox.addLayout(search_hbox)
        vbox.addWidget(self.searchText)
        vbox.addStretch(1)
        vbox.addLayout(btn_hbox)

        self.setLayout(vbox)
        self.resize(350, 190)
Esempio n. 12
0
 def setup(self):
     for label, value in self.data:
         if DEBUG_FORMLAYOUT:
             print("value:", value)
         if label is None and value is None:
             # Separator: (None, None)
             self.formlayout.addRow(QLabel(" "), QLabel(" "))
             self.widgets.append(None)
             continue
         elif label is None:
             # Comment
             self.formlayout.addRow(QLabel(value))
             self.widgets.append(None)
             continue
         elif tuple_to_qfont(value) is not None:
             field = FontLayout(value, self)
         elif text_to_qcolor(value).isValid():
             field = ColorLayout(QColor(value), self)
         elif is_text_string(value):
             if '\n' in value:
                 for linesep in (os.linesep, '\n'):
                     if linesep in value:
                         value = value.replace(linesep, u("\u2029"))
                 field = QTextEdit(value, self)
             else:
                 field = QLineEdit(value, self)
         elif isinstance(value, (list, tuple)):
             value = list(value)  # in case this is a tuple
             selindex = value.pop(0)
             field = QComboBox(self)
             if isinstance(value[0], (list, tuple)):
                 keys = [ key for key, _val in value ]
                 value = [ val for _key, val in value ]
             else:
                 keys = value
             field.addItems(value)
             if selindex in value:
                 selindex = value.index(selindex)
             elif selindex in keys:
                 selindex = keys.index(selindex)
             elif not isinstance(selindex, int):
                 print("Warning: '%s' index is invalid (label: "\
                       "%s, value: %s)" % (selindex, label, value),
                       file=STDERR)
                 selindex = 0
             field.setCurrentIndex(selindex)
         elif isinstance(value, bool):
             field = QCheckBox(self)
             field.setCheckState(Qt.Checked if value else Qt.Unchecked)
         elif isinstance(value, float):
             field = QLineEdit(repr(value), self)
             field.setValidator(QDoubleValidator(field))
             dialog = self.get_dialog()
             dialog.register_float_field(field)
             self.connect(field, SIGNAL('textChanged(QString)'),
                          lambda text: dialog.update_buttons())
         elif isinstance(value, int):
             field = QSpinBox(self)
             field.setRange(-1e9, 1e9)
             field.setValue(value)
         elif isinstance(value, datetime.datetime):
             field = QDateTimeEdit(self)
             field.setDateTime(value)
         elif isinstance(value, datetime.date):
             field = QDateEdit(self)
             field.setDate(value)
         else:
             field = QLineEdit(repr(value), self)
         self.formlayout.addRow(label, field)
         self.widgets.append(field)
Esempio n. 13
0
    def __init__(self, parent):
        QDialog.__init__(self, parent)
        self.prm = self.parent().prm
        self.currLocale = self.parent().prm['currentLocale']
        self.currLocale.setNumberOptions(
            self.currLocale.OmitGroupSeparator
            | self.currLocale.RejectGroupSeparator)
        screen = QDesktopWidget().screenGeometry()
        self.resize(screen.width() / 2.5, screen.height() / 3)
        self.isPlaying = False
        #self.audioManager = audioManager(self)
        #self.playThread = threadedPlayer(self)

        self.sizer = QGridLayout()
        self.v1Sizer = QVBoxLayout()
        self.v2Sizer = QVBoxLayout()
        self.calibSizer = QGridLayout()

        self.phonesTableWidget = QTableWidget()
        self.phonesTableWidget.setColumnCount(4)
        self.phonesTableWidget.setSelectionBehavior(
            QAbstractItemView.SelectRows)
        self.phonesTableWidget.setSelectionMode(
            QAbstractItemView.ExtendedSelection)

        self.phonesTableWidget.setHorizontalHeaderLabels([
            self.tr('Phones'),
            self.tr('Max Level'),
            self.tr('Default'), 'id'
        ])
        self.phonesTableWidget.hideColumn(3)
        self.phonesTableWidget.cellDoubleClicked[int, int].connect(
            self.onCellDoubleClicked)

        #RENAME Phones BUTTON
        self.renamePhonesButton = QPushButton(self.tr("Rename Phones"), self)
        self.renamePhonesButton.clicked.connect(self.onEditLabel)
        #Change Level Phones BUTTON
        self.changeLevelPhonesButton = QPushButton(self.tr("Change Max Level"),
                                                   self)
        self.changeLevelPhonesButton.clicked.connect(self.onEditMaxLevel)

        #ADD Phones BUTTON
        self.addPhonesButton = QPushButton(self.tr("Add Phones"), self)
        self.addPhonesButton.clicked.connect(self.onClickAddPhonesButton)
        #REMOVE Phones BUTTON
        self.removePhonesButton = QPushButton(self.tr("Remove Phones"), self)
        self.removePhonesButton.clicked.connect(self.onClickRemovePhonesButton)
        #Set Default Phones BUTTON
        self.setDefaultPhonesButton = QPushButton(self.tr("Set Default"), self)
        self.setDefaultPhonesButton.clicked.connect(self.onEditDefault)

        self.v1Sizer.addWidget(self.renamePhonesButton)
        self.v1Sizer.addWidget(self.changeLevelPhonesButton)
        self.v1Sizer.addWidget(self.addPhonesButton)
        self.v1Sizer.addWidget(self.removePhonesButton)
        self.v1Sizer.addWidget(self.setDefaultPhonesButton)
        self.v1Sizer.addStretch()
        self.phonesList = {}

        for i in range(len(self.prm['phones']['phonesChoices'])):
            currCount = i + 1
            thisID = self.prm['phones']['phonesID'][i]
            self.phonesList[thisID] = {}
            self.phonesList[thisID]['label'] = self.prm['phones'][
                'phonesChoices'][i]
            self.phonesList[thisID]['maxLevel'] = self.prm['phones'][
                'phonesMaxLevel'][i]
            self.phonesList[thisID]['default'] = self.prm['phones'][
                'defaultPhones'][i]
            self.phonesTableWidget.setRowCount(currCount)
            newItem = QTableWidgetItem(self.phonesList[thisID]['label'])
            newItem.setFlags(QtCore.Qt.ItemIsSelectable
                             | QtCore.Qt.ItemIsEnabled)
            self.phonesTableWidget.setItem(currCount - 1, 0, newItem)
            newItem = QTableWidgetItem(
                self.currLocale.toString(self.phonesList[thisID]['maxLevel']))
            newItem.setFlags(QtCore.Qt.ItemIsSelectable
                             | QtCore.Qt.ItemIsEnabled)
            self.phonesTableWidget.setItem(currCount - 1, 1, newItem)
            newItem = QTableWidgetItem(self.phonesList[thisID]['default'])
            newItem.setFlags(QtCore.Qt.ItemIsSelectable
                             | QtCore.Qt.ItemIsEnabled)
            self.phonesTableWidget.setItem(currCount - 1, 2, newItem)
            self.phonesList[thisID]['qid'] = QTableWidgetItem(thisID)
            self.phonesTableWidget.setItem(currCount - 1, 3,
                                           self.phonesList[thisID]['qid'])

        ##CALIBRATION TONE
        n = 0
        self.calLabel = QLabel(self.tr('Calibration Tone:'), self)
        self.calibSizer.addWidget(self.calLabel, n, 0, 1, 2)
        n = n + 1
        self.toneFreqLabel = QLabel(self.tr('Frequency (Hz)'), self)
        self.toneFreqTF = QLineEdit("1000")
        self.toneFreqTF.setValidator(QDoubleValidator(self))
        self.calibSizer.addWidget(self.toneFreqLabel, n, 0)
        self.calibSizer.addWidget(self.toneFreqTF, n, 1)
        n = n + 1
        self.toneLevLabel = QLabel(self.tr('Level (dB)'), self)
        self.toneLevTF = QLineEdit("60")
        self.toneLevTF.setValidator(QDoubleValidator(self))
        self.calibSizer.addWidget(self.toneLevLabel, n, 0)
        self.calibSizer.addWidget(self.toneLevTF, n, 1)
        n = n + 1
        self.toneDurLabel = QLabel(self.tr('Duration (ms)'), self)
        self.toneDurTF = QLineEdit("980")
        self.toneDurTF.setValidator(QDoubleValidator(self))
        self.calibSizer.addWidget(self.toneDurLabel, n, 0)
        self.calibSizer.addWidget(self.toneDurTF, n, 1)
        n = n + 1
        self.toneRampsLabel = QLabel(self.tr('Ramps (ms)'), self)
        self.toneRampsTF = QLineEdit("10")
        self.toneRampsTF.setValidator(QDoubleValidator(self))
        self.calibSizer.addWidget(self.toneRampsLabel, n, 0)
        self.calibSizer.addWidget(self.toneRampsTF, n, 1)
        n = n + 1
        self.earLabel = QLabel(self.tr('Ear:'), self)
        self.earChooser = QComboBox()
        self.earChooser.addItems(
            [self.tr("Right"),
             self.tr("Left"),
             self.tr("Both")])
        self.calibSizer.addWidget(self.earLabel, n, 0)
        self.calibSizer.addWidget(self.earChooser, n, 1)
        n = n + 1
        self.playCalibButton = QPushButton(self.tr("Play"), self)
        self.playCalibButton.clicked.connect(self.onClickPlayCalibButton)
        self.playCalibButton.setIcon(
            QIcon.fromTheme("media-playback-start",
                            QIcon(":/media-playback-start")))
        self.calibSizer.addWidget(self.playCalibButton, n, 0, 1, 2)
        n = n + 1
        self.stopCalibButton = QPushButton(self.tr("Stop"), self)
        self.stopCalibButton.clicked.connect(self.onClickStopCalibButton)
        self.stopCalibButton.setIcon(
            QIcon.fromTheme("media-playback-stop",
                            QIcon(":/media-playback-stop")))
        self.calibSizer.addWidget(self.stopCalibButton, n, 0, 1, 2)
        if self.prm['pref']['sound']['playCommand'] in [
                "alsaaudio", "pyaudio"
        ]:
            self.stopCalibButton.show()
        else:
            self.stopCalibButton.hide()

        buttonBox = QDialogButtonBox(QDialogButtonBox.Apply
                                     | QDialogButtonBox.Ok
                                     | QDialogButtonBox.Cancel)
        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)
        buttonBox.button(QDialogButtonBox.Apply).clicked.connect(
            self.permanentApply)

        self.sizer.addLayout(self.v1Sizer, 0, 0)
        self.v2Sizer.addLayout(self.calibSizer)
        self.v2Sizer.addStretch()
        self.sizer.addWidget(self.phonesTableWidget, 0, 1)
        self.sizer.addLayout(self.v2Sizer, 0, 2)
        self.sizer.addWidget(buttonBox, 1, 1, 1, 2)
        self.sizer.setColumnStretch(1, 2)
        self.setLayout(self.sizer)
        self.setWindowTitle(self.tr("Edit Phones"))
        self.show()
Esempio n. 14
0
    def __init__(self, reaction):
        super(ConditionsDialog, self).__init__()
        self.setGeometry(300, 200, 700, 350)
        self.setWindowTitle('Edit Conditions')
        if reaction is None:
            self._reaction = Reaction()
        else:
            self._reaction = reaction
        self._CanReturnReaction = False

        # Sets up GUI widgets

        # Reactants section
        self._reactantbox = QGroupBox("Reactants", self)
        self._reactantform = QFormLayout()
        self._reactantinfoboxes = []
        self._productinfoboxes = []
        self._catalystinfoboxes = []
        self._checkbuttons = []
        for x in range(Reaction.REACTING_SPECIES_LIMIT):
            self._reactantinfoboxes.append(QLineEdit())
            self._reactantinfoboxes[x * 2].setText(
                self._reaction.GetReactants()[x].GetFormula())
            self._reactantinfoboxes.append(QLineEdit())
            self._reactantinfoboxes[x * 2 + 1].setText(
                str(self._reaction.GetReactants()[x].GetInitialMoles()))
            self._reactantform.addRow(QLabel(str(x + 1) + ".\tFormula:"),
                                      self._reactantinfoboxes[x * 2])
            self._reactantform.addRow(QLabel("\tFinal Moles:"),
                                      self._reactantinfoboxes[x * 2 + 1])
            self._checkbuttons.append(QCheckBox("Use this reactant", self))
            self._checkbuttons[-1].setChecked(
                self._reaction.GetReactants()[x].GetUsed())
            self._reactantform.addRow(self._checkbuttons[-1])
        self._reactantbox.setLayout(self._reactantform)

        # Products section
        self._productbox = QGroupBox("Products", self)
        self._productform = QFormLayout()
        for x in range(Reaction.REACTING_SPECIES_LIMIT):
            self._productinfoboxes.append(QLineEdit())
            self._productinfoboxes[x * 2].setText(
                self._reaction.GetProducts()[x].GetFormula())
            self._productinfoboxes.append(QLineEdit())
            self._productinfoboxes[x * 2 + 1].setText(
                str(self._reaction.GetProducts()[x].GetInitialMoles()))
            self._productform.addRow(QLabel(str(x + 1) + ".\tFormula:"),
                                     self._productinfoboxes[x * 2])
            self._productform.addRow(QLabel("\tFinal Moles:"),
                                     self._productinfoboxes[x * 2 + 1])
            self._checkbuttons.append(QCheckBox("Use this product", self))
            self._checkbuttons[-1].setChecked(
                self._reaction.GetProducts()[x].GetUsed())
            self._productform.addRow(self._checkbuttons[-1])
        self._productbox.setLayout(self._productform)

        # Catalyst section
        self._catalystbox = QGroupBox("Catalyst", self)
        self._catalystform = QFormLayout()
        self._catalystinfoboxes.append(QLineEdit())
        self._catalystinfoboxes.append(QLineEdit())
        self._catalystinfoboxes[0].setText(
            self._reaction.GetCatalyst().GetFormula())
        self._catalystinfoboxes[1].setText(
            str(self._reaction.GetCatalyst().GetInitialMoles()))
        self._catalystform.addRow(QLabel("Formula:"),
                                  self._catalystinfoboxes[0])
        self._catalystform.addRow(QLabel("Moles:"), self._catalystinfoboxes[1])
        self._good = QRadioButton("Good")
        self._poor = QRadioButton("Poor")
        self._inhibitor = QRadioButton("Inhibitor")
        self._checkbuttons.append(QCheckBox("Use this catalyst", self))
        self._checkbuttons[-1].setChecked(
            self._reaction.GetCatalyst().GetUsed())
        efficacy = self._reaction.GetCatalyst().GetEfficacy()
        if efficacy == 5:
            self._good.setChecked(True)
        elif efficacy == 2:
            self._poor.setChecked(True)
        else:
            self._inhibitor.setChecked(True)
        self._cataefficacygroup = QVBoxLayout()
        self._cataefficacygroup.addWidget(self._good)
        self._cataefficacygroup.addWidget(self._poor)
        self._cataefficacygroup.addWidget(self._inhibitor)
        self._catalystform.addRow(QLabel("Efficacy:"), self._cataefficacygroup)
        self._catalystform.addRow(self._checkbuttons[-1])
        self._catalystbox.setLayout(self._catalystform)

        # Forward heat transfer section
        self._heatbox = QGroupBox("Forward heat transfer", self)
        self._heatform = QFormLayout()
        self._endo = QRadioButton("Endothermic")
        self._exo = QRadioButton("Exothermic")
        if self._reaction.GetEndothermic():
            self._endo.setChecked(True)
        else:
            self._exo.setChecked(True)
        self._heatform.addRow(self._endo)
        self._heatform.addRow(self._exo)
        self._heatbox.setLayout(self._heatform)

        # Other conditions section: vessel volume; temperature
        self._otherbox = QGroupBox("Other conditions")
        self._otherform = QFormLayout()
        self._tempbox = QLineEdit()
        self._volbox = QLineEdit()
        self._tempbox.setText(str(self._reaction.GetTemperature()))
        self._volbox.setText(str(self._reaction.GetVolume()))
        self._otherform.addRow(QLabel("Vessel volume:"), self._volbox)
        self._otherform.addRow(QLabel("Temperature:"), self._tempbox)
        self._otherbox.setLayout(self._otherform)

        # Help text explaining how to enter super/subscript characters.
        self._scriptinfo1 = QLabel("Enter _ before a subscript character.")
        self._scriptinfo2 = QLabel("Enter ^ before a superscript one.")

        # OK and cancel buttons; checkbox so that students can try to balance the equation before it is revealed
        self._try = QCheckBox("Students attempt to balance equation")
        self._try.setChecked(False)
        self._okbtn = QPushButton("OK")
        self._okbtn.clicked.connect(self.ApplyChanges)
        self._cancelbtn = QPushButton("Cancel")

        self._rightbox = QGroupBox()
        self._rightbox.setFlat(False)
        self._rightform = QVBoxLayout()
        self._rightform.addWidget(self._catalystbox)
        self._rightform.addWidget(self._heatbox)
        self._rightform.addWidget(self._otherbox)
        self._rightbox.setLayout(self._rightform)

        # Layout of all those group boxes
        self._grid = QGridLayout()
        self._grid.addWidget(self._scriptinfo1, 0, 0)
        self._grid.addWidget(self._scriptinfo2, 1, 0)
        self._grid.addWidget(self._reactantbox, 2, 0)
        self._grid.addWidget(self._productbox, 2, 1)
        self._grid.addWidget(self._rightbox, 2, 2)
        self._grid.addWidget(self._try, 3, 0)
        self._grid.addWidget(self._okbtn, 3, 1)
        self._grid.addWidget(self._cancelbtn, 3, 2)
        self.setLayout(self._grid)

        if reaction is None:
            self._reaction = Reaction()
        else:
            self._reaction = reaction

        self._cancelbtn.clicked.connect(self.close)
        self.exec_()
Esempio n. 15
0
    def initUI(self):
        self.setWindowFlags(Qt.WindowStaysOnTopHint)

        patternLabel = QLabel(u'请选择显示模式: ')
        paBox = QHBoxLayout()
        self.pattern1 = QRadioButton(u'指针模式 ', self)
        self.pattern1.setChecked(True)
        self.pattern2 = QRadioButton(u'扇形模式 ', self)
        paBox.addWidget(patternLabel)
        paBox.addStretch(1)
        paBox.addWidget(self.pattern1)
        paBox.addWidget(self.pattern2)

        angle_validator = QIntValidator(0, 360, self)
        len_validator = QDoubleValidator(0, 99.99999, 5,
                                         self)  # 取值范围为0~99.99999

        label = QLabel(u"请输入网络制式和频段的相应图形参数:")
        default_label = QLabel(u"默认")
        self.default_angle = QLineEdit()
        self.default_angle.setPlaceholderText(u'角度大小:20')
        self.default_angle.setValidator(angle_validator)
        self.default_len = QLineEdit()
        self.default_len.setPlaceholderText(u'长度:0.0015')
        self.default_len.setValidator(len_validator)
        default_hbox = QHBoxLayout()
        default_hbox.addWidget(default_label)
        default_hbox.setStretchFactor(default_label, 1)
        default_hbox.addWidget(self.default_angle)
        default_hbox.addWidget(self.default_len)
        default_hbox.addStretch(1)

        system = [u"网络制式", u"G", u"D", u"C", u"W", u"T", u"F", u"TDS"]
        frequency = [
            u"频段", u"700M", u"800M", u"900M", u"1800M", u"1900M", u"2100M",
            u"2300M", u"2600M"
        ]

        self.system_combox_1 = QComboBox()
        self.system_combox_1.addItems(system)
        self.frequency_combox_1 = QComboBox()
        self.frequency_combox_1.addItems(frequency)
        self.angle_1 = QLineEdit()
        self.angle_1.setPlaceholderText(u'角度大小:30')
        self.angle_1.setValidator(angle_validator)
        self.len_1 = QLineEdit()
        self.len_1.setPlaceholderText(u'长度:0.0015')
        self.len_1.setValidator(len_validator)
        hbox_1 = QHBoxLayout()
        hbox_1.setSpacing(10)
        hbox_1.addWidget(self.system_combox_1)
        hbox_1.addWidget(self.frequency_combox_1)
        hbox_1.addWidget(self.angle_1)
        hbox_1.addWidget(self.len_1)

        self.system_combox_2 = QComboBox()
        self.system_combox_2.addItems(system)
        self.frequency_combox_2 = QComboBox()
        self.frequency_combox_2.addItems(frequency)
        self.angle_2 = QLineEdit()
        self.angle_2.setPlaceholderText(u'角度大小:40')
        self.angle_2.setValidator(angle_validator)
        self.len_2 = QLineEdit()
        self.len_2.setPlaceholderText(u'长度:0.0015')
        self.len_2.setValidator(len_validator)
        hbox_2 = QHBoxLayout()
        hbox_2.setSpacing(10)
        hbox_2.addWidget(self.system_combox_2)
        hbox_2.addWidget(self.frequency_combox_2)
        hbox_2.addWidget(self.angle_2)
        hbox_2.addWidget(self.len_2)

        self.system_combox_3 = QComboBox()
        self.system_combox_3.addItems(system)
        self.frequency_combox_3 = QComboBox()
        self.frequency_combox_3.addItems(frequency)
        self.angle_3 = QLineEdit()
        self.angle_3.setPlaceholderText(u'角度大小:50')
        self.angle_3.setValidator(angle_validator)
        self.len_3 = QLineEdit()
        self.len_3.setPlaceholderText(u'长度:0.0015')
        self.len_3.setValidator(len_validator)
        hbox_3 = QHBoxLayout()
        hbox_3.setSpacing(10)
        hbox_3.addWidget(self.system_combox_3)
        hbox_3.addWidget(self.frequency_combox_3)
        hbox_3.addWidget(self.angle_3)
        hbox_3.addWidget(self.len_3)

        self.system_combox_4 = QComboBox()
        self.system_combox_4.addItems(system)
        self.frequency_combox_4 = QComboBox()
        self.frequency_combox_4.addItems(frequency)
        self.angle_4 = QLineEdit()
        self.angle_4.setPlaceholderText(u'角度大小:60')
        self.angle_4.setValidator(angle_validator)
        self.len_4 = QLineEdit()
        self.len_4.setPlaceholderText(u'长度:0.0015')
        self.len_4.setValidator(len_validator)
        hbox_4 = QHBoxLayout()
        hbox_4.setSpacing(10)
        hbox_4.addWidget(self.system_combox_4)
        hbox_4.addWidget(self.frequency_combox_4)
        hbox_4.addWidget(self.angle_4)
        hbox_4.addWidget(self.len_4)

        ok = QPushButton(u"确定")
        self.connect(ok, SIGNAL("clicked()"), self.okBtnListenner)
        operator = QPushButton(u'切换设置模式', self)
        operator.clicked.connect(self.operator_setting)
        btn_hbox = QHBoxLayout()
        btn_hbox.setSpacing(15)
        btn_hbox.addWidget(ok)
        btn_hbox.addWidget(operator)

        vbox = QVBoxLayout()
        vbox.setSpacing(10)
        vbox.addWidget(label)
        vbox.addLayout(paBox)
        vbox.addLayout(default_hbox)
        vbox.addLayout(hbox_1)
        vbox.addLayout(hbox_2)
        vbox.addLayout(hbox_3)
        vbox.addLayout(hbox_4)
        vbox.addStretch(1)
        vbox.addLayout(btn_hbox)

        self.setLayout(vbox)
Esempio n. 16
0
 def initialize(self, *args, **kwargs):
     " Init Main Class "
     super(Main, self).initialize(*args, **kwargs)
     self.locator.get_service("menuApp").add_action(
         QAction(QIcon.fromTheme("edit-select-all"),
                 "Create Setup.py",
                 self,
                 triggered=lambda: self.get_dialog()))
     self.dialog, self.group0 = QDialog(), QGroupBox()
     self.group0.setTitle(' Setup.py Creator ')
     self.pkgname, self.version = QLineEdit(), QDoubleSpinBox()
     self.urlproj, self.licence = QLineEdit('https://www.'), QLineEdit(
         'GPL')
     self.authors, self.emails = QLineEdit(
         getuser()), QLineEdit('@mail.com')
     self.descrip, self.button = QLineEdit(), QPushButton('Make Setup.py !')
     self.choices, self.indents = QComboBox(), QSpinBox()
     self.metada = QCheckBox('Use SheBang and Metadata')
     self.nosetest = QCheckBox('Use Nose Tests Framework integration')
     self.metada.setChecked(True)
     self.chckbx1 = QCheckBox('Copy output to ClipBoard when done')
     self.choices.addItems(
         ['from distutils.core import setup', 'import distutils.core'])
     self.indents.setValue(4)
     self.indents.setMaximum(8)
     self.indents.setMinimum(0)
     self.indents.setSingleStep(2)
     self.version.setValue(0.1)
     self.version.setMinimum(0.1)
     self.version.setDecimals(1)
     self.version.setSingleStep(0.1)
     self.button.setMinimumSize(400, 50)
     self.button.clicked.connect(self.make_setupy)
     glow = QGraphicsDropShadowEffect(self)
     glow.setOffset(0)
     glow.setBlurRadius(99)
     glow.setColor(QColor(99, 255, 255))
     self.button.setGraphicsEffect(glow)
     inf = QLabel(
         '''<a href="http://guide.python-distribute.org/future.html"
               ><center><i>INFO: This is Deprecated Legacy Packaging.</a>'''
     )
     inf.setTextInteractionFlags(Qt.LinksAccessibleByMouse)
     inf.setOpenExternalLinks(True)
     vboxg0 = QVBoxLayout(self.group0)
     for each_widget in (QLabel('<b>Package Name'), self.pkgname,
                         QLabel('<b>Version'),
                         self.version, QLabel('<b>URL'), self.urlproj,
                         QLabel('<b>Licence'), self.licence,
                         QLabel('<b>Author'), self.authors,
                         QLabel('<b>Mail'), self.emails,
                         QLabel('<b>Description'), self.descrip,
                         QLabel('<b>Imports'), self.choices,
                         QLabel('<b>Indentation Spaces '), self.indents,
                         self.metada, self.chckbx1, self.nosetest, inf,
                         QLabel('<center><small><i>{}'.format(HELPMSG)),
                         self.button):
         vboxg0.addWidget(each_widget)
         try:
             each_widget.setToolTip(each_widget.text())
         except:
             pass
     QVBoxLayout(self.dialog).addWidget(self.group0)
Esempio n. 17
0
    def initView(self):
        self.setWindowFlags(Qt.WindowStaysOnTopHint)

        jsLable = QLabel(u'设置不同运营商扇形的角度和半径长度,\n方便在地图上分辨出各运营商的小区', self)
        jsBox = QHBoxLayout()
        jsBox.addWidget(jsLable)

        patternLabel = QLabel(u'请选择显示模式: ')
        paBox = QHBoxLayout()
        self.pattern1 = QRadioButton(u'指针模式 ', self)
        self.pattern1.setChecked(True)
        self.pattern2 = QRadioButton(u'扇形模式 ', self)
        paBox.addWidget(patternLabel)
        paBox.addStretch(1)
        paBox.addWidget(self.pattern1)
        paBox.addWidget(self.pattern2)

        angle_validator = QIntValidator(0, 360, self)

        ydLable = QLabel(u"角度:", self)
        self.ydInput = QLineEdit(self)
        self.ydInput.setPlaceholderText(u'移动:20')
        self.ydInput.setValidator(angle_validator)
        ydLenLable = QLabel(u'长度:', self)
        self.ydLenInput = QLineEdit(self)
        self.ydLenInput.setPlaceholderText(u'移动:0.0015')
        ydBox = QHBoxLayout()
        ydBox.addWidget(ydLable)
        ydBox.addWidget(self.ydInput)
        ydBox.addWidget(ydLenLable)
        ydBox.addWidget(self.ydLenInput)

        ltLable = QLabel(u'角度:', self)
        self.ltInput = QLineEdit(self)
        self.ltInput.setPlaceholderText(u'联通:30')
        self.ltInput.setValidator(angle_validator)
        ltLenLable = QLabel(u'长度:', self)
        self.ltLenInput = QLineEdit(self)
        self.ltLenInput.setPlaceholderText(u'联通:0.0015')
        ltBox = QHBoxLayout()
        ltBox.addWidget(ltLable)
        ltBox.addWidget(self.ltInput)
        ltBox.addWidget(ltLenLable)
        ltBox.addWidget(self.ltLenInput)

        dxLable = QLabel(u'角度:', self)
        self.dxInput = QLineEdit(self)
        self.dxInput.setPlaceholderText(u'电信:40')
        self.dxInput.setValidator(angle_validator)
        dxLenLable = QLabel(u'长度:', self)
        self.dxLenInput = QLineEdit(self)
        self.dxLenInput.setPlaceholderText(u'电信:0.0015')
        dxBox = QHBoxLayout()
        dxBox.addWidget(dxLable)
        dxBox.addWidget(self.dxInput)
        dxBox.addWidget(dxLenLable)
        dxBox.addWidget(self.dxLenInput)

        ttLable = QLabel(u'角度:', self)
        self.ttInput = QLineEdit(self)
        self.ttInput.setPlaceholderText(u'铁塔:50')
        self.ttInput.setValidator(angle_validator)
        ttLenLable = QLabel(u'长度:', self)
        self.ttLenInput = QLineEdit(self)
        self.ttLenInput.setPlaceholderText(u'铁塔:0.0015')
        ttBox = QHBoxLayout()
        ttBox.addWidget(ttLable)
        ttBox.addWidget(self.ttInput)
        ttBox.addWidget(ttLenLable)
        ttBox.addWidget(self.ttLenInput)

        okBtn = QPushButton(u'确定', self)
        okBtn.clicked.connect(self.okBtnListenner)
        custom_btn = QPushButton(u'切换设置模式', self)
        custom_btn.clicked.connect(self.custom_setting)
        btnBox = QHBoxLayout()
        btnBox.addWidget(okBtn)
        btnBox.addWidget(custom_btn)

        vBox = QVBoxLayout()
        vBox.addLayout(jsBox)
        vBox.addLayout(paBox)
        vBox.addLayout(ydBox)
        vBox.addLayout(ltBox)
        vBox.addLayout(dxBox)
        vBox.addLayout(ttBox)
        vBox.addLayout(btnBox)

        vBox.setStretchFactor(jsLable, 3)
        vBox.setStretchFactor(ydBox, 2)
        vBox.setStretchFactor(ltBox, 2)
        vBox.setStretchFactor(dxBox, 2)
        vBox.setStretchFactor(ttBox, 2)
        vBox.setStretchFactor(btnBox, 1)

        self.setLayout(vBox)
Esempio n. 18
0
    def __init__(self, iface, memoryPointsLayer, memoryLinesLayer, ctllDb,
                 configTable, uriDb, schemaDb, mntUrl):
        """
        Constructor
        :param iface: interface
        :param memoryPointsLayer: working memory points layer
        :param memoryLinesLayer: working memory lines layer
        :param configTable: config table selected for import
        """
        QDialog.__init__(self)
        self.__iface = iface
        self.__memoryPointsLayer = memoryPointsLayer
        self.__memoryLinesLayer = memoryLinesLayer
        self.__ctlDb = ctllDb
        self.__configTable = configTable
        self.__uriDb = uriDb
        self.__schemaDb = schemaDb
        self.__mntUrl = mntUrl
        self.setWindowTitle(QCoreApplication.translate("VDLTools", "Settings"))
        self.__pointsLayers = []
        self.__linesLayers = []
        self.__tables = []
        self.__schemas = []
        self.__dbs = DBConnector.getUsedDatabases()

        for layer in list(QgsMapLayerRegistry.instance().mapLayers().values()):
            if layer is not None and layer.type(
            ) == QgsMapLayer.VectorLayer and layer.providerType() == "memory":
                if layer.geometryType() == QGis.Point:
                    self.__pointsLayers.append(layer)
                if layer.geometryType() == QGis.Line:
                    self.__linesLayers.append(layer)
        self.resize(450, 200)
        self.__layout = QGridLayout()

        pointLabel = QLabel(
            QCoreApplication.translate("VDLTools", "Working points layer : "))
        pointLabel.setMinimumHeight(20)
        pointLabel.setMinimumWidth(50)
        self.__layout.addWidget(pointLabel, 0, 1)

        self.__pointCombo = QComboBox()
        self.__pointCombo.setMinimumHeight(20)
        self.__pointCombo.setMinimumWidth(50)
        self.__pointCombo.addItem("")
        for layer in self.__pointsLayers:
            self.__pointCombo.addItem(layer.name())
        self.__layout.addWidget(self.__pointCombo, 0, 2)
        self.__pointCombo.currentIndexChanged.connect(self.__pointComboChanged)
        if self.__memoryPointsLayer is not None:
            if self.__memoryPointsLayer in self.__pointsLayers:
                self.__pointCombo.setCurrentIndex(
                    self.__pointsLayers.index(self.__memoryPointsLayer) + 1)

        lineLabel = QLabel(
            QCoreApplication.translate("VDLTools", "Working lines layer : "))
        lineLabel.setMinimumHeight(20)
        lineLabel.setMinimumWidth(50)
        self.__layout.addWidget(lineLabel, 1, 1)

        self.__lineCombo = QComboBox()
        self.__lineCombo.setMinimumHeight(20)
        self.__lineCombo.setMinimumWidth(50)
        self.__lineCombo.addItem("")
        for layer in self.__linesLayers:
            self.__lineCombo.addItem(layer.name())
        self.__layout.addWidget(self.__lineCombo, 1, 2)
        self.__lineCombo.currentIndexChanged.connect(self.__lineComboChanged)
        if self.__memoryLinesLayer is not None:
            if self.__memoryLinesLayer in self.__linesLayers:
                self.__lineCombo.setCurrentIndex(
                    self.__linesLayers.index(self.__memoryLinesLayer) + 1)

        dbLabel = QLabel(
            QCoreApplication.translate("VDLTools", "Import database : "))
        dbLabel.setMinimumHeight(20)
        dbLabel.setMinimumWidth(50)
        self.__layout.addWidget(dbLabel, 2, 1)

        self.__dbCombo = QComboBox()
        self.__dbCombo.setMinimumHeight(20)
        self.__dbCombo.setMinimumWidth(50)
        self.__dbCombo.addItem("")
        for db in list(self.__dbs.keys()):
            self.__dbCombo.addItem(db)
        self.__layout.addWidget(self.__dbCombo, 2, 2)

        schemaLabel = QLabel(
            QCoreApplication.translate("VDLTools", "Database schema : "))
        schemaLabel.setMinimumHeight(20)
        schemaLabel.setMinimumWidth(50)
        self.__layout.addWidget(schemaLabel, 3, 1)

        self.__schemaCombo = QComboBox()
        self.__schemaCombo.setMinimumHeight(20)
        self.__schemaCombo.setMinimumWidth(50)
        self.__schemaCombo.addItem("")
        self.__layout.addWidget(self.__schemaCombo, 3, 2)

        tableLabel = QLabel(
            QCoreApplication.translate("VDLTools", "Config table : "))
        tableLabel.setMinimumHeight(20)
        tableLabel.setMinimumWidth(50)
        self.__layout.addWidget(tableLabel, 4, 1)

        self.__tableCombo = QComboBox()
        self.__tableCombo.setMinimumHeight(20)
        self.__tableCombo.setMinimumWidth(50)
        self.__tableCombo.addItem("")
        self.__layout.addWidget(self.__tableCombo, 4, 2)

        mntLabel = QLabel(
            QCoreApplication.translate("VDLTools", "Url for MNT : "))
        schemaLabel.setMinimumHeight(20)
        schemaLabel.setMinimumWidth(50)
        self.__layout.addWidget(mntLabel, 5, 1)

        self.__mntText = QLineEdit()
        if self.__mntUrl is None or self.__mntUrl == "None":
            self.__mntText.insert(
                'http://map.lausanne.ch/main/wsgi/profile.json')
        else:
            self.__mntText.insert(self.__mntUrl)
        self.__mntText.setMinimumHeight(20)
        self.__mntText.setMinimumWidth(100)
        self.__layout.addWidget(self.__mntText, 5, 2)

        ctlLabel = QLabel(
            QCoreApplication.translate("VDLTools", "Control database : "))
        ctlLabel.setMinimumHeight(20)
        ctlLabel.setMinimumWidth(50)
        self.__layout.addWidget(ctlLabel, 6, 1)

        self.__ctlCombo = QComboBox()
        self.__ctlCombo.setMinimumHeight(20)
        self.__ctlCombo.setMinimumWidth(50)
        self.__ctlCombo.addItem("")
        for db in list(self.__dbs.keys()):
            self.__ctlCombo.addItem(db)
        self.__layout.addWidget(self.__ctlCombo, 6, 2)

        self.__okButton = QPushButton(
            QCoreApplication.translate("VDLTools", "OK"))
        self.__okButton.setMinimumHeight(20)
        self.__okButton.setMinimumWidth(100)

        self.__cancelButton = QPushButton(
            QCoreApplication.translate("VDLTools", "Cancel"))
        self.__cancelButton.setMinimumHeight(20)
        self.__cancelButton.setMinimumWidth(100)

        self.__layout.addWidget(self.__okButton, 100, 1)
        self.__layout.addWidget(self.__cancelButton, 100, 2)
        self.setLayout(self.__layout)

        self.__dbCombo.currentIndexChanged.connect(self.__dbComboChanged)
        self.__schemaCombo.currentIndexChanged.connect(
            self.__schemaComboChanged)
        self.__tableCombo.currentIndexChanged.connect(self.__tableComboChanged)

        self.__ctlCombo.currentIndexChanged.connect(self.__ctlComboChanged)

        if self.__uriDb is not None:
            if self.__uriDb.database() in list(self.__dbs.keys()):
                self.__dbCombo.setCurrentIndex(
                    list(self.__dbs.keys()).index(self.__uriDb.database()) + 1)

        if self.__ctlDb is not None:
            if self.__ctlDb.database() in list(self.__dbs.keys()):
                self.__ctlCombo.setCurrentIndex(
                    list(self.__dbs.keys()).index(self.__ctlDb.database()) + 1)
Esempio n. 19
0
    top_sorted = top.sort_values(by="amax", ascending=False).head(n=15)
    return top_sorted


# create our window
app = QApplication(sys.argv)
app.setWindowIcon(QIcon(app_path + 'task_tracker.png'))
w = QWidget()
w.setWindowTitle('Task Tracker')


# Set window size.
w.resize(280, 230)

# Create textbox
textbox = QLineEdit(w)
textbox.move(20, 20)
textbox.resize(240, 30)

# Create a button in the window
button = QPushButton('Add', w)
button.move(20, 60)

# Create a button in the window
button_dir = QPushButton('data', w)
button_dir.move(170, 60)

# Create a button in the window
listWidget = QListWidget(w)
tasks = latest_tasks().index.tolist()
for i in tasks:
Esempio n. 20
0
    def __init__(self, sid, parent=None):
        super(UnitForm, self).__init__(parent)

        self.sid = sid
        self.l1 = QLabel("Name")
        self.le = QLineEdit()
        self.le.setObjectName("host")
        self.le.setText("")

        self.l2 = QLabel("Abbrv.")
        self.le2 = QLineEdit()
        self.le2.setObjectName("Abbrv.")
        self.le2.setText("")

        self.pb = QPushButton()
        self.pb.setObjectName("Submit")
        self.pb.setText("Submit")

        self.pb1 = QPushButton()
        self.pb1.setObjectName("Cancel")
        self.pb1.setText("Cancel")

        layout = QFormLayout()
        layout.addRow(self.l1, self.le)
        layout.addRow(self.l2, self.le2)
        layout.addRow(self.pb1, self.pb)

        ko = 0
        layout1 = QGridLayout()

        details = self.pullDetails(self.sid)
        detailsname = str(details[2])
        arr = self.pullClass(self.sid)
        for i in arr:
            self.c = QCheckBox()
            self.c.setText(arr[i])
            self.c.setObjectName("chk" + str(i))
            self.b = QPushButton()
            self.b.setObjectName("btn" + str(i))
            self.b.setText('Add')
            self.b1 = QPushButton()
            self.b1.setObjectName("btn1" + str(i))
            self.b1.setText('Edit')
            self.connect(self.b,
                         SIGNAL("clicked()"),
                         lambda x=i: self.button_click(x))
            self.connect(self.b1,
                         SIGNAL("clicked()"),
                         lambda y=i: self.button_click(y))

            layout1.addWidget(self.c, ko, 0)
            layout1.addWidget(self.b, ko, 1)
            layout1.addWidget(self.b1, ko, 2)
            ko += 1

        groupBox = QGroupBox('Add Class')
        groupBox.setLayout(layout)

        groupBox1 = QGroupBox('All Classes')
        groupBox1.setLayout(layout1)

        grid = QGridLayout()
        grid.addWidget(groupBox, 0, 0)
        grid.addWidget(groupBox1, 1, 0)
        self.setLayout(grid)
        self.connect(self.pb, SIGNAL("clicked()"),
                     lambda: self.button_click(self.sid))
        self.connect(self.pb1, SIGNAL("clicked()"), self.close)
        self.setWindowTitle(detailsname)
Esempio n. 21
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.modified = False

        box = group_box(self.tr("Default method"), layout=layout(Qt.Vertical))
        self.controlArea.layout().addWidget(box)

        bgroup = QButtonGroup()

        for i, m in enumerate(self.METHODS[1:-1], 1):
            b = radio_button(m.name,
                             checked=i == self.default_method,
                             group=bgroup,
                             group_id=i)
            box.layout().addWidget(b)

        self.defbggroup = bgroup

        bgroup.buttonClicked[int].connect(self.set_default_method)
        box = group_box(self.tr("Individual attribute settings"),
                        layout=layout(Qt.Horizontal))
        self.controlArea.layout().addWidget(box)

        self.varview = QtGui.QListView(
            selectionMode=QtGui.QListView.ExtendedSelection)
        self.varview.setItemDelegate(DisplayFormatDelegate())
        self.varmodel = itemmodels.VariableListModel()
        self.varview.setModel(self.varmodel)
        self.varview.selectionModel().selectionChanged.connect(
            self._on_var_selection_changed)
        self.selection = self.varview.selectionModel()

        box.layout().addWidget(self.varview)

        method_layout = layout(Qt.Vertical, margins=0)
        box.layout().addLayout(method_layout)

        methodbox = group_box(layout=layout(Qt.Vertical))

        bgroup = QButtonGroup()
        for i, m in enumerate(self.METHODS):
            b = radio_button(m.name, group=bgroup, group_id=i)
            methodbox.layout().addWidget(b)

        assert self.METHODS[-1].short == "value"

        self.value_stack = value_stack = QStackedLayout()
        self.value_combo = QComboBox(activated=self._on_value_changed)
        self.value_line = QLineEdit(editingFinished=self._on_value_changed)
        self.value_line.setValidator(QDoubleValidator())
        value_stack.addWidget(self.value_combo)
        value_stack.addWidget(self.value_line)
        methodbox.layout().addLayout(value_stack)

        bgroup.buttonClicked[int].connect(
            self.set_method_for_current_selection)
        reset_button = push_button("Restore all to default",
                                   clicked=self.reset_var_methods,
                                   default=False,
                                   autoDefault=False)

        method_layout.addWidget(methodbox)
        method_layout.addStretch(2)
        method_layout.addWidget(reset_button)
        self.varmethodbox = methodbox
        self.varbgroup = bgroup

        gui.auto_commit(self.controlArea,
                        self,
                        "autocommit",
                        "Commit",
                        orientation="horizontal",
                        checkbox_label="Commit on any change")
        self.data = None
        self.learner = None
    def createWidgets(self):
        """
        """
        self.listingTab = QTabWidget()
        self.listingTab.setMinimumWidth(650)

        layoutGrid = QGridLayout()

        self.testSetPath = QLineEdit()
        self.testSetName = QLineEdit()

        self.testsTable = TestsTableView(self, core=self.core())
        self.testcasesTable = TestcasesTableView(self, core=self.core())

        self.stepsTable = StepsTableView(self, core=self.core())

        self.listingTab.addTab(self.testsTable, "Test(s)")
        self.listingTab.addTab(self.testcasesTable, "Testcase(s)")
        self.listingTab.addTab(self.stepsTable, "Steps(s)")

        self.ignoreTestcases = QCheckBox("Ignore testcase(s)")
        if self.core().settings().cfg()["export-results"]["ignore-testcase"]:
            self.ignoreTestcases.setCheckState(Qt.Checked)

        self.ignoreUncomplete = QCheckBox("Ignore uncomplete result(s)")
        if self.core().settings().cfg()["export-results"]["ignore-uncomplete"]:
            self.ignoreUncomplete.setCheckState(Qt.Checked)

        self.addMissingFoldersCheckBox = QCheckBox(
            self.tr("Create missing folders"))
        if self.core().settings().cfg()["export-results"]["add-folders"]:
            self.addMissingFoldersCheckBox.setCheckState(Qt.Checked)

        self.addTestsetCheckBox = QCheckBox(self.tr("Create testset"))
        if self.core().settings().cfg()["export-results"]["add-testset"]:
            self.addTestsetCheckBox.setCheckState(Qt.Checked)

        self.addTestinstanceCheckBox = QCheckBox(
            self.tr("Add test instance in testset"))
        if self.core().settings().cfg()["export-results"]["add-testinstance"]:
            self.addTestinstanceCheckBox.setCheckState(Qt.Checked)

        optionsLayout = QHBoxLayout()
        optionsLayout.addWidget(self.ignoreTestcases)
        optionsLayout.addWidget(self.ignoreUncomplete)
        optionsLayout.addStretch(1)

        # optionsTsLayout = QHBoxLayout()
        # optionsTsLayout.addWidget(self.addTestsetCheckBox)
        # optionsTsLayout.addWidget(self.addTestinstanceCheckBox)
        # optionsTsLayout.addStretch(1)

        layoutGrid.addWidget(QLabel("Remote Test Set Path:"), 0, 0)
        layoutGrid.addWidget(self.testSetPath, 0, 1)
        # layoutGrid.addWidget(self.addMissingFoldersCheckBox, 1, 1)
        layoutGrid.addWidget(QLabel("Remote Test Set Name:"), 2, 0)
        layoutGrid.addWidget(self.testSetName, 2, 1)
        # layoutGrid.addLayout(optionsTsLayout, 3, 1)
        layoutGrid.addWidget(QLabel("Local result(s):"), 4, 0)
        layoutGrid.addLayout(optionsLayout, 4, 1)
        layoutGrid.addWidget(QLabel("Test(s) Verdict:"), 5, 0)
        layoutGrid.addWidget(self.listingTab, 5, 1)

        self.exportStatusLabel = QLabel("Status: Disconnected", self)
        self.exportButton = QPushButton(self.tr("Export Result"), self)
        self.exportButton.setMinimumWidth(300)

        layoutRight = QHBoxLayout()
        layoutRight.addWidget(self.exportButton)
        layoutRight.addWidget(self.exportStatusLabel)
        layoutRight.addStretch(1)

        layoutGrid.addWidget(QLabel("Controls:"), 6, 0)
        layoutGrid.addLayout(layoutRight, 6, 1)

        layoutMain = QHBoxLayout()
        layoutMain.addLayout(layoutGrid)

        self.setLayout(layoutMain)
Esempio n. 23
0
    def home(self):
        self.imgindex = 0
        self.selectedname = ""
        self.imglen = 0
        self.delbtn = QtGui.QPushButton("Delete Entry", self)
        self.delbtn.resize(100, 30)
        self.delbtn.move(200, 125)
        # self.delbtn.move(0, 0)

        self.rightname = QLabel("", self)
        self.rightname.move(350, 5)
        self.rightname.resize(600, 20)
        self.rightname.setAlignment(Qt.AlignCenter)

        self.btn = QtGui.QPushButton("Enroll", self)
        # self.btn.clicked.connect()
        self.btn.resize(80, 30)
        self.btn.move(10, 125)

        self.nextbtn = QtGui.QPushButton("Next", self)
        self.delimagebtn = QtGui.QPushButton("Delete Image", self)
        self.previousbtn = QtGui.QPushButton("Previous", self)
        self.nextbtn.move(750, 530)
        self.delimagebtn.move(550, 530)
        self.previousbtn.move(450, 530)

        self.firstnametext = QLabel(self)
        self.firstnametext.setText("First Name:")
        self.firstnametext.move(10, 10)

        self.firstnamefield = QLineEdit(self)
        self.firstnamefield.setObjectName("First Name")
        self.firstnamefield.resize(300, 30)
        self.firstnamefield.move(100, 10)

        lastnametext = QLabel(self)
        lastnametext.setText("Last Name:")
        lastnametext.move(10, 50)

        self.lastnamefield = QLineEdit(self)
        self.lastnamefield.setObjectName("First Name")
        self.lastnamefield.resize(300, 30)
        self.lastnamefield.move(100, 50)

        self.dirbtn = QtGui.QPushButton("Choose Directory", self)
        self.dirbtn.resize(140, 30)
        self.dirbtn.move(10, 90)

        self.dirfield = QLineEdit(self)
        self.dirfield.setObjectName("Directory")
        self.dirfield.resize(250, 30)
        self.dirfield.move(150, 90)

        self.status = QLabel(self)
        self.status.move(10, 563)
        self.status.resize(400, 20)
        self.status.setText("Ready")

        self.rebuild = QtGui.QPushButton("Add Image", self)
        self.rebuild.move(650, 530)
        self.rebuild.resize(100, 30)

        self.listsize = QtGui.QLabel(self)
        self.listsize.setText(" Persons Enrolled")
        self.listsize.resize(200, 20)
        self.listsize.move(10, 160)

        self.list = QListWidget(self)
        self.list.resize(389, 380)
        self.list.move(10, 180)
        self.stat("Pulling list")
        refresh_list_elements(self.list, self.listsize)
        self.stat("Ready")

        self.image = QLabel(self)
        self.image.resize(490, 490)
        self.image.move(405, 30)

        self.list.doubleClicked.connect(self.on_double_click)
        self.connect(self, SIGNAL('triggered()'), self.closeEvent)
        self.connect(self.rebuild, SIGNAL("clicked()"), self.add_image)
        self.connect(self.nextbtn, SIGNAL("clicked()"), self.next_image)
        self.connect(self.previousbtn, SIGNAL("clicked()"),
                     self.previous_image)
        self.connect(self.delimagebtn, SIGNAL("clicked()"), self.delete_image)
        self.connect(self.dirbtn, SIGNAL("clicked()"), self.opendir)
        self.connect(self.delbtn, SIGNAL("clicked()"), self.button_delete)
        self.connect(self.btn, SIGNAL("clicked()"), self.button_click)
        self.show()
Esempio n. 24
0
    def __init__(self, iface):
        self.iface = iface
        self.plugin_dir = os.path.dirname(__file__)
        locale = QSettings().value('locale/userLocale')[0:2]
        locale_path = os.path.join(self.plugin_dir, 'i18n',
                                   'geobricks_trmm_qgis_{}.qm'.format(locale))
        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)
            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.translator)
        self.layout = QVBoxLayout()
        self.username = QLineEdit()
        self.username.setPlaceholderText(
            self.tr('e.g. [email protected]'))
        self.password = QLineEdit()
        self.password.setEchoMode(QLineEdit.Password)
        self.password.setPlaceholderText(
            self.tr('e.g. [email protected]'))
        self.download_folder = QLineEdit()
        try:
            if self.last_download_folder is not None:
                self.download_folder.setText(self.last_download_folder)
        except:
            self.last_download_folder = None
        self.frequency = QComboBox()
        self.frequency.addItem(self.tr('Daily Sum'), 'SUM')
        self.frequency.addItem(self.tr('Daily Average'), 'AVG')
        self.frequency.addItem(self.tr('None'), 'NONE')
        self.from_date = QCalendarWidget()
        self.to_date = QCalendarWidget()
        self.bar = QgsMessageBar()
        self.lbl_0 = QLabel('<b>' + self.tr('Username') + '</b>')
        self.lbl_1 = QLabel('<b>' + self.tr('Password') + '</b>')
        self.lbl_2 = QLabel('<b>' + self.tr('Aggregation') + '</b>')
        self.from_date_label = QLabel(
            '<b>' + self.tr('From Date') + '</b>: ' +
            QDate(2015, 7, 31).toString('MMMM d, yyyy'))
        self.to_date_label = QLabel(
            '<b>' + self.tr('To Date') + '</b>: ' +
            QDate(2015, 7, 31).toString('MMMM d, yyyy'))
        self.lbl_5 = QLabel('<b>' + self.tr('Download Folder') + '</b>')
        self.lbl_6 = QLabel('<i style="color: blue;">' +
                            self.tr('Create an account') + '</i>')
        self.lbl_7 = QLabel('<b>' + self.tr('Data availability') + '</b>: ' +
                            self.tr('from January 1st 1998 to July 31st 2015'))
        self.palette = QPalette()
        self.from_date_widget = QWidget()
        self.from_date_widget_layout = QVBoxLayout()
        self.dates_widget = QWidget()
        self.dates_widget_layout = QHBoxLayout()
        self.username_widget = QWidget()
        self.username_layout = QVBoxLayout()
        self.password_widget = QWidget()
        self.password_layout = QVBoxLayout()
        self.progressBar = QProgressBar()
        self.progress_label = QLabel('<b>' + self.tr('Progress') + '</b>')
        self.login_widget = QWidget()
        self.login_layout = QHBoxLayout()
        self.download_folder_widget = QWidget()
        self.download_folder_layout = QHBoxLayout()
        self.download_folder_button = QPushButton(self.tr('...'))
        self.download_button = QPushButton(self.tr('Start Download'))
        self.close_button = QPushButton(self.tr('Close Window'))
        self.add_to_canvas = QCheckBox(self.tr('Add output layer to canvas'))
        self.add_to_canvas.setChecked(True)
        self.to_date_widget = QWidget()
        self.to_date_widget_layout = QVBoxLayout()
        self.spacing = 16

        self.dlg = GeobricksTRMMDialog()
        self.actions = []
        self.menu = self.tr('Download Data')
        self.toolbar = self.iface.addToolBar(self.tr('TRMM Data Downloader'))
        self.toolbar.setObjectName('TRMMDataDownloader')
        self.is_rendered = False
Esempio n. 25
0
 def createEditor(self, parent, option, index):
     return QLineEdit(parent)
Esempio n. 26
0
 def createEditor(self, widget, option, index):
     if index.isValid():
         editor = QLineEdit(widget)
         editor.setValidator(TaskTypeNameValidator())
         return editor
Esempio n. 27
0
    def toolTypeSelected(self, index):
        #print "Got a new selection"
        #print self.comboBox.itemText(index)

        self.typeSelection = str(self.comboBox.itemText(index))
        for testw in self.test_widget:
            self.vboxlayout.removeWidget(testw)
            testw.hide()
        self.tooltypearray = []
        self.test_widget = []
        self.test_text = []
        self.test_line = []

        # The tool_config will always have tool_config name
        self.tooltypearray.append(["Tool Config Name", "tool_config", ""])

        # Now look up the selected connection type and present to the user...
        # First we start at the tool_library
        tool_name = str(self.typeSelection)
        tool_node = self.tool_nodes[tool_name]
        for param_node in tool_node.find('params'):
            type_val = param_node.get('param_type')
            default_val = param_node.text or ''
            self.tooltypearray.append(
                [param_node.get('name'), type_val, default_val])

        for i, param in enumerate(self.tooltypearray):
            # print "Key: %s , Val: %s" % (param[0],param[1])
            paramName = str(param[0] or '').strip()
            type_val = str(param[1] or '').strip()
            default_val = str(param[2] or '').strip()

            if (i == 0):
                widgetTemp = QFrame(self.variableBox)
                widgetTemp.setFrameStyle(QFrame.Panel | QFrame.Raised)
                widgetTemp.setLineWidth(2)
            else:
                widgetTemp = QWidget(self.variableBox)
            widgetTemp.setObjectName(QString("test_widget").append(QString(i)))
            self.test_widget.append(widgetTemp)
            hlayout = QHBoxLayout(widgetTemp)
            self.hboxlayout.append(hlayout)
            hlayout.setMargin(4)
            hlayout.setSpacing(4)
            hlayout.setObjectName(QString("hboxlayout").append(QString(i)))
            test_text = QLabel(widgetTemp)
            self.test_text.append(test_text)
            test_text.setObjectName(QString("test_text").append(QString(i)))
            if type_val == "Required":
                palette = test_text.palette()
                palette.setColor(QPalette.WindowText, Qt.red)
                test_text.setPalette(palette)
            test_text.setText(paramName)
            test_text_type = QLabel(widgetTemp)
            self.test_text_type.append(test_text_type)
            test_text_type.setObjectName(
                QString("test_text_type").append(QString(i)))
            paramName = type_val
            test_text_type.setText(
                QString("(").append(paramName).append(QString(")")))
            hlayout.addWidget(test_text)
            hlayout.addWidget(test_text_type)
            if type_val == 'db_connection_hook':
                test_line = QComboBox(widgetTemp)
                db_connection_choices = get_db_connection_names()
                for i in db_connection_choices:
                    test_line.addItem(QString(i))
                self.test_line.append(test_line)
                test_line.setEnabled(True)
                test_line.setMinimumSize(QSize(200, 0))
                test_line.setObjectName(
                    QString("test_line").append(QString(i)))
            else:
                test_line = QLineEdit(widgetTemp)
                self.test_line.append(test_line)
                test_line.setEnabled(True)
                test_line.setMinimumSize(QSize(200, 0))
                test_line.setObjectName(
                    QString("test_line").append(QString(i)))
#            test_line = QLineEdit(widgetTemp)
#            self.test_line.append(test_line)
#            test_line.setEnabled(True)
#            test_line.setMinimumSize(QSize(200,0))
#            test_line.setObjectName(QString("test_line").append(QString(i)))
#            test_line.setText(QString(""))
            hlayout.addWidget(test_line)
            self.vboxlayout.addWidget(widgetTemp)
Esempio n. 28
0
    def __init__(self, session, parent=None):
        super(ExpensesDialog, self).__init__(parent)
        self.session = session
        session = self.pullOnes('session', session)
        self.sessionname = str(session['name']) + ' Session'
        self.pagetitle = self.sessionname
        self.tableFont = QFont('Century Gothic', 8)
        #self.tableFont.setFamily('Century Gothic')
        self.tableHeaderStyle = "::section {" "background-color: teal; color:white}"
        #pull all CA
        self.editID = 0
        self.hold_account = {}
        self.hold_expenses = {}
        self.hold_expensesGroup = {}

        from_label = QLabel('From:')
        to_label = QLabel('To:')
        self.fromData = QDateEdit()
        self.toData = QDateEdit()
        currentDate = QDate()
        self.fromData.setDate(currentDate.currentDate())
        self.fromData.setCalendarPopup(True)
        self.toData.setDate(currentDate.currentDate())
        self.toData.setCalendarPopup(True)
        self.pull_btn = QPushButton()
        self.pull_btn.setText("Load")
        h_pull_box = QHBoxLayout()
        h_pull_box.addWidget(from_label)
        h_pull_box.addWidget(self.fromData)
        h_pull_box.addWidget(to_label)
        h_pull_box.addWidget(self.toData)
        h_pull_box.addWidget(self.pull_btn)

        expensesGroup = self.pullGroupExpenses()
        account = self.pullAccount()

        self.expenseGroupText = QLabel('Category')
        self.expenseGroupData = QComboBox()
        self.expenseGroupData.currentIndexChanged.connect(self.reloadExpenses)
        self.expenseText = QLabel('Expenses')
        self.expenseData = QComboBox()
        self.amountText = QLabel('Amount')
        self.amountData = QLineEdit()
        self.amountData.setPlaceholderText('0000.00')
        self.tellerText = QLabel('Teller/Reciept No.')
        self.tellerData = QLineEdit()
        self.tellerData.setPlaceholderText('xxxxxxxxx')
        self.accountText = QLabel('Account')
        self.accountData = QComboBox()
        self.dateText = QLabel('Date')
        self.dateData = QDateEdit()
        self.dateData.setDate(currentDate.currentDate())
        self.dateData.setCalendarPopup(True)
        self.descriptionText = QLabel('Brief Description')
        self.descriptionData = QPlainTextEdit()
        self.descriptionData.move(200, 100)
        hboz = QHBoxLayout()
        self.gender = QLabel('State')
        self.r1 = QRadioButton('Expenses')
        self.r1.setChecked(True)
        self.r2 = QRadioButton('Refund')
        hboz.addWidget(self.r1)
        hboz.addWidget(self.r2)

        i = 0
        for a in expensesGroup:
            self.hold_expensesGroup[i] = a['id']
            tex = str(a['name']).upper()
            self.expenseGroupData.addItem(tex)
            i += 1

        i = 0
        exp_key = self.hold_expensesGroup[self.expenseGroupData.currentIndex()]
        expenses = self.pullExpenses(exp_key)
        for a in expenses:
            self.hold_expenses[i] = a['id']
            tex = str(a['name']).upper()
            self.expenseData.addItem(tex)
            i += 1

        i = 0
        for a in account:
            self.hold_account[i] = a['id']
            tex = str(a['name']).upper()
            self.accountData.addItem(tex)
            i += 1

        self.FormLayout = QFormLayout()
        self.FormLayout.addRow(self.expenseGroupText, self.expenseGroupData)
        self.FormLayout.addRow(self.expenseText, self.expenseData)
        self.FormLayout.addRow(self.accountText, self.accountData)
        self.FormLayout.addRow(self.tellerText, self.tellerData)
        self.FormLayout.addRow(self.amountText, self.amountData)
        self.FormLayout.addRow(self.gender, hboz)
        self.FormLayout.addRow(self.dateText, self.dateData)
        self.FormLayout.addRow(self.descriptionText, self.descriptionData)

        groupBox1 = QGroupBox('Add Expenses')
        groupBox1.setLayout(self.FormLayout)

        self.pb = QPushButton()
        self.pb.setObjectName("Add")
        self.pb.setText("Add Expenses")

        self.pb1 = QPushButton()
        self.pb1.setObjectName("Edit")
        self.pb1.setText("Edit Row")
        self.pb1.setEnabled(False)

        self.pb2 = QPushButton()
        self.pb2.setObjectName("Close")
        self.pb2.setText("Close")

        self.pb3 = QPushButton()
        self.pb3.setObjectName("Delete")
        self.pb3.setText("Delete Row")
        self.pb3.setEnabled(False)

        self.pb4 = QPushButton()
        self.pb4.setObjectName("Reset")
        self.pb4.setText("Reset")
        self.pb4.hide()

        self.pb5 = QPushButton()
        self.pb5.setObjectName("Change")
        self.pb5.setText("Change Expenses")
        self.pb5.hide()

        self.pb6 = QPushButton()
        self.pb6.setObjectName("Clear")
        self.pb6.setText("Clear Selection")
        self.pb6.setEnabled(False)

        hbo = QHBoxLayout()
        hbo.addWidget(self.pb)
        hbo.addWidget(self.pb5)
        hbo.addWidget(self.pb4)
        hbo.addWidget(self.pb2)
        groupBox2 = QGroupBox('Expenses Data')
        groupBox2.setLayout(hbo)

        self.cols = ['SN', 'EXPENSES', 'ACCOUNT', 'AMOUNT', 'DATE']
        al = self.pullExpensesData()
        if len(al) > 0:
            al = al
        else:
            al = {}

        self.table = QTableWidget()
        header = self.table.horizontalHeader()
        header.setResizeMode(QHeaderView.ResizeToContents)
        header.setStretchLastSection(True)
        header.setStyleSheet(self.tableHeaderStyle)
        vheader = self.table.verticalHeader()
        vheader.setStyleSheet(self.tableHeaderStyle)
        # Body
        self.table.setWindowTitle("Expenses")
        self.table.resize(300, 250)
        self.table.setFont(self.tableFont)
        self.table.setSortingEnabled(2)
        #self.table.resizeColumnsToContents()
        self.table.setRowCount(len(al))
        self.table.setColumnCount(len(self.cols))
        self.table.setHorizontalHeaderLabels(self.cols)
        self.table.setContextMenuPolicy(Qt.CustomContextMenu)
        self.table.customContextMenuRequested.connect(self.handleHeaderMenu)
        self.table.hideColumn(0)
        self.table.setSelectionMode(QAbstractItemView.MultiSelection)
        self.table.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.table.setEditTriggers(QAbstractItemView.NoEditTriggers)

        i = 0
        for q in al:
            #row id
            self.table.setItem(i, 0, QTableWidgetItem(str(q['id'])))
            self.table.setItem(i, 1,
                               QTableWidgetItem(str(q['expensename']).upper()))
            self.table.setItem(i, 2,
                               QTableWidgetItem(str(q['accountname']).upper()))
            zamt = str("{:,}".format(float(q['amount'])))
            self.table.setItem(i, 3, QTableWidgetItem(zamt))
            damz = float(q['datepaid'])
            damt = datetime.utcfromtimestamp(damz).strftime('%d-%m-%Y')
            self.table.setItem(i, 4, QTableWidgetItem(str(damt)))
            i += 1
        self.table.itemSelectionChanged.connect(self.confirmSelection)
        self.table.resizeRowsToContents()
        v_pull_box = QVBoxLayout()
        self.h1_pull_box = QVBoxLayout()
        self.h1_pull_box.addWidget(self.table)
        v_pull_box.addLayout(h_pull_box)
        v_pull_box.addLayout(self.h1_pull_box)
        h2_pull_box = QHBoxLayout()
        h2_pull_box.addWidget(self.pb1)
        h2_pull_box.addWidget(self.pb3)
        h2_pull_box.addWidget(self.pb6)
        v_pull_box.addLayout(h2_pull_box)

        groupBox3 = QGroupBox()
        groupBox3.setLayout(hbo)
        groupBox2.setLayout(v_pull_box)

        grid = QGridLayout()
        grid.addWidget(groupBox1, 0, 0)
        grid.addWidget(groupBox2, 0, 1, 2, 1)
        grid.addWidget(groupBox3, 1, 0)

        self.setLayout(grid)
        self.connect(self.pb, SIGNAL("clicked()"), lambda: self.button_click())
        self.connect(self.pb1, SIGNAL("clicked()"),
                     lambda: self.button_editshow())
        self.connect(self.pb2, SIGNAL("clicked()"),
                     lambda: self.button_close(self))
        self.connect(self.pb3, SIGNAL("clicked()"),
                     lambda: self.button_delete())
        self.connect(self.pb4, SIGNAL("clicked()"),
                     lambda: self.button_reset())
        self.connect(self.pb5, SIGNAL("clicked()"), lambda: self.button_edit())
        self.connect(self.pb6, SIGNAL("clicked()"),
                     lambda: self.button_clear())
        self.connect(self.pull_btn,
                     SIGNAL("clicked()"),
                     lambda x=1: self.reloadTable(x))

        self.setWindowTitle(self.pagetitle)
Esempio n. 29
0
    def __init__(self, *args, **kwargs):
        super(ShortcutManagerDlg, self).__init__(*args, **kwargs)
        self.setWindowTitle("Shortcut Preferences")
        self.setMinimumWidth(500)
        self.setMinimumHeight(500)

        mgr = ShortcutManager()  # Singleton
        mgr._purgeDeletedShortcuts()

        scrollWidget = QWidget(parent=self)
        tempLayout = QVBoxLayout(scrollWidget)
        scrollWidget.setSizePolicy(QSizePolicy.Expanding,
                                   QSizePolicy.Expanding)

        treeWidget = QTreeWidget(parent=scrollWidget)
        treeWidget.setHeaderLabels(["Action", "Shortcut"])
        treeWidget.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        treeWidget.setColumnWidth(0, 300)
        treeWidget.setColumnWidth(1, 50)

        # Create a LineEdit for each shortcut,
        # and keep track of them in a dict
        shortcutEdits = collections.OrderedDict()
        for group, shortcutDict in mgr.shortcuts.items():
            groupItem = QTreeWidgetItem(treeWidget, QStringList(group))
            ListOfActions = set()
            for i, (shortcut, (desc, obj)) in enumerate(shortcutDict.items()):
                if desc in ListOfActions:
                    continue
                edit = QLineEdit(str(shortcut.key().toString()))
                shortcutEdits[shortcut] = edit
                item = QTreeWidgetItem(groupItem, QStringList(desc))
                item.setText(0, desc)
                ListOfActions.add(desc)
                treeWidget.setItemWidget(item, 1, edit)

        tempLayout.addWidget(treeWidget)

        # Add ok and cancel buttons
        buttonLayout = QHBoxLayout()
        cancelButton = QPushButton("Cancel")
        cancelButton.clicked.connect(self.reject)
        okButton = QPushButton("OK")
        okButton.clicked.connect(self.accept)
        okButton.setDefault(True)
        buttonLayout.addSpacerItem(QSpacerItem(10, 0, QSizePolicy.Expanding))
        buttonLayout.addWidget(cancelButton)
        buttonLayout.addWidget(okButton)
        tempLayout.addLayout(buttonLayout)

        scroll = QScrollArea(parent=self)
        scroll.setWidget(scrollWidget)
        scroll.setWidgetResizable(True)
        scroll.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        dlgLayout = QVBoxLayout()
        dlgLayout.addWidget(scroll)
        self.setLayout(dlgLayout)

        # Show the window
        result = self.exec_()

        # If the user didn't hit "cancel", apply his changes to the manager's shortcuts
        if result == QDialog.Accepted:
            for shortcut, edit in shortcutEdits.items():
                oldKey = str(shortcut.key().toString()).lower()
                newKey = str(edit.text()).lower()

                if oldKey != newKey and newKey != "":
                    # Before we add this shortcut to our dict, disable any other shortcuts it replaces
                    conflicting_shortcuts = mgr._findExistingShortcuts(newKey)
                    for conflicted in conflicting_shortcuts:
                        conflicted.setKey(QKeySequence(""))
                        try:
                            shortcutEdits[conflicted].setText("")
                        except KeyError:
                            # There might not be an edit for this shortcut if
                            #  it was skipped as a duplicate (see ListOfActions, above).
                            pass
                    shortcut.setKey(QKeySequence(newKey))

                # Make sure the tooltips get updated.
                mgr.updateToolTip(shortcut)
            mgr.storeToPreferences()
Esempio n. 30
0
 def createEditor(self, parent, option, index):
     lineedit = QLineEdit(parent)
     return lineedit