Skip to content

Commit

Permalink
testing coordinates_in_box utility function
Browse files Browse the repository at this point in the history
  • Loading branch information
dogeek committed Dec 7, 2019
1 parent 561b15a commit d81bd2e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/test_utilities.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) Dogeek 2019
# For license see LICENSE
from ttkwidgets.utilities import move_widget, parse_geometry
from ttkwidgets.utilities import move_widget, parse_geometry, coordinates_in_box
from tests import BaseWidgetTest
import tkinter as tk
import tkinter.ttk as ttk
Expand Down Expand Up @@ -50,4 +50,15 @@ def test_parse_geometry(self):
g = parse_geometry('1x1+1+1')
self.assertEqual(g, (1, 1, 1, 1))
g = parse_geometry('1x1-1-1')
self.assertEqual(g, (1, 1, -1, -1))
self.assertEqual(g, (1, 1, -1, -1))

def test_coordinates_in_box(self):
with self.assertRaises(ValueError):
coordinates_in_box((1, ), (1, 1, 3, 3))

with self.assertRaises(ValueError):
coordinates_in_box((1, 1), (1, 1, 3, 3, 4))

self.assertTrue(coordinates_in_box((1, 1), (0, 0, 2, 2)))
self.assertFalse(coordinates_in_box((1, 1), (1, 1, 2, 2), include_edges=False))
self.assertTrue(coordinates_in_box((0, 0), (-1, -1, 1, 1)))
1 change: 1 addition & 0 deletions ttkwidgets/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def copy_widget(widget, new_parent, level=0):
rv = widget.__class__(master=new_parent, **get_widget_options(widget))
for b in widget.bind():
script = widget.bind(b)
rv.bind(b, script) # Not sure it will work tho
# TODO: bind the script to the new widget (rv)
# set type [ getWidgetType $w ]
# set name [ string trimright $newparent.[lindex [split $w "." ] end ] "." ]
Expand Down

0 comments on commit d81bd2e

Please sign in to comment.