So, you want to make a gui with python? Let's start.
First of all, we'll use the tkinter module that comes with python, so nothing to install.
import tkinter as tk
Then we create a class (app) that will create the frame into the window,
class app(Frame): def __init__(self): tk.Frame.__init__(self) self.option_add("*Font","arial 16 bold") self.pack(expand=YES, fill=BOTH) self.master.title("My first window")
a label with written "Write down here" and an Entry text of a shining gold where I can write text for an input.... and that's all for now... display = StringVar() l = tk.Label(self,text="Write down here").pack() e = tk.Entry(self, relief=RIDGE, textvariable=display, justify='left', bd=15, bg='gold') e.pack(side=TOP, expand=YES, fill=BOTH)
Oh, finally we put the app into a mainloop that will keep the window work until we close it.
if __name__ == '__main__': app().mainloop()
This is what you will get
and this is the whole code
import tkinter as tk class app(Frame): def __init__(self): tk.Frame.__init__(self) self.option_add("*Font","arial 16 bold") self.pack(expand=YES, fill=BOTH) self.master.title("My first window") display = StringVar() l = tk.Label(self,text="Write down here").pack() e = tk.Entry(self, relief=RIDGE, textvariable=display, justify='left', bd=15, bg='gold') e.pack(side=TOP, expand=YES, fill=BOTH) if __name__ == '__main__': app().mainloop()
Comments
Post a Comment