2

I am using tkinter.filedialog.askopenfilename in Python to select a file. How do I change the font size for the file list displayed? I have found answers on StackOverflow on how to change the font of some items on the display (for example here), but do not know the name of the ttk widget that is used for the file list.

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
Jeff1019
  • 21
  • 1
  • I don't think `askopenfilename` gives that kind of control. The answer to that linked question which attempts to use a `ttk.Style` wouldn't work because `filedialog`s have nothing to do with `ttk` widgets (note how the `Style` created in never used after it's configured). You should be able to do what you want by creating your own dialog widget that internally used a [`tkinter.Listbox`](https://web.archive.org/web/20190323174019id_/http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/listbox.html) which does support a `font` option. – martineau Oct 18 '19 at 05:14
  • You might find the answers to the question [Correct way to implement a custom popup tkinter dialog box](https://stackoverflow.com/questions/10057672/correct-way-to-implement-a-custom-popup-tkinter-dialog-box) useful in creating your own dialog class. – martineau Oct 18 '19 at 05:23
  • I've run into the same issue. Modifying `TkDefaultFont` changes the font of the buttons and labels around the file list, but does not affect the file list itself. On my high density display, the file list uses a tiny font, I need to stick my nose in the monitor to read it. – Cris Luengo Nov 08 '21 at 23:33

0 Answers0