What would it take to make graphics show on the monitor without using stuff like tkinter and Qt? (tkinter and Qt are called toolkits right?)

That depends on what kind of graphics you are talking about. If yo just want to draw lines and circles and so on, you can use Jim Zelle's module graphics.py, a free download from:
http://mcsp.wartburg.edu/zelle/python/graphics.py

This module is a thin wrapper for Tkinter and may appeal to you because of its simplified syntax. Here is an example ...

from graphics import *

def drawStickFigure():
    win = GraphWin("Stick figure")
    head = Circle(Point(100, 60), 20).draw(win)
    body = Line(Point(100, 80), Point(100, 120)).draw(win)
    arms= Line(Point(60, 100), Point(140, 100)).draw(win)
    leg1 = Line(Point(100,120), Point(60,160)).draw(win)
    leg2 = Line(Point(100,120), Point(140,160)).draw(win)
    # pause for click in window
    win.getMouse()
    win.close()


drawStickFigure()

You can also draw using the module turtle that comes with Python. Again it uses Tkinter under the hood. Here is an example ...

# explore module turtle
# draw five turtle lines to form a pentagon

import turtle as tu

tu.title('draw a pentagon')

# optional ...
# values for speed are 'fastest' (no delay), 'fast', (delay 5ms),
# 'normal' (delay 10ms), 'slow' (delay 15ms), 'slowest' (delay 20ms)
#tu.speed('fastest')

# optional ...
# turtle by default starts at (x=0, y=0) center of a (450x550) window
# to pick another center lift the pen up then move
# to the right x units and up y units or ...
# to the left -x units and down -y units
# now drop the pen down to start drawing
tu.up()
tu.goto(60, 100)
tu.down()

# optional pen color
tu.color('blue')

# form a pentagon by drawing 5 lines of 100 pixels length
# changing the direction by 72 degrees (360/5) each time
for k in range(5):
    tu.right(72)
    tu.forward(100)

# keep showing until window corner x is clicked
tu.done()

Edited 7 Years Ago by vegaseat: n/a

Thanks for the examples.. but I'm afraid you've misunderstood me. I should have been more specific. Say no library existed for graphics.. i.e no tkinter, no qt, no graphics.py. etc..
What would I have to tell python in order for it to go and draw a certain sequence of pixels on screen? What parts of the operating system would it use to draw the requested graphics?

So I tell something to tkinter and tkinter tells a translated version of that "something" to windows?
If that's so, how come tkinter is cross platform?
I mean, Linux and Windows do things quite differently so how would tkinter know what functions to call on each operating system?

Edited 7 Years Ago by mahela007: n/a

Modules like Tkinter will look for the corresponding operating system's functions. One can build that in, or make it specific for the installation. In other words, Tkinter (the module, not the syntax) will differ from one OS install to the other, just like Python's module os differs.

Edited 7 Years Ago by vegaseat: syntax

So I tell something to tkinter and tkinter tells a translated version of that "something" to windows?
If that's so, how come tkinter is cross platform?
I mean, Linux and Windows do things quite differently so how would tkinter know what functions to call on each operating system?

When they say "cross platform", they mean a piece of software can be used it the same way on each of them. It doesn't necessarily mean it's implemented the same way everywhere.

In the case of a Tkinter application, it means you could run THAT application on different platforms without modification. They implemented Tkinter (and the underlying Tcl/Tk system) on several platforms differently, so that we don't have to do that with our programs.

Hope that clarifies it a bit.

yeah.. that helps a lot.. thanks
EDIT: SO under linux, it would probably sent signals to the X server right?

Edited 7 Years Ago by mahela007: n/a

If you wanted to draw a box on the screen and display some sort of message, you would have to access the memory on the video card. Before toolkits like Tkinter that is the way it was done. In simple terms, you would copy that part of the screen, blank it by putting whatever color you wanted to use, draw the outline of the box with another color, add any other color effects you wanted to use, and then display the message. When finished, you would copy back the original contents of the window. Every one who did programming had these routines in their toolbox, although C, not Python was the language of choice. Today, I don't think Python has the capability as that requires a little assembly code, so the programming language has to be able to execute some assembly.

Edited 7 Years Ago by woooee: n/a

So how does a toolkit eliminate the need to write that fundamental code? With the massive number of different graphics cards available today, how could a toolkit possibly know how to access the memory of the video cards?

and what do you mean by "the programming language has to execute some assembly"?

The assembly language part is done by your OS. Access to the memory of the video cards is done through drivers specific to the OS.

Edited 7 Years Ago by vegaseat: n/a

So it like...
tkinter... OS... Memoty of card... and finally the monitor?

So how does a toolkit eliminate the need to write that fundamental code? With the massive number of different graphics cards available today, how could a toolkit possibly know how to access the memory of the video cards?

How does Windows, or Linux, or <Insert OS Here> know how to access the memory of the video cards? Through drivers. Each video card has drivers for each OS it's supported on that lets the OS use the video card properly, and transitively, the toolkits on that operating system, like Tk for example.

right... Now I understand what driver do for programming.
Now.. are the drivers used by the kernel or some higher level of software in the system?

right... Now I understand what driver do for programming.
Now.. are the drivers used by the kernel or some higher level of software in the system?

I feel this discussion is continually diverging from the original question to a sort of "computer science fundamentals for beginners". If you are interested in computer science in general, there is the Computer Science forum here. Might be worth checking it out.

Agreed. You should do your own research from here. Especially since you are just going to forget most of this anyway. Herb Schildt was the consensus guru when this was commonly done, so if you can find a copy of "The Craft of C" online or in a library, it will explain what it takes to write the program. Bottom line is that somewhere, for every OS, you have to have something that puts pixels on the screen via a program, for every video card, monitor, etc. The precise details are left up to you.

Edited 7 Years Ago by woooee: n/a

I've already done a bit of reading on wikipedia and other tutorials. I tried to use this forums to try and glue it all together.. Anyway, thanks for your help.

This question has already been answered. Start a new discussion instead.