画图软件python版 Version 2.0 Beta 1

预发布版本

2.0版本运用了tkinter库,新增了控制面板

为了这个,我还特地去学了tkinter库...

测试版本,只有三角形和正方形,增加了清除界面和终止程序功能,想退出直接按结束程序键,不用再按x了。

代码如下👇

from turtle import *
import tkinter as tk
import sys

def triangle():
    clearscreen()
    for i in range(3):
        fd(200)
        lt(120)

def rectangle():
    clearscreen()
    for i in range(4):
        fd(200)
        lt(90)

def clearWindow():
    clearscreen()

def exitCommand():
    sys.exit()

window=tk.Tk()
window.title('paintControlPanel_v2.0') # 窗口标题
window.geometry('500x500') #窗口大小

button = tk.Button(text="三角形",font=("Arial",25),fg="black",command=triangle)
button.place(x=0,y=100)

button = tk.Button(text="正方形",font=("Arial",25),fg="black",command=rectangle)
button.place(x=0,y=200)

button = tk.Button(text="清除画板",font=("Arial",25),fg="black",command=clearWindow)
button.place(x=0,y=300)

button = tk.Button(text="结束程序",font=("Arial",25),fg="black",command=exitCommand)
button.place(x=200,y=300)

tk.Label(window, text="画图软件控制面板 v2.0 beta1", font='Consolas 15').pack()

window.mainloop()

如果运行不了,应该是没有sys库,重新装一下python就行了。

注意!!!此程序仅在python 3.x上运行!!!python 2.x会报错!!!

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值