Remove gray squares from my Tkinter program (Python)

Asked

Viewed 43 times

0

I would like to remove these gray squares from my program.

Quadrados cinza

from tkinter import *
import datetime
import time
import pygame, sys, random

pygame.init()
root = Tk()
root.title("SISTEMA DE VENDAS")
root.geometry('1366x768+0+0')

root.configure(background='yellow')
FrameABC = Frame(root, bg="grey", bd=20, relief=RIDGE)
FrameABC.grid()

#============================================================

lblDate = Label(FrameABC,text="\tSupermercados Rena\t",font=('arial',30,'bold'),padx=9, pady=9,
    bd=14,bg="Cadet Blue",fg="Cornsilk", justify=CENTER).grid(row=0, column=0)

lblDate = Label(FrameABC,text="\tData: \t",font=('arial',30,'bold'),padx=9, pady=9,
    bd=14,bg="Cadet Blue",fg="Cornsilk", justify=LEFT).grid(row=1, column=0)

lblDate = Label(FrameABC,text="\tHoras: \t",font=('arial',30,'bold'),padx=9, pady=9,
    bd=14,bg="Cadet Blue",fg="Cornsilk", justify=LEFT).grid(row=2, column=0)


root.mainloop()

2 answers

1

To the label that you added keep the full size is possible you use a property from the grid() calling for sticky that serves for you to "stick" your object(be it button, label and others) in the direction you wish.

The estate sticky takes a string as parameter, if you want to "stick" up for example it would be "N" from "North"(North).

Properties of Sticky

  • N: North (Upper)
  • E: East (Right)
  • S: South (Low)
  • W: West (Left)

OBS: You can join more than one direction to leave it as you want, so we can use a string like => "NSEW" that "will stick" in all directions.

In your case just add the sticky to the grid, thus:

lblDate = Label(FrameABC,text="\tData: \t",font=('arial',30,'bold'),padx=9, pady=9,
    bd=14,bg="Cadet Blue",fg="Cornsilk", justify=LEFT).grid(row=1, column=0, sticky  =  "NSEW")

lblDate = Label(FrameABC,text="\tHoras: \t",font=('arial',30,'bold'),padx=9, pady=9,
    bd=14,bg="Cadet Blue",fg="Cornsilk", justify=LEFT).grid(row=2, column=0, sticky  =  "NSEW")

TEST OF THE RESULT

More information

1

You want to remove only the color, right? If yes, just change the "Grey" color of that spot:

root.configure(background='yellow')
FrameABC = Frame(root, bg="grey", bd=20, relief=RIDGE)
FrameABC.grid()

Leaving so:

root.configure(background='yellow')
FrameABC = Frame(root, bg="Cadet Blue", bd=20, relief=RIDGE)
FrameABC.grid()

But if you want to remove them definitely, You can stretch the buttons, giving the possibility of it expanding occupying the free spaces as commented the sant0will

Browser other questions tagged

You are not signed in. Login or sign up in order to post.