Gtk.Frame
Gtk.Frame — A bin with a decorative frame and optional label
Object Hierarchy:
GObject
╰── GInitiallyUnowned
╰── Gtk.Widget
╰── Gtk.Container
╰── Gtk.Bin
╰── Gtk.Frame
╰── Gtk.AspectFrame
Functions:
- new
(label:str=None) -> Gtk.Widget
- set_label
(self, label:str=None)
- set_label_widget
(self, label_widget:Gtk.Widget=None)
- set_label_align
(self, xalign:float, yalign:float)
- set_shadow_type
(self, type:Gtk.ShadowType)
- get_label
(self) -> str
- get_label_align
(self) -> xalign:float, yalign:float
- get_label_widget
(self) -> Gtk.Widget or None
- get_shadow_type
(self) -> Gtk.ShadowType
Description:
The frame widget is a Gtk.Bin
that surrounds its child with a decorative frame and an optional label.
If present, the label is drawn in a gap in the top side of the frame. The position of the label can be controlled with Gtk.Frame::set_label_align()
.
Gtk.Frame as Gtk.Buildable:
The Gtk.Frame
implementation of the Gtk.Buildable interface supports placing a child in the label position by specifying label
as the type
attribute of a <child>
element. A normal content child can be specified without specifying a <child>
type attribute.
An example of a UI definition fragment with Gtk.Frame:
<object class="GtkFrame">
<child type="label">
<object class="GtkLabel" id="frame-label"/>
</child>
<child>
<object class="GtkEntry" id="frame-content"/>
</child>
</object>
Function Details:
new()
new (label:str=None) -> Gtk.Widget
Creates a new Gtk.Frame
, with optional label label
.If label
is None
, the label is omitted.
- Returns:
a new
Gtk.Frame
widget
set_label()
set_label (self, label:str=None)
Sets the text of the label. If label
is None
,the current label is removed.
set_label_widget()
set_label_widget (self, label_widget:Gtk.Widget=None)
Sets the label widget for the frame. This is the widget thatwill appear embedded in the top edge of the frame as atitle.
set_label_align()
set_label_align (self, xalign:float, yalign:float)
Sets the alignment of the frame widget’s label. Thedefault values for a newly created frame are 0.0 and 0.5.
set_shadow_type()
set_shadow_type (self, type:Gtk.ShadowType)
Sets the shadow type for frame
.
get_label()
get_label (self) -> str
If the frame’s label widget is a Gtk.Label
, returns thetext in the label widget. (The frame will have a Gtk.Label
for the label widget if a non-None
argument was passedto Gtk.Frame:new()
.)
- Returns:
the text in the label, or
None
if therewas no label widget or the lable widget was notaGtk.Label
. This string is owned by GTK+ andmust not be modified or freed.
get_label_align()
get_label_align (self) -> xalign:float, yalign:float
Retrieves the X and Y alignment of the frame’s label. SeeGtk.Frame:set_label_align()
.
get_label_widget()
get_label_widget (self) -> Gtk.Widget or None
Retrieves the label widget for the frame. SeeGtk.Frame:set_label_widget()
.
- Returns:
the label widget, or
None
ifthere is none.
get_shadow_type()
get_shadow_type (self) -> Gtk.ShadowType
Retrieves the shadow type of the frame. SeeGtk.Frame:set_shadow_type()
.
- Returns: the current shadow type of the frame.
Example:
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class Frame(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self)
self.set_title("Frame")
self.set_default_size(200, 200)
self.set_border_width(5)
self.connect("destroy", Gtk.main_quit)
frame = Gtk.Frame(label="Frame")
self.add(frame)
label = Gtk.Label("Label in a Frame")
frame.add(label)
window = Frame()
window.show_all()
Gtk.main()