简体   繁体   中英

Change background color of Tkinter window in Python 2.7

I am using the function tkFileDialog.askopenfilename() to ask the user to choose a file path. The problem is that, due to a dark theme I am using, the text is light grey. The background of the window should be black (it is black in the rest of the system), but for some reason in the tkinter window it remains white. Here is a screenshot:

在此处输入图片说明

As you can see, the text is barely readable.

I tried to change the color of the background of the window using .configure(background='black') but with no success... can anybody help?

Thank you very much!

Edit: alternatively, I would also be happy to change the color of the text to black... just not light grey on white!

From the source code in tkinter I do not see any options that allow for the background to be changed for askopenfilename() .

From the code:

# For the following classes and modules:
#
# options (all have default values):
#
# - defaultextension: added to filename if not explicitly given
#
# - filetypes: sequence of (label, pattern) tuples.  the same pattern
#   may occur with several patterns.  use "*" as pattern to indicate
#   all files.
#
# - initialdir: initial directory.  preserved by dialog instance.
#
# - initialfile: initial file (ignored by the open dialog).  preserved
#   by dialog instance.
#
# - parent: which window to place the dialog on top of
#
# - title: dialog title
#
# - multiple: if true user may select more than one file
#
# options for the directory chooser:
#
# - initialdir, parent, title: see above
#
# - mustexist: if true, user must pick an existing directory
#

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM