Пример #1
0
 def _try_rename(self):
     if self.text:
         # Try to change the function definition's binding
         old_var = self.unmodified_text.strip()
         new_var = self.text.strip()
         from blockcanvas.app.scripting import app
         app.update_function_variable_binding(self.box.graph_node, self.variable, new_var)
Пример #2
0
 def _try_rename(self):
     if self.text:
         # Try to change the function definition's binding
         old_var = self.unmodified_text.strip()
         new_var = self.text.strip()
         from blockcanvas.app.scripting import app
         app.update_function_variable_binding(self.box.graph_node,
                                              self.variable, new_var)
Пример #3
0
 def normal_dropped_on(self, event):
     """ Handle dropping onto this field for ContextVariable payloads.
     """
     if is_a_context_variable(event.obj):
         result = 'copy'
         from blockcanvas.app.scripting import app
         app.update_function_variable_binding(self.box.graph_node,
             self.variable, event.obj.name)
     else:
         result = 'none'
     event.window.set_drag_result(result)
     event.handled = (result == 'copy')
Пример #4
0
 def normal_dropped_on(self, event):
     """ Handle dropping onto this field for ContextVariable payloads.
     """
     if is_a_context_variable(event.obj):
         result = 'copy'
         from blockcanvas.app.scripting import app
         app.update_function_variable_binding(self.box.graph_node,
                                              self.variable, event.obj.name)
     else:
         result = 'none'
     event.window.set_drag_result(result)
     event.handled = (result == 'copy')
Пример #5
0
 def perform(self, event):
     dlg = SuffixDialog()
     if dlg.edit_traits(kind="livemodal"):
         suffix = dlg.suffix
         if suffix:
             for field in self.selected_fields:
                 old_text = field.variable.binding
                 if not old_text.isdigit():
                     from blockcanvas.app.scripting import app
                     new_text = old_text + '_' + suffix
                     app.update_function_variable_binding(field.box.graph_node,
                                                          field.variable, new_text)
         self.container.wiring_tool.clear_selection()
     return
 def perform(self, event):
     dlg = SuffixDialog()
     if dlg.edit_traits(kind="livemodal"):
         suffix = dlg.suffix
         if suffix:
             for field in self.selected_fields:
                 old_text = field.variable.binding
                 if not old_text.isdigit():
                     from blockcanvas.app.scripting import app
                     new_text = old_text + '_' + suffix
                     app.update_function_variable_binding(
                         field.box.graph_node, field.variable, new_text)
         self.container.wiring_tool.clear_selection()
     return
Пример #7
0
    def drag_end(self, event):

        import pprint 
        
        field = self._get_underlying_box_field(event.x, event.y)
        if field is self._start_field:
            return

        if field and self._start_field:
            self._end_field = field
            start_type = self._start_field.type
            end_type = self._end_field.type
            field.icon.bullet_state = 'up'
            if ((start_type == 'output' and end_type == 'input') or
                (start_type == 'input' and end_type == 'output')):
                               
                self.add_to_selection(self._end_field)
                if len(self.input_selected_fields) == len(self.output_selected_fields):
                    matches = self.match_inputs2outputs()
                    for input, pairs in matches.items():
                        for pair in pairs:
                            from blockcanvas.app.scripting import app
                            # Set the input (pair[0]) binding to output(pair[1])
                            app.update_function_variable_binding(field.box.graph_node,
                                                                 pair[0],
                                                                 pair[1].binding)
                                      
    #***************************************************************************************************#
    # This code that update a connection dict in the canvas_box is no more necessary                    #  
    #***************************************************************************************************#                
    #                    # If the updated of the binding were successful, add this connection
    #                    # to the canvas_box that holds the input field (an input can receive 
    #                    # just one connection rather than an output that could be connected
    #                    # with different blocks)
    #                    if self._start_field.type == 'input':
    #                        update_conn_field = self._start_field
    #                        ref_field = self._end_field
    #                    else:
    #                        update_conn_field = self._end_field
    #                        ref_field = self._start_field
    #                    
    #                    # UUID of the referenced graph_node
    #                    ref_uuid = ref_field.box.graph_node.uuid
    #                        
    #                    # Check if there exist an entry for this referenced graph_node in the
    #                    # current "source" graph_node
    #                    if ref_uuid in update_conn_field.box.connections: 
    #                        # Check if there is a tuple for the current variables that are to 
    #                        # be connected. 
    #                        conn_list = update_conn_field.box.connections[ref_uuid]
    #                        is_in = False
    #                        for connection in conn_list:
    #                            if connection == (update_conn_field.variable,ref_field.variable):
    #                                is_in = True
    #                        if not is_in:
    #                            conn_list.append((update_conn_field.variable,ref_field.variable))
    #                    else:
    #                       update_conn_field.box.connections[ref_uuid] = [(update_conn_field.variable,ref_field.variable)] 

    #***************************************************************************************************#    
                                                                         
        self.drag_cancel(event)