If you want to get the default background at runtime, you can use the cget
method. This may return a color name rather than an rgb value.
import Tkinter as tk
root = tk.Tk()
bg = root.cget("background")
# eg: 'systemWindowBody'
You can convert that to a tuple of the red, green and blue components
rgb = root.winfo_rgb(bg)
# eg: (65535, 65535, 65535)
You can then format the value as a hex string if you wish:
color = "#%x%x%x" % rgb
# eg: '#ffffffffffff'
To reset the background after changing it, save the value, and then use the value with the configure
command:
original_background = root.cget("background")
...
root.configure(background=original_background)