示例#1
0
    def __init__(self, proj=None, parent=None):
        super(CreateProjectWidget, self).__init__(parent)
        self.pm = ProjectManager()

        self.widget_metadata = QtGui.QWidget()
        self.widget_path = QtGui.QWidget()

        layout_path = QtGui.QFormLayout(self.widget_path)

        # Name and path
        if proj is None:
            date = strftime("%Y-%m-%d_%H-%M-%S", gmtime())
            name = 'project_%s' % date if not proj else proj.name
            projectdir = self.pm.defaultdir
        else:
            name = proj.name
            projectdir = proj.path.parent

        self.editor_name = widget('IStr', name)
        self.editor_projectdir = widget('IDirStr', projectdir)

        layout_path.addRow(QtGui.QLabel('Name'), self.editor_name)
        layout_path.addRow(QtGui.QLabel('Project Directory'),
                           self.editor_projectdir)
        layout_path.setLabelAlignment(QtCore.Qt.AlignLeft)

        # Metadata
        self._metadata = {}
        layout_metadata = QtGui.QFormLayout(self.widget_metadata)
        layout_metadata.setLabelAlignment(QtCore.Qt.AlignLeft)

        for cat, metadata in Project.DEFAULT_METADATA.iteritems():
            label = QtGui.QLabel(metadata.name.capitalize().replace('_', ' '))
            editor = widget(metadata.interface, metadata.value)
            editor.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding,
                                 QtGui.QSizePolicy.Preferred)
            self._metadata[cat] = editor
            layout_metadata.addRow(label, editor)

        if proj:
            for key in proj.DEFAULT_METADATA:
                self._metadata[key].setValue(proj.metadata[key])
            title = "Edit '%s' metadata" % proj.name
        else:
            title = "New Project"

        layout = QtGui.QVBoxLayout(self)
        layout.addWidget(QtGui.QLabel(title))
        layout.addWidget(self.widget_path)
        layout.addWidget(self.widget_metadata)
示例#2
0
def qt_container(container, **kwargs):
    widget = QtGui.QWidget()
    layout = QtGui.QFormLayout(widget)
    widget.editor = {}
    widget.control = {}
    for control in container.controls():
        editor = qt_editor(control, 'hline')
        if editor:
            widget.editor[control] = weakref.ref(editor)
            widget.control[control.name] = control
            layout.addRow(control.alias, editor)
    return widget
示例#3
0
    def __init__(self):
        QtGui.QWidget.__init__(self)
        layout = QtGui.QFormLayout(self)

        self.e_min = QtGui.QLineEdit('0')
        self.e_max = QtGui.QLineEdit('100')
        text = 'Can be an int (for instance -5) or empty (no limits)'
        self.e_min.setToolTip(text)
        self.e_min.setWhatsThis(text)
        self.e_max.setToolTip(text)
        self.e_max.setWhatsThis(text)

        layout.addRow(QtGui.QLabel('Minimum'), self.e_min)
        layout.addRow(QtGui.QLabel('Maximum'), self.e_max)
示例#4
0
    def __init__(self, name, categories, dtypes, project=None, parent=None):
        super(ParadigmInfoSelector, self).__init__(parent=parent)

        self._valid = True

        self.project = project
        self.categories = categories
        self.dtypes = dtypes

        layout = QtGui.QFormLayout(self)

        self.l_categories = QtGui.QLabel(
            "Select in which category you want to add this file: ")
        self.l_dtypes = QtGui.QLabel("Data type")
        self.l_name = QtGui.QLabel("Name: ")
        self.l_notes = QtGui.QLabel("Note:")
        self.l_info = QtGui.QLabel("All is ok")

        # Category selector
        if len(self.categories) > 1:
            self.cb_categories = QtGui.QComboBox(self)
            self.cb_categories.addItems(categories)
            if 'model' in categories:
                self.cb_categories.setCurrentIndex(categories.index('model'))
            self.cb_categories.currentIndexChanged.connect(self.check)

            layout.addRow(self.l_categories, self.cb_categories)

        if len(self.dtypes) > 1:
            # Dtype selector
            self.cb_dtypes = QtGui.QComboBox(self)
            self.cb_dtypes.addItems(dtypes)
            self.cb_dtypes.setCurrentIndex(0)
            self.cb_dtypes.currentIndexChanged.connect(self.check_data)

            layout.addRow(self.l_dtypes, self.cb_dtypes)

        self.line = QtGui.QLineEdit(name)
        self.line.textChanged.connect(self.check)
        layout.addRow(self.l_name, self.line)
        layout.addRow(self.l_notes, self.l_info)
        self.setLayout(layout)

        self.check()
示例#5
0
    def __init__(self):
        QtGui.QWidget.__init__(self)
        layout = QtGui.QFormLayout(self)

        self.e_min = QtGui.QLineEdit('0.0')
        self.e_max = QtGui.QLineEdit('1.0')
        self.e_step = QtGui.QLineEdit('0.01')
        text = 'Can be a float (for instance -0.5) or empty (no limits)'
        self.e_min.setToolTip(text)
        self.e_min.setWhatsThis(text)
        self.e_max.setToolTip(text)
        self.e_max.setWhatsThis(text)
        text = 'Must be a positive float (for instance 0.1)'
        self.e_step.setToolTip(text)
        self.e_step.setWhatsThis(text)

        layout.addRow(QtGui.QLabel('Minimum'), self.e_min)
        layout.addRow(QtGui.QLabel('Maximum'), self.e_max)
        layout.addRow(QtGui.QLabel('Step'), self.e_step)
示例#6
0
    def _set_config(self, config):
        # TODO
        # Manage memory (are children widgets destroyed when tabwidget.clear ?)
        # Once it is sure all widget are totally cleaned and destroyed,
        # we can move it to public method to allow to change config dynamically
        self._config = config
        sections = config.sections()

        self.tabwidget.clear()

        for section in sections:
            if section not in self.hidden_sections:
                self._option_values[section] = []
                tab = QtGui.QWidget(self.tabwidget)
                self.tabwidget.addTab(tab, section)
                layout = QtGui.QFormLayout(tab)
                options = config.options(section)
                for option_name in options:
                    value = config.get(section, option_name)
                    control, widget = Widget(option_name, value)
                    self._option_values[section].append(control)
                    layout.addRow(option_name, widget)
示例#7
0
    def __init__(self, filename="", categories=None, dtypes=None, parent=None):
        super(SelectCategory, self).__init__(parent=parent)

        if categories is None:
            categories = Project.DEFAULT_CATEGORIES.keys()
        if dtypes is None:
            dtypes = [
                plugin.default_name
                for plugin in iter_plugins('oalab.paradigm_applet')
            ]
            dtypes.append('Other')
        self.categories = categories

        layout = QtGui.QFormLayout(self)

        self.label = QtGui.QLabel(
            "Select in which category you want to add this file: ")
        self.l_dtypes = QtGui.QLabel("Data type")
        self.label2 = QtGui.QLabel("New filename: ")

        self.combo = QtGui.QComboBox(self)
        self.combo.addItems(categories)
        if 'model' in categories:
            self.combo.setCurrentIndex(categories.index('model'))

        self.combo_dtypes = QtGui.QComboBox(self)
        self.combo_dtypes.addItems(dtypes)
        self.combo_dtypes.setCurrentIndex(0)

        self.line = QtGui.QLineEdit(filename)

        layout.addRow(self.label, self.combo)
        layout.addRow(self.l_dtypes, self.combo_dtypes)
        layout.addRow(self.label2, self.line)

        self.setLayout(layout)