zoukankan      html  css  js  c++  java
  • python:窗口化和制作图形

    #
    from tkinter import *
    
    canvas = Canvas(width=800, height=600, bg='yellow')#声明窗口属性
    canvas.pack(expand=YES, fill=BOTH)
    k = 1
    j = 1
    for i in range(0, 26):
        canvas.create_oval(310 - k, 250 - k, 310 + k, 250 + k, width=1)#画圆
        k += j
        j += 1
    mainloop()#执行整个函数

    执行结果:

    #直线
    from tkinter import *
    canvas =Canvas(width=300,height=300,bg='white')#声明窗口属性
    canvas.pack(expand=YES,fill=BOTH)#执行窗口属性
    x0 = 260#声明坐标
    y0 = 260
    y1 = 90
    for i in range(10):
            canvas.create_line(x0,y0,x0,y1, width=1, fill='red')#画直线
            x0 = x0 - 5
            y0 = y0 - 5
            y1 = y1 + 5
    mainloop()#执行整个函数

    执行结果:

    #矩形
    from tkinter import *
    canvas =Canvas(width=300,height=300,bg='white')#声明窗口属性
    canvas.pack(expand=YES,fill=BOTH)#执行窗口属性
    x0 = 263
    y0 = 263
    y1 = 275
    x1 = 275
    for i in range(19):
        canvas.create_rectangle(x0, y0, x1, y1)
        x0 -= 5
        y0 -= 5
        x1 += 5
        y1 += 5
    mainloop()

    执行结果:

  • 相关阅读:
    网络基础
    Linux安装Redis
    mongodb——文档操作
    mangodb——集合的操作
    Linux安装MongoDB
    2021-10-14软件设计师
    2021-10-13
    How do you use System.Drawing in .NET Core?
    C# 9.0 新特性
    Mysql存储引擎
  • 原文地址:https://www.cnblogs.com/dxxblog/p/9008064.html
Copyright © 2011-2022 走看看