| 1 |
:mod:`!curses.panel` --- A panel stack extension for curses |
| 2 |
=========================================================== |
| 3 |
|
| 4 |
.. module:: curses.panel |
| 5 |
:synopsis: A panel stack extension that adds depth to curses windows. |
| 6 |
|
| 7 |
.. sectionauthor:: A.M. Kuchling <[email protected]> |
| 8 |
|
| 9 |
-------------- |
| 10 |
|
| 11 |
Panels are windows with the added feature of depth, so they can be stacked on |
| 12 |
top of each other, and only the visible portions of each window will be |
| 13 |
displayed. Panels can be added, moved up or down in the stack, and removed. |
| 14 |
|
| 15 |
|
| 16 |
.. _cursespanel-functions: |
| 17 |
|
| 18 |
Functions |
| 19 |
--------- |
| 20 |
|
| 21 |
The module :mod:`!curses.panel` defines the following exception: |
| 22 |
|
| 23 |
|
| 24 |
.. exception:: error |
| 25 |
|
| 26 |
Exception raised when a curses panel library function returns an error. |
| 27 |
|
| 28 |
|
| 29 |
The module :mod:`!curses.panel` defines the following functions: |
| 30 |
|
| 31 |
|
| 32 |
.. function:: bottom_panel() |
| 33 |
|
| 34 |
Returns the bottom panel in the panel stack. |
| 35 |
|
| 36 |
|
| 37 |
.. function:: new_panel(win) |
| 38 |
|
| 39 |
Returns a panel object, associating it with the given window *win* and |
| 40 |
placing the new panel on top of the panel stack. Be aware |
| 41 |
that you need to keep the returned panel object referenced explicitly. If you |
| 42 |
don't, the panel object is garbage collected and removed from the panel stack. |
| 43 |
|
| 44 |
|
| 45 |
.. function:: top_panel() |
| 46 |
|
| 47 |
Returns the top panel in the panel stack. |
| 48 |
|
| 49 |
|
| 50 |
.. function:: update_panels() |
| 51 |
|
| 52 |
Updates the virtual screen after changes in the panel stack. This does not call |
| 53 |
:func:`curses.doupdate`, so you'll have to do this yourself. |
| 54 |
|
| 55 |
|
| 56 |
.. _curses-panel-objects: |
| 57 |
|
| 58 |
Panel objects |
| 59 |
------------- |
| 60 |
|
| 61 |
.. raw:: html |
| 62 |
|
| 63 |
<!-- Keep the old URL fragments working (see gh-89554) --> |
| 64 |
<span id='curses.panel.Panel.above'></span> |
| 65 |
<span id='curses.panel.Panel.below'></span> |
| 66 |
<span id='curses.panel.Panel.bottom'></span> |
| 67 |
<span id='curses.panel.Panel.hidden'></span> |
| 68 |
<span id='curses.panel.Panel.hide'></span> |
| 69 |
<span id='curses.panel.Panel.move'></span> |
| 70 |
<span id='curses.panel.Panel.replace'></span> |
| 71 |
<span id='curses.panel.Panel.set_userptr'></span> |
| 72 |
<span id='curses.panel.Panel.show'></span> |
| 73 |
<span id='curses.panel.Panel.top'></span> |
| 74 |
<span id='curses.panel.Panel.userptr'></span> |
| 75 |
<span id='curses.panel.Panel.window'></span> |
| 76 |
|
| 77 |
.. class:: panel |
| 78 |
|
| 79 |
Panel objects, as returned by :func:`new_panel` above, are windows with a |
| 80 |
stacking order. There's always a window associated with a panel which |
| 81 |
determines the content, while the panel methods are responsible for the |
| 82 |
window's depth in the panel stack. |
| 83 |
|
| 84 |
Panel objects have the following methods: |
| 85 |
|
| 86 |
|
| 87 |
.. method:: panel.above() |
| 88 |
|
| 89 |
Returns the panel above the current panel. |
| 90 |
|
| 91 |
|
| 92 |
.. method:: panel.below() |
| 93 |
|
| 94 |
Returns the panel below the current panel. |
| 95 |
|
| 96 |
|
| 97 |
.. method:: panel.bottom() |
| 98 |
|
| 99 |
Push the panel to the bottom of the stack. |
| 100 |
|
| 101 |
|
| 102 |
.. method:: panel.hidden() |
| 103 |
|
| 104 |
Returns ``True`` if the panel is hidden (not visible), ``False`` otherwise. |
| 105 |
|
| 106 |
|
| 107 |
.. method:: panel.hide() |
| 108 |
|
| 109 |
Hide the panel. This does not delete the object, it just makes the window on |
| 110 |
screen invisible. |
| 111 |
|
| 112 |
|
| 113 |
.. method:: panel.move(y, x) |
| 114 |
|
| 115 |
Move the panel to the screen coordinates ``(y, x)``. |
| 116 |
|
| 117 |
|
| 118 |
.. method:: panel.replace(win) |
| 119 |
|
| 120 |
Change the window associated with the panel to the window *win*. |
| 121 |
|
| 122 |
|
| 123 |
.. method:: panel.set_userptr(obj) |
| 124 |
|
| 125 |
Set the panel's user pointer to *obj*. This is used to associate an arbitrary |
| 126 |
piece of data with the panel, and can be any Python object. |
| 127 |
|
| 128 |
|
| 129 |
.. method:: panel.show() |
| 130 |
|
| 131 |
Display the panel (which might have been hidden), placing it on top of |
| 132 |
the panel stack. |
| 133 |
|
| 134 |
|
| 135 |
.. method:: panel.top() |
| 136 |
|
| 137 |
Push panel to the top of the stack. |
| 138 |
|
| 139 |
|
| 140 |
.. method:: panel.userptr() |
| 141 |
|
| 142 |
Returns the user pointer for the panel. This might be any Python object. |
| 143 |
|
| 144 |
|
| 145 |
.. method:: panel.window() |
| 146 |
|
| 147 |
Returns the window object associated with the panel. |
| 148 |
|