How to Add Borders to a Frame in Python
Python is an interpretive programming language distributed as freeware. It is ideal for creating dynamic graphical applications. When programming in Python, you may need to fine-tune your graphical user interface by adding borders to a frame. In Python, frames are rectangular boxes used to group related widgets. For example, a frame may be a window holding a series of related buttons for a user to press, such as "Save", "Copy" and "Exit" buttons. You modify frames using the Python "Tkinter" module, the standard interface for the Python Tk GUI toolkit.
Instructions
-
-
1
Open your Python editor.
-
2
Load the Tkinter interface by typing:
from Tkinter import *
-
-
3
Define the frame in your code. For example, type:
frameWindow = Frame(title = "Example Window", height = 300, width = 300 )
In this example, Python creates a frame entitled "Example Window" and a window size of 300 by 300 pixels.
-
4
Add a border to your frame using the "bd" attribute. Continuing the example, add the following:
frameWindow = Frame(title = "Example Window", height = 300, width = 300, bd = 5 )
In this example, Python draws a black border five pixels wide around the window.
-
5
Change the border decoration from “flat” to “sunken,” “raised,” “groove” or “ridge” using the Relief attribute. For example, type:
frameWindow = Frame(title = "Example Window", height = 300, width = 300, bd = 5, relief = raised)
In this example, Python adds a raised border five pixels wide around the frame.
-
1