How to use the ttkwidgets.utilities.move_widget 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_utilities.py View on Github external
def test_move_widget(self):
        label = ttk.Label(self.window)
        tl = tk.Toplevel(self.window)
        label = move_widget(label, tl)
        self.assertIsChild(label, tl)
github TkinterEP / ttkwidgets / tests / test_utilities.py View on Github external
def test_move_widget_with_children_place(self):
        frame = ttk.Frame(self.window)
        label = ttk.Label(frame)
        parent = tk.Toplevel()
        label.place(x=53, y=13)
        info = label.place_info()
        frame.place(x=100, y=10)

        frame = move_widget(frame, parent)
        self.assertTrue(len(frame.place_slaves()) == 1)
        label2 = frame.nametowidget(frame.place_slaves()[0])
        self.assertTrue(label is not label2)

        self.assertGeometryInfoEquals(info, label2.place_info())
        self.assertRaises(tk.TclError, label.place_info)
        self.assertTrue(len(frame.place_info()) == 0)
        self.assertIn(label2, frame.place_slaves())
github TkinterEP / ttkwidgets / tests / test_utilities.py View on Github external
def test_move_widget_with_children_pack(self):
        frame = ttk.Frame(self.window)
        label = ttk.Label(frame)
        parent = tk.Toplevel()
        label.pack(side=tk.BOTTOM)
        info = label.pack_info()
        frame.pack(expand=True)

        frame = move_widget(frame, parent)
        self.assertTrue(len(frame.pack_slaves()) == 1)
        label2 = frame.nametowidget(frame.pack_slaves()[0])
        self.assertTrue(label is not label2)

        self.assertGeometryInfoEquals(info, label2.pack_info())
        self.assertRaises(tk.TclError, label.pack_info)
        self.assertRaises(tk.TclError, frame.pack_info)  # Frame is not packed
        self.assertIn(label2, frame.pack_slaves())
github TkinterEP / ttkwidgets / tests / test_utilities.py View on Github external
def test_move_widget_with_bound_method_on_parent(self):
        tl1 = tk.Toplevel(self.window)
        tl2 = tk.Toplevel(self.window)
        tl1._dummy_bind = self._dummy_bind

        button = ttk.Button(tl1)
        button.bind("", tl1._dummy_bind)
        button.event_generate("")
        self.assertHasBeenInvoked()

        button = move_widget(button, tl2)
        button.event_generate("")
        self.assertHasBeenInvoked()
github TkinterEP / ttkwidgets / tests / test_utilities.py View on Github external
def test_move_widget_with_children_grid(self):
        frame = ttk.Frame(self.window)
        label = ttk.Label(frame)
        parent = tk.Toplevel()
        label.grid(row=1, column=1)
        info = label.grid_info()
        frame.grid(row=1, column=1)

        frame = move_widget(frame, parent)
        self.assertTrue(len(frame.grid_slaves()) == 1)
        label2 = frame.nametowidget(frame.grid_slaves()[0])
        self.assertTrue(label is not label2)

        self.assertGeometryInfoEquals(info, label2.grid_info())
        self.assertRaises(tk.TclError, label.grid_info)
        self.assertTrue(len(frame.grid_info()) == 0)  # Frame is not in grid
        self.assertIn(label2, frame.grid_slaves())
github TkinterEP / ttkwidgets / tests / test_utilities.py View on Github external
def test_move_widget_none(self):
        label = ttk.Label(self.window)
        self.assertFalse(label.place_info() is True)
        self.assertFalse(label.grid_info() is True)
        self.assertRaises(tk.TclError, label.pack_info)
        tl = tk.Toplevel(self.window)
        label = move_widget(label, tl, preserve_geometry=True)
        self.assertFalse(label.place_info() is True)
        self.assertFalse(label.grid_info() is True)
        self.assertRaises(tk.TclError, label.pack_info)
github TkinterEP / ttkwidgets / tests / test_utilities.py View on Github external
def test_move_widget_pack(self):
        label = ttk.Label(self.window)
        label.pack(side=tk.LEFT)
        info = label.pack_info()
        tl = tk.Toplevel(self.window)
        label = move_widget(label, tl, preserve_geometry=True)
        self.assertIsChild(label, tl)
        self.assertIn(label, tl.pack_slaves())
        self.assertNotIn(label, self.window.pack_slaves())
        self.assertGeometryInfoEquals(info, label.pack_info())
github TkinterEP / ttkwidgets / tests / test_utilities.py View on Github external
def test_move_widget_with_command(self):
        widget = ttk.Button(self.window, command=self._dummy_bind)
        self.assertIsChild(widget, self.window)
        widget.invoke()
        self.assertHasBeenInvoked()

        parent = tk.Toplevel()
        child = move_widget(widget, parent)
        self.assertIsChild(child, parent)
        child.invoke()
        self.assertHasBeenInvoked()
github TkinterEP / ttkwidgets / ttkwidgets / notebook.py View on Github external
def move_to_toplevel(self, tab):
        tl = tk.Toplevel(self)
        move_widget(tab, tl)
        tab.grid()
        self._toplevels.append(tl)