Home > Blockchain >  GUI background issue
GUI background issue

Time:04-27

My problem is that I want to create a GUI with tkinter python and wrote this code and also specified its background but don't know why the background is completely black and due to this many thing are not visible. enter image description here

This is the code-

#we are using tkinter li
import tkinter as tk
from tkinter import *
from tkinter import messagebox

root = tk.Tk()
#we are using title command
root.title('PythonGuides')
#here we are changing its background
root.configure(background='lightgrey')
#here we are changing its
root.geometry('500x300')
root.configure(background='black')
L1 = Label(root,text="Enter name")
L1.grid(row=1,column=1,padx=5,pady=5)
E1 = Entry(root,width=30)
E1.grid(row=1 ,column=3,padx=5,pady=5)
L1 = Label(root,text="Enter Email")
L1.grid(row=2,column=1,padx=5,pady=5)
E1 = Entry(root,width=30)
E1.grid(row=2 ,column=3,padx=5,pady=5)
L1 = Label(root,text="Enter Password")
L1.grid(row=3,column=1,padx=5,pady=5)
E1 = Entry(root,width=30,show="*")
E1.grid(row=3 ,column=3,padx=5,pady=5)
L2 = Label(root,text="Select Gender")
L2.grid(row=4,column=1,padx=5,pady=5)
Cas = IntVar()
R1 = Radiobutton(root,text="Male",value=1,variable=Cas)
R2 = Radiobutton(root,text="FeMale",value=2,variable=Cas)
R3 = Radiobutton(root,text="Others",value=3,variable=Cas)
R1.grid(row=4,column=3,padx=5,pady=5)
R2.grid(row=5,column=3,padx=5,pady=5)
R3.grid(row=6,column=3,padx=5,pady=5)
C1 = Checkbutton(root,text="Verify terms and conditions")
C1.grid(row=7,column=3,padx=5,pady=5)
B1 = Button(root,width=20,padx=2,pady=2,text="Submit")
B1.grid(row=8,column=3,padx=5,pady=5)
root.mainloop()

CodePudding user response:

L1 = Label(root,text="Enter name", bg="black")

Add 'bg' attribute to your widget.

CodePudding user response:

Remove line 8 root.configure(background='black')

  • Related