Coverage for modules/org/openteacher/interfaces/qt/dialogShower/dialogShower : 49%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
|
#! /usr/bin/env python3 # -*- coding: utf-8 -*-
# Copyright 2011-2012, Milan Boers # Copyright 2013, Marten de Vries # # This file is part of OpenTeacher. # # OpenTeacher is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # OpenTeacher is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with OpenTeacher. If not, see <http://www.gnu.org/licenses/>.
super().__init__(*args, **kwargs)
frame = QtWidgets.QFrame() frame.setFrameStyle(QtWidgets.QFrame.Panel | QtWidgets.QFrame.Raised) frame.setMidLineWidth(2) frame.setLineWidth(3)
frameLayout = QtWidgets.QHBoxLayout() frameLayout.setAlignment(QtCore.Qt.AlignHCenter)
imageLabel = QtWidgets.QLabel("<img src=\"" + imagePath + "\" />") imageLabel.setAlignment(QtCore.Qt.AlignHCenter) frameLayout.addWidget(imageLabel)
textLabel = QtWidgets.QLabel(text) textLabel.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) textLabel.setWordWrap(True) textLabel.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) if redText: textLabel.setStyleSheet("color: #b60000; font-weight: bold;") else: textLabel.setStyleSheet("font-weight: bold;") frameLayout.addWidget(textLabel)
backButton = QtWidgets.QPushButton("Close") backButton.clicked.connect(lambda: self.buttonClicked.emit()) frameLayout.addWidget(backButton)
frame.setLayout(frameLayout)
layout = QtWidgets.QHBoxLayout() layout.addWidget(frame) self.setLayout(layout)
super().__init__(*args, **kwargs)
layout = QtWidgets.QVBoxLayout()
image = QtGui.QPixmap(imagePath) imageLabel = QtWidgets.QLabel() imageLabel.setPixmap(image) imageLabel.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) layout.addWidget(imageLabel)
textLabel = QtWidgets.QLabel(text) textLabel.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignTop) textLabel.setWordWrap(True) textLabel.setStyleSheet("font-size: 18px; font-weight: bold;") layout.addWidget(textLabel)
self.setLayout(layout)
dialog = Dialog(self.brokenImagePath, text, True) self.showDialog(tab, dialog)
dialog = Dialog(self.logoImagePath, text) self.showDialog(tab, dialog)
dialog = BigDialog(self.bigLogoImagePath, text) self.showBigDialog(dialog)
dialog = BigDialog(self.bigBrokenImagePath, text) self.showBigDialog(dialog)
tab = self.uiModule.addCustomTab(dialog, previousTabOnClose=True) tab.closeRequested.handle(tab.close)
tabLayout = tab.wrapperWidget.layout()
# First, remove all other errors if any are there for i in range(tabLayout.count() - 1): it = tabLayout.itemAt(i) w = tabLayout.itemAt(i).widget() if isinstance(w, Dialog): # Old error is still there, remove it. tabLayout.removeItem(it) w.setParent(None)
# What happens when you click the button on the dialog def removeWidget(): tabLayout.removeWidget(dialog) dialog.setParent(None)
dialog.buttonClicked.connect(removeWidget)
tabLayout.insertWidget(0, dialog)
"""This module allows to show a message in a in the main window embedded dialog.
To do that, you need to call .send() on one of the events defined in this class. The arguments are the tab on which it needs to be shown, and the text of the message.
"""
self._mm.mods(type="ui"), self._mm.mods(type="event"), )
global QtCore, QtGui, QtWidgets except ImportError: return global Dialog, BigDialog
|