Getting started with python command - DeafMan1983/PythonExamples GitHub Wiki
You know about Tkinter, It is very old and popular user interface for Python.
Like other websites TKinter getting started ...
I want tell you how does it work?
Open command / terminal
Type: python
, python3
( If you are Linux user then you type with "3" because Linux's Python are parallel other old version of Python like 2.x )
You should be careful if python and python3 have different versions. We put first time with Tkinter from packages of python-installation.
>>> import tkinter as tk
Then you put and prompt
>>> window = tk.Tk()
What does it happen?
That is new simple window of TKinter
:warning: Picture is copy-protected by RealPython :warning:
It works fin. Don't close it! Why do you ask me about not closing TKinter's window? I will explain later. Do you like add any widgets? Of course you can try with Label
>>> greeting = tk.Label(text="Hello, Tkinter")
And pack it
>>> greeting.pack()
And looks like that
:warning: Picture is copy-protected by RealPython :warning:
You know how do you get initial window with widget and you learn better.
You want save TkApp.py for example:
import tkinter as tk
window = tk.Tk()
label = tk.Label(text="Python rocks!")`
label.pack()
window.mainloop()
And try out python3 TkApp.py
If you trouble problem with code then you can check my full code under Github.
Then it works fine.
And you could visit RealPython and you can check many examples with TKinter :) Enjoy your pythin coding and happy coding!