Gtk.Revealer
Gtk.Revealer — Hide and show with animation
Object Hierarchy:
GObject
╰── GInitiallyUnowned
╰── Gtk.Widget
╰── Gtk.Container
╰── Gtk.Bin
╰── Gtk.Revealer
See also:
Functions:
- new
() -> Gtk.Widget
- get_reveal_child
(self) -> bool
- set_reveal_child
(self, reveal_child:bool)
- get_child_revealed
(self) -> bool
- get_transition_duration
(self) -> int
- set_transition_duration
(self, duration:int)
- get_transition_type
(self) -> Gtk.RevealerTransitionType
- set_transition_type
(self, transition:Gtk.RevealerTransitionType)
Description:
The Gtk.Revealer
widget is a container which animates the transition of its child from invisible to visible.
The style of transition can be controlled with Gtk.Revealer::set_transition_type()
.
These animations respect the Gtk.Settings:gtk-enable-animations setting.
The Gtk.Revealer
widget was added in GTK+ 3.10.
Function Details:
new()
new () -> Gtk.Widget
Creates a new Gtk.Revealer
.
Returns: a newly created Gtk.Revealer
Since: 3.10
get_reveal_child()
get_reveal_child (self) -> bool
Returns whether the child is currentlyrevealed. See Gtk.Revealer:set_reveal_child()
.
This function returns True
as soon as the transitionis to the revealed state is started. To learn whetherthe child is fully revealed (ie the transition is completed),use Gtk.Revealer:get_child_revealed()
.
Returns:
True
if the child is revealed.Since: 3.10
set_reveal_child()
set_reveal_child (self, reveal_child:bool)
Tells the Gtk.Revealer
to reveal or conceal its child.
The transition will be animated with the currenttransition type of revealer
.
- Since: 3.10
get_child_revealed()
get_child_revealed (self) -> bool
Returns whether the child is fully revealed, ie wetherthe transition to the revealed state is completed.
Returns:
True
if the child is fully revealedSince: 3.10
get_transition_duration()
get_transition_duration (self) -> int
Returns the amount of time (in milliseconds) thattransitions will take.
Returns: the transition duration
Since: 3.10
set_transition_duration()
set_transition_duration (self, duration:int)
Sets the duration that transitions will take.
- Since: 3.10
get_transition_type()
get_transition_type (self) -> Gtk.RevealerTransitionType
Gets the type of animation that will be usedfor transitions in revealer
.
Returns: the current transition type of
revealer
Since: 3.10
set_transition_type()
set_transition_type (self, transition:Gtk.RevealerTransitionType)
Sets the type of animation that will be used fortransitions in revealer
. Available types includevarious kinds of fades and slides.
- Since: 3.10
Example:
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class Revealer(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self)
self.connect("destroy", Gtk.main_quit)
grid = Gtk.Grid()
self.add(grid)
self.revealer = Gtk.Revealer()
self.revealer.set_reveal_child(True)
grid.attach(self.revealer, 0, 0, 1, 1)
label = Gtk.Label("Label in a Revealer")
self.revealer.add(label)
button = Gtk.Button("Reveal")
button.connect("clicked", self.on_reveal_clicked)
grid.attach(button, 0, 1, 1, 1)
def on_reveal_clicked(self, button):
reveal = self.revealer.get_reveal_child()
self.revealer.set_reveal_child(not reveal)
window = Revealer()
window.show_all()
Gtk.main()