src/eric7/EricWidgets/EricMessageBox.py

branch
eric7
changeset 11034
7b8a21fd2d58
parent 10439
21c28b0f9e41
child 11090
f5f5f5803935
equal deleted inserted replaced
11033:6b197c3389f7 11034:7b8a21fd2d58
5 5
6 """ 6 """
7 Module implementing QMessageBox replacements and more convenience function. 7 Module implementing QMessageBox replacements and more convenience function.
8 """ 8 """
9 9
10 from PyQt6.QtCore import Qt 10 from PyQt6.QtCore import QCoreApplication, Qt
11 from PyQt6.QtWidgets import QApplication, QMessageBox 11 from PyQt6.QtWidgets import QApplication, QMessageBox
12 12
13 ############################################################################### 13 ###############################################################################
14 ## Mappings to standard QMessageBox ## 14 ## Mappings to standard QMessageBox ##
15 ############################################################################### 15 ###############################################################################
140 @param textFormat format of the text 140 @param textFormat format of the text
141 @type Qt.TextFormat 141 @type Qt.TextFormat
142 @return button pressed by the user 142 @return button pressed by the user
143 @rtype QMessageBox.StandardButton 143 @rtype QMessageBox.StandardButton
144 """ 144 """
145 if parent is None:
146 parent = QCoreApplication.instance().getMainWindow()
147
145 messageBox = QMessageBox(parent) 148 messageBox = QMessageBox(parent)
146 messageBox.setIcon(icon) 149 messageBox.setIcon(icon)
147 if parent is not None: 150 if parent is not None:
148 messageBox.setWindowModality(Qt.WindowModality.WindowModal) 151 messageBox.setWindowModality(Qt.WindowModality.WindowModal)
149 if title == "": 152 if title == "":
162 return QMessageBox.StandardButton.NoButton 165 return QMessageBox.StandardButton.NoButton
163 else: 166 else:
164 return messageBox.standardButton(clickedButton) 167 return messageBox.standardButton(clickedButton)
165 168
166 169
167 # the about functions are here for consistency 170 def about(parent, title, text):
168 about = QMessageBox.about 171 """
169 aboutQt = QMessageBox.aboutQt 172 Function to show a modal dialog with some text about the application.
173
174 @param parent parent widget of the message box
175 @type QWidget
176 @param title caption of the message box
177 @type str
178 @param text text to be shown by the message box
179 @type str
180 """
181 if parent is None:
182 parent = QCoreApplication.instance().getMainWindow()
183
184 QMessageBox.about(parent, title, text)
185
186
187 def aboutQt(parent, title=""):
188 """
189 Function to show a modal dialog with text about Qt.
190
191 @param parent parent widget of the message box
192 @type QWidget
193 @param title caption of the message box (defaults to "")
194 @type str (optional)
195 """
196 if parent is None:
197 parent = QCoreApplication.instance().getMainWindow()
198
199 QMessageBox.aboutQt(parent, title)
170 200
171 201
172 def critical( 202 def critical(
173 parent, 203 parent,
174 title, 204 title,

eric ide

mercurial