-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from HelmholtzAI-Consultants-Munich/client-add…
…-in-prog Client add in prog
- Loading branch information
Showing
14 changed files
with
641 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from PyQt5.QtWidgets import QWidget, QMessageBox | ||
from PyQt5.QtCore import QTimer | ||
|
||
class MyWidget(QWidget): | ||
|
||
msg = None | ||
sim = False # will be used for testing to simulate user click | ||
|
||
def create_warning_box(self, message_text: str=" ", message_title: str="Information", add_cancel_btn: bool=False, custom_dialog=None) -> None: | ||
#setup box | ||
if custom_dialog is not None: self.msg = custom_dialog | ||
else: self.msg = QMessageBox() | ||
|
||
if message_title=="Warning": | ||
message_type = QMessageBox.Warning | ||
elif message_title=="Error": | ||
message_type = QMessageBox.Critical | ||
else: | ||
message_type = QMessageBox.Information | ||
self.msg.setIcon(message_type) | ||
self.msg.setText(message_text) | ||
self.msg.setWindowTitle(message_title) | ||
# if specified add a cancel button else only an ok | ||
if add_cancel_btn: | ||
self.msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) | ||
# simulate button click if specified - workaround used for testing | ||
if self.sim: QTimer.singleShot(0, self.msg.button(QMessageBox.Cancel).clicked) | ||
else: | ||
self.msg.setStandardButtons(QMessageBox.Ok) | ||
# simulate button click if specified - workaround used for testing | ||
if self.sim: QTimer.singleShot(0, self.msg.button(QMessageBox.Ok).clicked) | ||
# return if user clicks Ok and False otherwise | ||
usr_response = self.msg.exec() | ||
if usr_response == QMessageBox.Ok: return True | ||
else: return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.