File: wx.lib.agw.pycollapsiblepane.txt

package info (click to toggle)
wxpython4.0 4.0.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 211,112 kB
  • sloc: cpp: 888,355; python: 223,130; makefile: 52,087; ansic: 45,780; sh: 3,012; xml: 1,534; perl: 264
file content (189 lines) | stat: -rw-r--r-- 7,060 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2018 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc

.. module:: wx.lib.agw.pycollapsiblepane

.. currentmodule:: wx.lib.agw.pycollapsiblepane

.. highlight:: python



.. _wx.lib.agw.pycollapsiblepane:

==========================================================================================================================================
|phoenix_title|  **wx.lib.agw.pycollapsiblepane**
==========================================================================================================================================

:class:`~wx.lib.agw.pycollapsiblepane.PyCollapsiblePane` is a container with an embedded button-like control which
can be used by the user to collapse or expand the pane's contents.


Description
===========

A collapsible pane is a container with an embedded button-like control which
can be used by the user to collapse or expand the pane's contents.
Once constructed you should use the :meth:`~PyCollapsiblePane.GetPane` function to access the pane and
add your controls inside it (i.e. use the window returned from :meth:`~PyCollapsiblePane.GetPane` as the
parent for the controls which must go in the pane, **not** the :class:`PyCollapsiblePane`
itself!).

:note: Note that because of its nature of control which can dynamically (and drastically)
 change its size at run-time under user-input, when putting :class:`PyCollapsiblePane`
 inside a :class:`wx.Sizer` you should be careful to add it with a proportion value of zero;
 this is because otherwise all other windows with non-null proportion values would
 automatically get resized each time the user expands or collapse the pane window
 resulting usually in a weird, flickering effect.


Usage
=====

Usage example::

    import wx
    import wx.lib.agw.pycollapsiblepane as PCP

    class MyFrame(wx.Frame):

        def __init__(self, parent):

            wx.Frame.__init__(self, parent, -1, "PyCollapsiblePane Demo")

            panel = wx.Panel(self)

            title = wx.StaticText(panel, label="PyCollapsiblePane")
            title.SetFont(wx.Font(18, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
            title.SetForegroundColour("blue")

            self.cp = cp = PCP.PyCollapsiblePane(panel, label="Some Data",
                                                 style=wx.CP_DEFAULT_STYLE | wx.CP_NO_TLW_RESIZE)

            self.MakePaneContent(cp.GetPane())

            sizer = wx.BoxSizer(wx.VERTICAL)
            sizer.Add(title, 0, wx.ALL, 25)
            sizer.Add(cp, 0, wx.RIGHT | wx.LEFT | wx.EXPAND, 25)

            panel.SetSizer(sizer)
            sizer.Layout()


        def MakePaneContent(self, pane):
            ''' Just makes a few controls to put on `PyCollapsiblePane`. '''

            nameLbl = wx.StaticText(pane, -1, "Name:")
            name = wx.TextCtrl(pane, -1, "");

            addrLbl = wx.StaticText(pane, -1, "Address:")
            addr1 = wx.TextCtrl(pane, -1, "");
            addr2 = wx.TextCtrl(pane, -1, "");

            cstLbl = wx.StaticText(pane, -1, "City, State, Zip:")
            city  = wx.TextCtrl(pane, -1, "", size=(150,-1));
            state = wx.TextCtrl(pane, -1, "", size=(50,-1));
            zip   = wx.TextCtrl(pane, -1, "", size=(70,-1));

            addrSizer = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
            addrSizer.AddGrowableCol(1)
            addrSizer.Add(nameLbl, 0,
                          wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
            addrSizer.Add(name, 0, wx.EXPAND)
            addrSizer.Add(addrLbl, 0,
                          wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
            addrSizer.Add(addr1, 0, wx.EXPAND)
            addrSizer.Add((5,5))
            addrSizer.Add(addr2, 0, wx.EXPAND)

            addrSizer.Add(cstLbl, 0,
                          wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)

            cstSizer = wx.BoxSizer(wx.HORIZONTAL)
            cstSizer.Add(city, 1)
            cstSizer.Add(state, 0, wx.LEFT | wx.RIGHT, 5)
            cstSizer.Add(zip)
            addrSizer.Add(cstSizer, 0, wx.EXPAND)

            border = wx.BoxSizer()
            border.Add(addrSizer, 1, wx.EXPAND | wx.ALL, 5)
            pane.SetSizer(border)


    # our normal wxApp-derived class, as usual

    app = wx.App(0)

    frame = MyFrame(None)
    app.SetTopWindow(frame)
    frame.Show()

    app.MainLoop()



Window Styles
=============

This class supports the following window styles:

==================== =========== ==================================================
Window Styles        Hex Value   Description
==================== =========== ==================================================
``CP_NO_TLW_RESIZE``         0x2 By default :class:`PyCollapsiblePane` resizes the top level window containing it when its own size changes. This allows to easily implement dialogs containing an optionally shown part, for example, and so is the default behaviour but can be inconvenient in some specific cases -- use this flag to disable this automatic parent resizing then.
``CP_GTK_EXPANDER``          0x4 Uses a GTK expander instead of a button.
``CP_USE_STATICBOX``         0x8 Uses a :class:`StaticBox` around :class:`PyCollapsiblePane`.
``CP_LINE_ABOVE``           0x10 Draws a line above :class:`PyCollapsiblePane`.
==================== =========== ==================================================


Events Processing
=================

This class processes the following events:

=============================== ==================================================
Event Name                      Description
=============================== ==================================================
``EVT_COLLAPSIBLEPANE_CHANGED`` The user showed or hid the collapsible pane.
=============================== ==================================================


License And Version
===================

:class:`PyCollapsiblePane` is distributed under the wxPython license.

Latest Revision: Andrea Gavana @ 19 Dec 2012, 21.00 GMT

Version 0.5


|class_summary| Classes Summary
===============================

================================================================================ ================================================================================
:ref:`~wx.lib.agw.pycollapsiblepane.GTKExpander`                                 A :class:`GTKExpander` allows the user to hide or show its child by clicking on an expander
:ref:`~wx.lib.agw.pycollapsiblepane.PyCollapsiblePane`                           :class:`PyCollapsiblePane` is a container with an embedded button-like control which
================================================================================ ================================================================================


|


.. toctree::
   :maxdepth: 1
   :hidden:

   wx.lib.agw.pycollapsiblepane.GTKExpander
   wx.lib.agw.pycollapsiblepane.PyCollapsiblePane