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())
def test_children(self): app = App() for page in Page(app), Page(app, width=200, height=200): text1 = Label(page, "hello") text2 = Label(page, "there") page2 = Page(page) text3 = Label(page2, "in page 2") # print(page.isScrollable(), page.getChildren()) self.assertEqual(page.getChildren(), [text1, text2, page2]) self.assertEqual([text1, text2, page2, text3], page.getChildren(recurrent=True)) self.assertFalse(text1.isShown()) self.assertFalse(text2.isShown()) self.assertFalse(page2.isShown()) self.assertFalse(text3.isShown()) page.show(mainloop=False) self.assertTrue(text1.isShown()) self.assertTrue(text2.isShown()) self.assertFalse(page2.isShown()) self.assertFalse(text3.isShown()) page.showChildren(mainloop=False) self.assertTrue(page2.isShown()) self.assertTrue(text3.isShown()) page.hideChildren() self.assertFalse(text1.isShown()) self.assertFalse(text2.isShown()) self.assertFalse(page2.isShown()) self.assertFalse(text3.isShown()) page.removeChildren() self.assertTrue(page.isShown()) self.assertRaises(tk.TclError, text1.isShown) self.assertRaises(tk.TclError, text2.isShown) self.assertRaises(tk.TclError, page2.isShown) self.assertRaises(tk.TclError, text3.isShown)
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())
def test_siblings(self): for page in Page(App()), Page(App(), width=200, height=200): self.assertEqual(page.getChildren(), []) self.assertEqual(page.getParents(), []) self.assertEqual(page.getParents(includeSelf=True), [page]) self.assertEqual(page.getTopPage(), page) self.assertEqual(page.getSiblings(), []) page.showSiblings(mainloop=False) page.hideSiblings() page.removeSiblings() page.show(mainloop=False) self.assertTrue(page.isShown()) page.hide() self.assertFalse(page.isShown()) page.toggleShow(mainloop=False) self.assertTrue(page.isShown()) page.toggleShow(mainloop=False) self.assertFalse(page.isShown()) page3 = Page(page.app) page2 = Page(page.app) self.assertEqual(page.getSiblings(), [page3, page2]) page.showSiblings(mainloop=False) self.assertTrue(page2.isShown()) self.assertTrue(page3.isShown()) page.hideSiblings() self.assertFalse(page2.isShown()) self.assertFalse(page3.isShown()) page.showSiblings(ignore=page2, mainloop=False) self.assertFalse(page2.isShown()) self.assertTrue(page3.isShown()) page.hideSiblings(ignore=page3) self.assertFalse(page2.isShown()) self.assertTrue(page3.isShown()) page.remove() self.assertRaises(tk.TclError, page.isShown)
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))
def test_children(self): for page in Page(App()), Page(App(), width=200, height=200): self.assertEqual(page.getChildren(), []) page.showChildren(mainloop=False) page.hideChildren() page.removeChildren() page2 = Page(page) self.assertEqual(page.getChildren(), [page2]) self.assertFalse(page2.isShown()) page.showChildren(mainloop=False) self.assertTrue(page2.isShown()) page.hideChildren() self.assertFalse(page2.isShown()) page.removeChildren() self.assertRaises(tk.TclError, page2.isShown) self.assertEqual(page.getChildren(), []) page2 = Page(page) page3 = Page(page) self.assertEqual(page.getChildren(), [page2, page3]) self.assertEqual(page.getChildren(ignore=page2), [page3]) self.assertEqual(page.getChildren(ignore=page3), [page2]) self.assertEqual(page.getChildren(ignore=(page2, page3)), []) self.assertEqual(page.getChildren(ignore=[page2, page3]), []) self.assertEqual([page, page2, page3], page.app.getChildren(recurrent=True)) self.assertFalse(page2.isShown()) self.assertFalse(page3.isShown()) page.showChildren(ignore=(page2, page3), mainloop=False) self.assertFalse(page2.isShown()) self.assertFalse(page3.isShown()) page.showChildren(ignore=page2, mainloop=False) self.assertFalse(page2.isShown()) self.assertTrue(page3.isShown()) page.hideChildren() self.assertFalse(page2.isShown()) self.assertFalse(page3.isShown()) page.showChildren(mainloop=False) self.assertTrue(page2.isShown()) self.assertTrue(page3.isShown()) page.removeChildren() self.assertEqual(page.getChildren(), []) page.remove() self.assertRaises(tk.TclError, page.isShown)