Created
April 21, 2016 08:24
-
-
Save hackerdem/05e7fdba609fabe3a29b14b096c8cb68 to your computer and use it in GitHub Desktop.
python script for simple GUI design with tkinter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tkinter import * | |
from random import randrange | |
def drawshape(): | |
x1,x2,x3=150,400,250 | |
y1,y2,y3=250,150,350 | |
can1.create_line(y2,x3,y3,x3,width=2,fill=coul) | |
can1.create_line(y1,x1,y1,x2,width=2,fill=coul) | |
def change_shape_colour(): | |
global coul | |
pal=['purple','red','blue','orange','yellow'] | |
c=randrange(4) | |
coul=pal[c] | |
drawshape() | |
coul='dark green' | |
fen1=Tk() | |
can1=Canvas(fen1,bg='dark grey',height=500,width=500) | |
can1.pack(side=LEFT) | |
bou1=Button(fen1,text='Quitter',command=fen1.quit) | |
bou1.pack(side=BOTTOM) | |
bou2=Button(fen1,text='Draw a shape',command=drawshape) | |
bou2.pack() | |
bou3=Button(fen1,text='Change color',command=change_shape_colour) | |
bou3.pack() | |
fen1.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment