本文整理匯總了Python中gaphas.examples.Box.request_update方法的典型用法代碼示例。如果您正苦於以下問題:Python Box.request_update方法的具體用法?Python Box.request_update怎麽用?Python Box.request_update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gaphas.examples.Box
的用法示例。
在下文中一共展示了Box.request_update方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_minimal_se
# 需要導入模塊: from gaphas.examples import Box [as 別名]
# 或者: from gaphas.examples.Box import request_update [as 別名]
def test_minimal_se(self):
"""
Test resizing of element by dragging it SE handle.
"""
canvas = Canvas()
box = Box()
handles = box.handles()
canvas.add(box)
h_nw, h_ne, h_se, h_sw = handles
assert h_nw is handles[NW]
assert h_ne is handles[NE]
assert h_sw is handles[SW]
assert h_se is handles[SE]
h_se.pos.x -= 20 # h.se.{x,y} == -10
h_se.pos.y -= 20
assert h_se.pos.x == h_se.pos.y == -10
box.request_update()
canvas.update()
self.assertEquals(10, h_se.pos.x) # h_se changed above, should be 10
self.assertEquals(10, h_se.pos.y)
self.assertEquals(10, h_ne.pos.x)
self.assertEquals(10, h_sw.pos.y)
示例2: SimpleCanvas
# 需要導入模塊: from gaphas.examples import Box [as 別名]
# 或者: from gaphas.examples.Box import request_update [as 別名]
class SimpleCanvas(object):
"""Creates a test canvas object.
Adds a view, canvas, and handle connection tool to a test
case. Two boxes and a line are added to the canvas as well.
"""
def __init__(self):
self.canvas = Canvas()
self.box1 = Box()
self.canvas.add(self.box1)
self.box1.matrix.translate(100, 50)
self.box1.width = 40
self.box1.height = 40
self.box1.request_update()
self.box2 = Box()
self.canvas.add(self.box2)
self.box2.matrix.translate(100, 150)
self.box2.width = 50
self.box2.height = 50
self.box2.request_update()
self.line = Line()
self.head = self.line.handles()[0]
self.tail = self.line.handles()[-1]
self.tail.pos = 100, 100
self.canvas.add(self.line)
self.canvas.update_now()
self.view = GtkView()
self.view.canvas = self.canvas
self.win = Gtk.Window()
self.win.add(self.view)
self.view.show()
self.view.update()
self.win.show()
self.tool = ConnectHandleTool(self.view)
示例3: test_resize_se
# 需要導入模塊: from gaphas.examples import Box [as 別名]
# 或者: from gaphas.examples.Box import request_update [as 別名]
def test_resize_se(self):
"""
Test resizing of element by dragging it SE handle.
"""
canvas = Canvas()
box = Box()
handles = box.handles()
canvas.add(box)
h_nw, h_ne, h_se, h_sw = handles
assert h_nw is handles[NW]
assert h_ne is handles[NE]
assert h_sw is handles[SW]
assert h_se is handles[SE]
# to see how many solver was called:
# GAPHAS_TEST_COUNT=3 nosetests -s --with-prof --profile-restrict=gaphas gaphas/tests/test_element.py | grep -e '\<solve\>' -e dirty
count = getenv('GAPHAS_TEST_COUNT')
if count:
count = int(count)
else:
count = 1
for i in range(count):
h_se.pos.x += 100 # h.se.{x,y} = 10, now
h_se.pos.y += 100
box.request_update()
canvas.update()
self.assertEquals(110 * count, h_se.pos.x) # h_se changed above, should remain the same
self.assertEquals(110 * count, float(h_se.pos.y))
self.assertEquals(110 * count, float(h_ne.pos.x))
self.assertEquals(110 * count, float(h_sw.pos.y))