Python

From indicium
Revision as of 23:40, 23 May 2016 by Stefan (talk | contribs)
Jump to navigation Jump to search

Threading

http://www.tutorialspoint.com/python/python_multithreading.htm

Tkinter and simple GUI programming

#!/usr/bin/env python

from Tkinter import *

def drawframe():
	c.delete("all")
	c.create_rectangle(0, 0, 150, 75 + c.steffe_i, fill="blue")
	c.steffe_i += 1
	root.after(10, drawframe)

def mouseclick(event):
	print "Mouse click at", event.x, event.y

def keyclick(event):
	print "Key click", event.keysym

root = Tk()
c = Canvas(root, width=640, height=480)
c.pack()

root.bind("<Key>", keyclick)
root.bind("<Button-1>", mouseclick)

c.config(borderwidth = 10)
c.config(background = "grey15")
c.steffe_i = 0

root.after(10, drawframe)
mainloop()