Example #1
0
    def test_message_box():
        dialog = widgets.Dialog()

        timer = core.Timer(single_shot=True)
        timer.timeout.connect(lambda: dialog.question("测试question"))
        timer.start(0.1)

        timer = core.Timer(single_shot=True)
        timer.timeout.connect(lambda: dialog.warning("测试warning"))
        timer.start(0.1)

        timer = core.Timer(single_shot=True)
        timer.timeout.connect(lambda: dialog.information("测试information"))
        timer.start(0.1)

        timer = core.Timer(single_shot=True)
        timer.timeout.connect(lambda: dialog.about("测试about"))
        timer.start(0.1)

        timer = core.Timer(single_shot=True)
        timer.timeout.connect(lambda: dialog.message())
        timer.start(0.1)

        timer = core.Timer(single_shot=True)
        timer.timeout.connect(lambda: dialog.message(ok=False))
        timer.start(0.1)
Example #2
0
    def test_dialog(self):
        dialog = widgets.Dialog()
        executed = [False]

        @core.connect_with(dialog.closed)
        def is_closed():
            executed[0] = True

        timer = core.Timer(single_shot=True)
        timer.timeout.connect(dialog.close)
        timer.start(0.1)

        dialog.exec()
        self.assertTrue(executed[0])
Example #3
0
    def test_widget_exec(self):
        w = widgets.Widget()
        executed = [False]

        @core.connect_with(w.closed)
        def is_closed():
            executed[0] = True

        timer = core.Timer(single_shot=True)
        timer.timeout.connect(w.close)
        timer.start(0.1)

        w.exec()
        self.assertTrue(executed[0])
Example #4
0
    def test_main_window(self):
        main_window = widgets.MainWindow()
        executed = [False]

        @core.connect_with(main_window.closed)
        def is_closed():
            executed[0] = True

        timer = core.Timer(single_shot=True)
        timer.timeout.connect(main_window.close)
        timer.start(0.1)

        main_window.exec()
        self.assertTrue(executed[0])
Example #5
0
    def test_widget_cannot_close(self):
        w = widgets.Widget()
        w.can_close = False
        executed = [False]

        @core.connect_with(w.cannot_closed)
        def cannot_closed_event():
            executed[0] = True

        timer = core.Timer(single_shot=True)
        timer.timeout.connect(w.close)
        timer.start(0.1)

        self.assertFalse(executed[0])
        core.wait(0.2)
        self.assertTrue(executed[0])

        w.can_close = True
        w.close()