Using Image in Label - The Advantages of Learning Python Programming for Beginners: A Comprehensive Guide

Latest

Dive into the world of Python programming with our comprehensive resources

Music

logo

Saturday, January 14, 2023

Using Image in Label

 

In this article, we will see the use of image in the label that we add to our form.

We add the label image as below.

 

logo = tk.PhotoImage(file="D:\\starwarsss.png")

 

lbl1 = tk.Label(root, image=logo, width=700,height=700).pack(side="left",padx=10)

 

 


 

 

 

 

 

 

Figure 1

 

 

import tkinter as tk

 

root = tk.Tk()

root.title("Using image in label..bs")

root.geometry("1500x800")

 

logo = tk.PhotoImage(file="D:\\starwarsss.png")

 

lbl1 = tk.Label(root, image=logo, width=700,height=700).pack(side="left",padx=10)

 

exp = "Star Wars \n \n Star Wars is an American epic space opera[1] multimedia franchise created by George Lucas,\n which began with the eponymous 1977 film[b] and quickly became a worldwide pop-culture phenomenon.\n The franchise has been expanded into various films and other media,\n including television series, video games, novels, comic books,\n theme park attractions, and themed areas,\n comprising an all-encompassing fictional universe.[c] \n Star Wars is one of the highest-grossing media franchises of all time.\n The original film (Star Wars), retroactively subtitled \n Episode IV: A New Hope (1977), was followed by the sequels Episode V: The Empire Strikes Back (1980) \n and Episode VI: Return of the Jedi (1983), forming the original Star Wars trilogy.\n  Lucas later returned to the series to direct a prequel trilogy,\n consisting of Episode I: The Phantom Menace (1999), \n Episode II: Attack of the Clones (2002), and Episode III: Revenge of the Sith (2005).\n In 2012, Lucas sold his production company to Disney, \n relinquishing his ownership of the franchise. \n This led to a sequel trilogy,\n consisting of Episode VII: The Force Awakens (2015), \n Episode VIII: The Last Jedi (2017), and \n Episode IX: The Rise of Skywalker (2019). \n All nine films of the Skywalker Saga were nominated for Academy Awards, \n  with wins going to the first two releases. \n Together with the theatrical live action anthology films \n Rogue One (2016) and Solo (2018), the combined box office \n revenue of the films equated to over US$10 billion, \n which makes it the second-highest-grossing \n film franchise of all time.[3][4] \n Additional upcoming films are in the works, including an untitled \n  movie from Taika Waititi and Rogue Squadron \n directed by Patty Jenkins, both currently without release dates.[5] \n \n -From Wikipedia"

 

lbl2 = tk.Label(root,

              justify=tk.LEFT,

              padx = 620,pady=10,

              text=exp,font=('arial',12,'italic')).pack(side="right")

 

root.mainloop()

 

 

I have come to the end of this article. See you in my next article. Happy coding. Bahadir Sahin

No comments:

Post a Comment

Featured post

Python Introduction

What is Python? Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built ...