summaryrefslogtreecommitdiff
path: root/urwid/canvas.py
diff options
context:
space:
mode:
authorIan Ward <ian@excess.org>2011-09-21 11:11:04 -0400
committerIan Ward <ian@excess.org>2011-09-21 11:11:04 -0400
commit1e80051bcbe488a434205e057b7ff00126b8aabf (patch)
tree8750dc184b803c274c26d82ae46cd29369929e58 /urwid/canvas.py
parent380ee029538530cbf12ff12f132934b8244f71e3 (diff)
downloadurwid-1e80051bcbe488a434205e057b7ff00126b8aabf.tar.gz
Canvas: new set_pop_up() and get_pop_up() methods
Diffstat (limited to 'urwid/canvas.py')
-rw-r--r--urwid/canvas.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/urwid/canvas.py b/urwid/canvas.py
index 3ed0bf7..0f0d85d 100644
--- a/urwid/canvas.py
+++ b/urwid/canvas.py
@@ -269,6 +269,31 @@ class Canvas(object):
self.coords["cursor"] = c + (None,) # data part
cursor = property(get_cursor, set_cursor)
+ def get_pop_up(self):
+ c = self.coords.get("pop up", None)
+ if not c:
+ return
+ return c
+ def set_pop_up(self, w, left, top, overlay_width, overlay_height):
+ """
+ This method adds pop-up information to the canvas. This information
+ is intercepted by a PopUpTarget widget higher in the chain to
+ display a pop-up at the given (left, top) position relative to the
+ current canvas.
+
+ w -- widget to use for the pop-up
+ left, top -- integer x, y position eg. (0, 1) would align the
+ pop-up with this widget's left side and put its top one row below
+ this widget's top
+ overlay_width, overlay_height -- width and height parameters for
+ the Overlay widget used to position the pop-up
+ """
+ if self.widget_info and self.cacheable:
+ raise self._finalized_error
+
+ self.coords["pop up"] = (left, top, (
+ w, overlay_width, overlay_height))
+
def translate_coords(self, dx, dy):
"""
Return coords shifted by (dx, dy).