Changeset 11297:8cb078ed56ec in orange


Ignore:
Timestamp:
02/01/13 14:15:31 (15 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Small fixes to WidgetsScheme.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/scheme/widgetsscheme.py

    r11296 r11297  
    2121import sip 
    2222from PyQt4.QtGui import QShortcut, QKeySequence, QWhatsThisClickedEvent 
    23 from PyQt4.QtCore import Qt, QCoreApplication, QEvent 
     23from PyQt4.QtCore import Qt, QCoreApplication, QEvent, SIGNAL 
    2424 
    2525from .signalmanager import SignalManager, compress_signals, can_enable_dynamic 
    2626from .scheme import Scheme, SchemeNode 
    2727from .utils import name_lookup, check_arg, check_type 
     28from ..resources import icon_loader 
    2829from ..config import rc 
    2930 
     
    3536    A Scheme containing Orange Widgets managed with a `WidgetsSignalManager` 
    3637    instance. 
    37     This class handles the lifetime (creation/deletion, etc.) of OWBaseWidget 
    38     instances corresponding to the nodes of the scheme. 
     38 
     39    Extends the base `Scheme` class to handle the lifetime 
     40    (creation/deletion, etc.) of `OWBaseWidget` instances corresponding to 
     41    the nodes in the scheme. It also delegates the interwidget signal 
     42    propagation to an instance of `WidgetsSignalManager`. 
    3943 
    4044    """ 
     
    111115        # Add the node/widget mapping s before calling __init__ 
    112116        # Some OWWidgets might already send data in the constructor 
     117        # (should this be forbidden? Raise a warning?) 
    113118        self.signal_manager.on_node_added(node) 
     119 
    114120        self.widget_for_node[node] = widget 
    115121        self.node_for_widget[widget] = node 
     
    119125        widget.widgetInfo = desc 
    120126 
     127        widget.setWindowIcon( 
     128            icon_loader.from_description(desc).get(desc.icon) 
     129        ) 
     130 
    121131        widget.setVisible(node.properties.get("visible", False)) 
    122132 
    123133        node.title_changed.connect(widget.setCaption) 
     134 
    124135        # Bind widgets progress/processing state back to the node's properties 
    125136        widget.progressBarValueChanged.connect(node.set_progress) 
    126137        widget.processingStateChanged.connect(node.set_processing_state) 
     138        self.connect(widget, 
     139                     SIGNAL("blockingStateChanged(bool)"), 
     140                     self.signal_manager._update) 
    127141 
    128142        # Install a help shortcut on the widget 
     
    392406            w2 = scheme.widget_for_node[link.sink_node] 
    393407 
    394             # Input/OutputSignal are reused from description. interface 
    395             # is almost the same 
     408            # Input/OutputSignal are reused from description. Interface 
     409            # is almost the same as it was in orngSignalManager 
    396410            return SignalLink(w1, link.source_channel, 
    397411                              w2, link.sink_channel, 
     
    488502    Signal (actually slot) wrapper used by OWBaseWidget.connect overload. 
    489503    This disables (freezes) the widget's signal manager when slots are 
    490     invoked from GUI signals. Not sure if this is still needed, plenty of 
    491     widgets use the base QObject.connect 
     504    invoked from GUI signals. Not sure if this is still needed, could instead 
     505    just set the blocking flag on the widget itself. 
    492506 
    493507    """ 
     
    496510        self.method = method 
    497511 
    498     def __call__(self, *k): 
     512    def __call__(self, *args): 
    499513        manager = self.widget.signalManager 
    500  
    501         with manager.freeze(self.method): 
    502             self.method(*k) 
     514        if manager: 
     515            with manager.freeze(self.method): 
     516                self.method(*args) 
     517        else: 
     518            # Might be running stand alone without a manager. 
     519            self.method(*args) 
Note: See TracChangeset for help on using the changeset viewer.