/usr/share/doc/python-gtk2-tutorial/html/sec-AspectFrames.html is in python-gtk2-tutorial 2.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>10.6. Aspect Frames</title><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="PyGTK 2.0 Tutorial"><link rel="up" href="ch-ContainerWidgets.html" title="Chapter 10. Container Widgets"><link rel="previous" href="sec-Frames.html" title="10.5. Frames"><link rel="next" href="sec-PanedWindowWidgets.html" title="10.7. Paned Window Widgets"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">10.6. Aspect Frames</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="sec-Frames.html">Prev</a> </td><th width="60%" align="center">Chapter 10. Container Widgets</th><td width="20%" align="right"> <a accesskey="n" href="sec-PanedWindowWidgets.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec-AspectFrames"></a>10.6. Aspect Frames</h2></div></div><div></div></div><p>The aspect frame widget is like a frame widget, except that it
also enforces the aspect ratio (that is, the ratio of the width to the
height) of the child widget to have a certain value, adding extra space if
necessary. This is useful, for instance, if you want to preview a larger
image. The size of the preview should vary when the user resizes the window,
but the aspect ratio needs to always match the original image.</p><p>To create a new aspect frame use:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
aspect_frame = gtk.AspectFrame(<b class="parameter"><tt>label</tt></b>=None, <b class="parameter"><tt>xalign</tt></b>=0.5, <b class="parameter"><tt>yalign</tt></b>=0.5, <b class="parameter"><tt>ratio</tt></b>=1.0, <b class="parameter"><tt>obey_child</tt></b>=TRUE)
</pre></td></tr></table><p><i class="parameter"><tt>label</tt></i> specifies the text to be displayed
as the label. <i class="parameter"><tt>xalign</tt></i> and
<i class="parameter"><tt>yalign</tt></i> specify alignment as with <a href="http://www.pygtk.org/pygtk2reference/class-gtkalignment.html" target="_top"><tt class="classname">gtk.Alignment</tt></a>
widgets. If <i class="parameter"><tt>obey_child</tt></i> is <tt class="literal">TRUE</tt>,
the aspect ratio of a child widget will match the aspect ratio of the ideal
size it requests. Otherwise, it is given by
<i class="parameter"><tt>ratio</tt></i>.</p><p>To change the options of an existing aspect frame, you can
use:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
aspect_frame.set(<b class="parameter"><tt>xalign</tt></b>=0.0, <b class="parameter"><tt>yalign</tt></b>=0.0, <b class="parameter"><tt>ratio</tt></b>=1.0, <b class="parameter"><tt>obey_child</tt></b>=TRUE)
</pre></td></tr></table><p>As an example, the <a href="examples/aspectframe.py" target="_top"><span><b class="command">aspectframe.py</b></span></a>
program uses an <tt class="classname">AspectFrame</tt> to present a drawing area
whose aspect ratio will always be 2:1, no matter how the user resizes the
top-level window.
<a href="sec-AspectFrames.html#aspectframefig" title="Figure 10.5. Aspect Frame Example">Figure 10.5, “Aspect Frame Example”</a> illustrates the display of the
program:</p><div class="figure"><a name="aspectframefig"></a><p class="title"><b>Figure 10.5. Aspect Frame Example</b></p><div class="mediaobject" align="center"><img src="figures/aspectframe.png" align="middle" alt="Aspect Frame Example"></div></div><p>The source code for <a href="examples/aspectframe.py" target="_top"><span><b class="command">aspectframe.py</b></span></a>
is:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
1 #!/usr/bin/env python
2
3 # example aspectframe.py
4
5 import pygtk
6 pygtk.require('2.0')
7 import gtk
8
9 class AspectFrameExample:
10 def __init__(self):
11 window = gtk.Window(gtk.WINDOW_TOPLEVEL);
12 window.set_title("Aspect Frame")
13 window.connect("destroy", lambda x: gtk.main_quit())
14 window.set_border_width(10)
15
16 # Create an aspect_frame and add it to our toplevel window
17 aspect_frame = gtk.AspectFrame("2x1", # label
18 0.5, # center x
19 0.5, # center y
20 2, # xsize/ysize = 2
21 False) # ignore child's aspect
22 window.add(aspect_frame)
23 aspect_frame.show()
24
25 # Now add a child widget to the aspect frame
26 drawing_area = gtk.DrawingArea()
27
28 # Ask for a 200x200 window, but the AspectFrame will give us a 200x100
29 # window since we are forcing a 2x1 aspect ratio
30 drawing_area.set_size_request(200, 200)
31 aspect_frame.add(drawing_area)
32 drawing_area.show()
33 window.show()
34
35 def main():
36 gtk.main()
37 return 0
38
39 if __name__ == "__main__":
40 AspectFrameExample()
41 main()
</pre></td></tr></table></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sec-Frames.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch-ContainerWidgets.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sec-PanedWindowWidgets.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">10.5. Frames </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 10.7. Paned Window Widgets</td></tr></table></div></body></html>
|