To create a Label
with white text on black background in Tkinter, you can use the following code:
main.py137 chars9 lines
In this code, we first import the tkinter
module and create an instance of the Tk
class.
We then create a Label
widget using the Label
constructor, passing in the root as the first argument and the text we want to display as the second argument.
To style the label, we set the bg
(background) option to "black"
and the fg
(foreground) option to "white"
.
Finally, we use the pack
method to add the Label
widget to the root window and start the main event loop using the mainloop
method.
gistlibby LogSnag