首页 > 编程语言 >Python Tkinter Frame

Python Tkinter Frame

时间:2023-04-11 23:11:51浏览次数:38  
标签:Tkinter option Python Frame width 组件 root frame

Python Tkinter Frame

tkinter的Frame组件:这个组件是容器组件,用于在复杂布局中将其他的组件分组。
所谓容器组件,就是可以收纳其它组件,可以做其它组件的父组件的组件。

frame的属性:
  bg 或 background  :  frame组件的背景颜色
  bd 或 borderwidth  :  frame的边框宽度,默认值为2像素
  width  :  frame组件的宽度,默认值为0
  height  :  frame组件的高度,默认值为0
  padx  :  frame的X方向的内边距,默认值为0
  pady  :  frame的Y方向的内边距,默认值为0
  relief  :  frame的样式

 

from tkinter import  *
root=Tk()
root.geometry ( '300x150+888+444')
frl=Frame(root)# 创建一个框架 Frame
frl.pack()
root.mainloop()

 

 

from tkinter import *  
root1 = Tk()
for fm in ['violet', 'indigo', 'blue', 'green', 'yellow','orange','red']:  
    Frame(height = 25,width = 740,bg = fm).pack()  
root1.mainloop()

 

 

 

from tkinter import *
root = Tk()
frame1 = Frame(root, highlightbackground="blue", highlightthickness=1,width=600, height=100, bd=10)
frame1.pack()
root.mainloop()

 

 

from tkinter import  *
root=Tk()
root.geometry ( '300x150+888+444')
fr1=Frame(root,width=100,height=50,bg='lightgreen')#第4行代码,创建一个框架 Frame
fr1.pack()
root.mainloop()

 

 

from tkinter import  *
root=Tk()
root.geometry ( '300x150+888+444')
fr1=Frame(root,width=100,height=50,bg='lightgreen', borderwidth=5, relief="ridge")#第4行代码,创建一个框架 Frame
fr1.pack()
root.mainloop()

 

 

Relief styles

The relief style of a widget refers to certain simulated 3-D effects around the outside of the widget. Here is a screen shot of a row of buttons exhibiting all the possible relief styles:

The width of these borders depends on the borderwidth option of the widget. The above graphic shows what they look like with a 5-pixel border; the default border width is 2.

 

 

序号可选项 & 描述
1

bg

框架背景颜色

2

bd

框架的大小,默认为 2 个像素

3

cursor

鼠标移动到框架时,光标的形状,可以设置为 arrow, circle, cross, plus 等。

4

height

框架的高度,默认值是 0。

5

highlightbackground

框架没有获得焦点时,高亮边框的颜色,默认由系统指定。

6

highlightcolor

框架获得焦点时,高亮边框的颜色

7

highlightthickness

指定高亮边框的宽度,默认值为 0不带高亮边框)

8

relief

边框样式,可选的有:FLAT、SUNKEN、RAISED、GROOVE、RIDGE。默认为 FLAT。

9

width

设置框架宽度,默认值是 0。

10

takefocus

指定该组件是否接受输入焦点(用户可以通过 tab 键将焦点转移上来),默认为 false。

 

  • bg: The Tkinter frame’s bg option is the normal bg( background color ), which is used to display behind the indicator and the label.
  • bd: The Tkinter frame’s bd option is very much helpful in setting the border size around the indicator, and by default, its size is only 2 pixels.
  • cursor: The “cursor” option helps set this cursor option to a cursor name ( dot, arrow, etc.. ). With this mouse cursor’s help, it will help change the pattern when the cursor/mouse point is over the checkbutton/ we can call it as changing the pattern when the checkbutton is below the cursor point.
  • height: The “height” option of this is only the new frame’s vertical dimension.
  • highlightbackground: The “highlightbackground” option of the Tkinter frame is the focus highlight’s color when the frame don’t have any focus.
  • highlightcolor: The “highlightcolor” option of the Tkinter frame only shows the color in the focus highlight when there is a focus for the frame.
  • highlightthickness: The “highlightthickness” option is the focus highlight’s thickness.
  • relief: The “relief” option of the Tkinter frame is the only checkbutton which don’t even stand out from the background, and by default, the relief value is FLAT (relief = FLAT). You can set this option to all of the other styles.
  • width: The “width” option of the Tkinter frame is the checkbutton’s width which is the size of the text or the image by default. One can also use this option to the number of the characters, and this width checkbutton also have room for many characters always.

 

 

————————————————

REF

https://www.runoob.com/python/python-tk-frame.html

https://tkdocs.com/shipman/ttk-Frame.html

https://www.educba.com/tkinter-frame/#:~:text=relief%3A%20The%20%E2%80%9Crelief%E2%80%9D%20option%20of%20the%20Tkinter%20frame,this%20option%20to%20all%20of%20the%20other%20styles.
https://blog.csdn.net/hyf64/article/details/121259489

 

标签:Tkinter,option,Python,Frame,width,组件,root,frame
From: https://www.cnblogs.com/emanlee/p/17308123.html

相关文章

  • python搭建私有pypi源
    #不带密码认证的dockerrun--namepypi--restartalways-p8080:8080-dpypiserver/pypiserver-P.-a.#带密码认证的dockerrun--namepypi--restartalways-v.htpasswd:/data/.htpasswd-p8080:8080-dpypiserver/pypiserver-P.htpasswd#无需检验......
  • python 开数组
     列表推导式~N=int(10)#二维数组a=[[jforiinrange(N)]forjinrange(20)]a[1][1]=8a[1][2]=2foriinrange(N):forjinrange(N):print(a[i][j],end='')print('')#多维数组a=[[[iforjinrange(N)]forkinrange(3)]......
  • Python爬图片(面向对象版)
    importrequestsfromlxmlimportetreefromthreadingimportThreadclassSpider(object):def__init__(self):self.header={"user-agent":"Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chro......
  • python习题-排列组合序列
    【题目描述】用户输入整数n(1<=n<=26)和整数m(m<=n),然后输入n个不同的字母,请编写程序输出在这n个字母中选择m个字母的所有排列序列和组合序列。【源代码程序】importitertools#输入整数n和mn=int(input("请输入整数n(1<=n<=26):"))m=int(input("请输入整数m(m<=n):"))#输入......
  • Python爬图片
    1importrequests2fromlxmlimportetree34header={5"user-agent":"Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/112.0.0.0Safari/537.36"6}789defspider(page_num):......
  • Python中struct 模块的使用教程
    1.struct简单介绍struct是Python的内置模块,在使用socket通信的时候,大多数据的传输都是以二进制流的形式的存在,而struct模块就提供了一种机制,该机制可以将某些特定的结构体类型打包成二进制流的字符串然后再网络传输,而接收端也应该可以通过某种机制进行解包还原出......
  • ros-python学习样例笔记
    1.通信基本原理介绍待写2.三种通信方式的程序样例(python版)2.1topic通信方式(非自定义和自定义)2.1.1创建工作空间和topic功能包在ubuntu中打开命令行,输入下面的命令创建并初始化工作空间,一定要回到XXX_ws的目录下初始化工作空间#创建工作空间文件夹my_ros(一般命名......
  • 在win10下用pyinstaller 包成.exe win7运行报错error loading Python DLL
    在win10下运行一切正常,复制到win7电脑运行,直接报错,有两个错误,一个是缺少xxxxx.dll一个是errorloadingPythonDLL......正常思路以为是缺少dll,按照提示名称下载dll放到系统目录,没啥用。最后搜索一大堆论坛,找到如下思路:原因为win7系统中缺少运行库,需要安装VisualStudio201......
  • Python queue (队列)
     importthreadingimporttimeimportqueuedefproducer():count=1while1:q.put('No.%i'%count)print('ProducerputNo.%i'%count)time.sleep(1)count+=1defcustomer(name):whi......
  • python opencv putText
    pythonopencvputText importcv2#Loadimageimg=cv2.imread("image.jpg")#Definetexttodrawtext="Hello,World!"#Definepositiontodrawtextatposition=(50,50)#Definefonttype,scale,color,andthicknessfont......