- 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 - Containers
PyGTK pbrary provides different container classes to control the placement of widgets inside a window. The easiest way is to use a fixed container class and place a widget inside it by specifying its absolute coordinates measured in pixels.
Let us now follow these steps −
Step 1 − Declare an object of the fixed class
fixed = gtk.Fixed()
Step 2 − Create a button widget and add it to the fixed container by using put() method which needs x and y coordinates. Here, the button will be placed at (100,100) position.
btn = gtk.Button("Hello") fixed.put(btn, 100,100)
Step 3 − You can place multiple controls in the fixed container. And, add it to the top-level window and invoke the show_all() method
self.add(fixed) self.show_all()
This Absolute Layout, however, is not suitable because of the following reasons −
The position of the widget does not change even if the window is resized.
The appearance may not be uniform on different display devices with different resolutions.
Modification in the layout is difficult as it may need redesigning of the entire form.
The following is the original window −
The following is the resized window −
The position of the button is unchanged here.
PyGTK API provides container classes for enhanced management of positioning of widgets inside the container. The advantages of Layout managers over absolute positioning are −
Widgets inside the window are automatically resized.
Ensures uniform appearance on display devices with different resolutions.
Adding or removing widget dynamically is possible without having to redesign.
gtk.Container acts as the base class for the following classes −
gtk.ButtonBox
gtk.Box
gtk.Apgnment
gtk.EventBox
gtk.Table