示例#1
0
 def flags(self, index):
     'Returns the item flags for the given index.'
     if index.column() == 0:
         # The First Column is just a label and unchangable
         return Qt.ItemIsEnabled | Qt.ItemIsSelectable
     if not index.isValid():
         return Qt.ItemFlag(0)
     childPref = self.index2Pref(index)
     if childPref:
         if childPref.qt_is_editable():
             return Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable
     return Qt.ItemFlag(0)
示例#2
0
 def __init__(self, parent, modal=True, flags=Qt.WindowFlags(), caption="Select Tags", ok_button="Select"):
     QDialog.__init__(self, parent, flags)
     self.setModal(modal)
     self.setWindowTitle(caption)
     lo = QVBoxLayout(self)
     lo.setMargin(10)
     lo.setSpacing(5)
     # tag selector
     self.wtagsel = QListWidget(self)
     lo.addWidget(self.wtagsel)
     #    self.wtagsel.setColumnMode(QListBox.FitToWidth)
     self.wtagsel.setSelectionMode(QListWidget.MultiSelection)
     QObject.connect(self.wtagsel, SIGNAL("itemSelectionChanged()"), self._check_tag)
     # buttons
     lo.addSpacing(10)
     lo2 = QHBoxLayout()
     lo.addLayout(lo2)
     lo2.setContentsMargins(0, 0, 0, 0)
     lo2.setMargin(5)
     self.wokbtn = QPushButton(ok_button, self)
     self.wokbtn.setMinimumWidth(128)
     QObject.connect(self.wokbtn, SIGNAL("clicked()"), self.accept)
     self.wokbtn.setEnabled(False)
     cancelbtn = QPushButton("Cancel", self)
     cancelbtn.setMinimumWidth(128)
     QObject.connect(cancelbtn, SIGNAL("clicked()"), self.reject)
     lo2.addWidget(self.wokbtn)
     lo2.addStretch(1)
     lo2.addWidget(cancelbtn)
     self.setMinimumWidth(384)
     self._tagnames = []
示例#3
0
def make():
    demo = Qwt.QwtPlot()
    picker = Qwt.QwtPlotPicker(Qwt.QwtPlot.xBottom,
                Qwt.QwtPlot.yLeft,
                Qwt.QwtPicker.PointSelection,
                Qwt.QwtPlotPicker.CrossRubberBand,
                Qwt.QwtPicker.AlwaysOn,
                demo.canvas())
    picker.connect(
        picker, Qt.SIGNAL('selected(const QwtDoublePoint&)'), aSlot)
    return demo
示例#4
0
 def __init__(self, checked=False, is_tristate=False):
     QTableWidgetItem.__init__(self, '')
     self.setFlags(
         Qt.ItemFlags(Qt.ItemIsSelectable | Qt.ItemIsUserCheckable
                      | Qt.ItemIsEnabled))
     if is_tristate:
         self.setFlags(self.flags() | Qt.ItemIsTristate)
     if checked:
         self.setCheckState(Qt.Checked)
     else:
         if is_tristate and checked is None:
             self.setCheckState(Qt.PartiallyChecked)
         else:
             self.setCheckState(Qt.Unchecked)
示例#5
0
 def __init__(self, parent, modal=True, flags=Qt.WindowFlags()):
     QDialog.__init__(self, parent, flags)
     self.setModal(modal)
     self.setWindowTitle("Add FITS brick")
     lo = QVBoxLayout(self)
     lo.setMargin(10)
     lo.setSpacing(5)
     # file selector
     self.wfile = FileSelector(self,
                               label="FITS filename:",
                               dialog_label="FITS file",
                               default_suffix="fits",
                               file_types="FITS files (*.fits *.FITS)",
                               file_mode=QFileDialog.ExistingFile)
     lo.addWidget(self.wfile)
     # overwrite or add mode
     lo1 = QGridLayout()
     lo.addLayout(lo1)
     lo1.setContentsMargins(0, 0, 0, 0)
     lo1.addWidget(QLabel("Padding factor:", self), 0, 0)
     self.wpad = QLineEdit("2", self)
     self.wpad.setValidator(QDoubleValidator(self))
     lo1.addWidget(self.wpad, 0, 1)
     lo1.addWidget(QLabel("Assign source name:", self), 1, 0)
     self.wname = QLineEdit(self)
     lo1.addWidget(self.wname, 1, 1)
     # OK/cancel buttons
     lo.addSpacing(10)
     lo2 = QHBoxLayout()
     lo.addLayout(lo2)
     lo2.setContentsMargins(0, 0, 0, 0)
     lo2.setMargin(5)
     self.wokbtn = QPushButton("OK", self)
     self.wokbtn.setMinimumWidth(128)
     QObject.connect(self.wokbtn, SIGNAL("clicked()"), self.accept)
     self.wokbtn.setEnabled(False)
     cancelbtn = QPushButton("Cancel", self)
     cancelbtn.setMinimumWidth(128)
     QObject.connect(cancelbtn, SIGNAL("clicked()"), self.reject)
     lo2.addWidget(self.wokbtn)
     lo2.addStretch(1)
     lo2.addWidget(cancelbtn)
     self.setMinimumWidth(384)
     # signals
     QObject.connect(self.wfile, SIGNAL("filenameSelected"),
                     self._fileSelected)
     # internal state
     self.qerrmsg = QErrorMessage(self)
    def __init__(self, parent, get_option, get_help, db=None, book_id=None):
        # Dummy attributes to fool the Widget() option handler code. We handle
        # everything in our *handler methods.
        for i in range(1, 4):
            x = 'sr%d_' % i
            for y in ('search', 'replace'):
                z = x + y
                setattr(self, 'opt_' + z, z)
        self.opt_search_replace = 'search_replace'

        Widget.__init__(self, parent, [
            'search_replace', 'sr1_search', 'sr1_replace', 'sr2_search',
            'sr2_replace', 'sr3_search', 'sr3_replace'
        ])
        self.db, self.book_id = db, book_id

        self.sr_search.set_msg(_('&Search Regular Expression'))
        self.sr_search.set_book_id(book_id)
        self.sr_search.set_db(db)

        self.sr_search.doc_update.connect(self.update_doc)

        proto = QTableWidgetItem()
        proto.setFlags(Qt.ItemFlags(Qt.ItemIsSelectable + Qt.ItemIsEnabled))
        self.search_replace.setItemPrototype(proto)
        self.search_replace.setColumnCount(2)
        self.search_replace.setColumnWidth(0, 320)
        self.search_replace.setColumnWidth(1, 320)
        self.search_replace.setHorizontalHeaderLabels(
            [_('Search Regular Expression'),
             _('Replacement Text')])

        self.sr_add.clicked.connect(self.sr_add_clicked)
        self.sr_change.clicked.connect(self.sr_change_clicked)
        self.sr_remove.clicked.connect(self.sr_remove_clicked)
        self.sr_load.clicked.connect(self.sr_load_clicked)
        self.sr_save.clicked.connect(self.sr_save_clicked)
        self.sr_up.clicked.connect(self.sr_up_clicked)
        self.sr_down.clicked.connect(self.sr_down_clicked)
        self.search_replace.currentCellChanged.connect(
            self.sr_currentCellChanged)

        self.initialize_options(get_option, get_help, db, book_id)
示例#7
0
 def __init__(self, parent, modal=True, flags=Qt.WindowFlags()):
     QDialog.__init__(self, parent, flags)
     self.setModal(modal)
     self.setWindowTitle("Add Tag")
     lo = QVBoxLayout(self)
     lo.setMargin(10)
     lo.setSpacing(5)
     # tag selector
     lo1 = QHBoxLayout()
     lo.addLayout(lo1)
     lo1.setSpacing(5)
     self.wtagsel = QComboBox(self)
     self.wtagsel.setEditable(True)
     wtagsel_lbl = QLabel("&Tag:", self)
     wtagsel_lbl.setBuddy(self.wtagsel)
     lo1.addWidget(wtagsel_lbl, 0)
     lo1.addWidget(self.wtagsel, 1)
     QObject.connect(self.wtagsel, SIGNAL("activated(int)"),
                     self._check_tag)
     QObject.connect(self.wtagsel,
                     SIGNAL("editTextChanged(const QString &)"),
                     self._check_tag_text)
     # value editor
     self.valedit = ValueTypeEditor(self)
     lo.addWidget(self.valedit)
     # buttons
     lo.addSpacing(10)
     lo2 = QHBoxLayout()
     lo.addLayout(lo2)
     lo2.setContentsMargins(0, 0, 0, 0)
     lo2.setMargin(5)
     self.wokbtn = QPushButton("OK", self)
     self.wokbtn.setMinimumWidth(128)
     QObject.connect(self.wokbtn, SIGNAL("clicked()"), self.accept)
     self.wokbtn.setEnabled(False)
     cancelbtn = QPushButton("Cancel", self)
     cancelbtn.setMinimumWidth(128)
     QObject.connect(cancelbtn, SIGNAL("clicked()"), self.reject)
     lo2.addWidget(self.wokbtn)
     lo2.addStretch(1)
     lo2.addWidget(cancelbtn)
     self.setMinimumWidth(384)
示例#8
0
 def __init__(self, parent, modal=True, flags=Qt.WindowFlags()):
     QDialog.__init__(self, parent, flags)
     self.setModal(modal)
     self.setWindowTitle("Export Karma annotations")
     lo = QVBoxLayout(self)
     lo.setMargin(10)
     lo.setSpacing(5)
     # file selector
     self.wfile = FileSelector(self,
                               label="Filename:",
                               dialog_label="Karma annotations filename",
                               default_suffix="ann",
                               file_types="Karma annotations (*.ann)")
     lo.addWidget(self.wfile)
     # selected sources checkbox
     self.wsel = QCheckBox("selected sources only", self)
     lo.addWidget(self.wsel)
     # OK/cancel buttons
     lo.addSpacing(10)
     lo2 = QHBoxLayout()
     lo.addLayout(lo2)
     lo2.setContentsMargins(0, 0, 0, 0)
     lo2.setMargin(5)
     self.wokbtn = QPushButton("OK", self)
     self.wokbtn.setMinimumWidth(128)
     QObject.connect(self.wokbtn, SIGNAL("clicked()"), self.accept)
     self.wokbtn.setEnabled(False)
     cancelbtn = QPushButton("Cancel", self)
     cancelbtn.setMinimumWidth(128)
     QObject.connect(cancelbtn, SIGNAL("clicked()"), self.reject)
     lo2.addWidget(self.wokbtn)
     lo2.addStretch(1)
     lo2.addWidget(cancelbtn)
     self.setMinimumWidth(384)
     # signals
     QObject.connect(self.wfile, SIGNAL("valid"), self.wokbtn.setEnabled)
     # internal state
     self.qerrmsg = QErrorMessage(self)
     self._model_filename = None
示例#9
0
 def __init__(self, parent, modal=True, flags=Qt.WindowFlags()):
     QDialog.__init__(self, parent, flags)
     self.setModal(modal)
     self.setWindowTitle("Convert sources to FITS brick")
     lo = QVBoxLayout(self)
     lo.setMargin(10)
     lo.setSpacing(5)
     # file selector
     self.wfile = FileSelector(self,
                               label="FITS filename:",
                               dialog_label="Output FITS file",
                               default_suffix="fits",
                               file_types="FITS files (*.fits *.FITS)",
                               file_mode=QFileDialog.ExistingFile)
     lo.addWidget(self.wfile)
     # reference frequency
     lo1 = QHBoxLayout()
     lo.addLayout(lo1)
     lo1.setContentsMargins(0, 0, 0, 0)
     label = QLabel("Frequency, MHz:", self)
     lo1.addWidget(label)
     tip = """<P>If your sky model contains spectral information (such as spectral indices), then a brick may be generated
 for a specific frequency. If a frequency is not specified here, the reference frequency of the model sources will be assumed.</P>"""
     self.wfreq = QLineEdit(self)
     self.wfreq.setValidator(QDoubleValidator(self))
     label.setToolTip(tip)
     self.wfreq.setToolTip(tip)
     lo1.addWidget(self.wfreq)
     # beam gain
     lo1 = QHBoxLayout()
     lo.addLayout(lo1)
     lo1.setContentsMargins(0, 0, 0, 0)
     self.wpb_apply = QCheckBox("Apply primary beam expression:", self)
     self.wpb_apply.setChecked(True)
     lo1.addWidget(self.wpb_apply)
     tip = """<P>If this option is specified, a primary power beam gain will be applied to the sources before inserting
 them into the brick. This can be any valid Python expression making use of the variables 'r' (corresponding
 to distance from field centre, in radians) and 'fq' (corresponding to frequency.)</P>"""
     self.wpb_exp = QLineEdit(self)
     self.wpb_apply.setToolTip(tip)
     self.wpb_exp.setToolTip(tip)
     lo1.addWidget(self.wpb_exp)
     # overwrite or add mode
     lo1 = QHBoxLayout()
     lo.addLayout(lo1)
     lo1.setContentsMargins(0, 0, 0, 0)
     self.woverwrite = QRadioButton("overwrite image", self)
     self.woverwrite.setChecked(True)
     lo1.addWidget(self.woverwrite)
     self.waddinto = QRadioButton("add into image", self)
     lo1.addWidget(self.waddinto)
     # add to model
     self.wadd = QCheckBox(
         "Add resulting brick to sky model as a FITS image component", self)
     lo.addWidget(self.wadd)
     lo1 = QHBoxLayout()
     lo.addLayout(lo1)
     lo1.setContentsMargins(0, 0, 0, 0)
     self.wpad = QLineEdit(self)
     self.wpad.setValidator(QDoubleValidator(self))
     self.wpad.setText("1.1")
     lab = QLabel("...with padding factor:", self)
     lab.setToolTip(
         """<P>The padding factor determines the amount of null padding inserted around the image during
   the prediction stage. Padding alleviates the effects of tapering and detapering in the uv-brick, which can show
   up towards the edges of the image. For a factor of N, the image will be padded out to N times its original size.
   This increases memory use, so if you have no flux at the edges of the image anyway, then a pad factor of 1 is
   perfectly fine.</P>""")
     self.wpad.setToolTip(lab.toolTip())
     QObject.connect(self.wadd, SIGNAL("toggled(bool)"),
                     self.wpad.setEnabled)
     QObject.connect(self.wadd, SIGNAL("toggled(bool)"), lab.setEnabled)
     self.wpad.setEnabled(False)
     lab.setEnabled(False)
     lo1.addStretch(1)
     lo1.addWidget(lab, 0)
     lo1.addWidget(self.wpad, 1)
     self.wdel = QCheckBox(
         "Remove from the sky model sources that go into the brick", self)
     lo.addWidget(self.wdel)
     # OK/cancel buttons
     lo.addSpacing(10)
     lo2 = QHBoxLayout()
     lo.addLayout(lo2)
     lo2.setContentsMargins(0, 0, 0, 0)
     lo2.setMargin(5)
     self.wokbtn = QPushButton("OK", self)
     self.wokbtn.setMinimumWidth(128)
     QObject.connect(self.wokbtn, SIGNAL("clicked()"), self.accept)
     self.wokbtn.setEnabled(False)
     cancelbtn = QPushButton("Cancel", self)
     cancelbtn.setMinimumWidth(128)
     QObject.connect(cancelbtn, SIGNAL("clicked()"), self.reject)
     lo2.addWidget(self.wokbtn)
     lo2.addStretch(1)
     lo2.addWidget(cancelbtn)
     self.setMinimumWidth(384)
     # signals
     QObject.connect(self.wfile, SIGNAL("filenameSelected"),
                     self._fileSelected)
     # internal state
     self.qerrmsg = QErrorMessage(self)
示例#10
0
    def setMainWidgetFLFormSearchDB(self, w):
        if not self.cursor_ or not w:
            return
        if self.showed:
            if self.mainWidget_ and not self.mainWidget_ == w:
                self.initMainWidget(w)
        else:
            w.hide()

        if self.layoutButtons:
            del self.layoutButtons

        if self.layout:
            del self.layout

        w.setFont(QtGui.qApp.font())
        desk = QtGui.QApplication.desktop.availableGeometry(self)
        geo = w.geometry()
        tooLarge = False

        if geo.width() > desk.width() or geo.height() > desk.heigh():
            sv = QtGui.QScrollArea(self)
            #sv->setResizePolicy(QScrollView::AutoOneFit) FIXME
            sv.hide()
            sv.addChild(w)
            self.layout = QtGui.QVBoxLayout(self, 5, 5, "vlay" + self.name_)
            self.Layout.add(sv)
            sv.resize(self.size().expand(desk.size()))
            self.layoutButtons = QtGui.QHBoxLayout(self.layout, 3,
                                                   "hlay" + self.name_)
            self.formReady.connect(sv.show())
            tooLarge = True
        else:
            self.layout = QtGui.QVBoxLayout(self, 2, 3, "vlay" + self.name_)
            self.layout.add(w)
            self.layoutButtons = QtGui.QHBoxLayout(self.layout, 3,
                                                   "hlay" + self.name_)

        pbSize = Qt.qsize(22, 22)
        """
        QToolButton *wt = QWhatsThis::whatsThisButton(this);
        wt->setIconSet(QPixmap::fromMimeSource("about.png"));
        layoutButtons->addWidget(wt);
        wt->show()
        """
        self.layoutButtons.addItem(
            QtGui.QSpacerItem(20, 20, Qt.QSizePolicy.Expanding,
                              Qt.QSizePolicy.Minimum))
        self.pushButtonAccept = QtGui.QPushButton(self, "pushButtonAccept")
        self.pushButtonAccept.sizePolicy(
            Qt.QSizePolicy(
                0, 0, 0, 0,
                self.pushButtonAccept.sizePolicy().hasHeightForWidth()))
        self.pushButtonAccept.setMinimumSize(pbSize)
        self.pushButtonAccept.setMaximumSize(pbSize)
        ok = QtGui.QIcon(FLUtil.filedir("icons", "button_ok.png"))
        self.pushButtonAccept.setIcon(ok)
        self.pushButtonAccept.setFocusPolicy(QtGui.QWidget.NoFocus)

        #pushButtonAccept->setAccel(QKeySequence(Qt::Key_F10)); FIXME
        self.pushButtonAccept.setDefault(True)
        #QToolTip::add(pushButtonAccept, tr("Seleccionar registro actual y cerrar formulario (F10)")); FIXME
        #QWhatsThis::add(pushButtonAccept, tr("Seleccionar registro actual y cerrar formulario (F10)")); FIXME
        self.layoutButtons.addWidget(self.pushButtonAccept)
        self.pushButtonAccept.clicked.connect(self.accept())

        self.pushButtonCancel = QtGui.QPushButton(self, "pushButtonCancel")
        self.pushButtonCancel.sizePolicy(
            Qt.QSizePolicy(
                0, 0, 0, 0,
                self.pushButtonAccept.sizePolicy().hasHeightForWidth()))
        self.pushButtonCancel.setMinimumSize(pbSize)
        self.pushButtonCancel.setMaximumSize(pbSize)
        cancel = QtGui.QIcon(FLUtil.filedir("icons", "button_cancel.png"))
        self.pushButtonAccept.setIcon(cancel)
        self.pushButtonCancel.setFocusPolicy(QtGui.QWidget.NoFocus)
        #pushButtonCancel->setAccel(QKeySequence(tr("Esc"))); #FIXME
        #QToolTip::add(pushButtonCancel, tr("Cerrar formulario sin seleccionar registro (Esc)")); #FIXME
        #QWhatsThis::add(pushButtonCancel, tr("Cerrar formulario sin seleccionar registro (Esc)")); #FIXME
        self.layoutButtons.addItem(
            QtGui.QSpacerItem(20, 20, Qt.QSizePolicy.Fixed,
                              Qt.QSizePolicy.Fixed))
        self.layoutButtons.addWidget(self.pushButtonCancel)
        self.pushButtonCancel.clicked.connect(self.reject())

        self.mainWidget_ = w
        self.cursor_.setEdition(False)
        self.cursor_.setBrowse(False)
        self.cursor_.recordChoosed.connect(self.accept())

        if not tooLarge:
            mWidth = self.mainWidget_.width()
            mHeight = self.mainWidget_.height()
            actWin = QtGui.qApp.activeWindow()
            if actWin:
                screen = actWin.geometry()
            else:
                screen = QtGui.qApp.mainWidget().geometry()
            p = screen.center() - Qt.QPoint(mWidth / 2, mHeight / 2)

            if p.x() + mWidth > desk.width():
                p.setx(desk.width() - mWidth)
            if p.y() + mHeight > desk.height():
                p.sety(desk.height() - mHeight)
            if p.x() < 0:
                p.setx(0)
            if p.y() < 0:
                p.sety(0)
            self.move(p)
示例#11
0
 def __init__(self, parent, modal=True, flags=Qt.WindowFlags()):
     QDialog.__init__(self, parent, flags)
     self.setModal(modal)
     self.setWindowTitle("Restore model into image")
     lo = QVBoxLayout(self)
     lo.setMargin(10)
     lo.setSpacing(5)
     # file selector
     self.wfile_in = FileSelector(self, label="Input FITS file:", dialog_label="Input FITS file",
                                  default_suffix="fits", file_types="FITS files (*.fits *.FITS)",
                                  file_mode=QFileDialog.ExistingFile)
     lo.addWidget(self.wfile_in)
     self.wfile_out = FileSelector(self, label="Output FITS file:", dialog_label="Output FITS file",
                                   default_suffix="fits", file_types="FITS files (*.fits *.FITS)",
                                   file_mode=QFileDialog.AnyFile)
     lo.addWidget(self.wfile_out)
     # beam size
     lo1 = QHBoxLayout()
     lo.addLayout(lo1)
     lo1.setContentsMargins(0, 0, 0, 0)
     lo1.addWidget(QLabel("Restoring beam FWHM, major axis:", self))
     self.wbmaj = QLineEdit(self)
     lo1.addWidget(self.wbmaj)
     lo1.addWidget(QLabel("\"     minor axis:", self))
     self.wbmin = QLineEdit(self)
     lo1.addWidget(self.wbmin)
     lo1.addWidget(QLabel("\"     P.A.:", self))
     self.wbpa = QLineEdit(self)
     lo1.addWidget(self.wbpa)
     lo1.addWidget(QLabel("\u00B0", self))
     for w in self.wbmaj, self.wbmin, self.wbpa:
         w.setValidator(QDoubleValidator(self))
     lo1 = QHBoxLayout()
     lo.addLayout(lo1)
     lo1.setContentsMargins(0, 0, 0, 0)
     self.wfile_psf = FileSelector(self, label="Set restoring beam by fitting PSF image:",
                                   dialog_label="PSF FITS file", default_suffix="fits",
                                   file_types="FITS files (*.fits *.FITS)", file_mode=QFileDialog.ExistingFile)
     lo1.addSpacing(32)
     lo1.addWidget(self.wfile_psf)
     # selection only
     self.wselonly = QCheckBox("restore selected model sources only", self)
     lo.addWidget(self.wselonly)
     # OK/cancel buttons
     lo.addSpacing(10)
     lo2 = QHBoxLayout()
     lo.addLayout(lo2)
     lo2.setContentsMargins(0, 0, 0, 0)
     lo2.setMargin(5)
     self.wokbtn = QPushButton("OK", self)
     self.wokbtn.setMinimumWidth(128)
     QObject.connect(self.wokbtn, SIGNAL("clicked()"), self.accept)
     self.wokbtn.setEnabled(False)
     cancelbtn = QPushButton("Cancel", self)
     cancelbtn.setMinimumWidth(128)
     QObject.connect(cancelbtn, SIGNAL("clicked()"), self.reject)
     lo2.addWidget(self.wokbtn)
     lo2.addStretch(1)
     lo2.addWidget(cancelbtn)
     self.setMinimumWidth(384)
     # signals
     QObject.connect(self.wfile_in, SIGNAL("filenameSelected"), self._fileSelected)
     QObject.connect(self.wfile_in, SIGNAL("filenameSelected"), self._inputFileSelected)
     QObject.connect(self.wfile_out, SIGNAL("filenameSelected"), self._fileSelected)
     QObject.connect(self.wfile_psf, SIGNAL("filenameSelected"), self._psfFileSelected)
     # internal state
     self.qerrmsg = QErrorMessage(self)
示例#12
0
 def __init__(self, parent, flags=Qt.WindowFlags()):
     QDialog.__init__(self, parent, flags)
     self.setModal(False)
     self.setWindowTitle("Select sources by...")
     lo = QVBoxLayout(self)
     lo.setMargin(10)
     lo.setSpacing(5)
     # select by
     lo1 = QHBoxLayout()
     lo.addLayout(lo1)
     lo1.setContentsMargins(0, 0, 0, 0)
     #    lab = QLabel("Select:")
     #   lo1.addWidget(lab)
     self.wselby = QComboBox(self)
     lo1.addWidget(self.wselby, 0)
     QObject.connect(self.wselby, SIGNAL("activated(const QString &)"),
                     self._setup_selection_by)
     # under/over
     self.wgele = QComboBox(self)
     lo1.addWidget(self.wgele, 0)
     self.wgele.addItems([">", ">=", "<=", "<", "sum<=", "sum>"])
     QObject.connect(self.wgele, SIGNAL("activated(const QString &)"),
                     self._select_threshold)
     # threshold value
     self.wthreshold = QLineEdit(self)
     QObject.connect(self.wthreshold, SIGNAL("editingFinished()"),
                     self._select_threshold)
     lo1.addWidget(self.wthreshold, 1)
     # min and max label
     self.wminmax = QLabel(self)
     lo.addWidget(self.wminmax)
     # selection slider
     lo1 = QHBoxLayout()
     lo.addLayout(lo1)
     self.wpercent = QSlider(self)
     self.wpercent.setTracking(False)
     QObject.connect(self.wpercent, SIGNAL("valueChanged(int)"),
                     self._select_percentile)
     QObject.connect(self.wpercent, SIGNAL("sliderMoved(int)"),
                     self._select_percentile_threshold)
     self.wpercent.setRange(0, 100)
     self.wpercent.setOrientation(Qt.Horizontal)
     lo1.addWidget(self.wpercent)
     self.wpercent_lbl = QLabel("0%", self)
     self.wpercent_lbl.setMinimumWidth(64)
     lo1.addWidget(self.wpercent_lbl)
     #    # hide button
     #    lo.addSpacing(10)
     #    lo2 = QHBoxLayout()
     #    lo.addLayout(lo2)
     #    lo2.setContentsMargins(0,0,0,0)
     #    hidebtn = QPushButton("Close",self)
     #    hidebtn.setMinimumWidth(128)
     #    QObject.connect(hidebtn,SIGNAL("clicked()"),self.hide)
     #    lo2.addStretch(1)
     #    lo2.addWidget(hidebtn)
     #    lo2.addStretch(1)
     #    self.setMinimumWidth(384)
     self._in_select_threshold = False
     self._sort_index = None
     self.qerrmsg = QErrorMessage(self)
示例#13
0
def main(args):
    app = Qt.QApplication(args)
    demo = make()
    demo.show()
    sys.exit(app.exec_())
示例#14
0
 def setMainWidgetFLFormSearchDB(self, w):
     if not self.cursor_ or not w:
         return
     if self.showed:
         if self.mainWidget_ and not self.mainWidget_ == w:
             self.initMainWidget(w)
     else:
         w.hide()
     
     if self.layoutButtons:
         del self.layoutButtons
     
     if self.layout:
         del self.layout 
     
     w.setFont(QtGui.qApp.font())
     desk = QtGui.QApplication.desktop.availableGeometry(self)
     geo = w.geometry()
     tooLarge = False
     
     if geo.width() > desk.width() or geo.height() > desk.heigh():
         sv = QtGui.QScrollArea(self)
         #sv->setResizePolicy(QScrollView::AutoOneFit) FIXME
         sv.hide()
         sv.addChild(w)
         self.layout = QtGui.QVBoxLayout(self, 5,5,"vlay" + self.name_)
         self.Layout.add(sv)
         sv.resize(self.size().expand(desk.size()))
         self.layoutButtons = QtGui.QHBoxLayout(self.layout, 3, "hlay" + self.name_)
         self.formReady.connect(sv.show())
         tooLarge = True
     else:
         self.layout = QtGui.QVBoxLayout(self, 2, 3, "vlay" + self.name_)
         self.layout.add(w)
         self.layoutButtons = QtGui.QHBoxLayout(self.layout, 3, "hlay" + self.name_)
         
     
     pbSize = Qt.qsize(22,22)
     """
     QToolButton *wt = QWhatsThis::whatsThisButton(this);
     wt->setIconSet(QPixmap::fromMimeSource("about.png"));
     layoutButtons->addWidget(wt);
     wt->show()
     """
     self.layoutButtons.addItem(QtGui.QSpacerItem(20,20, Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Minimum))
     self.pushButtonAccept = QtGui.QPushButton(self,"pushButtonAccept")
     self.pushButtonAccept.sizePolicy(Qt.QSizePolicy(0,0,0,0, self.pushButtonAccept.sizePolicy().hasHeightForWidth()))
     self.pushButtonAccept.setMinimumSize(pbSize)
     self.pushButtonAccept.setMaximumSize(pbSize)
     ok = QtGui.QIcon(FLUtil.filedir("icons","button_ok.png"))
     self.pushButtonAccept.setIcon(ok)
     self.pushButtonAccept.setFocusPolicy(QtGui.QWidget.NoFocus)
     
     #pushButtonAccept->setAccel(QKeySequence(Qt::Key_F10)); FIXME
     self.pushButtonAccept.setDefault(True)
     #QToolTip::add(pushButtonAccept, tr("Seleccionar registro actual y cerrar formulario (F10)")); FIXME
     #QWhatsThis::add(pushButtonAccept, tr("Seleccionar registro actual y cerrar formulario (F10)")); FIXME
     self.layoutButtons.addWidget(self.pushButtonAccept)
     self.pushButtonAccept.clicked.connect(self.accept())
     
     self.pushButtonCancel = QtGui.QPushButton(self, "pushButtonCancel")
     self.pushButtonCancel.sizePolicy(Qt.QSizePolicy(0,0,0,0, self.pushButtonAccept.sizePolicy().hasHeightForWidth()))
     self.pushButtonCancel.setMinimumSize(pbSize)
     self.pushButtonCancel.setMaximumSize(pbSize)
     cancel = QtGui.QIcon(FLUtil.filedir("icons","button_cancel.png"))
     self.pushButtonAccept.setIcon(cancel)
     self.pushButtonCancel.setFocusPolicy(QtGui.QWidget.NoFocus)
     #pushButtonCancel->setAccel(QKeySequence(tr("Esc"))); #FIXME
     #QToolTip::add(pushButtonCancel, tr("Cerrar formulario sin seleccionar registro (Esc)")); #FIXME
     #QWhatsThis::add(pushButtonCancel, tr("Cerrar formulario sin seleccionar registro (Esc)")); #FIXME
     self.layoutButtons.addItem(QtGui.QSpacerItem(20,20, Qt.QSizePolicy.Fixed, Qt.QSizePolicy.Fixed))
     self.layoutButtons.addWidget(self.pushButtonCancel)
     self.pushButtonCancel.clicked.connect(self.reject())
     
     self.mainWidget_ = w
     self.cursor_.setEdition(False)
     self.cursor_.setBrowse(False)
     self.cursor_.recordChoosed.connect(self.accept())
     
     if not tooLarge:
         mWidth = self.mainWidget_.width()
         mHeight = self.mainWidget_.height()
         actWin = QtGui.qApp.activeWindow()
         if actWin:
             screen = actWin.geometry()
         else:
             screen = QtGui.qApp.mainWidget().geometry()
         p = screen.center() - Qt.QPoint(mWidth / 2, mHeight / 2)
         
         if p.x() + mWidth > desk.width():
             p.setx(desk.width() - mWidth)
         if p.y() + mHeight > desk.height():
             p.sety(desk.height() - mHeight)
         if p.x() < 0:
             p.setx(0)
         if p.y() < 0:
             p.sety(0)
         self.move(p)