python tkinter frame remove_Python tkinter之Frame(容器)

# -*- encoding=utf-8 -*-

import tkinter

from tkinter import *

if __name__ == '__main__':

win = tkinter.Tk() # 窗口

win.title('南风丶轻语') # 标题

screenwidth = win.winfo_screenwidth() # 屏幕宽度

screenheight = win.winfo_screenheight() # 屏幕高度

width = 500

height = 400

x = int((screenwidth - width) / 2)

y = int((screenheight - height) / 2)

win.geometry('{}x{}+{}+{}'.format(width, height, x, y)) # 大小以及位置

frame1 = Frame(

master=win, # 父容器

bg='yellow', # 背景颜色

relief='groove', # 边框的3D样式 flat、sunken、raised、groove、ridge、solid。

bd=3, # 边框的大小

height=100, # 高度

width=100, # 宽度

padx=1, # 内间距,字体与边框的X距离

pady=1, # 内间距,字体与边框的Y距离

cursor='circle', # 鼠标移动时样式 arrow, circle, cross, plus...

)

frame1.pack()

frame2 = Frame(

master=win, # 父容器

bg='yellow', # 背景颜色

relief='groove', # 边框的3D样式 flat、sunken、raised、groove、ridge、solid。

bd=3, # 边框的大小

height=100, # 高度

width=100, # 宽度

padx=1, # 内间距,字体与边框的X距离

pady=1, # 内间距,字体与边框的Y距离

cursor='circle', # 鼠标移动时样式 arrow, circle, cross, plus...

)

frame2.pack()

# 未设置propagate(False)时自动根据子组件改变自身大小

frame3 = Frame(

master=win, # 父容器

bg='yellow', # 背景颜色

relief='groove', # 边框的3D样式 flat、sunken、raised、groove、ridge、solid。

bd=3, # 边框的大小

height=100, # 高度

width=100, # 宽度

padx=1, # 内间距,字体与边框的X距离

pady=1, # 内间距,字体与边框的Y距离

cursor='circle', # 鼠标移动时样式 arrow, circle, cross, plus...

)

frame3.pack()

frame3.propagate(False) # 不自动根据子组件改变自身大小

Label(frame2, text='标签', width=3, height=1).pack(side=TOP)

Button(frame2, text='按钮', ).pack(side=TOP)

Label(frame3, text='标签', ).pack(side=TOP)

Button(frame3, text='按钮', ).pack(side=TOP)

win.mainloop()

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值