Home > other >  Why height parameter is not working in Label Widget?
Why height parameter is not working in Label Widget?

Time:12-20

    colors = Label(
    text="Surprise",
    foreground="Bisque",
    background="Hot Pink",
    width=150,
    height=100   
)
colors.pack()

Pycharm showing me to remove the attribute height it is not an option

CodePudding user response:

There are a few things to note here. First: in order to make a label, you need to specify which window it should go in, so the first parameter will normally be root. Second: the height option is for the number of lines of text not the number of pixels, this setting you are trying to use will be very very big (same for width).

Normally you shouldn't try to set the size of a label in this way because in most cases it will just automatically go to the correct size for the text you put inside of it. Instead, if you want a specific number of pixels, you should create a Frame widget with the specific size and put the Label widget inside of the frame widget

  • Related