用户:
笑饮清风的流浪地球查看:2 回复:5 评论:2 创建时间:2019-08-11T15:03:25
【作品展示】

【作品介绍】
一键画图V3.0.17
【作品源代码】
import turtle
import time
import random
myPen = turtle.Pen()
print('现在是')
print(time.ctime())
print('一键画图现在支持画多边形,艺术图')
name = ['AUX工作室出品', 'Python工程师笑饮清风创作', '一键画图V3.0.17正式版']
print('欢迎使用一键画图V3.0.17正式版,本工具由AUX工作室的Python工程师出品。')
print('加载中,请稍候(大约需要1秒)')
myPen.penup()
myPen.goto((-650), 0)
myPen.pendown()
myPen.write( name,font=("Airal", 30))
k = int(input('请问你要进入随机模式,还是指定模式?(随机模式就是随机画一个图形,指定模式就是指定画一个图形),随机模式请输入1,指定模式请输入2:'))
if (k == 2):
Input = int(input('请问你想画圆形,还是正方形,正方形请输入1,圆形请输入2,多边形请输入3,三角形请输入4,艺术图形请输入5:'))
a = int(input('请输入画笔速度:'))
b = int(input('请输入画笔粗细:'))
ae = int(input('请问你要画实心的图形,还是空心的图形?,实心请输入1,空心请输入2(艺术图形请输入2):'))
myPen.speed(a)
myPen.pensize(b)
myPen.pencolor('black')
myPen.penup()
myPen.goto((-650), 0)
myPen.pendown()
myPen.clear()
q = int(input('请问你要画什么颜色的图形?,黑色请输入1,红色请输入2,黄色请输入3,绿色请输入4,蓝色请输入5:'))
if (q == 1):
myPen.pencolor('black')
if (q == 2):
myPen.pencolor('red')
if (q == 3):
myPen.pencolor('yellow')
if (q == 4):
myPen.pencolor('green')
if (q == 5):
myPen.pencolor('blue')
if (ae == 2):
if (Input == 3):
r = int(input('请问你要画几边形?'))
t = int(input('请问你要画多大?'))
s = int(input('请问你要画几个多边形?'))
myPen.penup()
myPen.goto((-650), 0)
myPen.pendown()
for u in range(s):
myPen.penup()
myPen.forward(100)
myPen.pendown()
myPen.circle(t, steps=r)
else:
if (Input == 1):
d = int(input('请问你要画几个正方形:'))
f = int(input('请输入正方形边长,最好不要超过100:'))
if (d > 1):
for c in range(d):
myPen.penup()
myPen.forward(f)
myPen.pendown()
for x in range(4):
myPen.forward(f)
myPen.right(90)
else:
myPen.goto(0, 0)
for j in range(4):
myPen.forward(f)
myPen.right(90)
if (Input == 2):
e = int(input('请问你要画几个圆:'))
g = int(input('请输入圆形的半径,最好不要超过100!:'))
if (e > 1):
for h in range(e):
myPen.penup()
myPen.forward(100)
myPen.pendown()
myPen.circle(g)
else:
myPen.goto(0, 0)
myPen.circle(g)
if (Input == 4):
myPen.clear()
myPen.penup()
myPen.goto(0, 0)
myPen.pendown()
l = int(input('请问你要画就个三角形?'))
m = int(input('请问你要画多大?'))
o = int(input('请问你要每个三角形隔多少?'))
for n in range(l):
myPen.circle(m, steps=3)
myPen.penup()
myPen.forward(o)
myPen.pendown()
elif (Input == 5):
w = int(input('请问你是想画第一种,还是第二种,第一种请输入1,第二种请输入2:'))
ad = int(input('请问你是否想要来点特效?想请输入1,不想请输入2:'))
if (w == 1):
ac = int(input('请问你想画多大?'))
if (ad == 1):
for v in range(ac):
myPen.forward(v)
myPen.pencolor('black')
myPen.right(90)
myPen.pencolor('blue')
myPen.forward(v)
myPen.pencolor('red')
else:
for af in range(ac):
myPen.forward(af)
myPen.right(90)
myPen.forward(af)
elif (w == 2):
ab = int(input('请问你想画多大?'))
if (ad == 1):
for y in range(ab):
yPen.pencolor('red')
myPen.forward(z)
myPen.pencolor('blue')
myPen.right(90)
myPen.pencolor('black')
else:
pass
else:
pass
else:
i = int(input('请问你要画什么颜色的实心图形,黑色请输入1,红色请输入2,黄色请输入3,绿色请输入4,蓝色请输入5:'))
if (i == 1):
myPen.fillcolor('black')
elif (i == 2):
myPen.fillcolor('red')
elif (i == 3):
myPen.fillcolor('yellow')
elif (i == 4):
myPen.fillcolor('green')
else:
myPen.fillcolor('blue')
if (Input == 3):
r = int(input('请问你要画几边形?'))
t = int(input('请问你要画多大?'))
s = int(input('请问你要画几个多边形?'))
myPen.penup()
myPen.goto((-650), 0)
myPen.pendown()
for u in range(s):
myPen.penup()
myPen.forward(100)
myPen.pendown()
myPen.begin_fill()
myPen.circle(t, steps=r)
myPen.end_fill()
else:
if (Input == 1):
d = int(input('请问你要画几个正方形:'))
f = int(input('请输入正方形边长,最好不要超过100:'))
if (d > 1):
for c in range(d):
myPen.penup()
myPen.forward(f)
myPen.pendown()
for x in range(4):
myPen.begin_fill()
myPen.forward(f)
myPen.right(90)
myPen.end_fill()
else:
myPen.goto(0, 0)
for j in range(4):
myPen.penup()
myPen.goto(0, 0)
myPen.pendown()
myPen.begin_fill()
myPen.forward(f)
myPen.right(90)
myPen.end_fill()
if (Input == 2):
e = int(input('请问你要画几个圆:'))
g = int(input('请输入圆形的半径,最好不要超过100!:'))
if (e > 1):
for h in range(e):
myPen.penup()
myPen.forward(100)
myPen.pendown()
myPen.begin_fill()
myPen.circle(g)
myPen.end_fill()
else:
myPen.penup()
myPen.goto(0, 0)
myPen.pendown()
myPen.begin_fill()
myPen.circle(g)
myPen.end_fill()
if (Input == 4):
myPen.clear()
myPen.penup()
myPen.goto(0, 0)
myPen.pendown()
l = int(input('请问你要画就个三角形?'))
m = int(input('请问你要画多大?'))
o = int(input('请问你要每个三角形隔多少?'))
for n in range(l):
myPen.begin_fill()
myPen.circle(m, steps=3)
myPen.end_fill()
myPen.penup()
myPen.forward(o)
myPen.pendown()
else:
myPen.goto(0, 0)
myPen.clear()
myPen.circle(random.randint(1, 100), steps=random.randint(1, 100))
p = int(input('请问还有什么可以帮到你的吗?(作者QQ:1283913046)'))
myPen.pencolor('black')
byebye = ['谢谢你的使用,下次再见']
myPen.penup()
myPen.goto(0, 0)
myPen.pendown()
myPen.clear()
myPen.write( byebye,font=("Airal", 30))
print('谢谢你的使用,下次再见')
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn
QBZ_from tkinter import*
from tkinter.colorchooser import*
from tkinter import messagebox
#说明
introduction = Tk()
introduction.withdraw()
messagebox.showinfo(title='说明',
message='此为一个画图软件,灵感来自于人工智能————御眼重明,目前仍在开发阶段,现在版本为V7 .0(点击确定继续)')
messagebox.showinfo(title='说明',
message='用鼠标操控画笔,按住滑动便可画出图案,可以设置线条颜色和填充颜色,左边是形状按钮,还有背景颜色设置,点击便可画出不同的形状(点击确定开始)')
#设置背景颜色
#创建按钮和画布
window = Tk()
window.configure(background="gray", cursor="fleur", width=1000, height=900)
window.title("绘图软件 V.7.0")
window.geometry("2000x2000")
instruction = Label(window, text="用鼠标左键在下方画布上绘画",
background="gray", cursor="shuttle")
instruction.pack()
BlackButton = Button(window, bg="black", fg="white",
text="背景黑色", cursor="fleur")
BlackButton.pack()
BlackButton.place(x=10, y=450)
whiteButton = Button(window, bg="white",
text="背景白色", cursor="fleur")
whiteButton.pack()
whiteButton.place(x=10, y=420)
fillButton = Button(window, bg="blue", fg="white", activebackground="blue",
activeforeground="white", text="填充颜色", cursor="gumby gumby")
fillButton.pack()
fillButton.place(x=10, y=350)
colorButton = Button(window, bg="skyblue", activebackground="skyblue",
text="线条颜色", cursor="gumby gumby")
colorButton.pack()
colorButton.place(x=10, y=380)
rectButton = Button(window, bg="green", text="方形",
cursor="dotbox")
rectButton.pack()
rectButton.place(x=10, y=310)
lineButton = Button(window, bg="red",
text="铅笔", cursor="gumby gumby")
lineButton.pack()
lineButton.place(x=10, y=270)
circleButton = Button(window, bg="orange",
text="圆圈", cursor="circle")
circleButton.pack()
circleButton.place(x=10, y=230)
explosiveButton = Button(window, bg="pink",
text="线段", cursor="gumby gumby")
explosiveButton.pack()
explosiveButton.place(x=10, y=190)
clearButton = Button(window, bg="yellow",
text="清除", cursor="dotbox")
clearButton.pack()
clearButton.place(x=10, y=150)
myCanvas = Canvas(window, width=1300, height=1000,
cursor="spraycan", bg="white")
myCanvas.pack()
#背景颜色
def Black(event):
myCanvas.configure(bg="black")
window.update()
BlackButton.bind("<Button-1>", Black)
def white(event):
myCanvas.configure(bg="white")
window.update()
whiteButton.bind("<Button-1>", white)
#改变画笔颜色的程序
myColor = "black"
myShape = "line"
myfill = "white"
#定义x,y轴
def pen_down(event):
global prevX
global prevY
prevX = event.x
prevY = event.y
myCanvas.bind("<ButtonPress-1>", pen_down)
#画线的程序
def draw(event):
global prevX
global prevY
if myShape == "line":
myCanvas.create_line(prevX, prevY, event.x, event.y, fill=myColor)
prevX = event.x
prevY = event.y
myCanvas.bind("<B1-Motion>", draw)
def pen_up(event):
if myShape == "circle":
myCanvas.create_oval(prevX, prevY, event.x,
event.y, outline=myColor, width=5, fill=myfill)
if myShape == "rectangle":
myCanvas.create_rectangle(
prevX, prevY, event.x, event.y, outline=myColor, width=5, fill=myfill)
if myShape == "explosive":
myCanvas.create_polygon(prevX, prevY, event.x,
event.y, outline=myColor, width=5, fill=myfill)
myCanvas.bind("<ButtonRelease-1>", pen_up)
#改变颜色
def pick_color(event):
global myColor
myColor = askcolor()
myColor = myColor[1]
colorButton.bind("<Button-1>", pick_color)
def pick_fill(event):
global myfill
myfill = askcolor()
myfill = myfill[1]
fillButton.bind("<Button-1>", pick_fill)
#清除画布的程序
def clear(event):
myCanvas.delete(ALL)
clearButton.bind("<Button-1>", clear)
def set_line(event):
global myShape
myShape = "line"
lineButton.bind("<Button-1>", set_line)
def set_rect(event):
global myShape
myShape = "rectangle"
rectButton.bind("<Button-1>", set_rect)
def set_circle(event):
global myShape
myShape = "circle"
circleButton.bind("<Button-1>", set_circle)
def set_explosive(event):
global myShape
myShape = "explosive"
explosiveButton.bind("<Button-1>", set_explosive)
window.mainloop()
点赞0
评论