Tkinter | SoloLearn: Learn to code for FREE!



Does anyone knows how to write python programmes with tkinter? How?

8/5/2019 8:33:17 AM


7 Answers

New Answer


Use any IDE that is not Sololearn Code Playground. Like IDLE or PyCharm


Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, tkinter is most commonly used method. You can use any IDE like pycharm to write it.


There are many books and tutorials, this one gives you the very basics


from tkinter import * import random def rand(): text.delete('1.0','end') a,b,c='',32,'abcdefABCDEF1234567890' for i in range(b): a+=random.choice(c) text.insert('end',a) def des(): r.destroy() r=Tk() text=Text(r,height=20,width=40) text.pack() btn1=Button(r,text='rand',command=rand) btn2=Button(r,text='exit',command=des) btn1.pack() btn2.pack() r.mainloop() On ide work))) Pyinstaller build this code in .exe file


From tkinter import * And then the code Mainloop()


heres a simple label changing gui from tkinter import * #import tkinter root = Tk() #root can be anything like win,window etc. label = Label(root, text="hi!") label.pack() #You have now put text into the window, Well done! def clicked() : #defining the click handeler label.configure(text="Button was clicked !") #Anytime you call this function your label gets configured! btn = Button(root, text="change text", command=clicked) #button (dont put () after your function) btn.pack() #Awsome! we have made a button that changes the text root.mainloop() #Done! You can find more online (I reccomend like for geeks tkinter tutorial) and dont use codeplayground for tkinter #Tkinter does not work on mobile :( My simple travel agency code: Good luck with GUI!