def main(): sys.excepthook = exception_logger os.environ['QT_MAC_WANTS_LAYER'] = '1' # Workaround for https://bugreports.qt.io/browse/QTBUG-87014 error = init_and_check_db(get_app_path()) if error.code == LedgerInitError.EmptyDbInitialized: # If DB was just created from SQL - initialize it again error = init_and_check_db(get_app_path()) app = QApplication([]) language = JalDB().get_language_code(JalSettings().getValue('Language', default=1)) translator = QTranslator(app) language_file = get_app_path() + Setup.LANG_PATH + os.sep + language + '.qm' translator.load(language_file) app.installTranslator(translator) if error.code == LedgerInitError.OutdatedDbSchema: error = update_db_schema(get_app_path()) if error.code == LedgerInitError.DbInitSuccess: error = init_and_check_db(get_app_path()) if error.code != LedgerInitError.DbInitSuccess: window = QMessageBox() window.setAttribute(Qt.WA_DeleteOnClose) window.setWindowTitle("JAL: Start-up aborted") window.setIcon(QMessageBox.Critical) window.setText(error.message) window.setInformativeText(error.details) else: window = MainWindow(language) window.show() app.exec() app.removeTranslator(translator)
def showAboutWindow(self): about_box = QMessageBox(self) about_box.setAttribute(Qt.WA_DeleteOnClose) about_box.setWindowTitle(self.tr("About")) title = self.tr("<h3>JAL</h3><p>Just Another Ledger, version {version}</p>".format(version=__version__)) about_box.setText(title) about = self.tr("<p>More information, manuals and problem reports are at " "<a href=https://github.com/titov-vv/jal>github home page</a></p>" "<p>Questions, comments, help or donations:</p>" "<p><a href=mailto:[email protected]>[email protected]</a></p>" "<p><a href=https://t.me/jal_support>Telegram</a></p>") about_box.setInformativeText(about) about_box.show()
def slot_save(self) -> None: save_all_databases() # Misuse message dialog as notification https://stackoverflow.com/a/43134238 msgbox = QMessageBox(self) msgbox.setWindowTitle('Save') msgbox.setText('Saved pointers, constraints and annotations.') msgbox.setModal(False) msgbox.show() # Automatically hide dialog after half a second timer = QTimer(self) timer.timeout.connect(msgbox.close) timer.timeout.connect(timer.stop) timer.timeout.connect(timer.deleteLater) timer.start(500)
#!/usr/bin/python import sys from PySide6.QtWidgets import QApplication, QMessageBox # Create the application object app = QApplication(sys.argv) # Create a simple dialog box msg_box = QMessageBox() msg_box.setText("Hello World!") msg_box.show() sys.exit(msg_box.exec_())
def run(): initialization_result = initialize() conf = config() window_config = conf['window'] WIDTH = window_config['width'] HEIGHT = window_config['height'] app = QApplication(sys.argv) app.setStyleSheet(style) geometry = app.screens()[0].size() clipboard = app.clipboard() widget = MainWidget(clipboard) widget.setWindowOpacity(window_config['opacity']) widget.resize(WIDTH, HEIGHT) widget.move(0, geometry.height() - HEIGHT - 280) widget.setWindowTitle('Albion Online Stats') widget.setWindowIcon(QtGui.QIcon(path('albion-stats-icon.png'))) if window_config['always_on_top']: widget.setWindowFlag(Qt.WindowStaysOnTopHint) if window_config['frameless']: widget.setWindowFlag(Qt.FramelessWindowHint) widget.show() current_version, latest_version = (get_current_version(), get_latest_version()) if latest_version and current_version != latest_version: msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setWindowTitle("Update available!") msg.setText("Another version of app is avaliable.") msg.setInformativeText( "You are using app in version {}, latest version is {}".format( current_version, latest_version)) msg.setStandardButtons(QMessageBox.Ok) msg.show() if initialization_result == InitializationResult.NetworkInterfaceListMissing: msg = QMessageBox() msg.setIcon(QMessageBox.Critical) msg.setWindowTitle("Unable to track network traffic data!") msg.setText( "On windows make sure that WinPcap is installed in your system.") msg.setInformativeText( "WinPcap can be installed from <a href='{}'>here</a> <br>\ <b>Make sure to install with the \"Install Npcap in WinPcap API-compatible Mode\"<b> option<br><br>\ In case where npcap is installed try to fix npcap and restart the app" .format('https://nmap.org/npcap/dist/npcap-0.9990.exe')) msg.setStandardButtons(QMessageBox.Ok) button = QPushButton("Fix npcap") button.clicked.connect(fix_npcap) msg.addButton(button, QMessageBox.NoRole) msg.show() sys.exit(app.exec_())
def do_something_to_demo(self): message_box = QMessageBox(self) message_box.setText( "You just pushed the button - imagine database work here") message_box.setWindowTitle("Comp490 Demo") message_box.show()
def do_something_to_test(self): message_box = QMessageBox(self) message_box.setText( "You just pushed the button - imagine database work here") message_box.setWindowTitle("API Data") message_box.show()