File tree 4 files changed +72
-0
lines changed
4 files changed +72
-0
lines changed Original file line number Diff line number Diff line change
1
+ import gi
2
+
3
+ gi .require_version ("Gtk" , "3.0" )
4
+ from gi .repository import Gtk
5
+
6
+
7
+ class ExpanderExample (Gtk .Window ):
8
+ def __init__ (self ):
9
+ Gtk .Window .__init__ (self , title = "Expander Demo" )
10
+
11
+ self .set_size_request (350 , 100 )
12
+
13
+ vbox = Gtk .Box (orientation = Gtk .Orientation .VERTICAL , spacing = 6 )
14
+ self .add (vbox )
15
+
16
+ text_expander = Gtk .Expander (
17
+ label = "This expander displays additional information"
18
+ )
19
+ text_expander .set_expanded (True )
20
+ vbox .add (text_expander )
21
+
22
+ msg = """
23
+ This message is quite long, complicated even:
24
+ - It has a list with a sublist:
25
+ - of 3 elements;
26
+ - taking several lines;
27
+ - with indentation.
28
+ """
29
+ details = Gtk .Label (label = msg )
30
+ text_expander .add (details )
31
+
32
+ widget_expander = Gtk .Expander (label = "Expand for more controls" )
33
+ vbox .add (widget_expander )
34
+
35
+ expander_hbox = Gtk .HBox ()
36
+ widget_expander .add (expander_hbox )
37
+
38
+ expander_hbox .add (Gtk .Label (label = "Text message" ))
39
+ expander_hbox .add (Gtk .Button (label = "Click me" ))
40
+
41
+ self .show_all ()
42
+
43
+
44
+ win = ExpanderExample ()
45
+ win .connect ("destroy" , Gtk .main_quit )
46
+ win .show_all ()
47
+ Gtk .main ()
Original file line number Diff line number Diff line change
1
+ Expander
2
+ ========
3
+
4
+ Expanders allow to dynamically hide or show information within a window or
5
+ dialog. An expander can take a single widget that will be displayed when
6
+ expanded.
7
+
8
+ Expanders remain expanded until clicked again. When the state of an expander
9
+ is changed, the "activate" signal is emitted.
10
+
11
+ An expander can be programmatically expanded or collapsed by passing `True` or
12
+ `False` to :meth:`Gtk.Expander.set_expanded`. Note that doing so causes the
13
+ "activate" signal to be emitted.
14
+
15
+ More than one widget, such as a :class:`Gtk.Label` and :class:`Gtk.Button`,
16
+ can be added by appending them to a :class:`Gtk.Box`.
17
+
18
+ Example
19
+ ^^^^^^^
20
+
21
+ .. image:: ../images/expander_example.png
22
+
23
+ .. literalinclude:: ../examples/expander_example.py
24
+ :linenos:
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ Contents:
43
43
label
44
44
entry
45
45
button_widgets
46
+ expander
46
47
progressbar
47
48
spinner
48
49
treeview
You can’t perform that action at this time.
0 commit comments