1010# ---- Third party imports
1111from qtpy .QtCore import QSize , Qt
1212from qtpy .QtGui import QIcon
13- from qtpy .QtWidgets import QGridLayout , QLabel , QWidget , QTextBrowser
13+ from qtpy .QtWidgets import QGridLayout , QLabel , QWidget
1414import qtawesome as qta
1515
16-
1716# ---- Local imports
1817from qtapputils .qthelpers import create_waitspinner
1918from qtapputils .colors import RED , GREEN , BLUE
@@ -33,7 +32,7 @@ class ProcessStatusBar(QWidget):
3332 NEED_UPDATE = 4
3433
3534 def __init__ (self , parent = None , iconsize = 24 , ndots = 11 ,
36- orientation = Qt .Horizontal , spacing = None ,
35+ orientation = Qt .Horizontal , spacing : int = 5 ,
3736 contents_margin : list = None ,
3837 hsize_policy = 'minimum' , vsize_policy = 'minimum' ,
3938 text_valign = 'center' , icon_valign = 'center' ):
@@ -52,8 +51,7 @@ def __init__(self, parent=None, iconsize=24, ndots=11,
5251 Orientation of the progress status bar. The default is
5352 Qt.Horizontal.
5453 spacing : in, optional
55- Spacing between the icon and the label. Default to 0 if
56- orientation is horizontal and to 5 if vertical.
54+ Spacing between the icon and the label. The default is 5.
5755 contents_margin : list[int], optional
5856 A list of four integers corresponding to the left, top, right, and
5957 bottom contents margin. The default is 0 on all sides.
@@ -81,23 +79,13 @@ def __init__(self, parent=None, iconsize=24, ndots=11,
8179 'bottom' : Qt .AlignBottom
8280 }
8381
84- class LabelBrowser (QTextBrowser ):
85- def text (self ):
86- return self .toPlainText ()
87-
88- def minimumSizeHint (self ):
89- return QLabel ().minimumSizeHint ()
90-
91- def sizeHint (self ):
92- return QLabel ().sizeHint ()
93-
9482 text_valign = VALIGN_DICT [text_valign ]
95- self ._label = LabelBrowser ()
83+ self ._label = QLabel ()
9684 if orientation == Qt .Horizontal :
9785 self ._label .setAlignment (Qt .AlignLeft | text_valign )
9886 else :
99- self ._label .setAlignment (Qt .AlignCenter | text_valign )
100- self ._label .setLineWrapMode ( LabelBrowser . WidgetWidth )
87+ self ._label .setAlignment (Qt .AlignHCenter | text_valign )
88+ self ._label .setWordWrap ( True )
10189 self ._label .setTextInteractionFlags (
10290 Qt .TextSelectableByMouse | Qt .TextBrowserInteraction )
10391 self ._label .setOpenExternalLinks (True )
@@ -134,19 +122,19 @@ def sizeHint(self):
134122 else :
135123 alignment = Qt .AlignCenter | icon_valign
136124 layout .addWidget (self ._spinner , 1 , 1 , alignment )
137- for widget in self ._icons .values ():
138- layout .addWidget (widget , 1 , 1 , alignment )
125+ for icon in self ._icons .values ():
126+ layout .addWidget (icon , 1 , 1 , alignment )
127+
139128 if orientation == Qt .Horizontal :
140- layout .setColumnMinimumWidth (2 , 5 )
141- layout .addWidget (self ._label , 1 , 3 )
129+ layout .addWidget (self ._label , 1 , 2 )
142130 if vsize_policy == 'minimum' :
143131 layout .setRowStretch (0 , 100 )
144132 layout .setRowStretch (3 , 100 )
145133 elif vsize_policy == 'expanding' :
146134 layout .setRowStretch (1 , 100 )
147135 # We ignore 'hsize_policy' when orientation is horizontal.
148- layout .setColumnStretch (3 , 100 )
149- layout .setSpacing (spacing or 0 )
136+ layout .setColumnStretch (2 , 100 )
137+ layout .setSpacing (spacing )
150138 else :
151139 layout .addWidget (self ._label , 2 , 1 )
152140 if vsize_policy == 'minimum' :
@@ -163,7 +151,7 @@ def sizeHint(self):
163151 layout .setColumnStretch (2 , 100 )
164152 elif hsize_policy == 'expanding' :
165153 layout .setColumnStretch (1 , 100 )
166- layout .setSpacing (spacing or 5 )
154+ layout .setSpacing (spacing )
167155
168156 def show_icon (self , icon_name ):
169157 """Show icon named 'icon_name' and hide all other icons."""
0 commit comments