Pthon-Tkinter按钮学习-Two

import tkinter
from tkinter import *
def go():  # 函数
    print("go函数")

win = tkinter.Tk()  # 构造窗体
win.title("hello  zhaolin")  # 标题
win.geometry("500x500+500+100")  # 800宽度,800高度,x,y坐标,左上角

button = tkinter.Button(win, text="有种点我0", command=go)  # 收到消息执行go函数
# button.place(height = 40,width=60, x=300,y=500-40,relx=0.5)

# button = tkinter.Button(win, text="有种点我1", command=go)  # 收到消息执行go函数
# button.place(height = 40,width=60, relwidth=0.5, relheight=0.5,x=10,y=10)
# Button(win, text="位置0", command=go).place(height = 40,width=60, x=100,y=100)
Button(win, text="位置9", command=go).place(height = 40,width=60, x=100,y=100, anchor='center')
# Button(win, text="位置1", command=go).place(height = 40,width=60, x=100,y=100, anchor='n')
# Button(win, text="位置2", command=go).place(height = 40,width=60, x=100,y=100, anchor='ne')
# Button(win, text="位置3", command=go).place(height = 40,width=60, x=100,y=100, anchor='e')
# Button(win, text="位置4", command=go).place(height = 40,width=60, x=100,y=100, anchor='se')
# Button(win, text="位置5", command=go).place(height = 40,width=60, x=100,y=100, anchor='s')
# Button(win, text="位置6", command=go).place(height = 40,width=60, x=100,y=100, anchor='sw')
# Button(win, text="位置7", command=go).place(height = 40,width=60, x=100,y=100, anchor='w')
# Button(win, text="位置8", command=go).place(height = 40,width=60, x=100,y=100, anchor='nw')


# button1 = tkinter.Button(win, text="有种点", command=lambda: print("hello world"), width=20, height=10)
# button1.pack()  # 加载到窗体

win.mainloop()  # 进入消息循环机制

'''
in = master  - 相对于其放置小部件的master
in_ = master  - 请参阅'in'选项说明
x = 此小部件左上顶点的x锚点
y = 此小部件左上顶点的y锚点
relx :将此小部件的锚点定位在0.0和1.0之间,相对于主窗口的宽度(1.0是右边缘)
depend:将此小部件的锚点定位在0.0和1.0之间,相对于主窗口的高度(1.0是底边)
anchor:根据给定位置定位锚点,可以为 " n, ne, e, se, s, sw, w, nw, or center ",
        例如:'center'为控件的中心点在给定位置,
             's'为控件底部中心在给定位置,
             'sw'为控件左下角在给定位置。
width : 此小部件的宽度(以像素为单位)
height: 此小部件的高度(以像素为单位)
relwidth : 此小部件的宽度介于0.0和1.0之间,相对于主窗口的宽度(1.0是和主窗口的宽度相同)
relheight: 此小部件的高度介于0.0和1.0之间,相对于主窗口的高度(1.0是和主窗口的高度相同)
bordermode :“inside”或“outside” - 是主窗口的边界宽度到??
'''


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值