Exemple #1
0
    def __init__(self, parent, proc_exec_panel, context):
        super(ExecContextWidget, self).__init__(parent)
        self.proc_exec_panel = proc_exec_panel
        self.context = context

        self.setLayout(QtGui.QVBoxLayout())

        if context['proc_doc']:
            doc_label = QtGui.QTextEdit(self)
            doc_label.setReadOnly(True)
            doc_label.setPlainText(context['proc_doc'])
            self.layout().addWidget(doc_label)

        self.param_layout = QtGui.QFormLayout()
        self.param_layout.setLabelAlignment(QtCore.Qt.AlignRight)
        self.layout().addLayout(self.param_layout)

        lb = QtGui.QLabel(', '.join(context['needed_features']) or 'None',
                          self)
        self.param_layout.addRow('Worker Features', lb)

        lb = QtGui.QLabel(context['document'] or 'None', self)
        self.param_layout.addRow('Document', lb)

        why = context[
            'why_needs_to_run'] and ': ' + context['why_needs_to_run'] or ''
        lb = QtGui.QLabel(
            context['needs_to_run'] and 'Yes' + why or 'No' + why, self)
        self.param_layout.addRow('Needed', lb)

        why = context['why'] and ': ' + context['why'] or ''
        lb = QtGui.QLabel(
            (context['allow_exec'] and 'Yes' or '<font color="#FF8888">No') +
            str(why), self)
        self.param_layout.addRow('Ready', lb)

        input_controler = ContextAttrController(self, 'run',
                                                self.context['run'])
        value_editor = self.proc_exec_panel.EDITOR_FACTORY.create(
            self, 'bool', input_controler)
        #        value_editor.set_editable()
        #        value_editor.set_busy = lambda: None
        #        value_editor._input_controler = input_controler
        #        input_controler.value_editor = value_editor
        #        value_editor.set_value(self.context['run'])
        self.param_layout.addRow('Run', value_editor)

        self.param_layout.addRow(' ', QtGui.QWidget(self))

        for param in self.context['params']:
            controller = ContextParamController(self, param['name'], param)
            value_editor = self.proc_exec_panel.EDITOR_FACTORY.create(
                self,
                param['editor'],
                controller,
                options=param['editor_options'])

            self.param_layout.addRow(param['name'], value_editor)
Exemple #2
0
    def __init__(self, parent, client):
        super(UserPanel, self).__init__(parent)
        self.client = client

        self.setWidgetResizable(True)
        self.setWidget(QtGui.QWidget(self))
        self.setFrameStyle(self.NoFrame)

        self.widget().setLayout(QtGui.QVBoxLayout())
        #self.widget().layout().setContentsMargins(0,0,0,0)

        self.definition = None
Exemple #3
0
    def __init__(self, parent, client):
        super(ProcExecDialog, self).__init__(parent)

        self.setLayout(QtGui.QVBoxLayout())

        self.pep = ProcExecPanel(self, client)
        self.pep.context_updated.connect(self._on_context_update)
        self.layout().addWidget(self.pep)

        buttons_layout = QtGui.QHBoxLayout()
        self.layout().addLayout(buttons_layout)

        self.execute_button = QtGui.QPushButton('Execute', self)
        self.execute_button.clicked.connect(self.execute)
        buttons_layout.addWidget(self.execute_button)

        b = QtGui.QPushButton('Close', self)
        b.clicked.connect(self.close)
        buttons_layout.addWidget(b)
Exemple #4
0
    def __init__(self, parent, proc_exec_panel, node_id, open=True):
        super(NodeBox, self).__init__(parent)
        self.proc_exec_panel = proc_exec_panel
        self.node_id = node_id

        self.setStyleSheet(self._SS)

        self.update_label()

        lo = QtGui.QVBoxLayout()
        lo.setContentsMargins(0, 10, 0, 0)
        lo.setSpacing(0)
        self.setLayout(lo)

        self._holder = QtGui.QWidget(self)
        self._holder.setLayout(QtGui.QFormLayout())
        lo.addWidget(self._holder)

        self.setCheckable(True)
        self.toggled.connect(self._on_toggled)
        self.setChecked(open)
Exemple #5
0
    def __init__(self, parent, client, extra_root_names={}):
        super(NodeTreePanel, self).__init__(parent)

        self.client = client
        self.current_node_id = None

        self._item_menu_filler_func = None
        self._on_current_changed_func = None
        self._extra_root_names = extra_root_names
        self._root_names = {}

        self._bookmarks = {}  # user bookmarks
        self._live_bookmarks = {
        }  # dynamic/programatic/non-persistent bookmarks

        self.model = FlowModel(parent=self, client=self.client)

        # Widgets
        self.setLayout(QtGui.QVBoxLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)

        # MENUS
        self.menu_bar = TreeViewMenuBar(self)
        self.layout().addWidget(self.menu_bar)

        # TREE
        self.tree = QtGui.QTreeView(self)
        self.tree.setAlternatingRowColors(False)
        self.tree.setDragEnabled(True)
        self.tree.setItemDelegate(FlowItemDelegate(self))
        self.tree.setRootIsDecorated(True)
        self.layout().addWidget(self.tree)

        self.tree.setModel(self.model)

        self.sel_model = QtGui.QItemSelectionModel(self.model)
        self.sel_model.currentChanged.connect(self._on_current_changed)
        self.tree.setSelectionModel(self.sel_model)
Exemple #6
0
    def __init__(self, parent, client):
        super(ProcExecPanel, self).__init__(parent)
        if self.__class__.EDITOR_FACTORY is None:
            self.__class__.EDITOR_FACTORY = get_global_factory()

        self.client = client

        self._context = None

        self.setLayout(QtGui.QVBoxLayout())

        #
        #    HEADER
        #
        self.header = QtGui.QLabel(self)
        self.layout().addWidget(self.header)

        if self.USE_SPLITTER:
            splitter = QtGui.QSplitter(self)
            self.layout().addWidget(splitter, stretch=100)
        else:
            splitter = QtGui.QHBoxLayout()
            self.layout().addLayout(splitter)

        #
        #    INPUT COLUMN
        #
        input_scroll = QtGui.QScrollArea(self)
        input_scroll.setFrameStyle(input_scroll.NoFrame)
        input_scroll.setWidgetResizable(True)
        self.input_parent = QtGui.QWidget()
        lo = QtGui.QVBoxLayout()
        self.input_layout = QtGui.QVBoxLayout()
        lo.addLayout(self.input_layout)
        lo.addStretch(100)
        self.input_parent.setLayout(lo)
        input_scroll.setWidget(self.input_parent)
        splitter.addWidget(input_scroll)

        self._node_boxes = {}
        self._node_boxes_open = {}

        #
        #    WORKER COLUMN
        #
        column = QtGui.QWidget(self)
        column.setLayout(QtGui.QVBoxLayout())
        column.layout().setContentsMargins(0, 0, 0, 0)
        splitter.addWidget(column)

        self.workers_table = WorkersTable(self.client, self)
        self.workers_table.show_mine_only(True)
        self.workers_table.selectionModel().selectionChanged.connect(
            self._on_worker_changed)
        self.workers_table.refresh_done.connect(self._on_worker_changed)

        self.workers_tb = WorkerToolBar(self, self.workers_table)

        column.layout().addWidget(self.workers_tb)
        column.layout().addWidget(self.workers_table)

        self.workers_table.on_connect()
        self.workers_tb.on_connect()

        self.depth_needed_features_label = QtGui.QLabel(
            'Overall Features Needed: <no context loaded>', self)
        column.layout().addWidget(self.depth_needed_features_label)

        self.acceptable_docs_label = QtGui.QLabel(
            'Acceptable Document: <no context loaded>', self)
        column.layout().addWidget(self.acceptable_docs_label)

        self.selected_worker_features_label = QtGui.QLabel(
            'Selected Features: <No Worker Selected>', self)
        column.layout().addWidget(self.selected_worker_features_label)

        self.selected_worker_doc_label = QtGui.QLabel(
            'Selected Document: <No Worker Seleced>', self)
        column.layout().addWidget(self.selected_worker_doc_label)

        if self.USE_SPLITTER:
            if 0:
                # make the detail panel hidden but resizable:
                splitter.setSizes([1, 0])
            else:
                splitter.setSizes([100, 100])
Exemple #7
0
        if label is None:
            raise ValueError('Could not find an label for value %r'%(value,))
        
        for i in range(self._cb.count()):
            if self._cb.itemText(i) == label:
                self._cb.setCurrentIndex(i)
                self.selected.emit(label, value)
                return
        raise ValueError('Could not find an item with label %r'%(label,))
        
if __name__ == '__main__':
    import sys
    app = QtGui.QApplication(sys.argv)
    f = QtGui.QFrame(None)
    f.resize(500,500)
    f.setLayout(QtGui.QVBoxLayout())
    
    def on_select(label, data):
        print 'Selected:', label, data
        
    w = Selector('Select One of those...', f)
    w.selected.connect(on_select)
    f.layout().addWidget(w)

    def fill():
        items = [ ('Item '+str(i)+' hop', i) for i in range(50) ]
        w.set_items(items)
        
    def fetch():
        w.show_wait()
        QtCore.QTimer.singleShot(1000, fill)