Changeset 4993:e35c5b28b1c7 in orange


Ignore:
Timestamp:
07/18/08 23:10:14 (6 years ago)
Author:
janezd <janez.demsar@…>
Branch:
default
Convert:
f92f4b983e5e56bac328b89e4a7d4331c7e7b6de
Message:
  • if a button can be toggled, it can now also be linked to a master's attribute
File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/OWGUI.py

    r4987 r4993  
    351351def button(widget, master, label, callback = None, disabled=0, tooltip=None, debuggingEnabled = 1, width = None, height = None, toggleButton = False, value = "", addToLayout = 1): 
    352352    btn = QPushButton(label, widget) 
    353     if addToLayout and widget.layout(): widget.layout().addWidget(btn) 
     353    if addToLayout and widget.layout(): 
     354        widget.layout().addWidget(btn) 
    354355 
    355356    if width: 
     
    360361    if tooltip: 
    361362        btn.setToolTip(tooltip) 
    362     if toggleButton: 
     363         
     364    if toggleButton or value: 
    363365        btn.setCheckable(True) 
    364  
    365     if callback: 
     366         
     367    if value: 
     368        btn.setChecked(getdeepattr(master, value)) 
     369        cfront, cback, cfunc = connectControl(btn, master, value, None, "toggled(bool)", CallFrontButton(btn), 
     370                                  cfunc = callback and FunctionCallback(master, callback, widget=btn)) 
     371    elif callback: 
    366372        master.connect(btn, SIGNAL("clicked()"), callback) 
     373         
    367374    if debuggingEnabled: 
    368375        master._guiElements = getattr(master, "_guiElements", []) + [("button", btn, callback)] 
     
    594601        if labelWidth: 
    595602            lbl.setFixedSize(labelWidth, lbl.sizeHint().height()) 
    596         print orientation 
    597603        if orientation and orientation!="horizontal": 
    598604            separator(hb, height=2) 
    599605            hb = widgetBox(hb, 0) 
    600             print "hb" 
    601606    else: 
    602607        hb = widgetBox(widget, box, 0) 
     
    13771382            self.control.setCheckState(values[value]) 
    13781383 
     1384class CallFrontButton(ControlledCallFront): 
     1385    def action(self, value): 
     1386        if value != None: 
     1387            self.control.setChecked(bool(value)) 
    13791388 
    13801389class CallFrontComboBox(ControlledCallFront): 
Note: See TracChangeset for help on using the changeset viewer.