x8mouse 发表于 2017-10-15 09:10:30

{:5_106:}学习收藏..............

林小小 发表于 2017-12-16 21:09:09

dddddddddddddddddddddddd

a13978061328 发表于 2018-2-14 17:07:32

{:10_266:}

cnidily 发表于 2018-3-8 20:07:00

xuexi

zhangxiuyuxzg 发表于 2018-3-13 09:46:35

学习一下!

wbais 发表于 2018-5-17 15:42:42

哭,没有鱼币肿么办。。。

无名似名 发表于 2018-6-7 21:56:35

canvas我看大部分的gui组价都有

zhou995287902 发表于 2018-7-1 16:45:23

学习学习!{:5_91:}

森兔子 发表于 2018-9-2 16:45:32

点赞楼主{:10_245:}功能真的强大{:10_245:}

nbPlus 发表于 2018-9-12 16:55:23

学习

wangzhezhixin 发表于 2018-9-17 08:35:59

小甲鱼老师什么时候讲一下matplotlib,matplotlib好像用的也满多的

学学看看 发表于 2018-11-28 17:52:46

结了霜的泪 发表于 2019-1-21 09:58:18

Leozhanggg 发表于 2017-7-26 15:02
from tkinter import *

root = Tk()


优秀

薄荷的琦姑娘 发表于 2019-3-5 16:23:16

from tkinter import *

root = Tk()

w = Canvas(root,width=600,height=600,background='white')
w.pack()

#辅助线
w.create_line(0,300,600,300,fill='grey',dash=(4,4))

w.create_line(300,0,300,600,fill='grey',dash=(4,4))


center_x,center_y = 300,220

#head 头(直径240)
w.create_oval(180,100,420,340,fill='deepskyblue')

# 脸(直径200)
w.create_oval(200,140,400,340,fill='white')

# 眼睛(长60, 宽50)
w.create_oval(250,120,300,180,fill='white')
w.create_oval(350,120,300,180,fill='white')

# 眼珠子(长15, 宽10)
w.create_oval(280,140,295,160,fill='black')
w.create_oval(320,140,305,160,fill='black')

# 眼珠子发光点(长10, 宽5)
w.create_oval(285,145,290,155,fill='white')
w.create_oval(315,145,310,155,fill='white')

#鼻子(直径20)
w.create_oval(290,165,310,185,fill='red')

#鼻子下方的线
w.create_line(300,185,300,270)

#嘴巴
w.create_arc(230,190,370,270,extent=-180,style=ARC)
#w.create_arc(240,250,360,250,extent=-180,style=ARC)

#胡子
w.create_line(230,185,280,200)
w.create_line(220,215,280,215)
w.create_line(230,245,280,230)
w.create_line(370,185,320,200)
w.create_line(380,215,320,215)
w.create_line(370,245,320,230)

#身体
w.create_rectangle(210,300,390,450,fill='deepskyblue')

#肚子
w.create_oval(230,280,370,420,fill='white')

w.create_arc(230,280,370,420,style=ARC,fill='red')

#项圈
w.create_line(205,295,395,295,capstyle='round',width=20,fill='red')

#铃铛
w.create_oval(285,300,315,330,fill='yellow')
w.create_line(285,315,315,315,capstyle='round',width=2)
w.create_oval(296,318,304,326,fill='red')
w.create_line(300,326,300,330)

#口袋
w.create_arc(250,300,350,400,extent=-180)

#脚
w.create_arc(280,430,320,470,extent=180,fill='white')
w.create_line(280,450,320,450,fill='white')
w.create_oval(190,430,290,470,fill='white')
w.create_oval(410,430,310,470,fill='white')

#左手
points1 =[
    #手臂左上
    210,310,
    #手臂左下
    170,350,
    #手臂右上
    190,370,
    #手臂右下
    210,360
    ]
w.create_polygon(points1,outline='black',fill='deepskyblue')
w.create_oval(150,346,190,386,fill='white')

#右手
points2 =[
    #手臂左上
    390,310,
    #手臂左下
    430,350,
    #手臂右上
    410,370,
    #手臂右下
    390,360
    ]
w.create_polygon(points2,outline='black',fill='deepskyblue')
w.create_oval(450,346,410,386,fill='white')

#擦掉手臂线
w.create_line(210,310,210,350,fill='deepskyblue')
w.create_line(390,310,390,350,fill='deepskyblue')

mainloop()

yysscc 发表于 2019-3-28 11:02:31

FigureCanvasAgg不算canvas的对象吗?

雅蠛蝶~ 发表于 2019-6-5 21:12:16

可以用canvas画一个多边型然后把图片放到多边形里面去吗?请问怎么做?

cheadache 发表于 2019-7-13 14:49:46

本帖最后由 cheadache 于 2019-7-13 15:01 编辑

from tkinter import *


root = Tk()

c = Canvas(root, width=500, height=600, background='white')
c.pack()
grid_x = c.create_line(-250, 0, 250, 0, dash=(10, 10), fill='gray')
grid_y = c.create_line(0, -300, 0, 300, dash=(10, 10), fill='gray')

#所有都在原点绘图,方便对称计算,最后再移动动画面中央
#头
head_01 = c.create_oval(100, 103, -100, -103, fill='DeepSkyBlue')
c.move(head_01, 0, -70)
head_02 = c.create_oval(85, 88, -85, -88, fill='white')
c.move(head_02, 0, -50)
head_eye01 = c.create_oval(20, 23, -20, -23, fill='white')
head_eye02 = c.create_oval(20, 23, -20, -23, fill='white')
c.move(head_eye01, -20, -135)
c.move(head_eye02, 20, -135)
head_eye_hole01 = c.create_oval(6, 8, -6, -8, fill='black')
head_eye_hole02 = c.create_oval(6, 8, -6, -8, fill='black')
c.move(head_eye_hole01, -10, -135)
c.move(head_eye_hole02, 10, -135)
head_eye_flash01 = c.create_oval(2, 5, -2, -5, fill='white')
head_eye_flash02 = c.create_oval(2, 5, -2, -5, fill='white')
c.move(head_eye_flash01, -10, -135)
c.move(head_eye_flash02, 10, -135)
head_nose = c.create_oval(8, 8, -8, -8, fill='red')
c.move(head_nose, 0, -115)
head_mouse01 = c.create_arc(50, 15, -50, -15, style=ARC, extent=-180)
c.move(head_mouse01, 0, -50)
head_mouse02 = c.create_line(0, -35, 0, -107)
head_beard01 = c.create_line(-20, -90, -60, -100)
head_beard02 = c.create_line(20, -90, 60, -100)
head_beard03 = c.create_line(-20, -80, -65, -80)
head_beard04 = c.create_line(20, -80, 65, -80)
head_beard05 = c.create_line(-20, -70, -60, -60)
head_beard06 = c.create_line(20, -70, 60, -60)
#手和胳膊
body_arm_left = c.create_polygon(-80, 0, -80, 40, -125, 50, -135, 35, fill='deepskyblue', outline='black')
body_arm_right = c.create_polygon(80, 0, 80, 40, 125, 50, 135, 35, fill='deepskyblue', outline='black')
body_hand_right = c.create_oval(20, 20, -20, -20, fill='white')
c.move(body_hand_right, 130, 42.5)
body_hand_right = c.create_oval(20, 20, -20, -20, fill='white')
c.move(body_hand_right, -130, 42.5)
body_main = c.create_rectangle(-80, -10, 80, 110, fill='deepskyblue')
body_tummy = c.create_arc(-60, -60, 60, 60, fill='white', extent=270, start=135, style=CHORD)
c.move(body_tummy, 0, 30)
body_bag = c.create_arc(-40, -40, 40, 40, fill='white', extent=-180)
c.move(body_bag, 0, 30)
#腿
cover = c.create_arc(20, 20, -20, -20, fill='white', extent=180)
c.move(cover, 0, 115)
cover02 = c.create_arc(20, 20, -20, -20, fill='white', extent=-180, outline='')
c.move(cover02, 0, 110)
foot_left = c.create_oval(-40, -20, 40, 20, fill='white')
c.move(foot_left, -50, 115)
foot_right = c.create_oval(-40, -20, 40, 20, fill='white')
c.move(foot_right, 50, 115)
#铃铛
bell_07 = c.create_line(-80, -10, 80, -10, fill='black', width=17, capstyle='round')
bell_05 = c.create_line(-80, -10, 80, -10, fill='red', width=15, capstyle='round')
bell_01 = c.create_oval(15, 15, -15, -15, fill='yellow')
bell_02 = c.create_line(-12, -5, 12, -5, fill='black', width=7, capstyle='round')
bell_03 = c.create_line(-12, -5, 12, -5, fill='yellow', width=5, capstyle='round')
bell_04 = c.create_oval(4, 4, -4, -4, fill='red')
c.move(bell_04, 0, 6)
bell_06 = c.create_line(0, 8, 0, 15)

#移动动画面中央
for each in c.find_all():
    c.move(each, 250, 300)

mainloop()

Ruanc 发表于 2019-7-25 14:54:29

abc0012544 发表于 2016-1-29 15:38
请教下,弧线是怎么画的呀?我的参数一直有问题

我也是,画出来的弧线的大小和位置和我预期的都不一样,好奇怪

Ruanc 发表于 2019-7-25 14:56:17

想请教弧线怎么画,参数一直有问题,画出来的和预期的结果不一样哇

回忆浅离 发表于 2019-7-31 12:09:41

没金币了
页: 1 [2] 3
查看完整版本: Tkinter 窗口组件:Canvas