Python之tkinter窗口入门学习

目录

Tkinter使用练习:


Tkinter使用练习:

Tkinter 是使用 python 进行窗口视窗设计的模块。作为 python 特定的GUI界面,是一个图像的窗口,tkinter是python 自带的,能够做绘画和界面创造等!

用create_rectangle, create_oval, create_arc, create_polygon, create_line分别绘制矩形,椭圆,圆弧,多边形,线段

from tkinter import *
root = Tk()                                      #初始化窗口
root.title('绘画')                               #顶层窗口名称
                #设置窗口大小        
canvas1=Canvas(width=300, height=400, bg='yellow')     

#在画布上创建文字
canvas1.create_text(100,40,text='hello,Mr.Niu-------',font=("Times",16))

canvas1.pack()
root.mainloop()

from tkinter import *
root = Tk()                                      #初始化窗口
root.title('绘画')                               #顶层窗口名称
                #设置窗口大小        
canvas1=Canvas(width=300, height=400, bg='yellow')     

#在画布上创建文字
canvas1.create_text(100,20,text='hello,Mr.Niu-------',font=("Times",16))

 #(30,30)为左上角坐标,(200,200)右下角坐标    ,填充颜色
canvas1.create_rectangle(50,50,80,80,fill='white')        
 #(30,30)为左上角坐标,(200,200)右下角坐标    ,填充颜色
canvas1.create_rectangle(85,50,115,80,fill='white',outline='red',width='2')




canvas1.pack()
root.mainloop()

create_xx()里的数字意思是坐标:(x1,y1),(x2,y2),(x3,y3)create_xx(x1,y1,x2,y2,x3,y3)

发布了96 篇原创文章 · 获赞 76 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/u010244992/article/details/104706476