Esempio n. 1
0
    def test_pos(self):
        app = App()
        self.assertEqual(Vec2(), app.getWindowPos())
        self.assertEqual(Vec2(1), app.getSize())
        app.show(mainloop=False)
        self.assertEqual(True, app.getWindowPos().inrange(1, 500))

        self.assertEqual(Vec2(), app.getTopLeftPos())
        self.assertEqual(Vec2(200), app.getBottomRightPos())
        self.assertEqual(Vec2(200), app.getSize())

        app.setSize(Vec2(250, 300))
        app.widget.update()
        self.assertEqual(Vec2(250, 300), app.getSize())

        app.setSize(145)
        app.widget.update()
        self.assertEqual(Vec2(145), app.getSize())

        page = Page(app, width=300, height=250)
        page.show(mainloop=False)
        self.assertEqual(Vec2(300, 250), app.getBottomRightPos())
        self.assertEqual(Vec2(300, 250), app.getSize())

        self.assertEqual(True, app.getMouse().inrange(-100000, 100000))

        self.assertEqual(page.frame, app.getElementByPos(10))

        page.remove()
        self.assertEqual(app, app.getElementByPos(10))

        self.assertEqual(None, app.getElementByPos(-10))
        self.assertEqual(None, app.getElementByPos(400))
Esempio n. 2
0
    def test_getVisibleFraction(self):
        app = App()
        page = Page(app, width=100, height=100, scrollable=True)
        page2 = Page(page, width=196, height=196)

        with self.assertRaises(AttributeError):
            app.getVisibleFraction(page.canvas)

        page2.show(mainloop=False)
        self.assertEqual(Vec2(0.5), app.getVisibleFraction(page.canvas))
Esempio n. 3
0
    def test_parents(self):
        for page in Page(App()), Page(App(), width=200, height=200):
            page2 = Page(page)
            page3 = Page(page2)
            self.assertEqual(page3.getParents(), [page2, page])
            self.assertEqual(page3.getParents(includeSelf=True),
                             [page3, page2, page])
            self.assertEqual(page3.getTopPage(), page)

            page3.show(mainloop=False)
            self.assertTrue(page3.isShown())
            self.assertTrue(page2.isShown())
            self.assertTrue(page.isShown())
            self.assertTrue(page3.app.isShown())
            self.assertTrue(page2.app.isShown())
            self.assertTrue(page.app.isShown())
Esempio n. 4
0
    def test_init(self):
        page = Page(App())
        label = Label(page, "random")
        page.show(mainloop=False)

        red = label.createStyle("color red", bg="red", priority=3)
        blue = label.createStyle("color blue", bg="blue", priority=2)

        self.assertEqual(False, red.isEnabled())

        blue.enable()
        self.assertEqual("blue", label.getWidgetConfig("bg"))

        blue.disable()
        red.enable()
        self.assertEqual(True, red.isEnabled())
        self.assertEqual("red", label.getWidgetConfig("bg"))

        blue.enable()
        self.assertEqual("red", label.getWidgetConfig("bg"))

        red.disable()
        self.assertEqual(False, red.isEnabled())
        self.assertEqual("blue", label.getWidgetConfig("bg"))

        blue.delete()
        self.assertEqual(False, blue.isEnabled())
        self.assertEqual(red.styleHandler.originalStyle["bg"],
                         label.getWidgetConfig("bg"))

        self.assertRaises(AttributeError, blue.enable)
        self.assertEqual(False, blue.isEnabled())

        self.assertEqual(2, len(label.styleHandler.allStyles))
        self.assertEqual(1, len(label.styleHandler.styles.objects))
        red.enable()
        self.assertEqual(2, len(label.styleHandler.allStyles))
        self.assertEqual(2, len(label.styleHandler.styles.objects))
        red.enable()
        self.assertEqual(2, len(label.styleHandler.allStyles))
        self.assertEqual(2, len(label.styleHandler.styles.objects))

        page.app.remove()
Esempio n. 5
0
    def test_pos(self):
        app = App()
        page = Page(app, width=200, height=100)
        self.assertEqual(Vec2(), page.getTopLeftPos())
        self.assertEqual(Vec2(1), page.getBottomRightPos())
        self.assertEqual(Vec2(1), page.getSize())

        page.show(mainloop=False)
        self.assertEqual(True, page.getWindowPos().inrange(1, 500))
        self.assertEqual(Vec2(200, 100), page.getSize())
        self.assertEqual(Vec2(0), page.getTopLeftPos())
        self.assertEqual(Vec2(200, 100), page.getBottomRightPos())

        page.setSize(Vec2(250, 300))
        app.widget.update()
        self.assertEqual(Vec2(250, 300), page.getSize())

        page.setSize(120)
        app.widget.update()
        self.assertEqual(Vec2(120), page.getSize())
Esempio n. 6
0
    def test_states(self):
        app = App()
        page = Page(app)

        self.assertEqual(False, page.isShown())
        self.assertEqual(True, page.exists())
        self.assertEqual(False, page.isPacked())

        page.show(mainloop=False)
        self.assertEqual(True, page.isShown())
        self.assertEqual(True, page.exists())
        self.assertEqual(True, page.isPacked())

        page.hide()
        self.assertEqual(False, page.isShown())
        self.assertEqual(True, page.exists())
        self.assertEqual(False, page.isPacked())

        page.remove()
        self.assertEqual(False, page.isShown(error=False))
        self.assertEqual(False, page.exists())
        self.assertEqual(False, page.isPacked())
Esempio n. 7
0
    def test_children(self):
        app = App()
        self.assertEqual(app.getChildren(), [])
        app.showChildren(mainloop=False)
        app.hideChildren()
        app.removeChildren()

        page = Page(app)
        self.assertEqual(app.getChildren(), [page])
        self.assertFalse(page.isShown())
        app.showChildren(mainloop=False)
        self.assertTrue(page.isShown())
        app.hideChildren()
        self.assertFalse(page.isShown())
        app.removeChildren()
        self.assertRaises(tk.TclError, page.isShown)
        self.assertEqual(app.getChildren(), [])

        page = Page(app, height=200)
        page2 = Page(app)
        self.assertEqual(app.getChildren(), [page, page2])
        self.assertEqual(app.getChildren(ignore=page), [page2])
        self.assertEqual(app.getChildren(ignore=page2), [page])
        self.assertEqual(app.getChildren(ignore=(page, page2)), [])

        self.assertFalse(page.isShown())
        self.assertFalse(page2.isShown())

        app.showChildren(ignore=(page, page2), mainloop=False)
        self.assertFalse(page.isShown())
        self.assertFalse(page2.isShown())

        app.showChildren(ignore=page, mainloop=False)
        self.assertFalse(page.isShown())
        self.assertTrue(page2.isShown())

        app.hideChildren()
        self.assertFalse(page.isShown())
        self.assertFalse(page2.isShown())

        app.showChildren(mainloop=False)
        self.assertTrue(page.isShown())
        self.assertTrue(page2.isShown())

        app.removeChildren()
        self.assertEqual(app.getChildren(), [])

        page = Page(app, width=200)
        page2 = Page(page)

        page2.show(mainloop=False)
        self.assertTrue(page.isShown())

        page.hideChildren()
        self.assertFalse(page2.isShown())

        page2.show(mainloop=False)
        self.assertTrue(page2.isShown())

        self.assertEqual([page, page2], app.getChildren(recurrent=True))
        labelEntry = LabelEntry(page2)
        self.assertEqual(
            [page, page2, labelEntry, labelEntry.label, labelEntry.entry],
            app.getChildren(recurrent=True))
Esempio n. 8
0

def test():
    print(app.widget.winfo_screenwidth(), app.widget.winfo_screenheight())
    spreadsheet.setSize(app.getSize())


# df = pd.DataFrame([[random.randint(-100, 100) for _ in range(20)] for _ in range(20)])
# df = df.append(["hello\nthere"], ignore_index=True)

df = pd.DataFrame([
    "\n   hello\nthere", "   hello\nthere\nyo", "\n\n",
    "verylongstring verylongstring verylongstring verylongstring verylongstring"
])

app = App()
page = Page(app)
spreadsheet = Spreadsheet(page, cellVSB=True)
spreadsheet.loadDataFrame(df)

# spreadsheet.maximize()
spreadsheet.setSize(1000)

# spreadsheet.menu("TESTING", Maximize=test)

page.show()

# page = Page(app)
# Button(page, value="testing")
# print(page.getElementByValue("testing"))
Esempio n. 9
0
    def test_init(self):
        page = Page(App())
        canvas = Canvas(page)
        page.show(mainloop=False)

        self.assertEqual(True, canvas.isShown())
Esempio n. 10
0
    def test_init(self):
        page = Page(App())
        frame = Frame(page)
        page.show(mainloop=False)

        self.assertEqual(True, frame.isShown())
Esempio n. 11
0
    def test_init(self):
        page = Page(App())
        scrollbar = Scrollbar(page)
        page.show(mainloop=False)

        self.assertEqual(True, scrollbar.isShown())