- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Creating a LabelFrame inside a Tkinter Canvas
Tkinter provides many built-in widgets which can be used to create highlevel desktop applications. The LabelFrame widget is one of them, which allows the users to add a labelled frame. The Label is another widget in the LabelFrame, which is used to add text or images in a frame or any container.
There are two main components of the LabelFrame widget,
The Title Bar (also known as the text of the LabelFrame widget).
The content (the content of the LabelFrame widget. You can add an image, or text as the content inside the LabelFrame widget.)
To define a LabelFrame widget, you’ll need to define the constructor of the LabelFrame(root) widget.
Example
Here is a working example of the LabelFrame widget in which we will add some text as the content of the LabelFrame widget.
# Import the required libraries from tkinter import * # Create an instance of tkinter frame or window win = Tk() # Set the size of the window win.geometry("700x350") # Create a canvas widget canvas= Canvas(win) canvas.pack() # Create a LabelFrame widget lf = LabelFrame(canvas,text= "Welcome Window") # Add a label in the labelFrame widget label= Label(lf, text= "This text is inside the LabelFrame.") label.config(font= 'Arial 12') label.pack(padx=20, pady=20) lf.pack() win.mainloop()
Output
Running the above code will display a window that contains a LabelFrame widget and some text inside it.
- Related Articles
- How to add text inside a Tkinter Canvas?
- Set style for Labelframe in Python Tkinter
- Creating a Dropdown Menu using Tkinter
- Creating a Browse Button with Tkinter
- Creating a table look-a-like using Tkinter
- Creating a button in tkinter in Python
- Creating a Frameless window in Python Tkinter
- Creating a Transparent window in Python Tkinter
- Creating a prompt dialog box using Tkinter?
- Create a text inside circles in HTML5 Canvas
- How to create a Button on a Tkinter Canvas?
- How to draw a line on a Tkinter canvas?
- Creating scrollable Listbox within a grid using Tkinter
- How to make a Tkinter canvas rectangle transparent?
- How to move a Tkinter canvas with Mouse?
