Esempio n. 1
0
    def test_set_central_widget(self):
        main_window = widgets.MainWindow()
        sub_widget = widgets.Widget()
        main_window.set_central_widget(sub_widget)
        self.assertIsNotNone(main_window.center_widget)
        main_window.close()

        dock_widget = widgets.DockWidget()
        sub_widget = widgets.Widget()
        dock_widget.set_central_widget(sub_widget)
        self.assertIsNotNone(dock_widget.center_widget)
        dock_widget.set_focus()
        dock_widget.close()
Esempio n. 2
0
    def test_widget_background_color(self):
        w = widgets.Widget()
        w.background_color = core.Qt.blue
        self.assertEqual(w.background_color, core.Qt.blue)

        w.show()
        core.wait(0.1)
        w.close()
Esempio n. 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])
Esempio n. 4
0
    def test_widget_export(self):
        w = widgets.Widget()
        w.resize(1000, 800)
        self.assertTrue(w.export_to_pdf(self.mock_pdf_path))
        self.assertTrue(self.mock_pdf_path.exists())

        w.resize(800, 1000)
        self.assertTrue(w.export_to_pdf(self.mock_pdf_path))
        self.assertTrue(self.mock_pdf_path.exists())

        self.assertTrue(w.export_to_picture(self.mock_png_path))
        self.assertTrue(self.mock_png_path.exists())

        self.assertTrue(w.export_to_svg(self.mock_svg_path))
        self.assertTrue(self.mock_svg_path.exists())
Esempio n. 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()