How to set up Python TKinter Label or Background
from tkinter import *
class Musicplayer:
def __init__(self,Tk):
self.root=Tk
self.root.title("EBS MUSIC PLAYER")
self.root.geometry("600x450")
self.root.configure(background="white")
self.mainbackground = PhotoImage(file="music-png-png_600x450.png")
canvas = Canvas(self.root, width=600, height=450)
canvas.pack(fill=BOTH, expand=True)
canvas.create_image(0, 0, image=self.mainbackground, anchor='nw')
self.title_label = Label(text="Working With Music Player", fg="black").place(x=50, y=50)
root=Tk()
obj=Musicplayer(root)
root.mainloop()
Note :
For Label:
Label widget
text - the text to display on the label
bg - the background color of the label
fg - the foreground (text) color of the label
font - the font used for the text on the label
width - the width of the label
height - the height of the label
anchor - the position of the text on the label (e.g. "center", "nw", "ne")
justify - the alignment of the text within the label (e.g. "center", "left", "right")
For Background:
bg - the background color of a widget
highlightbackground - the color of the border around a widget when it is not focused
highlightcolor - the color of the border around a widget when it is focused
highlightthickness - the thickness of the border around a widget
relief - the type of border around a widget (e.g. "flat", "raised", "sunken")
place() - a method to place a widget at a specific position within a window
pack() - a method to automatically place and size a widget within a window based on its contents and the window size
grid() - a method to place a widget within a grid layout within a window, allowing for more precise control over positioning
No module named PIL Install PIL module: If you haven't installed PIL yet, install it using pip, the..
Lambda is a small and anonymous function in Python, where you can use many arguments but only ..
Connect with mysql database using python Install the mysql-connector-python-rf - $..
Insert data into MySQL table using Python. Install mysqlclient Open Terminal..
Get the latest news and updates by signing up to our daily newsletter.We won't sell your email or spam you !