- PyGTK - Drag and Drop
- PyGTK - Timeout
- PyGTK - Ruler Class
- PyGTK - Clipboard Class
- PyGTK - Calendar Class
- PyGTK - SpinButton Class
- PyGTK - DrawingArea Class
- PyGTK - Image Class
- PyGTK - Arrow Class
- PyGTK - Scrolledwindow Class
- PyGTK - Viewport Class
- PyGTK - ProgressBar Class
- PyGTK - Statusbar Class
- PyGTK - Paned Class
- PyGTK - TreeView Class
- PyGTK - AspectFrame Class
- PyGTK - Frame Class
- PyGTK - Notebook Class
- PyGTK - File Chooser Dialog
- PyGTK - Color Selection Dialog
- PyGTK - Font Selection Dialog
- PyGTK - AboutDialog Class
- PyGTK - MessageDialog Class
- PyGTK - Dialog Class
- PyGTK - Scrollbar Class
- PyGTK - Scale Class
- PyGTK - Range Class
- PyGTK - Adjustment Class
- PyGTK - Toolbar Class
- PyGTK - MenuBar, Menu & MenuItem
- PyGTK - RadioButton Class
- PyGTK - CheckButton Class
- PyGTK - ToggleButton Class
- PyGTK - ComboBox Class
- PyGTK - Layout Class
- PyGTK - EventBox Class
- PyGTK - Alignment Class
- PyGTK - ButtonBox Class
- PyGTK - Box Class
- PyGTK - Containers
- PyGTK - Event Handling
- PyGTK - Signal Handling
- PyGTK - Entry Class
- PyGTK - Label CLass
- PyGTK - Button Class
- PyGTK - Window Class
- PyGTK - Important Classes
- PyGTK - Hello World
- PyGTK - Environment
- PyGTK - Introduction
- PyGTK - Home
PyGTK Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
PyGTK - Layout Class
The gtk.Layout is a container widget similar to gtk.Fixed. Widgets are placed in Layout widget by specifying absolute coordinates. However, the Layout differs from fixed widget in the following ways −
The layout widget can have infinite width and height. The maximum value of width and height is pmited by the size of unsigned integer.
A gtk.DrawingArea widget can be enclosed in a layout container. The DrawingArea is a canvas on which 2D elements pke pne, rectangle etc. can be drawn.
In order to put the Layout container in the toplevel window of lesser dimensions, it can be associated with the scrollbars or can be placed in a ScrolledWindow.
The gtk.Layout class has the following constructor −
gtk.Layout(hadjustment = None, vadjustment = None)
The hadjustment and vadjustment properties represent an object having an adjustable bounded value.
The following table psts out the frequently used methods of the layout −
put(widget, x, y) | Places a child widget at the specified coordinates |
set_size(w, h) | Sets the size of the Layout container to the specified width and height |
The Layout object emits the set_scroll_adjustment signal when the adjustments associated with it are changed.
Example
In the following example, a Label is paced at the centre of a Layout container, which in turn is to be placed in a toplevel window of smaller size. Hence, it is first added to a ScrolledWindow and the ScrolledWindow is then added to the main window.
Observe the code −
import gtk class PyApp(gtk.Window): def __init__(self): super(PyApp, self).__init__() self.set_title("layout") self.set_size_request(300,200) self.set_position(gtk.WIN_POS_CENTER) sc = gtk.ScrolledWindow() lo = gtk.Layout() lo.set_size(400,400) button = gtk.Button("Press Me") lo.put(button, 125,200) sc.add(lo) self.add(sc) self.connect("destroy", gtk.main_quit) self.show_all() PyApp() gtk.main()
The above code will generate the following output −
Advertisements