def ioTab(self, parent):
     tab = QtGui.QFrame()
     l = QtGui.QVBoxLayout()
     tab.setLayout(l)
     nc = uvcdatCommons.QFramedWidget("NetCDF Settings")
     self.netCDF3 = nc.addCheckBox("Generate NetCDF 3 Format Files")
     self.ncShuffle = nc.addCheckBox("Shuffle")
     if cdms2.getNetcdfShuffleFlag():
         self.ncShuffle.setChecked(True)
     self.ncDeflate = nc.addCheckBox("Deflate", newRow=True)
     if cdms2.getNetcdfDeflateFlag():
         self.ncDeflate.setChecked(True)
     self.ncDeflateLevel = nc.addLabeledSlider("Deflate Level",
                                               newRow=True,
                                               minimum=0,
                                               maximum=9)
     self.ncDeflateLevel.setTickInterval(1)
     self.ncDeflateLevel.setTickPosition(QtGui.QSlider.TicksAbove)
     self.ncDeflateLevel.setValue(cdms2.getNetcdfDeflateLevelFlag())
     self.connect(self.netCDF3, QtCore.SIGNAL("stateChanged(int)"), self.nc)
     self.connect(self.ncShuffle, QtCore.SIGNAL("stateChanged(int)"),
                  self.nc)
     self.connect(self.ncDeflate, QtCore.SIGNAL("stateChanged(int)"),
                  self.nc)
     self.connect(self.ncDeflateLevel, QtCore.SIGNAL("valueChanged(int)"),
                  self.nc)
     l.addWidget(nc)
     printers = uvcdatCommons.QFramedWidget("Printers Settings")
     printers.setEnabled(False)
     l.addWidget(printers)
     return tab
Exemple #2
0
    def __init__(self, parent):
        QtGui.QDialog.__init__(self, parent)
        self.parent = parent
        self.root = parent.root
        self.dim = str(self.root.preferences.defRanges.currentText())
        self.setWindowTitle('Default Range for %s' % self.dim)
        v = QtGui.QVBoxLayout(self)
        v.setMargin(0)
        v.setSpacing(0)
        self.setLayout(v)
        ranges = uvcdatCommons.QFramedWidget("Ranges for %s" % self.dim)
        self.start = ranges.addLabeledLineEdit("First Value:")
        self.stop = ranges.addLabeledLineEdit("Last Value:")
        drange = getattr(customizeUVCDAT, "%sRange" % self.dim, None)
        if drange is not None:
            self.start.setText("%f" % drange[0])
            self.stop.setText("%f" % drange[1])
        v.addWidget(ranges)

        b = QtGui.QPushButton("Apply")
        v.addWidget(b)
        self.connect(b, QtCore.SIGNAL("clicked()"), self.applyRange)

        b = QtGui.QPushButton("Close")
        v.addWidget(b)
        self.connect(b, QtCore.SIGNAL("clicked()"), self.close)
Exemple #3
0
    def vcsTab(self, parent):
        tab = QtGui.QFrame()
        l = QtGui.QVBoxLayout()
        tab.setLayout(l)
        self.saveVCS = QtGui.QPushButton("Save VCS Settings")
        self.connect(self.saveVCS, QtCore.SIGNAL("clicked()"),
                     self.root.canvas[0].saveinitialfile)
        l.addWidget(self.saveVCS)

        fonts = sorted(self.root.canvas[0].listelements("font"))
        #fonts.pop(fonts.index("default"))
        font = uvcdatCommons.QFramedWidget("Fonts")
        self.vcsFont = c = font.addLabeledComboBox("Default Font", fonts)
        print self.root.canvas[0].listelements("font")
        c.setCurrentIndex(fonts.index(self.root.canvas[0].getfontname(1)))
        self.connect(c, QtCore.SIGNAL("currentIndexChanged(int)"),
                     self.newDefaultFont)

        b = font.addButton("Load a font for file", newRow=True)
        self.connect(b, QtCore.SIGNAL("clicked()"), self.addFont)
        l.addWidget(font)

        aspect = uvcdatCommons.QFramedWidget("Aspect Ratio")
        self.aspectType = aspect.addRadioFrame(
            "Type", ["None", "Auto (lat/lon)", "Custom"])
        self.aspectCustom = aspect.addLabeledLineEdit(
            "Custom value (Y=n*X) n:")
        self.connect(self.aspectType.buttonGroup,
                     QtCore.SIGNAL("buttonClicked(int)"), self.aspectClicked)
        default = customizeUVCDAT.defaultAspectRatio
        for b in self.aspectType.buttonGroup.buttons():
            if str(b.text()) == default:
                #b.setChecked(True)
                b.click()

#        l.addWidget(aspect)

        return tab
Exemple #4
0
    def __init__(self, parent=None, defs={}):
        QtGui.QDialog.__init__(self, parent=parent)
        self.defs = defs
        self.parent = parent
        self.root = parent.root
        l = QtGui.QVBoxLayout()
        self.setLayout(l)

        module = defs["func"].__module__

        ## Prepare defaults vals
        ins = inspect.getargspec(defs["func"])
        mydefaults = {}
        n = len(ins.args) - len(ins.defaults)
        for i in range(len(ins.defaults)):
            mydefaults[ins.args[i + n]] = ins.defaults[i]

        if module == "genutil.averager":
            nm = module
        else:
            nm = "%s.%s" % (module, defs["func"].__name__)
        self.setWindowTitle(nm)

        ## First a few error checks
        selectedVars = self.root.dockVariable.widget(
        ).getSelectedDefinedVariables()
        if len(selectedVars) < defs["nargsMin"]:
            parent.errorMsg.showMessage(
                "%s requires at least %i input variables" %
                (defs["func"].__name__, defs["nargsMin"]))
            self.accept()
            return
        if len(selectedVars) > defs["nargsMax"]:
            parent.errorMsg.showMessage(
                "%s requires at most %i input variables" %
                (defs["func"].__name__, defs["nargsMax"]))
            self.accept()
            return

        lb = QtGui.QLabel("Options for: %s" % nm)
        l.addWidget(lb)
        lb = QtGui.QLabel("Documentation:")
        l.addWidget(lb)
        te = QtGui.QTextEdit()
        txt = defs["func"].__doc__
        te.setPlainText(txt)
        te.setReadOnly(True)
        f = te.currentFont()
        fm = QtGui.QFontMetrics(f)
        minWidth = min(max(map(fm.width, txt.split("\n"))), 65 * fm.width("W"))
        minHeight = min(len(txt.split()), 20)
        te.setMinimumHeight(fm.height() * minHeight)
        te.setMinimumWidth(minWidth)
        l.addWidget(te)

        ## Show the user what he's using
        if len(selectedVars) > 0:
            lb = QtGui.QLabel("Variables selected:")
            l.addWidget(lb)
            te = QtGui.QTextEdit()
            te.setDocumentTitle("BLA")
            te.setMaximumHeight(fm.height() * (len(selectedVars) + 1))
            txt = ""
            for v in selectedVars:
                txt += "%s %s\n" % (v.id, str(v.shape))
            te.setPlainText(txt[:-1])
            te.setReadOnly(True)
            l.addWidget(te)

        ## section showing the axes
        if defs.get("axes", True):
            axFrame = uvcdatCommons.QFramedWidget("Axes Options:")
            if defs.get("multiAxes", True):
                self.selAxes = []
                for ax in selectedVars[0].getAxisList():
                    c = axFrame.addCheckBox("%s" % ax.id, newRow=True)
                    self.selAxes.append(c)
                    if ax == selectedVars[0].getAxis(0):
                        c.setCheckState(QtCore.Qt.Checked)
            else:
                self.selAxes = axFrame.addLabeledComboBox(
                    "Axis:", selectedVars[0].getAxisIds())

            l.addWidget(axFrame)
        self.entries = []
        ## Ok now the "choices"
        self.choices = []
        choices = uvcdatCommons.QFramedWidget("Options:")
        hasChoices = False
        for c in sorted(defs.get("choices", [])):
            hasChoices = True
            if isinstance(c, str):
                ## Ok it's a simple yes/no
                self.choices.append(choices.addCheckBox(c, newRow=True))
                if c in mydefaults.keys():
                    if mydefaults[c] in [1, "yes", True]:
                        self.choices[-1].setChecked(True)
            else:
                ## Ok it's a radio button or a combobox if too many
                vals = c[1]
                if len in vals:
                    vals.pop(vals.index(len))
                    vals += range(max(selectedVars[0].shape))
                vals2 = []
                for v in vals:
                    vals2.append(repr(v))
                vals = vals2
                if len(vals) > 5:
                    self.choices.append(
                        choices.addLabeledComboBox(c[0], vals, newRow=True))
                    if c in mydefaults.keys():
                        try:
                            self.choices[-1].setCurrentindex(
                                vals.index(mydefaults[c]))
                        except Exception, err:
                            pass
                else:
                    self.choices.append(
                        choices.addRadioFrame(c[0], vals, newRow=True))
                    if c in mydefaults.keys():
                        try:
                            b = self.choices[-1].buttonGroup.button(
                                vals.index(mydefaults[c]))
                            b.setChecked(True)
                        except Exception, err:
                            pass
Exemple #5
0
                            pass
                else:
                    self.choices.append(
                        choices.addRadioFrame(c[0], vals, newRow=True))
                    if c in mydefaults.keys():
                        try:
                            b = self.choices[-1].buttonGroup.button(
                                vals.index(mydefaults[c]))
                            b.setChecked(True)
                        except Exception, err:
                            pass
        if hasChoices:
            l.addWidget(choices)

        hasEntries = False
        entries = uvcdatCommons.QFramedWidget("Entries:")
        ## Files entries first
        for e in defs.get("fileEntries", []):
            hasEntries = True
            self.entries.append(QFileOpener(e))
            entries.addWidget(self.entries[-1], newRow=True)
            if e in mydefaults.keys():
                self.entries[-1].fileEntry.setText(mydefaults[e])
        for e in defs.get("entries", []):
            hasEntries = True
            self.entries.append(entries.addLabeledLineEdit(e, newRow=True))
            if e in mydefaults.keys():
                self.entries[-1].setText(repr(mydefaults[e]))
        if hasEntries:
            l.addWidget(entries)
        ##Ok and Finally the ok/cancel buttons
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.root = parent.root
        vbox = QtGui.QVBoxLayout()
        vbox.setMargin(0)

        # Create options bar
        self.toolBar = QtGui.QToolBar()
        self.setFixedHeight(50)
        #self.setFixedWidth(50)
        self.toolBar.setIconSize(
            QtCore.QSize(customizeUVCDAT.iconsize, customizeUVCDAT.iconsize))
        actionInfo = [
            ('script_folder_smooth.ico', 'Open a script file.',
             self.openScript, True),
            ('folder_image_blue.ico', 'Save plots.', self.savePlots, True),
            ('printer.ico', 'Print plots.', self.printPlots, True),
            ('vistrails_icon.png', 'Vistrails Builder.', self.vistrails, True),
            ('esgf.png',
             'Connection to the Earth System Grid Federation (ESGF) data archive.',
             self.ESGF, True),
            ('symbol_help.ico',
             'Display assistant content for this application.', self.help,
             False),
        ]

        for info in actionInfo:
            pth = os.path.join(customizeUVCDAT.ICONPATH, info[0])
            icon = QtGui.QIcon(pth)
            action = self.toolBar.addAction(icon, 'help')
            action.setToolTip(info[1])
            self.connect(action, QtCore.SIGNAL("triggered()"), info[2])
            action.setEnabled(info[3])
        self.toolBar.addSeparator()

        vbox.addWidget(self.toolBar, 0)
        self.setLayout(vbox)
        self.files = []

        ## Printers dialog
        osprinters = os.environ.get("PRINTER", None)
        if osprinters is None:
            printers = []
        else:
            printers = [
                osprinters,
            ]
        vcsprinters = sorted(uvcdatCommons.getAvailablePrinters())
        if osprinters is not None and osprinters in vcsprinters:
            vcsprinters.pop(vcsprinters.index(osprinters))
        printers += vcsprinters
        printers += [
            "Custom",
        ]

        d = QtGui.QDialog()
        l = QtGui.QVBoxLayout()
        d.setLayout(l)
        fp = uvcdatCommons.QFramedWidget("Printer Selection", parent=self)
        self.qprinters = fp.addLabeledComboBox("Printer", printers)
        self.connect(self.qprinters, QtCore.SIGNAL("currentIndexChanged(int)"),
                     self.changedPrinter)
        l.addWidget(fp)
        self.customPrinter = fp.addLabeledLineEdit("Custom Printer Name:",
                                                   newRow=True)
        f = QtGui.QFrame()
        h = QtGui.QHBoxLayout()
        b1 = QtGui.QPushButton("Print")
        h.addWidget(b1)
        b2 = QtGui.QPushButton("Cancel")
        h.addWidget(b2)
        self.connect(b1, QtCore.SIGNAL("clicked()"), self.printerSelected)
        self.connect(b2, QtCore.SIGNAL("clicked()"), d.hide)
        f.setLayout(h)
        l.addWidget(f)
        self.qprinters.setCurrentIndex(1)
        self.qprinters.setCurrentIndex(0)

        self.printers = d
        d.hide()

        self.esgf = esgf.QEsgfBrowser(parent=self.root)
        self.esgf.addGateway(gateway=customizeUVCDAT.defaultEsgfNode,
                             mapping=customizeUVCDAT.defaultEsgfMapping)
        self.esgf.hide()