by re4nightwing
First of all check out my previous video Python GUI programming Episode-02
Help me by subscribing to my channel
Okay, today I'm going to show you how to add font property[text styling], a button to your python GUI interface.
Okay for the text styling I'm using this code below:
ex : Label(window,bg="yellow",text="My first label",fg='grey',font="Verdana 16 bold") .grid(row=0,column=0,sticky=E)
For this example I have used font property in a Label.
You can use in lot of places like buttons, text entry, ...etc
Actually almost everywhere.
In this example , Verdana means the font face you need to display on and 16 means the font size. I have used 16px and at last bold means the font style.
If you want to keep it in normal form by either putting "none" or leaving it blank.
Okay for buttons in python :
ex: Button(window, text="Done", width=10,command=Show_answer,bd=2,font="Verdana 10 ", bg="#458392" ).grid(row=3,column=1)
You can put a button by using the code above.
window means the panel name I have given to my python GUI interface.
You have to put the text You want to display on the button where I have put "Done".
Width means the you know the width of the button in pixels.
Okay this is the hard part, when you are putting a button you have to assign a command to it and i have used "Show_answer" as command you can use any word you want in it but you have to define it by using a code like this :
ex: def Show_answer():
print("Subscribe")
when you click on the button this code will execute and give you the out put on your python shell as "Subscribe".
like that you can assign any kind of work to your button.
In button bd means the border size, font is same as above, bg means the button colour.
And at last this the code for an exit button to your own software..:
ex : def Exit():
window.destroy()
exit()
Button(window, text="Exit", width=10,command=Exit,bd=2,font="Verdana 10 ", bg="#435789" ) .grid(row=3,column=2)
Okay this code will destroy your python interface.
Remember you have to put your panel name in the "window" places to work all these codes.
thanks for visiting...
Check out My YouTube channel - Epic Docks

0 Comments