1717from qtpy .QtWidgets import (
1818 QAbstractButton , QApplication , QStyle , QStylePainter ,
1919 QDialog , QPushButton , QDialogButtonBox , QWidget , QTabWidget ,
20- QGridLayout , QTabBar , QStyleOptionTab )
20+ QGridLayout , QTabBar , QStyleOptionTab , QLabel )
2121
2222
2323class HorizontalTabBar (QTabBar ):
@@ -80,31 +80,36 @@ class ConfDialog(QDialog):
8080 A dialog window to manage app preferences.
8181 """
8282
83- def __init__ (self , main , icon : QIcon = None , resizable : bool = True ):
83+ def __init__ (self , main , icon : QIcon = None , resizable : bool = True ,
84+ min_height : int = None , sup_message : str = None ,
85+ btn_labels : dict = None , win_title : str = 'Preferences' ):
8486 super ().__init__ (main )
8587 self .main = main
8688
87- self .setWindowTitle ('Preferences' )
89+ self .setWindowTitle (win_title )
8890 if icon is not None :
8991 self .setWindowIcon (icon )
9092 self .setWindowFlags (
9193 self .windowFlags () & ~ Qt .WindowContextHelpButtonHint )
9294 self .setModal (True )
93- self .setMinimumHeight (500 )
95+ if min_height is not None :
96+ self .setMinimumHeight (min_height )
9497
9598 self .confpages_tabwidget = QTabWidget ()
9699 self .confpages_tabwidget .setTabBar (HorizontalTabBar ())
97100 self .confpages_tabwidget .setTabPosition (QTabWidget .West )
98101 self ._confpages = {}
99102
100103 # Setup the dialog button box.
101- self .ok_button = QPushButton ('OK' )
104+ btn_labels = {} if btn_labels is None else btn_labels
105+
106+ self .ok_button = QPushButton (btn_labels .get ('ok' , 'OK' ))
102107 self .ok_button .setDefault (False )
103108 self .ok_button .setAutoDefault (False )
104- self .apply_button = QPushButton (' Apply' )
109+ self .apply_button = QPushButton (btn_labels . get ( 'apply' , ' Apply') )
105110 self .apply_button .setDefault (True )
106111 self .apply_button .setEnabled (False )
107- self .cancel_button = QPushButton (' Cancel' )
112+ self .cancel_button = QPushButton (btn_labels . get ( 'cancel' , ' Cancel') )
108113 self .cancel_button .setDefault (False )
109114 self .cancel_button .setAutoDefault (False )
110115
@@ -117,9 +122,17 @@ def __init__(self, main, icon: QIcon = None, resizable: bool = True):
117122
118123 # Setup the main layout.
119124 main_layout = QGridLayout (self )
120- main_layout .addWidget (self .confpages_tabwidget )
121- main_layout .addWidget (button_box )
122- main_layout .setRowStretch (0 , 1 )
125+
126+ row = 0
127+ if sup_message is not None :
128+ label = QLabel (sup_message )
129+ label .setWordWrap (True )
130+ label .setMargin (10 )
131+ main_layout .addWidget (label , row , 0 )
132+ row += 1
133+ main_layout .addWidget (self .confpages_tabwidget , row , 0 )
134+ main_layout .setRowStretch (row , 1 )
135+ main_layout .addWidget (button_box , row + 1 , 0 )
123136 if resizable is False :
124137 main_layout .setSizeConstraint (main_layout .SetFixedSize )
125138
0 commit comments