Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Tkinter Labels going outside window

I am trying to see different fonts and how they look in tkinter but they are going outside the window. I saw other answers on this and how to add a scrollbar but none of them are working. So is there a way I can add a scrollbar in my app or any other solution so I can view all Fonts.

Thanks

This is my code

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

from tkinter import Tk, font, Label
root = Tk()
x = font.families()
for i in x:
    l = Label(root, text=i, font=(i, 12))
    l.pack()
root.mainloop()

Can someone pls help

>Solution :

enter image description here

from tkinter import Tk, font, Label
root = Tk()
row=0
col=0
x = font.families()
for i in x:
    l = Label(text=i, font=(i, 10))
    l.grid(column=col,row=row)
    row+=1
    if row>23:
        row=0
        col+=1
root.mainloop()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading