def test_calling_show_log_multiple_times_will_not_create_multiple_windows(self): self.aw = MainWindow() self.aw.show_logwindow() li1 = self.aw.mdi.subWindowList() self.aw.show_logwindow() li2 = self.aw.mdi.subWindowList() self.assertEqual(li1, li2)
def __init__(self, args=None): args = parser.parse_args(args=args) logger = logging.getLogger() logger.info(args.names) self.app = QApplication([]) self.win = MainWindow() self.win.show() super(Main, self).__init__()
def test_calling_show_log_in_main_window_will_show_log_dialog(self): self.aw = MainWindow() self.assertFalse([x for x in self.aw.mdi.subWindowList() if isinstance(x.widget(), LogDialog)]) self.aw.show_logwindow() li = [x for x in self.aw.mdi.subWindowList() if isinstance(x.widget(), LogDialog)] self.assertTrue(li) self.assertEqual(li[0].widget(), self.aw.logdialog)
def closing_log_window_can_be_followed_by_opening_it_again_and_same_log_window_will_reaapper( self): self.aw = MainWindow() self.aw.show_logwindow() li1 = self.aw.mdi.subWindowList() logdialog1 = [x for x in li1 if isinstance(x.widget(), LogDialog)][0] logdialog1.close() self.aw.show_logwindow() li2 = self.aw.mdi.subWindowList() logdialog2 = [x for x in li2 if isinstance(x.widget(), LogDialog)][0] self.assertEqual(logdialog1.widget(), logdialog2.widget())
def test_main_window_remember_geometry(self): oldgeometry = QtCore.QRect(10, 10, 1000, 750) self.aw.setGeometry(oldgeometry) self.aw.close() # now start a new session. self.app.closeAllWindows() self.app.exit() self.app = None time.sleep(1) self.app = QApplication([]) self.aw = MainWindow() self.assertEqual(self.aw.geometry(), oldgeometry)
class Main(QObject): def __init__(self, args=None): args = parser.parse_args(args=args) logger = logging.getLogger() logger.info(args.names) self.app = QApplication([]) self.win = MainWindow() self.win.show() super(Main, self).__init__() @pyqtSlot() def show_application(self): sys.exit(self.app.exec_())
def test_risk_matrix_etc_remember_geometry(self): oldgeometry1 = QtCore.QRect(100, 100, 500, 500) self.aw.riskmatrix.parent().setGeometry(oldgeometry1) oldgeometry2 = QtCore.QRect(200, 150, 505, 508) self.aw.networkmap.parent().setGeometry(oldgeometry2) oldgeometry3 = QtCore.QRect(300, 200, 509, 510) self.aw.get_wlc_windows()[0].parent().setGeometry(oldgeometry3) oldgeometry4 = QtCore.QRect(100, 300, 511, 512) self.aw.datawindow.parent().setGeometry(oldgeometry4) self.aw.show() # now start a new session. self.app.closeAllWindows() self.app.exit() self.app = None time.sleep(1) self.app = QApplication([]) self.aw = MainWindow() self.assertEqual(oldgeometry1, self.aw.riskmatrix.parent().geometry()) self.assertEqual(oldgeometry2, self.aw.networkmap.parent().geometry()) self.assertEqual(oldgeometry3, self.aw.get_wlc_windows()[0].parent().geometry()) self.assertEqual(oldgeometry4, self.aw.datawindow.parent().geometry())
# logger=logging.getLogger() # logger.addHandler(emittinglogger) @pyqtSlot(object) def reciever(object): pass # print("I Got: ", str(object)) if __name__ == "__main__": from rrpam_wds.gui.dialogs import MainWindow app = QApplication([]) mw = MainWindow() # setup_logging() # logger=logging.getLogger() # win=QPlainTextEdit() # mw.mdi.addSubWindow(win) # print(logger.handlers) # from rrpam_wds.logger import EmittingLogger # handler=[x for x in logger.handlers if isinstance(x,EmittingLogger)][0] # handler.logsender.logsender_signal.connect(reciever) # handler.logsender.logsender_signal.connect(win.appendPlainText) logger = logging.getLogger() logger.info("Hello, world!") logger.info("Hello, world!") mw.show() mw.show_logwindow()
import logging import sys from PyQt5.QtCore import QTimer from PyQt5.QtWidgets import QApplication from rrpam_wds.gui.dialogs import MainWindow def test_dummy(): assert 1 == 1 if __name__ == "__main__": app = QApplication(sys.argv) aw = MainWindow() aw.add_optimaltimegraph() for w in aw.mdi.subWindowList(): w.close() # following should not raise exceptions aw.show() aw.deleteLater() QTimer.singleShot(5000, app.quit) # Make the application quit just after start logger = logging.getLogger() logger.info("Boo") val = app.exec_()
def setUp(self): self.app = QApplication.instance() or QApplication(sys.argv) self.start = time.time() self.aw = MainWindow() self.aw.progressbar = mock.MagicMock()
def main(argv=[]): currentExitCode = EXIT_CODE_REBOOT while currentExitCode == EXIT_CODE_REBOOT: app = QApplication([]) if getattr(sys, 'frozen', False): # frozen dir_ = os.path.dirname(sys.executable) else: # unfrozen dir_ = os.path.dirname(os.path.realpath(__file__)) # IMG_PATH = IMG_PATH.append(os.path.join(dir_, 'images')) # Create and display the splash screen splash_pix = QPixmap( os.path.join(dir_, './rrpam_wds/gui/images/splash_screen.png')) if (splash_pix is None): pass splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) # splash.setMask(splash_pix.mask()) splash.show() import time start = time.time() while time.time() - start < .5: time.sleep(0.001) app.processEvents() from rrpam_wds.gui.dialogs import MainWindow from guidata.configtools import get_icon app.setWindowIcon(get_icon("main_logo.png")) if (len(argv) > 1 and argv[1] == TESTARG): # pragma: no cover # first run tests win = MainWindow() import rrpam_wds.tests.test_optimal_time_graph as og og.main(og.TC, test=False, mainwindow=win) win = None win = MainWindow() import rrpam_wds.tests.test_main_window as mw mw.main(mw.TC, test=False, mainwindow=win) win = None time.sleep(3) app.processEvents() time.sleep(1) win = MainWindow() win.show() if (splash): splash.finish(win) splash = None currentExitCode = app.exec_() app = None time.sleep(0.1)
def test_creating_main_window_will_write_log_messages(self): self.aw = MainWindow() log = self.aw.logdialog.get_text() self.assertIn(self.aw.LOGSTARTMESSAGE, log) self.aw.show_logwindow()
class TC(Test_Parent): def setUp(self): # special setup for this test set. global start self.app = QApplication.instance() or QApplication(sys.argv) start = time.time() def test_creating_main_window_will_write_log_messages(self): self.aw = MainWindow() log = self.aw.logdialog.get_text() self.assertIn(self.aw.LOGSTARTMESSAGE, log) self.aw.show_logwindow() def test_calling_show_log_in_main_window_will_show_log_dialog(self): self.aw = MainWindow() self.assertFalse([x for x in self.aw.mdi.subWindowList() if isinstance(x.widget(), LogDialog)]) self.aw.show_logwindow() li = [x for x in self.aw.mdi.subWindowList() if isinstance(x.widget(), LogDialog)] self.assertTrue(li) self.assertEqual(li[0].widget(), self.aw.logdialog) def test_calling_show_log_multiple_times_will_not_create_multiple_windows(self): self.aw = MainWindow() self.aw.show_logwindow() li1 = self.aw.mdi.subWindowList() self.aw.show_logwindow() li2 = self.aw.mdi.subWindowList() self.assertEqual(li1, li2) def closing_log_window_can_be_followed_by_opening_it_again_and_same_log_window_will_reaapper( self): self.aw = MainWindow() self.aw.show_logwindow() li1 = self.aw.mdi.subWindowList() logdialog1 = [x for x in li1 if isinstance(x.widget(), LogDialog)][0] logdialog1.close() self.aw.show_logwindow() li2 = self.aw.mdi.subWindowList() logdialog2 = [x for x in li2 if isinstance(x.widget(), LogDialog)][0] self.assertEqual(logdialog1.widget(), logdialog2.widget())