Drawer(size, parentWindow, minSize=None, maxSize=None, preferredEdge='left', forceEdge=False, leadingOffset=20, trailingOffset=20)¶
A drawer attached to a window. Drawers are capable of containing controls.
To add a control to a drawer, simply set it as an attribute of the drawer.:
from vanilla import * class DrawerDemo(object): def __init__(self): self.w = Window((200, 200)) self.w.button = Button((10, 10, -10, 20), "Toggle Drawer", callback=self.toggleDrawer) self.d = Drawer((100, 150), self.w) self.d.textBox = TextBox((10, 10, -10, -10), "This is a drawer.") self.w.open() self.d.open() def toggleDrawer(self, sender): self.d.toggle() DrawerDemo()
No special naming is required for the attributes. However, each attribute must have a unique name.
size Tuple of form (width, height) representing the size of the drawer.
parentWindow The window that the drawer should be attached to.
minSize Tuple of form (width, height) representing the minimum size of the drawer.
maxSize Tuple of form (width, height) representing the maximum size of the drawer.
preferredEdge The preferred edge of the window that the drawe should be attached to. If the drawer cannot be opened on the preferred edge, it will be opened on the opposite edge. The options are:
“left” “right” “top” “bottom”
forceEdge Boolean representing if the drawer should always be opened on the preferred edge.
leadingOffset Distance between the top or left edge of the drawer and the parent window.
trailingOffset Distance between the bottom or right edge of the drawer and the parent window.
Close the drawer.
Enable or disable the object. onOff should be a boolean.
Return the NSDrawer that this object wraps.
The position and size of the object as a tuple of form (left, top, width, height).
Return True if the drawer is open, False if it is closed.
Return a bool indicting if the object is visible or not.
Move the object by x units and y units.
Open the drawer.
Change the size of the object to width and height.
Set the postion and size of the object.
posSize A tuple of form (left, top, width, height).
Show or hide the object.
onOff A boolean value representing if the object should be shown or not.
Open the drawer if it is closed. Close it if it is open.