the wxpython gui library drawing graphics in earlier we looked at the turtle graphics api for generating vector and raster graphics in python the wxpython library provides its own facilities for generating cross platform graphic displays using linessquarescirclestext etc this is provided via the device context device context (often shortened to just dcis an object on which graphics and text can be drawn it is intended to allow different output devices to all have common graphics api (also known as the gdi or graphics device interfacespecific device contexts can be instantiate depending on whether the program is to use window on computer screen or some other output medium (such as printerthere are several device context types available such as wx windowdcwx paintdc and wx clientdcthe wx windowdc is used if we want to paint on the whole window (windows onlythis includes window decorations the wx clientdc is used to draw on the client area of window the client area is the area of window without its decorations (title and borderthe wx paintdc is used to draw on the client area as well but is intended to support the window refresh paint event handling mechanism note that the wx paintdc should be used only from wx paintevent handler while the wx clientdc should never be used from wx paintevent handler whichever device context is usedthey all support similar set of methods that are used to generate graphicssuch asdrawcircle (xyradiusdraws circle with the given centre and radius drawellipse (xywidthheightdraws an ellipse contained in the rectangle specified either with the given top left corner and the given size or directly drawpoint (xydraws point using the color of the current pen drawrectangle (xywidthheightdraws rectangle with the given corner coordinate and size drawtext (textxydraws text string at the specified pointusing the current text fontand the current text foreground and background colours drawline (pt pt )/drawline ( this method draws line from the first point to the second it is also important to understand when the device context is refreshed/redrawn for exampleif you resize windowmaximise itminimise itmove itor modify its contents the window is redrawn this generates an eventa paintevent you can bind method to the paintevent (using wx evt_paintthat can be called each time the window is refreshed