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

Added rst documentation for the canvas gui package.

Fixing docstrings in the process.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/gui/stackedwidget.py

    r11365 r11366  
    44===================== 
    55 
    6 A widget similar to QStackedWidget that supports animated 
     6A widget similar to :class:`QStackedWidget` supporting animated 
    77transitions between widgets. 
    88 
     
    2525 
    2626def clipMinMax(size, minSize, maxSize): 
    27     """Clip the size so it is bigger then minSize but smaller than maxSize. 
     27    """ 
     28    Clip the size so it is bigger then minSize but smaller than maxSize. 
    2829    """ 
    2930    return size.expandedTo(minSize).boundedTo(maxSize) 
     
    3132 
    3233def fixSizePolicy(size, hint, policy): 
    33     """Fix size so it conforms to the size policy and the given size hint. 
     34    """ 
     35    Fix size so it conforms to the size policy and the given size hint. 
    3436    """ 
    3537    width, height = hint.width(), hint.height() 
     
    5355 
    5456class StackLayout(QStackedLayout): 
    55     """A stacked layout with `sizeHint` always the same as that 
    56     of the current widget. 
     57    """ 
     58    A stacked layout with ``sizeHint`` always the same as that of the 
     59    `current` widget. 
    5760 
    5861    """ 
     
    99102 
    100103    def _onCurrentChanged(self, index): 
    101         """Current widget changed, invalidate the layout. 
     104        """ 
     105        Current widget changed, invalidate the layout. 
    102106        """ 
    103107        self.invalidate() 
     
    105109 
    106110class AnimatedStackedWidget(QFrame): 
     111    # Current widget has changed 
    107112    currentChanged = Signal(int) 
     113 
     114    # Transition animation has started 
    108115    transitionStarted = Signal() 
     116 
     117    # Transition animation has finished 
    109118    transitionFinished = Signal() 
    110119 
     
    136145 
    137146    def setAnimationEnabled(self, animationEnabled): 
    138         """Enable/disable transition animations. 
     147        """ 
     148        Enable/disable transition animations. 
    139149        """ 
    140150        if self.__animationEnabled != animationEnabled: 
     
    145155 
    146156    def animationEnabled(self): 
     157        """ 
     158        Is the transition animation enabled. 
     159        """ 
    147160        return self.__animationEnabled 
    148161 
    149162    def addWidget(self, widget): 
    150         """Add the widget to the stack in the last place. 
     163        """ 
     164        Append the widget to the stack and return its index. 
    151165        """ 
    152166        return self.insertWidget(self.layout().count(), widget) 
    153167 
    154168    def insertWidget(self, index, widget): 
    155         """Insert widget at index. 
     169        """ 
     170        Insert `widget` into the stack at `index`. 
    156171        """ 
    157172        index = min(index, self.count()) 
     
    162177 
    163178    def removeWidget(self, widget): 
    164         """Remove `widget` from the stack. 
     179        """ 
     180        Remove `widget` from the stack. 
     181 
     182        .. note:: The widget is hidden but is not deleted. 
     183 
    165184        """ 
    166185        index = self.__widgets.index(widget) 
     
    169188 
    170189    def widget(self, index): 
    171         """Return the widget at `index` 
     190        """ 
     191        Return the widget at `index` 
    172192        """ 
    173193        return self.__widgets[index] 
    174194 
    175195    def indexOf(self, widget): 
    176         """Return the index of `widget` in the stack. 
     196        """ 
     197        Return the index of `widget` in the stack. 
    177198        """ 
    178199        return self.__widgets.index(widget) 
    179200 
    180201    def count(self): 
    181         """Return the number of widgets in the stack. 
     202        """ 
     203        Return the number of widgets in the stack. 
    182204        """ 
    183205        return max(self.layout().count() - 1, 0) 
    184206 
    185207    def setCurrentWidget(self, widget): 
    186         """Set the current shown widget. 
     208        """ 
     209        Set the current shown widget. 
    187210        """ 
    188211        index = self.__widgets.index(widget) 
     
    190213 
    191214    def setCurrentIndex(self, index): 
    192         """Set the current shown widget index. 
     215        """ 
     216        Set the current shown widget index. 
    193217        """ 
    194218        index = max(min(index, self.count() - 1), 0) 
     
    217241 
    218242    def currentIndex(self): 
     243        """ 
     244        Return the current shown widget index. 
     245        """ 
    219246        return self.__currentIndex 
    220247 
     
    226253 
    227254    def __transitionStart(self): 
    228         """Start the transition. 
     255        """ 
     256        Start the transition. 
    229257        """ 
    230258        log.debug("Stack transition start (%s)", str(self.objectName())) 
     
    236264 
    237265    def __onTransitionFinished(self): 
    238         """Transition has finished. 
     266        """ 
     267        Transition has finished. 
    239268        """ 
    240269        log.debug("Stack transition finished (%s)" % str(self.objectName())) 
     
    252281 
    253282class CrossFadePixmapWidget(QWidget): 
    254     """A widget for cross fading between two pixmaps. 
     283    """ 
     284    A widget for cross fading between two pixmaps. 
    255285    """ 
    256286    def __init__(self, parent=None, pixmap1=None, pixmap2=None): 
     
    262292 
    263293    def setPixmap(self, pixmap): 
    264         """Set pixmap 1 
     294        """ 
     295        Set pixmap 1 
    265296        """ 
    266297        self.pixmap1 = pixmap 
     
    268299 
    269300    def setPixmap2(self, pixmap): 
    270         """Set pixmap 2 
     301        """ 
     302        Set pixmap 2 
    271303        """ 
    272304        self.pixmap2 = pixmap 
     
    274306 
    275307    def setBlendingFactor(self, factor): 
    276         """Set the blending factor between the two pixmaps. 
     308        """ 
     309        Set the blending factor between the two pixmaps. 
    277310        """ 
    278311        self.__blendingFactor = factor 
     
    280313 
    281314    def blendingFactor(self): 
    282         """Pixmap blending factor between 0.0 and 1.0 
     315        """ 
     316        Pixmap blending factor between 0.0 and 1.0 
    283317        """ 
    284318        return self.__blendingFactor 
     
    288322 
    289323    def sizeHint(self): 
    290         """Return an interpolated size between pixmap1.size() 
     324        """ 
     325        Return an interpolated size between pixmap1.size() 
    291326        and pixmap2.size() 
    292327 
     
    300335 
    301336    def paintEvent(self, event): 
    302         """Paint the interpolated pixmap image. 
     337        """ 
     338        Paint the interpolated pixmap image. 
    303339        """ 
    304340        p = QPainter(self) 
Note: See TracChangeset for help on using the changeset viewer.