1414from PyQt4 import QtGui , QtCore
1515from PyQt4 .QtCore import Qt , pyqtSignal as Signal
1616from PyQt4 .QtGui import QCursor , QApplication , QTableView , QHeaderView , \
17- QStyledItemDelegate
17+ QStyledItemDelegate , QSizePolicy , QColor
1818
1919# Some Orange widgets might expect this here
2020from Orange .widgets .webview import WebView as WebviewWidget # pylint: disable=unused-import
@@ -234,7 +234,10 @@ def miscellanea(control, box, parent,
234234 :type sizePolicy: PyQt4.QtQui.QSizePolicy
235235 """
236236 for prop , val in kwargs .items ():
237- getattr (control , "set" + prop [0 ].upper () + prop [1 :])(val )
237+ if prop == "sizePolicy" :
238+ control .setSizePolicy (QSizePolicy (* val ))
239+ else :
240+ getattr (control , "set" + prop [0 ].upper () + prop [1 :])(val )
238241 if disabled :
239242 # if disabled==False, do nothing; it can be already disabled
240243 control .setDisabled (disabled )
@@ -249,6 +252,8 @@ def miscellanea(control, box, parent,
249252 box .layout ().indexOf (control ) == - 1 :
250253 box .layout ().addWidget (control )
251254 if sizePolicy is not None :
255+ if isinstance (sizePolicy , tuple ):
256+ sizePolicy = QSizePolicy (* sizePolicy )
252257 (box or control ).setSizePolicy (sizePolicy )
253258 if addToLayout and parent and parent .layout () is not None :
254259 parent .layout ().addWidget (box or control , stretch )
@@ -1069,8 +1074,8 @@ def button(widget, master, label, callback=None, width=None, height=None,
10691074 activated on pressing Return.
10701075 :type autoDefault: bool
10711076 :param buttonType: the button type (default: `QPushButton`)
1072- :type buttonType: PyQt4.QtGui.QAbstractButton
1073- :rtype: PyQt4.QtGui.QAbstractButton
1077+ :type buttonType: PyQt4.QtGui.QPushButton
1078+ :rtype: PyQt4.QtGui.QPushButton
10741079 """
10751080 button = buttonType (widget )
10761081 if label :
@@ -1350,6 +1355,8 @@ def appendRadioButton(group, label, insertInto=None,
13501355 if tooltip is not None :
13511356 w .setToolTip (tooltip )
13521357 if sizePolicy :
1358+ if isinstance (sizePolicy , tuple ):
1359+ sizePolicy = QSizePolicy (* sizePolicy )
13531360 w .setSizePolicy (sizePolicy )
13541361 if addToLayout :
13551362 dest = insertInto or group
@@ -2218,17 +2225,16 @@ def do_commit():
22182225 orientation = Qt .Vertical if checkbox_label else Qt .Horizontal
22192226 b = widgetBox (widget , box = box , orientation = orientation ,
22202227 addToLayout = False )
2221- b .setSizePolicy (QtGui . QSizePolicy .Preferred , QtGui . QSizePolicy .Maximum )
2228+ b .setSizePolicy (QSizePolicy .Preferred , QSizePolicy .Maximum )
22222229
22232230 b .checkbox = cb = checkBox (b , master , value , checkbox_label ,
22242231 callback = checkbox_toggled , tooltip = auto_label )
22252232 if _is_horizontal (orientation ):
22262233 b .layout ().addSpacing (10 )
2227- cb .setSizePolicy (QtGui . QSizePolicy .Preferred , QtGui . QSizePolicy .Preferred )
2234+ cb .setSizePolicy (QSizePolicy .Preferred , QSizePolicy .Preferred )
22282235 b .button = btn = button (b , master , label , callback = lambda : do_commit ())
22292236 if not checkbox_label :
2230- btn .setSizePolicy (QtGui .QSizePolicy .Expanding ,
2231- QtGui .QSizePolicy .Preferred )
2237+ btn .setSizePolicy (QSizePolicy .Expanding , QSizePolicy .Preferred )
22322238 checkbox_toggled ()
22332239 setattr (master , commit_name , unconditional_commit )
22342240 misc ['addToLayout' ] = misc .get ('addToLayout' , True ) and \
@@ -3090,11 +3096,19 @@ def get_bar_brush(self, _, index):
30903096 return QtGui .QBrush (bar_brush )
30913097
30923098
3099+ class HorizontalGridDelegate (QStyledItemDelegate ):
3100+ def paint (self , painter , option , index ):
3101+ painter .save ()
3102+ painter .setPen (QColor (212 , 212 , 212 ))
3103+ painter .drawLine (option .rect .bottomLeft (), option .rect .bottomRight ())
3104+ painter .restore ()
3105+ QStyledItemDelegate .paint (self , painter , option , index )
3106+
3107+
30933108class VerticalLabel (QtGui .QLabel ):
30943109 def __init__ (self , text , parent = None ):
30953110 super ().__init__ (text , parent )
3096- self .setSizePolicy (QtGui .QSizePolicy .Preferred ,
3097- QtGui .QSizePolicy .MinimumExpanding )
3111+ self .setSizePolicy (QSizePolicy .Preferred , QSizePolicy .MinimumExpanding )
30983112 self .setMaximumWidth (self .sizeHint ().width () + 2 )
30993113 self .setMargin (4 )
31003114
0 commit comments