Loading [MathJax]/jax/input/TeX/config.js
前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >Python - Tkinter pac

Python - Tkinter pac

作者头像
py3study
发布于 2020-01-10 07:36:15
发布于 2020-01-10 07:36:15
91300
代码可运行
举报
文章被收录于专栏:python3python3
运行总次数:0
代码可运行

This geometry manager organizes widgets in blocks before placing them in the parent widget.

Syntax:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
widget.pack( pack_options )

Here is the list of possible options:

  • expand: When set to true, widget expands to fill any space not otherwise used in widget's parent.
  • fill: Determines whether widget fills any extra space allocated to it by the packer, or keeps its own minimal dimensions: NONE (default), X (fill only horizontally), Y (fill only vertically), or BOTH (fill both horizontally and vertically).
  • side: Determines which side of the parent widget packs against: TOP (default), BOTTOM, LEFT, or RIGHT.

Example:

Try following example by moving cursor on different buttons:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
from Tkinter import *

root = Tk()
frame = Frame(root)
frame.pack()

bottomframe = Frame(root)
bottomframe.pack( side = BOTTOM )

redbutton = Button(frame, text="Red", fg="red")
redbutton.pack( side = LEFT)

greenbutton = Button(frame, text="Brown", fg="brown")
greenbutton.pack( side = LEFT )

bluebutton = Button(frame, text="Blue", fg="blue")
bluebutton.pack( side = LEFT )

blackbutton = Button(bottomframe, text="Black", fg="black")
blackbutton.pack( side = BOTTOM)

root.mainloop()
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/07/30 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
python tkinter
1、 from tkinter import Label widget=Label(None,text='Hello Gui') widget.pack() widget.mainloop() 2| expand fill:组件随窗口调整大小 from tkinter import * widget=Label(None,text='Hello Gui') widget.pack(expand=YES,fill=BOTH) widget.mainloop()
用户5760343
2022/05/13
1.3K0
python tkinter
python tkinter(2)
1、设置label的字体、颜色、背景色、宽、高 from tkinter import * root = Tk() labelfont = ('times', 20, 'bold') # family, size, style widget = Label(root, text='Hello config world') widget.config(bg='black', fg='yellow') # yellow text on black label widget.config(font=labelfont) # use a larger font widget.config(height=3, width=20) # initial size: lines,chars widget.pack(expand=YES, fill=BOTH) root.mainloop() 2、bd设置边框、relief=设置边框类型,cursor鼠标
用户5760343
2022/05/13
8320
python tkinter(2)
Python Tkinter 简单使用
label = Label(root, text="Hello World!", height=10, width=30, fg="black", bg="pink")
py3study
2020/01/17
9530
快速学会Python tkinter的Pack布局
GUI编程就相当于小孩子搭积木,每个积木块应该放在哪里?每个积木块显示为多大?也就是这些大小和位置都需要进行管理,而布局管理器正是负责管理各组件的大小和位置,此外,当用户调整了窗口的大小之后,布局管理器还会自动调整窗口中各组件的大小和位置。
疯狂软件李刚
2020/06/24
1.7K0
python tkinter 常用组件封装
""" wrap up widget construction in functions for easier use, making some assumptions (e.g., expansion); use extras kw args for width, font/color """
用户5760343
2022/05/13
8910
Python打包GUI界面组件汇总,Tkinter(TK)实例代码
Tkinter是python自带的gui界面工具,作为非常强大的内置库tkinter,利用它可以很轻松做出一些简易的UI界面,Tkinter中给我们提供了15种控件供大家使用。
二爷
2020/07/22
7.1K0
Python打包GUI界面组件汇总,Tkinter(TK)实例代码
python textEditor 自制编辑器
""" ############################################################################### An extended Frame that makes window menus and toolbars automatically. Use GuiMakerFrameMenu for embedded components (makes frame-based menus). Use GuiMakerWindowMenu for top-level windows (makes Tk8.0 window menus). See the self-test code (and PyEdit) for an example layout tree format. ############################################################################### """
用户5760343
2022/05/13
1.3K0
python textEditor 自制编辑器
python编写简单抽奖系统
#!/usr/bin/env python coding=utf-8 from Tkinter import * import time import random class App: def init(self,master): frame = Frame(master) frame.pack() v = StringVar() self.e = Entry(frame,textvariable=v,bd='5')
艳艳代码杂货店
2021/11/01
9060
教你用Python写界面
作为Pyhon开发者,你迟早都会碰到图形用户界面(GUI)应用开发任务,这时候我们就需要一些界面库来帮助我们快速搭建界面,python的界面库很多,我认识的并不多,这里只列出几种我认识的
py3study
2020/01/07
4.6K0
教你用Python写界面
python tkinter 设计指南
pack() 是一种较为简单的布局方法,在不使用任何参数的情况下,它会将控件以添加时的先后顺序,自上而下,一行一行的进行排列,并且默认居中显示。pack() 方法的常用参数如下所示:
独元殇
2023/03/21
7.1K0
python clock 时钟
--------------------------------windows.py------------------------------- """ ############################################################################### Classes that encapsulate top-level interfaces. Allows same GUI to be main, pop-up, or attached; content classes may inherit from these directly, or be mixed together with them per usage mode; may also be called directly without a subclass; designed to be mixed in after (further to the right than) app-specific classes: else, subclass gets methods here (destroy, okayToQuit), instead of from app-specific classes--can't redefine. ############################################################################### """
用户5760343
2022/05/13
9120
python clock 时钟
【python】tkinter组件,from Tkinter import * 与 import Tkinter 的区别
tkinter可以用于 Python 的 GUI 编程,提供了一些常用的组件,如按钮、标签、文本框等,方便用户进行界面设计和交互。可以通过导入 tkinter 模块来使用这些组件。
20岁爱吃必胜客
2023/03/09
3.4K0
【python】tkinter组件,from Tkinter import * 与 import Tkinter 的区别
​Python | GUI编程之tkinter (一)
本文内容为使用Python3的tkinter模块,开发GUI。在阅读本文前,请确保你已经或可能满足以下条件:
LogicPanda
2019/07/30
6.1K0
python tkinter(3) menu 例子
2、optionmenu from tkinter import * root = Tk()
用户5760343
2022/05/13
7090
python tkinter(3) menu 例子
python开发的简单窗口界面的倒计时界面
下面的代码通过Tkinter制作windows窗口界面,然后时间了一个简单的倒计时功能,代码可以直接运行
代码伴一生
2021/11/03
9340
python的tkinter使用
当点击按钮Hello World(click me)时,会打印出“hi there, everyone !"。点击按钮QUIT则退出。
py3study
2020/01/07
1.2K0
Tkinter 入门之旅
Tkinter 作为 Python 的标准库,是非常流行的 Python GUI 工具,同时也是非常容易学习的,今天我们就来开启 Tkinter 的入门之旅
周萝卜
2021/11/08
6.6K0
python3 GUI
参考一:https://www.cnblogs.com/monsteryang/p/6558904.html 参考二:https://blog.csdn.net/yingshukun/article/details/53983812 参考三:https://blog.csdn.net/C_Creator/article/details/52383334
py3study
2020/01/06
1.2K0
python3 GUI
python 简易编辑器 text
print('PP4E scrolledtext') from tkinter import *
用户5760343
2022/05/13
4440
python 简易编辑器 text
Python的GUI编程和tkinter,Wxpython
根窗体是图像化应用程序的根控制器,是tkinter的底层控件的实例。当导入tkinter模块后,调用 Tk()方法可初始化一个根窗体实例 root ,用 title() 方法可设置其标题文字,用geometry()方法可以设置窗体的大小(以像素为单位)。将其置于主循环中,除非用户关闭,否则程序始终处于运行状态。执行该程序,一个窗体就呈现出来了。在这个主循环的根窗体中,可持续呈现中的其他可视化控件实例,监测事件的发生并执行相应的处理程序
十二惊惶
2024/02/28
5420
相关推荐
python tkinter
更多 >
领券
💥开发者 MCP广场重磅上线!
精选全网热门MCP server,让你的AI更好用 🚀
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验