How to use the ttkwidgets.Notebook function in ttkwidgets

To help you get started, we’ve selected a few ttkwidgets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TkinterEP / ttkwidgets / tests / test_notebook.py View on Github external
def test_notebook_init(self):
        nb = Notebook(self.window)
        nb.grid()
        self.window.update()
github TkinterEP / ttkwidgets / tests / test_notebook.py View on Github external
def test_notebook_forget_tab(self):
        nb = Notebook(self.window)
        ids = list()
        n = 3
        for i in range(n):
            frame = ttk.Frame(self.window, width=200, height=200)
            id = nb.add(frame, text="Frame" + str(i))
            ids.append(id)

        tabs = nb.tabs()
        self.assertIn(id, tabs)
        nb.forget(id)  # Test forgetting of the last created tab
        tabs = nb.tabs()
        self.assertEquals(len(tabs), n-1)
        self.assertNotIn(id, tabs)
github TkinterEP / ttkwidgets / tests / test_notebook.py View on Github external
def test_notebook_insert(self):
        nb = Notebook(self.window, drag_to_toplevel=False)
        ids = list()
        n = 3
        for i in range(n):
            frame = ttk.Frame(self.window, width=200, height=200)
            ids.append(nb.add(frame, text="Frame" + str(i)))
            print(ids)
        id = nb.insert(n-2, ttk.Frame(self.window, width=200, height=200), text="Added")
        tabs = nb.tabs()
        self.assertIn(id, tabs)
        self.assertEquals(tabs.index(id), n-2)
        self.assertEquals(nb.index(id), n-2)
        self.assertEqual(nb._visible_tabs, [0, 3, 1, 2])
github TkinterEP / ttkwidgets / tests / test_notebook.py View on Github external
def test_notebook_select_tab(self):
        nb = Notebook(self.window)
        frame = ttk.Frame(self.window, width=200, height=200)
        frame2 = ttk.Frame(self.window, width=200, height=200)
        nb.add(frame, text="Frame")
        nb.add(frame2, text="Frame2")
        nb.grid()
        nb.select_next()
        nb.select_next()
        nb.select_prev()
        self.window.update()
github TkinterEP / ttkwidgets / tests / test_notebook.py View on Github external
def test_notebook_config_tab(self):
        nb = Notebook(self.window)
        for i in range(10):
            frame = ttk.Frame(self.window, width=200, height=200)
            nb.add(frame, text="Frame" + str(i))

        with self.assertRaises(ValueError):
            nb.tab(tk.CURRENT, state='random')

        nb.tab(tk.CURRENT, text="Changed")
        self.window.update()
github TkinterEP / ttkwidgets / tests / test_notebook.py View on Github external
def test_notebook_move_tab(self):
        nb = Notebook(self.window, drag_to_toplevel=False)
        frames = []
        for i in range(3):
            frame = ttk.Frame(self.window, width=200, height=200)
            frames.append(frame)
            nb.add(frame, text="Frame" + str(i))
        nb._dragged_tab = nb._tab_labels[0]
        nb._swap(nb._tab_labels[1])
        nb._on_click(None)
        self.assertEqual(nb._visible_tabs, [1, 0, 2])
github TkinterEP / ttkwidgets / tests / test_notebook.py View on Github external
def test_notebook_index(self):
        nb = Notebook(self.window)
        ids = list()
        frames = list()
        n = 10
        for i in range(n):
            frame = ttk.Frame(self.window, width=200, height=200)
            frames.append(frame)
            ids.append(nb.add(frame, text="Frame" + str(i)))

        with self.assertRaises(KeyError):
            nb.index(str(self.window) + '.!frame11')

        self.assertTrue(all(ids.index(id) == nb.index(id) for id in ids))
        self.assertTrue(all(nb.index(id) == nb.index(frame) for id, frame in zip(ids, frames)))

        self.assertEqual(nb.index(tk.END), n)
        nb.current_tab = 0
github TkinterEP / ttkwidgets / tests / test_notebook.py View on Github external
def test_notebook_add_tab(self):
        nb = Notebook(self.window)
        frame = ttk.Frame(self.window, width=200, height=200)
        nb.add(frame, text="Frame")
        nb.grid()
        self.window.update()
github TkinterEP / ttkwidgets / examples / example_notebook.py View on Github external
def __init__(self, master):
        ttk.Frame.__init__(self, master)
        colors = ['red', 'blue', 'green', 'yellow', 'cyan', 'magenta', 'black', 'white', 'purple', 'brown']
        self.nb = Notebook(self, tabdrag=True, tabmenu=True, closebutton=True, closecommand=self.closecmd)
        self.frames = [tk.Frame(self, width=300, height=300, bg=color) for i, color in enumerate(colors)]
        for i, w in enumerate(self.frames):
            self.nb.add(w, text="Frame " + str(i))
            w.grid()
        self.nb.grid()