from tkinter import *
import tkinter.messagebox as messagebox
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.pack()
self.createWidgets()
def createWidgets(self):
self.nameInput = Entry(self)
self.nameInput.pack()
self.alertButton = Button(self, text='Hello', command=self.hello)
self.alertButton.pack()
def hello(self):
name = self.nameInput.get() or 'world'
messagebox.showinfo('Message', 'hello, %s' % name)
app = Application()
# 设置窗口标题:
app.master.title('这是一个标题')
# 主消息循环:
app.mainloop()
运行结果:
from turtle import *
# 设置色彩模式是RGB:
colormode(255)
lt(90)
lv = 14
l = 120
s = 45
width(lv)
# 初始化RGB颜色:
r = 0
g = 0
b = 0
pencolor(r, g, b)
penup()
bk(l)
pendown()
fd(l)
def draw_tree(l, level):
global r, g, b
# save the current pen width
w = width()
# narrow the pen width
width(w * 3.0 / 4.0)
# set color:
r = r + 1
g = g + 2
b = b + 3
pencolor(r % 200, g % 200, b % 200)
l = 3.0 / 4.0 * l
lt(s)
fd(l)
if level < lv:
draw_tree(l, level + 1)
bk(l)
rt(2 * s)
fd(l)
if level < lv:
draw_tree(l, level + 1)
bk(l)
lt(s)
width(w)
speed("fastest")
draw_tree(l, 4)
done()
运行结果:
下载地址 https://sourceforge.net/projects/eric-ide/files/eric6/stable/ , 下载最新版本即可;
解压安装包,进入文件目录,执行 python install.py 命令(Eric是用python开发的);
注:安装过程中会检查依赖,升级或者安装插件,根据提示进行操作即可,该升级的升级,该安装的安装(安装的东西不少,需要花些时间);