-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTkinter.py
More file actions
64 lines (49 loc) · 1.93 KB
/
Tkinter.py
File metadata and controls
64 lines (49 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from tkinter import *
import turtle
# Function for Red Button - Expanding Spiral
def draw_red_pattern():
a = turtle.Turtle()
a.speed(0)
a.pencolor("red")
for i in range(100): # Creates a swirling effect
a.circle(i * 2, 180) # Draws a half-circle with increasing radius
a.right(60) # Slight rotation to create a spiral effect
# Function for Blue Button - Square with Hexagons
def draw_blue_pattern():
a = turtle.Turtle()
a.speed(0)
a.pencolor("blue")
for i in range(200): # Creates a swirling effect
a.circle(i * 1, 180) # Draws a half-circle with increasing radius
a.right(60) # Slight rotation to create a spiral effect
# Function for Green Button - Star Pattern
def draw_green_pattern():
a = turtle.Turtle()
a.speed(0)
a.pencolor("green")
for i in range(75): # Creates a swirling effect
a.circle(i * 3, 180) # Draws a half-circle with increasing radius
a.right(60) # Slight rotation to create a spiral effect
# Function for Black Button - Circular Flower
def draw_black_pattern():
a = turtle.Turtle()
a.speed(0)
a.pencolor("black")
for i in range(400): # Creates a swirling effect
a.circle(i * 0.5, 180)
a.dot(50)# Draws a half-circle with increasing radius
a.right(60) # Slight rotation to create a spiral effect
a.dot(100)
a.hideturtle()
# Create Tkinter window
parent = Tk()
# Buttons with commands linked to respective functions
redbutton = Button(parent, text="Red", fg="red", command=draw_red_pattern)
redbutton.pack(side=LEFT)
greenbutton = Button(parent, text="Green", fg="green", command=draw_green_pattern)
greenbutton.pack(side=RIGHT)
bluebutton = Button(parent, text="Blue", fg="blue", command=draw_blue_pattern)
bluebutton.pack(side=TOP)
blackbutton = Button(parent, text="Black", fg="black", command=draw_black_pattern)
blackbutton.pack(side=BOTTOM)
parent.mainloop()