1 Replies - 1789 Views - Last Post: 18 February 2019 - 09:30 AM

#1 attreya   User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 15-August 18

Create your first Python GUI using 5 lines of Code

Posted 15 August 2018 - 03:33 AM

Here is a quick code snippet that you can just paste in a Python terminal (or whatever you use to execute Python code) and it will create a basic Graphical interface window. Kinda like this picture. Make sure you are using Python 3+ though.

Here are the five lines of code if you would like to 'copy paste' :

from tkinter import *

root = Tk()
root.geometry('300x300')
root.title("First Tkinter Window")
root.mainloop()


I am using a package called 'Tkinter' to create this GUI. The beauty of this package is that you don't need to install or pip install any package. This comes inbuilt inside Python! Crazy right? Here is a step by step understanding of what we are doing in these first lines.

Line 1 - Importing the Tkinter package
Line 2 - Tk() is creating the window that you see and storing it inside the 'root' variable
Line 3 - This is the dimension of the window. Height and width (optional)
Line 4 - To change the title of the window
Line 5 - Make sure the window stays and doesn't disappear.

Obviously there is much more to the 'Tkinter' framework.

I am creating a much more advance GUI on my Youtube Playlist - Python GUI Programming using Tkinter + Pygame

Have already uploaded 30 videos and would be uploading 3 videos every alternate day

What do you guys think of the videos?

Is This A Good Question/Topic? 0
  • +

Replies To: Create your first Python GUI using 5 lines of Code

#2 Nick10714   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 15-February 19

Re: Create your first Python GUI using 5 lines of Code

Posted 18 February 2019 - 09:30 AM

Just copied this into IDLE, this is very cool. your videos are very helpful!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1