Changeset 11408:c2d2400b6a90 in orange


Ignore:
Timestamp:
03/19/13 19:36:52 (13 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Fixes for Widgets Development documentation.

Location:
docs/extend-widgets/rst
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • docs/extend-widgets/rst/basics.rst

    r11050 r11408  
    110110set with 10% of the data instances. Not to mess with other widgets, we 
    111111will create a Test directory within OrangeWidgets directory, and write 
    112 the widget in a file called `OWDataSamplerA <OWDataSamplerA.py>`: OW for Orange Widget, 
     112the widget in a file called `OWDataSamplerA.py`: OW for Orange Widget, 
    113113DataSampler since this is what widget will be doing, and A since we 
    114114prototype a number of this widgets in our tutorial. 
     
    223223output channel. 
    224224 
    225 Although our widget is now ready to test, for a final touch, let's 
    226 design an icon for our widget. As specified in the widget header, we 
    227 will call it `DataSamplerA.png <DataSamplerA.png>`_ and will 
    228 put it in icons subdirectory of OrangeWidgets directory (together with 
    229 all other icons of other widgets). 
     225.. 
     226   Although our widget is now ready to test, for a final touch, let's 
     227   design an icon for our widget. As specified in the widget header, we 
     228   will call it :download:`DataSamplerA.png <DataSamplerA.png>` and will 
     229   put it in icons subdirectory of OrangeWidgets directory (together with 
     230   all other icons of other widgets). 
    230231 
    231232For a test, we now open Orange Canvas. There should be a new pane in a 
  • docs/extend-widgets/rst/channels.rst

    r11050 r11408  
    5151 
    5252    self.inputs = [("Data", ExampleTable, self.dataset), 
    53                ("Learner", orange.Learner, self.learner, Multiple)] 
     53                   ("Learner", orange.Learner, self.learner, Multiple + Default)] 
    5454 
    5555Notice that everything is pretty much the same as it was with 
     
    6363channel for its type (more on default channels later). 
    6464 
     65.. note:: :obj:`Default` flag here is used for illustration. Since *Learner* 
     66          channel is the only channel for a :class:`orange.Learner` type 
     67          it is also the default. 
     68 
    6569How does the widget know from which widget did the token come from? 
    6670In Orange, tokens are sent around with an id of a widget that is 
    67 sending the token (essentially, with a pointer to the corresponding 
    68 widget object), and having a multi-input channel only tells Orange to 
     71sending the token, and having a multi-input channel only tells Orange to 
    6972send a token together with sending widget id, the two arguments with 
    7073which the receiving function is called. For our :obj:`Learner` 
     
    146149all that is needed is the augmenting the list :: 
    147150 
    148     self.scoring = [("Classification Accuracy", orngStat.CA),\ 
    149                 ("AUC", orngStat.AUC), \ 
    150                 ("BrierScore", orngStat.BrierScore),\ 
    151                 ("Information Score", orngStat.IS),\ 
    152                 ("Sensitivity", orngStat.sens), \ 
    153                 ("Specificity", orngStat.spec)] 
     151    self.scoring = [("Classification Accuracy", orngStat.CA), 
     152                    ("AUC", orngStat.AUC), 
     153                    ("BrierScore", orngStat.BrierScore), 
     154                    ("Information Score", orngStat.IS), 
     155                    ("Sensitivity", orngStat.sens), 
     156                    ("Specificity", orngStat.spec)] 
    154157 
    155158which is defined in the initialization part of the widget. The 
     
    160163essentially means that switching from one to another scoring function 
    161164(and displaying the result in the table) takes only a split of a 
    162 second. To see the rest of the widget, check out `its code <OWLearningCurveA.py>`_. 
     165second. To see the rest of the widget, check out 
     166:download:`its code <OWLearningCurveA.py>`. 
    163167 
    164168***************************** 
     
    176180    self.outputs = [("Sampled Data", ExampleTable), ("Other Data", ExampleTable)] 
    177181 
    178 We used this in the third incarnation of `data sampler widget <OWDataSamplerC.py>`_, 
     182We used this in the third incarnation of :download:`data sampler widget <OWDataSamplerC.py>`, 
    179183with essentially the only other change in the code in the :obj:`selection` and 
    180184:obj:`commit` functions:: 
     
    221225When enlisting the input channel of the same type, the non-default 
    222226channels have a special flag in the channel specification list. So for 
    223 our new `learning curve <OWLearningCurveB.py>`_ widget, the 
     227our new :download:`learning curve <OWLearningCurveB.py>` widget, the 
    224228channel specification is:: 
    225229 
    226230    self.inputs = [("Train Data", ExampleTable, self.trainset, Default), 
    227                ("Test Data", ExampleTable, self.testset), 
    228                ("Learner", orange.Learner, self.learner, Multiple)] 
     231                   ("Test Data", ExampleTable, self.testset), 
     232                   ("Learner", orange.Learner, self.learner, Multiple)] 
    229233 
    230234That is, the :obj:`Train Data` channel is a single-token 
    231235channel which is a default one (third parameter). Note that the flags can 
    232 be added (or OR-d) together so :obj:`Default + Multi` is a valid flag. 
     236be added (or OR-d) together so :obj:`Default + Multiple` is a valid flag. 
    233237To test how this works, connect a file widget to a learning curve widget and 
    234238- nothing will really happen: 
  • docs/extend-widgets/rst/contextsettings.rst

    r11049 r11408  
    33########################## 
    44 
    5 You have already learned about :obj:`storing widget settings <settings>`. 
     5You have already learned about :doc:`storing widget settings <settings>`. 
    66But there's more: some settings are context 
    77dependent. Open Orange Canvas and observe the scatter plot - feed it 
     
    3131Here's the widget's :obj:`__init__` function. 
    3232 
    33 Part of `OWAttributeSampler.py <OWAttributeSampler.py>`_:: 
     33Part of :download:`OWAttributeSampler.py <OWAttributeSampler.py>`:: 
    3434 
    3535    def __init__(self, parent=None, signalManager=None): 
     
    6666called. 
    6767 
    68 Part of `OWAttributeSampler.py <OWAttributeSampler.py>`_:: 
     68Part of :download:`OWAttributeSampler.py`:: 
    6969 
    7070    def dataset(self, data): 
     
    168168                         selected="selectedAttributes")])} 
    169169 
    170 (More about these shortcuts in the `technical information about settings <settings-technical.htm>`). 
    171  
    172170Why the dictionary and the empty string as the key? A widget can 
    173171have multiple contexts, depending, usually, on multiple input 
     
    188186function :obj:`dataset` 
    189187 
    190 Part of `OWAttributeSampler.py <OWAttributeSampler.py>`:: 
     188Part of :download:`OWAttributeSampler.py`:: 
    191189 
    192190    def dataset(self, data): 
     
    266264store is picklable and short enough, so you won't blow up the .ini 
    267265files that store these settings. 
    268  
    269 For more information about context handling, see the `technical information about 
    270 settings <settings-technical.htm>`_. 
  • docs/extend-widgets/rst/graphing.rst

    r11049 r11408  
    9696axis plot using the same color. Developers are thus advised to use 
    9797:obj:`ColorPaletteHSV`, which is provided as a method within 
    98 :obj:`OWWidget` class. :obj:`ColorPaletteHSV` takes an 
     98:mod:`OWWidget` module. :obj:`ColorPaletteHSV` takes an 
    9999integer as an attribute, and returns a list of corresponding number of 
    100100colors. In our learning curve widget, we use it within a function that 
     
    121121 
    122122    self.cbox = OWGUI.widgetBox(self.controlArea, "Learners") 
    123     self.llb = OWGUI.listBox(self.cbox, self, "selectedLearners", selectionMode=QListWidget.MultiSelection, callback=self.learnerSelectionChanged) 
     123    self.llb = OWGUI.listBox(self.cbox, self, "selectedLearners", 
     124                             selectionMode=QListWidget.MultiSelection, 
     125                             callback=self.learnerSelectionChanged) 
    124126 
    125127    self.llb.setMinimumHeight(50) 
     
    142144 
    143145    def learnerSelectionChanged(self): 
    144         if self.blockSelectionChanges: return 
     146        if self.blockSelectionChanges: 
     147            return 
    145148        for (i,lt) in enumerate(self.learners): 
    146149            l = lt[1] 
     
    153156            l.isSelected = i in self.selectedLearners 
    154157 
    155 The complete code of this widget is available `here <OWLearningCurveC.py>`_.  
     158The complete code of this widget is available :download:`here <OWLearningCurveC.py>`.  
    156159This is almost like a typical 
    157160widget that is include in a standard Orange distribution, with a 
  • docs/extend-widgets/rst/index.rst

    r11049 r11408  
    1717   plots 
    1818   contextsettings 
    19  
    20 `Code and icons <code.zip>`_ from the tutorial. To learn where to put Python 
    21 files and icons, read :doc:`Getting Started <basics>`. 
    2219 
    2320 
  • docs/extend-widgets/rst/owgui.rst

    r11049 r11408  
    1111synchronized with a Python object's attribute (which, by the way, gets 
    1212automatically saved and retrieved when the widgets is closed and reopened), 
    13 attaches a callback function to the control, make it disable or enable other controls... 
     13attaches a callback function to the control, make it disable or enable other 
     14controls... 
    1415 
    1516***************** 
     
    2223presented here will only be described in cases where they have a different meaning. 
    2324 
    24 widget (required) 
    25 Widget on which control will be drawn - can be widget's :obj:`controlArea` or another box. 
    26  
    27 master (required) 
    28 Object which includes an attribute that are used to store control's 
    29 state, most often the object which called the function that 
    30 initialized the control. 
    31  
    32 value (required) 
    33 String with the name of the master's attribute that synchronizes with the 
    34 state of the control (and vice-versa - when this attribute is changed, the control changes as well). This attribute should usually be also included the master's :obj:`settingsList`, so that it is automatically saved and retrieved. 
    35  
    36 box (default: None) 
    37 Indicates if there should be a box that is drawn around the control. If :obj:`box` is :obj:`None`, no box is drawn; if it is a string, it is also used as box's name. If :obj:`box` is any other true value (such as :obj:`True` :), an unlabeled box is drawn. 
    38  
    39 callback (default: None) 
    40 A function to be called when the state of the control is changed. Can include a single function, or a list of functions that will be called in the order provided. If callback function changes the value of the controlled attribute (the one given as the :obj:`value` argument described above) it may trigger a cycle; a simple trick to avoid this is shown in the description of <a href="#listBox">listBox function</a>. 
    41  
    42 tooltip (default: None) 
    43 A string that is displayed in a tooltip that appears when mouse is over the control. 
    44  
    45 label (default: None) 
    46 A string that is displayed as control's label. 
    47  
    48 labelWidth (default: None) 
    49 Sets the label's width. This is useful for aligning the controls. 
    50  
    51 orientation (default: "vertical") 
    52 When label is used, determines the relative placement of the label and the control. Label can be above the control, "vertical", or in the same line with control, "horizontal". Instead of "vertical" and "horizontal" you can also use :obj:`True` and :obj:`False` or 1 and 0, respectively. (Remember this as "vertical" being the usual order of controls in the widgets, so vertical is "true".) 
    53  
    54 disabled (default: False) 
    55 Tells whether the control be disabled upon the initialization. 
    56  
    57 addSpace (default: False) 
    58 If true, a space of 8 pixels is added after the widget by calling :obj:`OWGUI.separator`. :obj:`addSpace` can also be an integer specifying the height of the added space. 
     25`widget` (required) 
     26   Widget on which control will be drawn - can be widget's :obj:`controlArea` 
     27   or another box. 
     28 
     29`master` (required) 
     30   Object which includes an attribute that are used to store control's 
     31   state, most often the object which called the function that 
     32   initialized the control. 
     33 
     34`value` (required) 
     35   String with the name of the master's attribute that synchronizes with the 
     36   state of the control (and vice-versa - when this attribute is changed, the control changes as well). This attribute should usually be also included the master's :obj:`settingsList`, so that it is automatically saved and retrieved. 
     37 
     38`box` (default: None) 
     39   Indicates if there should be a box that is drawn around the control. If `box` is ``None``, no box is drawn; if it is a string, it is also used as box's name. If `box` is any other true value (such as ``True`` :), an unlabeled box is drawn. 
     40 
     41`callback` (default: None) 
     42   A function to be called when the state of the control is changed. Can 
     43   include a single function, or a list of functions that will be called in 
     44   the order provided. If callback function changes the value of the controlled 
     45   attribute (the one given as the `value` argument described above) it may 
     46   trigger a cycle 
     47 
     48   .. 
     49      ; a simple trick to avoid this is shown in the description 
     50      of :func:`listBox` function. 
     51 
     52`tooltip` (default: None) 
     53   A string that is displayed in a tooltip that appears when mouse is over the control. 
     54 
     55`label` (default: None) 
     56   A string that is displayed as control's label. 
     57 
     58`labelWidth` (default: None) 
     59   Sets the label's width. This is useful for aligning the controls. 
     60 
     61`orientation` (default: "vertical") 
     62   When label is used, determines the relative placement of the label and the control. Label can be above the control, "vertical", or in the same line with control, "horizontal". Instead of "vertical" and "horizontal" you can also use ``True`` and ``False`` or 1 and 0, respectively. (Remember this as "vertical" being the usual order of controls in the widgets, so vertical is "true".) 
     63 
     64`disabled` (default: False) 
     65   Tells whether the control be disabled upon the initialization. 
     66 
     67`addSpace` (default: False) 
     68   If true, a space of 8 pixels is added after the widget by calling :func:`separator`. `addSpace` can also be an integer specifying the height of the added space. 
    5969 
    6070 
     
    7585and synchronization with the designated widget's attribute. 
    7686 
    77 checkBox(widget, master, value, label[, box, tooltip, callback, disabled, labelWidth, disables]) 
    78  
    79 disables (default: []) 
    80 If the check box needs to disable some other controls they can be given in list  :obj:`disables`, e.g. :obj:`disables=[someOtherCheckBox, someLineEdit]`. If the other control should be disabled when the checkbox is checked, do it like this: :obj:`disables=[someOtherCheckBox, (-1, someLineEdit)]` - now :obj:`someOtherCheckBox` will be enabled when this check box is checked, while :obj:`someLineEdit` will be enabled when the check box is unchecked. 
    81  
    82 labelWidth (default: None) 
    83 :obj:`labelWidth` can be used to align this widget with others. 
     87.. function:: checkBox(widget, master, value, label[, box, tooltip, callback, disabled, labelWidth, disables]) 
     88 
     89   `disables` (default: []) 
     90      If the check box needs to disable some other controls they can be given in list  `disables`, e.g. ``disables=[someOtherCheckBox, someLineEdit]``. If the other control should be disabled when the checkbox is checked, do it like this: ``disables=[someOtherCheckBox, (-1, someLineEdit)]`` - now `someOtherCheckBox` will be enabled when this check box is checked, while `someLineEdit` will be enabled when the check box is unchecked. 
     91 
     92   `labelWidth` (default: None) 
     93      `labelWidth` can be used to align this widget with others. 
    8494 
    8595 
     
    8999Edit box, a wrapper around QLineEdit. 
    90100 
    91 lineEdit(widget, master, value[, label, labelWidth, orientation, box, tooltip, callback, valueType, validator, controlWidth]) 
    92  
    93  
    94 valueType (default: str) 
    95 A type into which the value is cast. 
    96  
    97 validator (default: None) 
    98 A standard Qt validator that can be associated with the control. 
     101.. function:: lineEdit(widget, master, value[, label, labelWidth, orientation, box, tooltip, callback, valueType, validator, controlWidth]) 
     102 
     103   `valueType` (default: str) 
     104      A type into which the value is cast. 
     105 
     106   `validator` (default: None) 
     107      A standard Qt validator that can be associated with the control. 
    99108 
    100109 
     
    105114and its callback in a single line. 
    106115 
    107 button(widget, master, label[, callback, disabled, tooltip]) 
     116.. function:: button(widget, master, label[, callback, disabled, tooltip]) 
    108117 
    109118 
     
    111120************* 
    112121 
    113 OWGUI can create an individual radio button or a box of radio buttons or an individual radio button. 
     122OWGUI can create an individual radio button or a box of radio buttons or an 
     123individual radio button. 
    114124 
    115125An individual radio button is created by :obj:`radioButton`. 
    116126 
    117 radioButton(widget, master, value, label[, box, tooltip, callback, addSpace]) 
    118  
    119 The function provides the usual capabilities of OWGUI controls. It is though  
    120 your responsibility to put it in something like a :obj:`QVButtonGroup`. 
     127.. function:: radioButton(widget, master, value, label[, box, tooltip, callback, addSpace]) 
     128 
     129   The function provides the usual capabilities of OWGUI controls. It is though  
     130   your responsibility to put it in something like a :obj:`QVButtonGroup`. 
    121131 
    122132A box of radio buttons is created by function :obj:`radioButtonsInBox`. 
    123133 
    124  
    125 radioButtonsInBox(widget, master, value, btnLabels[, box, tooltips, callback) 
    126  
    127 value (required) 
    128 Synchronized with the index of the selected radio button. 
    129  
    130 btnLabels (required) 
    131 A list with labels for radio buttons. Labels can be strings or pixmaps. 
    132  
    133 tooltips (default: None) 
    134 A list of tooltips, one for each button. 
     134.. function:: radioButtonsInBox(widget, master, value, btnLabels[, box, tooltips, callback) 
     135 
     136   `value` (required) 
     137      Synchronized with the index of the selected radio button. 
     138 
     139   `btnLabels` (required) 
     140      A list with labels for radio buttons. Labels can be strings or pixmaps. 
     141 
     142   `tooltips` (default: None) 
     143      A list of tooltips, one for each button. 
    135144 
    136145 
     
    140149A wrapper around QComboBox. 
    141150 
    142 comboBox(widget, master, value[, box, label, labelWidth, orientation, items, tooltip, callback, sendSelectedValue, valueType, control2attributeDict, emptyString]) 
    143  
    144 <dl class="attributes"> 
    145 items (default: []) 
    146 A list of combo box's items. Unlike most OWGUI, :obj:`items` have one Orange-specific quirk: its element can be either a string, in which case it is used as a label, or a tuple, where the first element is a label name and the last is the attribute type which is used to create an icon. Most attribute lists in Orange Widgets are constructed this way. 
    147  
    148 sendSelectedValue (default: 0) 
    149 If false, attribute :obj:`value` will be assigned the index of the selected item. Otherwise, it is assigned the currently selected item's label. 
    150  
    151 control2attributeDict (default: {}) 
    152 A dictionary for translating the item's label into :obj:`value`. It is used only is :obj:`sendSelectedValue` is true, and even then a label is translated only if an item with such a key is found in the dictionary; otherwise, label is written to :obj:`value` as it is.  
    153  
    154 emptyString (default: "") 
    155 Tells which combo box's item corresponds to an empty :obj:`value`. This is typically used when combo box's labels are attribute names and an item "(none)", which allows user to select no attribute. If we give :obj:`emptyString="(none)"`, :obj:`value` will be an empty string when the user selects "(none)". This is equivalent to specifying :obj:`control2attributeDict = {"(none)": ""}` (and is actually implemented like that), but far more convenient. 
    156  
    157 valueType (default: str or unicode) 
    158 A function through which the currently selected item's label is converted prior to looking into :obj:`control2attributeDict`. Needed to convert Qt's QString. 
     151.. function:: comboBox(widget, master, value[, box, label, labelWidth, orientation, items, tooltip, callback, sendSelectedValue, valueType, control2attributeDict, emptyString]) 
     152 
     153   `items` (default: []) 
     154      A list of combo box's items. Unlike most OWGUI, `items` have one Orange-specific quirk: its element can be either a string, in which case it is used as a label, or a tuple, where the first element is a label name and the last is the attribute type which is used to create an icon. Most attribute lists in Orange Widgets are constructed this way. 
     155 
     156   `sendSelectedValue` (default: 0) 
     157      If false, attribute `value` will be assigned the index of the selected item. Otherwise, it is assigned the currently selected item's label. 
     158 
     159   `control2attributeDict` (default: {}) 
     160      A dictionary for translating the item's label into `value`. It is used only is `sendSelectedValue` is true, and even then a label is translated only if an item with such a key is found in the dictionary; otherwise, label is written to `value` as it is.  
     161 
     162   `emptyString` (default: "") 
     163      Tells which combo box's item corresponds to an empty `value`. This is typically used when combo box's labels are attribute names and an item "(none)", which allows user to select no attribute. If we give ``emptyString="(none)"``, `value` will be an empty string when the user selects "(none)". This is equivalent to specifying ``control2attributeDict={"(none)": ""}`` (and is actually implemented like that), but far more convenient. 
     164 
     165   `valueType` (default: str or unicode) 
     166      A function through which the currently selected item's label is converted prior to looking into `control2attributeDict`. Needed to convert Qt's QString. 
    159167 
    160168 
     
    166174 
    167175 
    168 listBox(widget, master, value, labels[, box, tooltip, callback, selectionMode]) 
    169  
    170 <dl class="attributes"> 
    171 value (required) 
    172 The name of master's attribute containing indices of all selected values. 
    173  
    174 labels (required) 
    175 The name of master's attribute containing the list box's labels. Similar to :obj:`items` in combo box, list :obj:`labels` have one Orange-specific quirk: its element can be either a string, in which case it is used as a label, or a tuple, where the first element is a label name and the second can be either an icon on an integer, representing the attribute type which is used to create an icon. Most attribute lists in Orange Widgets are constructed this way. 
    176  
    177 selectionMode (default: QListWidget.SingleSelection) 
    178 Tells whether the user can select a single item (:obj:`QListWidget.SingleSelection`), multiple items (:obj:`QListWidget.MultiSelection`, :obj:`QListWidget.ExtendedSelection`) or nothing (:obj:`QListWidget.NoSelection`). 
    179  
    180  
    181 :obj:`value` is automatically cast to :obj:`OWGUI.ControlledList` (this is needed because the list should report any changes to the control, the list box; :obj:`OWGUI.ControlledList` is like an ordinary Python :obj:`list` except that it triggers synchronization with the list box at every change). 
    182  
    183 :obj:`labels` is only partially synchronized with the list box: if a new list is assigning to :obj:`labels` attribute, the list will change. If elements of the existing list are changed or added, the list box won't budge. You should never change the list, but always assign a new list (or reassign the same after it's changed). If the labels are stored in :obj:`self.listLabels` and you write :obj:`self.listLabels[1]="a new label"`, the list box won't change. To trigger the synchronization, you should continue by :obj:`self.listLabels = self.listLabels`. This may seem awkward, but by our experience a list of selected items is seldom changed changed "per-item", so we were too lazy to write the annoyingly complex backward callbacks. 
    184  
    185 <span> 
    186 <span onclick="toggleVisibility(this);" class="hideshow">Show Example</span> 
    187 <span class="hideshow"><a href="gui_listbox.py">Download example (gui_listbox.py)</a></span> 
    188 <span class="hideshow"><a href="gui_listbox_attr.py">Download example (gui_listbox_attr.py)</a></span> 
     176.. function:: listBox(widget, master, value, labels[, box, tooltip, callback, selectionMode]) 
     177 
     178   `value` (required) 
     179      The name of master's attribute containing indices of all selected values. 
     180 
     181   `labels` (required) 
     182      The name of master's attribute containing the list box's labels. Similar to `items` in combo box, list `labels` have one Orange-specific quirk: its element can be either a string, in which case it is used as a label, or a tuple, where the first element is a label name and the second can be either an icon on an integer, representing the attribute type which is used to create an icon. Most attribute lists in Orange Widgets are constructed this way. 
     183 
     184   `selectionMode` (default: QListWidget.SingleSelection) 
     185      Tells whether the user can select a single item (:obj:`QListWidget.SingleSelection`), multiple items (:obj:`QListWidget.MultiSelection`, :obj:`QListWidget.ExtendedSelection`) or nothing (:obj:`QListWidget.NoSelection`). 
     186 
     187   `value` is automatically cast to :obj:`OWGUI.ControlledList` (this is needed because the list should report any changes to the control, the list box; :obj:`OWGUI.ControlledList` is like an ordinary Python :obj:`list` except that it triggers synchronization with the list box at every change). 
     188 
     189   `labels` is only partially synchronized with the list box: if a new list is assigning to `labels` attribute, the list will change. If elements of the existing list are changed or added, the list box won't budge. You should never change the list, but always assign a new list (or reassign the same after it's changed). If the labels are stored in ``self.listLabels`` and you write ``self.listLabels[1]="a new label"``, the list box won't change. To trigger the synchronization, you should continue by ``self.listLabels = self.listLabels``. This may seem awkward, but by our experience a list of selected items is seldom changed changed "per-item", so we were too lazy to write the annoyingly complex backward callbacks. 
     190 
    189191 
    190192 
     
    194196Spin control, a wrapper around QSpinBox. 
    195197 
    196 spin(widget, master, value, min, max[, step, box, label, labelWidth, orientation, tooltip, callback, controlWidth]) 
    197  
    198  
    199 min, max, step=1 
    200 Minimal and maximal value, and step. 
     198.. function:: spin(widget, master, value, min, max[, step, box, label, labelWidth, orientation, tooltip, callback, controlWidth]) 
     199 
     200   `min`, `max`, `step=1` 
     201      Minimal and maximal value, and step. 
    201202 
    202203 
     
    206207A wrapper around QSlider that allows user setting a numerical value between the given bounds. 
    207208 
    208 hSlider(widget, master, value[, box, minValue, maxValue, step, callback, labelFormat, ticks, divideFactor]) 
    209  
    210  
    211 minValue (default: 0), maxValue (default: 10), step (default: 1) 
    212 Minimal and maximal value for the spin control, and its step. 
    213  
    214 ticks (default: 0) 
    215 If non-zero, it gives the interval between two ticks. The ticks will appear below the groove. 
    216  
    217 labelFormat (default: " %d") 
    218 Defines the look of the label on the righthand side of the slider. It has to contain one format character (like %d in the default), but can contain other text as well. 
    219  
    220 divideFactor (default: 1.0) 
    221 The value printed in the label is divided by :obj:`divideFactor`. 
    222  
    223  
    224 For an example of usage, see the second example in the description of <a href="#labels-example">labels</a>. 
     209.. function:: hSlider(widget, master, value[, box, minValue, maxValue, step, callback, labelFormat, ticks, divideFactor]) 
     210 
     211 
     212   `minValue` (default: 0), `maxValue` (default: 10), `step` (default: 1) 
     213      Minimal and maximal value for the spin control, and its step. 
     214 
     215   `ticks` (default: 0) 
     216      If non-zero, it gives the interval between two ticks. The ticks will appear below the groove. 
     217 
     218   `labelFormat` (default: " %d") 
     219      Defines the look of the label on the righthand side of the slider. It has to contain one format character (like %d in the default), but can contain other text as well. 
     220 
     221   `divideFactor` (default: 1.0) 
     222      The value printed in the label is divided by `divideFactor`. 
    225223 
    226224 
     
    231229OWGUI.checkBox and OWGUI.spin. 
    232230 
    233 checkWithSpin(widget, master, label, min, max, checked, value[, posttext, step, tooltip, checkCallback, spinCallback, labelWidth]) 
    234  
    235 min, max, step (required) 
    236 Minimal and maximal value for the spin control, and its step. 
    237  
    238 checked (required) 
    239 Master's attribute that is synchronized with the state of the check box. 
    240  
    241 value (required) 
    242 The attribute that is synchronized with the spin. 
    243  
    244 posttext (default: None) 
    245 Text which appears on the right-hand side of the control. 
    246  
    247 checkCallback (default: None), spinCallback (default: None) 
    248 Function that are called when the state of the check box or spin changes. 
     231.. function:: checkWithSpin(widget, master, label, min, max, checked, value[, posttext, step, tooltip, checkCallback, spinCallback, labelWidth]) 
     232 
     233   `min`, `max`, `step` (required) 
     234      Minimal and maximal value for the spin control, and its step. 
     235 
     236   `checked` (required) 
     237      Master's attribute that is synchronized with the state of the check box. 
     238 
     239   `value` (required) 
     240      The attribute that is synchronized with the spin. 
     241 
     242   `posttext` (default: None) 
     243      Text which appears on the right-hand side of the control. 
     244 
     245   `checkCallback` (default: None), `spinCallback` (default: None) 
     246      Function that are called when the state of the check box or spin changes. 
    249247 
    250248 
     
    252250****** 
    253251 
    254 There are two functions for constructing labels. The first is a simple wrapper around QLabel which differs only in allowing to specify a fixed width without needing an extra line. Note that unlike most other OWGUI widgets, this one does not have the argument :obj:`master`. 
    255  
    256 widgetLabel(widget, label[, labelWidth]) 
    257  
    258 The second is a label which can synchronize with values of master widget's attributes. 
    259  
    260 label(widget, master, label[, labelWidth]) 
    261  
    262 label 
    263 :obj:`label` is a format string following Python's syntax (see the corresponding Python documentation): the label's content is rendered as :obj:`label % master.__dict__`. 
     252There are two functions for constructing labels. The first is a simple wrapper around QLabel which differs only in allowing to specify a fixed width without needing an extra line. Note that unlike most other OWGUI widgets, this one does not have the argument `master`. 
     253 
     254.. function:: widgetLabel(widget, label[, labelWidth]) 
     255 
     256   The second is a label which can synchronize with values of master widget's attributes. 
     257 
     258.. function:: label(widget, master, label[, labelWidth]) 
     259 
     260   `label` 
     261      `label` is a format string following Python's syntax (see the 
     262      corresponding Python documentation): the label's content is rendered as 
     263      ``label % master.__dict__``. 
    264264 
    265265 
     
    272272 
    273273 
    274 widgetBox(widget, box=None, orientation='vertical', addSpace=False) 
    275 Creates a box in which other widgets can be put. If :obj:`box` is given and not false, the box will be framed. If :obj:`box` is a string, it will be used for the box name (don't capitalize each word; spaces in front or after the string will be trimmed and replaced with a single space). Argument :obj:`orientation` can be :obj:`"vertical"` or :obj:`"horizontal"` (or :obj:`True` and :obj:`False`, or :obj:`1` and :obj:`0`, respectively). 
     274.. function:: widgetBox(widget, box=None, orientation='vertical', addSpace=False) 
     275 
     276   Creates a box in which other widgets can be put. If `box` is given 
     277   and not false, the box will be framed. If `box` is a string, it will 
     278   be used for the box name (don't capitalize each word; spaces in front or 
     279   after the string will be trimmed and replaced with a single space). 
     280   Argument `orientation` can be ``"vertical"`` or ``"horizontal"`` 
     281   (or ``True`` and ``False``, or ``1`` and ``0``, respectively). 
    276282 
    277283 
     
    280286 
    281287 
    282 indentedBox(widget, sep=20) 
    283 Creates an indented box. Widgets which are subsequently put into that box will be arranged vertically and aligned with an indentation of :obj:`sep`. 
     288.. function:: indentedBox(widget, sep=20) 
     289 
     290      Creates an indented box. Widgets which are subsequently put into 
     291      that box will be arranged vertically and aligned with an indentation 
     292      of `sep`. 
    284293 
    285294 
     
    288297 
    289298Most widgets look better if we insert some vertical space between the controls 
    290 or groups of controls. A few functions have an optional argument :obj:`addSpace` 
     299or groups of controls. A few functions have an optional argument `addSpace` 
    291300by which we can request such space to be added. For other occasions, we can use 
    292301the following two functions. 
    293302 
    294 separator(widget, width=0, height=8) 
    295  
    296 Function :obj:`separator` inserts a fixed amount of space into :obj:`widget`. 
    297 Although the caller can specify the amount, leaving the default will help the 
    298 widgets having uniform look. 
    299  
    300 rubber(widget[, orientation="vertical"]) 
    301  
    302 Similar to separator, except that the size is (1, 1) and that it expands in the 
    303 specified direction if the widget is expanded. Most widgets should have rubber 
    304 somewhere in their :obj:`controlArea`. 
     303.. function:: separator(widget, width=0, height=8) 
     304 
     305   Function `separator` inserts a fixed amount of space into `widget`. 
     306   Although the caller can specify the amount, leaving the default will help the 
     307   widgets having uniform look. 
     308 
     309.. function:: rubber(widget[, orientation="vertical"]) 
     310 
     311   Similar to separator, except that the size is (1, 1) and that it expands in the 
     312   specified direction if the widget is expanded. Most widgets should have rubber 
     313   somewhere in their :obj:`controlArea`. 
    305314 
    306315Attribute Icons 
    307316*************** 
    308317 
    309 getAttributeIcons() 
    310  
    311 Returns a dictionary with attribute types (:obj:`orange.VarTypes.Discrete`, 
    312 :obj:`orange.VarTypes.Continuous`, :obj:`orange.VarTypes.String`, -1) as keys 
    313 and colored pixmaps as values. The dictionary can be used in list and combo 
    314 boxes showing attributes for easier distinguishing between attributes of different types. 
     318.. function:: getAttributeIcons() 
     319 
     320   Returns a dictionary with attribute types (:obj:`orange.VarTypes.Discrete`, 
     321   :obj:`orange.VarTypes.Continuous`, :obj:`orange.VarTypes.String`, -1) as keys 
     322   and colored pixmaps as values. The dictionary can be used in list and combo 
     323   boxes showing attributes for easier distinguishing between attributes of different types. 
    315324 
    316325Send automatically / Send 
     
    324333Programming this into every widget is annoying and error-prone; at the time when the function described here was written, not many widgets actually did this properly. 
    325334 
    326 setStopper(master, sendButton, stopCheckbox, changedFlag, callback) 
    327  
    328 sendButton 
    329 The button that will be disabled when the check box is checked. 
    330  
    331 stopCheckbox 
    332 Check box that decides whether the changes are sent/commited/applied automatically. 
    333  
    334 changedFlag 
    335 The name of the :obj:`master`'s attribute which tells whether there is a change which has not been sent/applied yet. 
    336  
    337 callback 
    338 The function that sends the data or applies the changes. This is typically the function which is also used as the :obj:`sendButton`'s callback. 
    339  
    340  
    341 :obj:`setStopper` is a trivial three lines long function which connects a few signals. Its true importance is in enforcing the correct procedure for implementing such button-check box combinations. Make sure to carefully observe and follow the example provided below. 
    342  
     335.. function:: setStopper(master, sendButton, stopCheckbox, changedFlag, callback) 
     336 
     337   `sendButton` 
     338      The button that will be disabled when the check box is checked. 
     339 
     340   `stopCheckbox` 
     341      Check box that decides whether the changes are sent/commited/applied automatically. 
     342 
     343   `changedFlag` 
     344      The name of the `master`'s attribute which tells whether there is a change which has not been sent/applied yet. 
     345 
     346   `callback` 
     347      The function that sends the data or applies the changes. This is typically the function which is also used as the `sendButton`'s callback. 
     348 
     349 
     350:obj:`setStopper` is a trivial three lines long function which connects a few signals. Its true importance is in enforcing the correct procedure for implementing such button-check box combinations. 
     351 
     352.. 
     353   Make sure to carefully observe and follow the example provided below. 
     354 
     355   Missing, where did it go? 
     356 
  • docs/extend-widgets/rst/plots.rst

    r11049 r11408  
    8282the following subsection. 
    8383 
    84 <h2>Colors in Orange Widgets</h2> 
     84************************ 
     85Colors in Orange Widgets 
     86************************ 
    8587 
    8688Uniform assignment of colors across different widget is an 
     
    147149            l.isSelected = i in self.selectedLearners 
    148150 
    149 The complete code of this widget is available `here <OWLearningCurve_plot.py>`_. 
     151The complete code of this widget is available :download:`here <OWLearningCurve_plot.py>`. 
    150152This is almost like a typical 
    151153widget that is include in a standard Orange distribution, with a 
  • docs/extend-widgets/rst/plotsbasic.rst

    r11049 r11408  
    123123******************** 
    124124 
    125 You can find the full code for the example `here <owplot_example.py>`_. 
     125You can find the full code for the example :download:`here <owplot_example.py>`. 
    126126This particular example has a timer, so that :obj:`set_data` is called every 
    127127five seconds, and attributes are chosen at random each time, athough always  
  • docs/extend-widgets/rst/progressbar.rst

    r11049 r11408  
    2020widgets, has for this purpose a set of functions, which include: 
    2121 
    22 <xmp class="code"> 
    23 progressBarInit() 
    24 progressBarSet(value) 
    25 progressBarFinished() 
    26 </xmp> 
     22.. method:: progressBarInit() 
     23 
     24.. method:: progressBarSet(value) 
     25 
     26.. method:: progressBarFinished() 
     27 
    2728 
    2829where value is any number between 0 and 100. Sometimes, like it is 
  • docs/extend-widgets/rst/settings.rst

    r11049 r11408  
    154154            self.commit() 
    155155 
    156 You can now also inspect the `complete code <OWDataSamplerB.py>`_ of this 
    157 widget. To distinguish it with a widget we have developed in the 
    158 previous section, we have designed a special `icon <DataSamplerB.png>`_ for it. If you wish to test is 
     156You can now also inspect the :download:`complete code <OWDataSamplerB.py>` 
     157of this widget. To distinguish it with a widget we have developed in the 
     158previous section, we have designed a special 
     159:download:`icon <DataSamplerB.png>` for it. If you wish to test is 
    159160widget in the Orange Canvas, put its code in the Test directory we 
    160161have created for the previous widget, update the Canvas registry, and 
     
    175176state so that when the user changes a check box, the attribute changes 
    176177and vice-versa. Although you can create such a link manually, you 
    177 should always use the module <a href="owgui.htm">OWGUI</a> instead; 
     178should always use the module :doc:`OWGUI <owgui.rst>` instead; 
    178179for instance, for a check box, use :obj:`OWGUI.checkBox` and not 
    179180simply the Qt's :obj:`QCheckBox`. 
     
    182183the data, while other are context-dependent. For the first to be saved 
    183184properly, you only need to list them in the :obj:`settingsList` 
    184 in the widget definition, as already described <a 
    185 href="settings.htm">elsewhere</a>. 
     185in the widget definition, as already described :doc:`elsewhere <settings.rst>` 
    186186 
    187187************************** 
     
    286286comes the third data set, which only has attributes A, D and E. The 
    287287context now can't be reused since the attribute used for the 
    288 <em>required</em> :obj:`attrY` (the y axis) is missing. 
     288*required* :obj:`attrY` (the y axis) is missing. 
    289289 
    290290OK, now it is time to be a bit formal. As said, 
     
    347347 
    348348But the tuples are actually a shortcut for instances of 
    349 :obj:`ContextField`. When you say :obj:`"attrX"` this is 
    350 actually :obj:`ContextField("attrX", 
    351 DomainContextHandler.Required)` (you should appreciate the 
    352 shortcurt, right?). But see this monster from widget "Select 
     349:obj:`ContextField`. When you say :obj:`"attrX"` this is actually 
     350:obj:`ContextField("attrX", DomainContextHandler.Required)` (you should 
     351appreciate the shortcurt, right?). But see this monster from widget "Select 
    353352Attributes" (file OWDataDomain.py):: 
    354353 
     
    366365 
    367366 
    368 :obj:`ContextField`'s constructor gets the name and flags and a list of arguments that are written directly into the object instance. To follow the example, recall what Select Attributes looks like: it allows you to select a subset of attributes, the class attribute and the meta attributes that you want to use; the attributes in the corresponding three list boxes are stored in the widget's variables :obj:`chosenAttributes`, :obj:`classAttribute` and :obj:`metaAttributes` respectively. When the user selects some attributes in any of these boxes, the selection is stored in :obj:`selectedChosen`, :obj:`selectedClass` and <cose>selectedMeta</cose>. The remaining attributes - those that are not in any of these three list boxes - are in the leftover listbox on the left-hand side of the widget, and the content of the box is stored in the widget's variable :obj:`inputAttributes`. 
    369  
    370 The above definition tells that the context needs to store the contents of the three list boxes by specifying the corresponding variables; the list of attributes is given as the name of the field and the list of selected attributes is in the optional named attribute :obj:`selected`. By :obj:`reservoir` we told the context handler that the attributes are taken from :obj:`inputAttributes`. So, when a context is retrieved, all the attributes that are not in any of the three list boxes are put into :obj:`inputAttributes`. 
    371  
    372 Why the mess? Couldn't we just store :obj:`inputAttributes` as the fourth list box? Imagine that the user first loads the data with attributes A, B, C, D, E and F, puts A, B, C in chosen and D in class. E and F are left in :obj:`inputAttributes`. Now she loads another data which has attributes A, B, C, D, E, and G. The contexts should match (the new data has all the attributes we need), but :obj:`inputAttributes` should now contain E and G, not E and F, since F doesn't exist any more, while G needs to be made available. 
    373  
    374 You can use :obj:`ContextField` (instead of tuples and strings) for declaring any fields, but you will usually need them only for lists or, maybe, some complicated future controls. 
     367:obj:`ContextField`'s constructor gets the name and flags and a list of 
     368arguments that are written directly into the object instance. To follow the 
     369example, recall what Select Attributes looks like: it allows you to select a 
     370subset of attributes, the class attribute and the meta attributes that you 
     371want to use; the attributes in the corresponding three list boxes are stored 
     372in the widget's variables :obj:`chosenAttributes`, :obj:`classAttribute` 
     373and :obj:`metaAttributes` respectively. When the user selects some attributes 
     374in any of these boxes, the selection is stored in :obj:`selectedChosen`, 
     375:obj:`selectedClass` and :obj:`selectedMeta`. The remaining attributes 
     376- those that are not in any of these three list boxes - are in the leftover 
     377listbox on the left-hand side of the widget, and the content of the box is 
     378stored in the widget's variable :obj:`inputAttributes`. 
     379 
     380The above definition tells that the context needs to store the contents of 
     381the three list boxes by specifying the corresponding variables; the list of 
     382attributes is given as the name of the field and the list of selected 
     383attributes is in the optional named attribute :obj:`selected`. By 
     384:obj:`reservoir` we told the context handler that the attributes are taken 
     385from :obj:`inputAttributes`. So, when a context is retrieved, all the 
     386attributes that are not in any of the three list boxes are put into 
     387:obj:`inputAttributes`. 
     388 
     389Why the mess? Couldn't we just store :obj:`inputAttributes` as the fourth 
     390list box? Imagine that the user first loads the data with attributes A, B, 
     391C, D, E and F, puts A, B, C in chosen and D in class. E and F are left in 
     392:obj:`inputAttributes`. Now she loads another data which has attributes A, 
     393B, C, D, E, and G. The contexts should match (the new data has all the 
     394attributes we need), but :obj:`inputAttributes` should now contain E and 
     395G, not E and F, since F doesn't exist any more, while G needs to be made 
     396available. 
     397 
     398You can use :obj:`ContextField` (instead of tuples and strings) for 
     399declaring any fields, but you will usually need them only for lists or, 
     400maybe, some complicated future controls. 
    375401 
    376402 
Note: See TracChangeset for help on using the changeset viewer.