FUN WITH CODING
|
|
FUN WITH CODING
|
|
CHANGE TEXT FONT AND SIZE
|
|
from tkinter import * screen = Tk() screen.minsize(400,400)# H / V screen.title("Changing the Font") screen.configure(background="#71d0c8") pageTitle = Label(screen, text = "This is my font") pageTitle.config(font=("Courier", 35)) pageTitle.place(x = 20, y = 20) pageTitle = Label(screen, text = "This is my font") pageTitle.config(font=("Georgia", 30)) pageTitle.place(x = 20, y = 80) pageTitle = Label(screen, text = "This is my font", bg = "#71d0c8") pageTitle.config(font=("Comic Sans MS", 25)) pageTitle.place(x = 20, y = 140)
BUTTON STYLES AND SIZE
|
|
...
TIME DELAY A POP-UP MESAGE
|
|
from tkinter import * screen = Tk() screen.minsize(305,475)# H / V screen.title("Using time delay") screen.configure(background="#71d0c8") userName = ("Bob") def homeScreen(userName): welcome = Label(screen, text = "Welcome " + userName) welcome.place(x = 100, y = 40) welcome.after(2500, removeEntry)#Delays for 2500 the runs the function removeEntry def removeEntry(): for i in screen.winfo_children(): i.destroy() homeScreen(userName) screen.mainloop()
PLACING A MATPLOTLIB GRAPH IN A TKINTER WINDOW
|
|
from tkinter import * from pandas import DataFrame import matplotlib.pyplot as plt from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg #Creates the library to hold the data data = {'Technology': ["Mac","PC","Google Home","Playstation","C64","GoPro","Samsung","iphone","Huawei","X-Box"], 'User_Rating': [21,45,35,76,34,87,34,5,60,50]} #Select the variable data for the data to use and then make the #column equal the technology library index and user rating index df1 = DataFrame(data,columns=['Technology','User_Rating']) screen = Tk() screen.minsize(600,600) screen.title ("Matplotlib with Tkinter") myChart = plt.Figure(figsize=(8,5), dpi=100)#Chart size parameters ax1 = myChart.add_subplot(111)#Grid parameters of the chart bar1 = FigureCanvasTkAgg(myChart, screen) bar1.get_tk_widget().pack() df1 = df1[['Technology','User_Rating']].groupby('Technology').sum() df1.plot(kind='bar', legend=True, ax=ax1) ax1.set_title('Technology and Consumer Rating') screen.mainloop()
LEARN PYTHON CONTENT
|
|
SUGGESTIONS
We would love to hear from you |
SUBSCRIBE
To enjoy more benefits |