Do you love programming? Which language do you love to code in? I love a lot, actually, I am quite fond of programming. My favourite language is Python. But, you know what simply programming the normal syntax code doesn’t make it interesting with time. Your programming should be interactive and we can make our codes interactive by using graphics. So, in the post, I, would love to bring to you the basics of Python Programming Graphics.


Today’s computer applications aren’t limited to the type of textual input and output that we’ve been using thus far . Most applications that you simply are conversant in probably have a Graphical interface (GUI). This gives visual elements like windows, icons, buttons and menus.

Interactive graphics programming generally become confusing. Even entire textbooks are also dedicate to the intricacies of graphics. Industrial-strength GUI applications are also usually developed employing a dedicated graphics programming framework. Python though comes with its own standard GUI module called Tkinter.

Even so, taking the time to find out Tkinter would detract from the more fundamental task of learning the principles of programming and style that are the main target of this book.

There is a ” ” library in Python created by John Zelle. This library is open source and is available as a free Python module file. This graphics library, also makes it easier to write down simple graphics programs.

Python Graphics Programming

To use the methods in one has to import it. In every Python Graphics program you create. Also, isn’t a component standard Python distribution. It gets save as within the folder. Where you’ll save your Python Graphics programs.

Generally, any Python Graphics program requires one to do these four tasks namely :

  • Importing the ” ” library.
  • Then, creating a GraphWin Object
  • Hereafter, paint the output of graphics functions on the declared window object
  • Finally, closing the opened GraphWin Object

Graphics Programming in Python

from graphics import *

The next thing is to make a window area where the output of Python Graphics program are going to display.

Window_object= GraphWin(text-title, width, height)
display = GraphWin(' Circle' of Rainbow, 200, 200)


cir= Circle(Point(200, 200, 10)

This code will draw a circle of radius 10 pixels at center 200, 200

Now, we need to close the GraphWin Object


Meanwhile, here’s Heat Maps in Python for you !!

>>> p = Point(50, 60) >>> p.getX() 50. >>> p.getY() 60. >>> win = GraphWin() >>> p.draw(win) >>> p2 = Point(140, 100) >>> p2.draw(win) Python Programming, 1/e.
# Celsius to Fahrenheit conversion using " " library .....

from graphics import *

def main():
       wins = GraphWin("Celsius Converter", 350, 250)
       wins.setCoords(0.0, 1.0, 3.0, 4.0)
Text(Point(1,3), "Temp in Celsius : ").draw(win)
Text(Point(1,1), "Temp in Fahrenheit : ").draw(win)
input = Entry(Point(2,4), 6)
output = Text(Point(2,1),"")
button = Text(Point(1.5,2.0),"Convert It")
Rectangle(Point(1,1.5), Point(2,2.5)).draw(win)

while True :
        win.getMouse()            # waiting for a click

 # Conversions
cel = eval(input.getText())
Fah = 9.0/5.0 * cel + 32

 # Output
output.setText("%0.1f" % Fah)
# Program for Rainbow Colours Concentric Circles

graphics import *
def main():
    work = GraphWin('Rainbow Circle', 200, 200) 
    x = work.getWidth()/2 
    y = work.getHeight()/2 

 while i <= len(col_arr):
        cir=Circle(Point(x, y), 11 +11*i) 
    message = Text(Point(work.getWidth()/2, 250), 'Click to Exit')



As we have seen that Graphics generally make our programming codes interactive. Thus, for GUI works we need to implement Graphics. So, here I brought to you information about the ” ” library built by John Zelle. Thus, with this article, I have hope to have cleared your many doubts. So, get on with the tricks !!!

Categorized in: