File: wx.InfoBar.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 (448 lines) | stat: -rw-r--r-- 14,808 bytes parent folder | download
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
.. 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



.. _wx.InfoBar:

==========================================================================================================================================
|phoenix_title|  **wx.InfoBar**
==========================================================================================================================================

An info bar is a transient window shown at top or bottom of its parent window to display non-critical information to the user.          

This class provides another way to show messages to the user, intermediate between message boxes and status bar messages. The message boxes are modal and thus interrupt the users work flow and should be used sparingly for this reason. However status bar messages are often too easy not to notice at all. An info bar provides a way to present the messages which has a much higher chance to be noticed by the user but without being annoying. 

Info bar may show an icon (on the left), text message and, optionally, buttons allowing the user to react to the information presented. It always has a close button at the right allowing the user to dismiss it so it isn't necessary to provide a button just to close it. 

:ref:`wx.InfoBar`  calls its parent :meth:`wx.Window.Layout`   method and assumes that it will change the parent layout appropriately depending on whether the info bar itself is shown or hidden. Usually this is achieved by simply using a sizer for the parent window layout and adding :ref:`wx.InfoBar`  to this sizer as one of the items. Considering the usual placement of the info bars, normally this sizer should be a vertical :ref:`wx.BoxSizer`  and the bar its first or last element so the simplest possible example of using this class would be: ::

        class MyFrame(wx.Frame):

            def __init__(self, parent):

                wx.Frame.__init__(self, parent, title='InfoBar!')

                self.infoBar = wx.InfoBar(self)

                sizer = wx.BoxSizer(wx.VERTICAL)
                sizer.Add(self.infoBar, wx.SizerFlags().Expand())

                # ... add other frame controls to the sizer ...
                self.SetSizer(sizer)


            def SomeMethod(self):

                self.infoBar.ShowMessage("Something happened", wx.ICON_INFORMATION)



See the dialogs sample for more sophisticated examples. 

Currently this class is implemented generically (i.e. in the same platform-independent way for all ports) and also natively in wxGTK but the native implementation requires a recent  







         



.. versionadded:: 2.9.1 
     







.. seealso:: :ref:`wx.StatusBar`, :ref:`wx.MessageDialog`  







|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>InfoBar</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.InfoBar_inheritance.png" alt="Inheritance diagram of InfoBar" usemap="#dummy" class="inheritance"/></center>
   </div>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.Control.html" title="wx.Control" alt="" coords="60,237,148,267"/> <area shape="rect" id="node6" href="wx.InfoBar.html" title="wx.InfoBar" alt="" coords="61,315,147,344"/> <area shape="rect" id="node2" href="wx.Window.html" title="wx.Window" alt="" coords="59,160,148,189"/> <area shape="rect" id="node3" href="wx.Object.html" title="wx.Object" alt="" coords="5,5,87,35"/> <area shape="rect" id="node5" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="48,83,159,112"/> <area shape="rect" id="node4" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="112,5,213,35"/> </map> 
   </p>

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.InfoBar.__init__`                                                     Default constructor.
:meth:`~wx.InfoBar.AddButton`                                                    Add a button to be shown in the info bar.
:meth:`~wx.InfoBar.Create`                                                       Create the info bar window.
:meth:`~wx.InfoBar.Dismiss`                                                      Hide the info bar window.
:meth:`~wx.InfoBar.GetEffectDuration`                                            Return the effect animation duration currently used.
:meth:`~wx.InfoBar.GetHideEffect`                                                Return the effect currently used for hiding the bar.
:meth:`~wx.InfoBar.GetShowEffect`                                                Return the effect currently used for showing the bar.
:meth:`~wx.InfoBar.RemoveButton`                                                 Remove a button previously added by :meth:`~InfoBar.AddButton` .
:meth:`~wx.InfoBar.SetEffectDuration`                                            Set the duration of the animation used when showing or hiding the bar.
:meth:`~wx.InfoBar.SetFont`                                                      Overridden base class methods changes the font of the text message.
:meth:`~wx.InfoBar.SetShowHideEffects`                                           Set the effects to use when showing and hiding the bar.
:meth:`~wx.InfoBar.ShowMessage`                                                  Show a message in the bar.
================================================================================ ================================================================================


|


|property_summary| Properties Summary
=====================================

================================================================================ ================================================================================
:attr:`~wx.InfoBar.EffectDuration`                                               See :meth:`~wx.InfoBar.GetEffectDuration` and :meth:`~wx.InfoBar.SetEffectDuration`
:attr:`~wx.InfoBar.HideEffect`                                                   See :meth:`~wx.InfoBar.GetHideEffect`
:attr:`~wx.InfoBar.ShowEffect`                                                   See :meth:`~wx.InfoBar.GetShowEffect`
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: wx.InfoBar(Control)

   **Possible constructors**::

       InfoBar()
       
       InfoBar(parent, winid=ID_ANY)
       
   
   An info bar is a transient window shown at top or bottom of its parent
   window to display non-critical information to the user.



   .. method:: __init__(self, *args, **kw)



      |overload| Overloaded Implementations:

      **~~~**

      
      **__init__** `(self)`
      
      Default constructor.                  
      
      Use :meth:`Create`   for the objects created using this constructor.                   
      
      
      
      
      **~~~**

      
      **__init__** `(self, parent, winid=ID_ANY)`
      
      Constructor creating the info bar window.                  
      
                      
      
      
      :param `parent`: 
      :type `parent`: wx.Window
      :param `winid`: 
      :type `winid`: wx.WindowID
      
      
      
      
      
      
      .. seealso:: :meth:`Create`     
      
      
      
      
      
      
      
      **~~~**






   .. method:: AddButton(self, btnid, label="")

      Add a button to be shown in the info bar.                  

      The button added by this method will be shown to the right of the text (in ``LTR`` layout), with each successive button being added to the right of the previous one. If any buttons are added to the info bar using this method, the default "Close" button is not shown as it is assumed that the extra buttons already allow the user to close it. 

      Clicking the button will generate a normal ``EVT_COMMAND_BUTTON_CLICKED`` event which can be handled as usual. The default handler in :ref:`wx.InfoBar`  itself closes the window whenever a button in it is clicked so if you wish the info bar to be hidden when the button is clicked, simply call  ``event.Skip()``   in the button handler to let the base class handler do it (calling  :meth:`Dismiss`   explicitly works too, of course). On the other hand, if you don't skip the event, the info bar will remain opened so make sure to do it for at least some buttons to allow the user to close it. 

      Notice that the generic :ref:`wx.InfoBar`  implementation handles the button events itself and so they are not propagated to the info bar parent and you need to either inherit from :ref:`wx.InfoBar`  and handle them in your derived class or use :meth:`wx.EvtHandler.Connect` , as is done in the dialogs sample, to handle the button events in the parent frame. 




      :param `btnid`: Id of the button. It will be used in the button message clicking this button will generate.   
      :type `btnid`: wx.WindowID
      :param `label`: The label of the button. It may only be empty if  `btnid`  is one of the stock ids in which case the corresponding stock label (see :ref:`wx.GetStockLabel`) will be used.   
      :type `label`: string






                  





   .. method:: Create(self, parent, winid=ID_ANY)

      Create the info bar window.                  

      Notice that unlike most of the other Window-derived classes, :ref:`wx.InfoBar`  is created hidden and is only shown when :meth:`ShowMessage`   is called. This is more convenient as usually the info bar is created to be shown at some later time and not immediately and so creating it hidden avoids the need to call :meth:`Hide`   explicitly from the code using it. 

      This should be only called if the object was created using its default constructor. 




      :param `parent`: A valid parent window pointer.   
      :type `parent`: wx.Window
      :param `winid`: The id of the info bar window, usually unused as currently no events are generated by this class.   
      :type `winid`: wx.WindowID








      :rtype: `bool`



                  





   .. method:: Dismiss(self)

      Hide the info bar window.                  

      This method hides the window and lays out the parent window to account for its disappearance (unlike a simple :meth:`Hide` ).                   





   .. method:: GetEffectDuration(self)

      Return the effect animation duration currently used.                  

      :rtype: `int`








   .. method:: GetHideEffect(self)

      Return the effect currently used for hiding the bar.                  

      :rtype: :ref:`wx.ShowEffect`








   .. method:: GetShowEffect(self)

      Return the effect currently used for showing the bar.                  

      :rtype: :ref:`wx.ShowEffect`








   .. method:: RemoveButton(self, btnid)

      Remove a button previously added by :meth:`AddButton` .                  




      :param `btnid`: Id of the button to remove. If more than one button with the same id is used in the info bar (which is in any case not recommended), the last, i.e. most recently added, button with this id is removed.   
      :type `btnid`: wx.WindowID




                  





   .. method:: SetEffectDuration(self, duration)

      Set the duration of the animation used when showing or hiding the bar.                  

      By default, 500ms duration is used. 




      :param `duration`: Duration of the animation, in milliseconds.   
      :type `duration`: int




                  





   .. method:: SetFont(self, font)

      Overridden base class methods changes the font of the text message.                  

      :ref:`wx.InfoBar`  overrides this method to use the font passed to it for its text message part. By default a larger and bold version of the standard font is used. 

      This method is generic-only.                  


      :param `font`: 
      :type `font`: wx.Font




      :rtype: `bool`








   .. method:: SetShowHideEffects(self, showEffect, hideEffect)

      Set the effects to use when showing and hiding the bar.                  

      Either or both of the parameters can be set to ``wx.SHOW_EFFECT_NONE`` to disable using effects entirely. 

      By default, the info bar uses ``wx.SHOW_EFFECT_SLIDE_TO_BOTTOM`` effect for showing itself and ``wx.SHOW_EFFECT_SLIDE_TO_TOP`` for hiding if it is the first element of the containing sizer and reverse effects if it's the last one. If it is neither the first nor the last element, no effect is used to avoid the use of an inappropriate one and this function must be called if an effect is desired. 




      :param `showEffect`: The effect to use when showing the bar.   
      :type `showEffect`: wx.ShowEffect
      :param `hideEffect`: The effect to use when hiding the bar.   
      :type `hideEffect`: wx.ShowEffect






                  





   .. method:: ShowMessage(self, msg, flags=ICON_INFORMATION)

      Show a message in the bar.                  

      If the bar is currently hidden, it will be shown. Otherwise its message will be updated in place. 




      :param `msg`: The text of the message.   
      :type `msg`: string
      :param `flags`: One of ``wx.ICON_NONE``, ``wx.ICON_INFORMATION`` (default), ``wx.ICON_QUESTION``, ``wx.ICON_WARNING`` or ``wx.ICON_ERROR`` values. These flags have the same meaning as in :ref:`wx.MessageDialog`  for the generic version, i.e. show (or not, in case of ``wx.ICON_NONE``) the corresponding icon in the bar but can be interpreted by the native versions. For example, the GTK+ native implementation doesn't show icons at all but uses this parameter to select the appropriate background colour for the notification.   
      :type `flags`: int






                  





   .. attribute:: EffectDuration

      See :meth:`~wx.InfoBar.GetEffectDuration` and :meth:`~wx.InfoBar.SetEffectDuration`


   .. attribute:: HideEffect

      See :meth:`~wx.InfoBar.GetHideEffect`


   .. attribute:: ShowEffect

      See :meth:`~wx.InfoBar.GetShowEffect`