![python 3 tutorial python 3 tutorial](https://learnbyexample.github.io/100_page_python_intro/images/py_docs_1.png)
btn = Button(window, text="Click Me", bg="orange", fg="red") You can change the foreground for a button or any other widget using fg property.Īlso, you can change the background color for any widget using bg property. Change button foreground and background colors
![python 3 tutorial python 3 tutorial](https://wiki.freecadweb.org/images/0/0b/FreeCAD_Python_console.png)
If you forget and place the button on the same column which is 0, it will show the button only, since the button will be on the top of the label. Note that we place the button on the second column of the window which is 1. So our window will be like this: from tkinter import * Let’s start by adding the button to the window, the button is created and added to the window the same as the label: btn = Button(window, text="Click Me")
#Python 3 tutorial how to
Let’s try adding more GUI widgets like buttons and see how to handle the button click event. The above line sets the window width to 350 pixels and the height to 200 pixels. We can set the default window size using geometry function like this: window.geometry('350x200') Great, but the window is so small, we can even see the title, what about setting the window size? Setting window size Note that the font parameter can be passed to any widget to change its font not labels only. To do so, you can pass the font parameter like this: lbl = Label(window, text="Hello", font=("Arial Bold", 50)) You can set the label font so you can make it bigger and maybe bold. Without calling the grid function for the label, it won’t show up.