tkinter之grid布局

简介: tkinter之grid布局
import tkinter as tk
from tkinter import messagebox
from PIL import Image, ImageTk

root = tk.Tk()
root.title("逻辑网")
root.iconbitmap('../image/icon.ico')
root.resizable(0, 0)
tk.Label(root, text="用户名").grid(row=0, sticky="w")
tk.Label(root, text="密码").grid(row=1, sticky="w")
tk.Entry(root).grid(row=0, column=1)
tk.Entry(root, show="*").grid(row=1, column=1)
# 加载图片LOGO,注意这里是gif格式的图片
image = Image.open("../image/eyes.png")
photo = ImageTk.PhotoImage(image)
# photo = tk.PhotoImage(file="C:/Users/Administrator/Desktop/1.gif")
tk.Label(root, image=photo).grid(row=0, column=2, rowspan=2, padx='4px', pady='5px')


# 编写一个简单的回调函数
def login():
    messagebox.showinfo("温馨提示", '你很穷!')


# 使用grid()函数来布局,并控制按钮的显示位置
tk.Button(root, text="登录", width=10, command=login).grid(row=3, column=0, columnspan=2, sticky="w", padx=10, pady=5)
tk.Button(root, text="退出", width=10, command=root.quit).grid(row=3, column=1, columnspan=2, sticky="e", padx=10,
                                                               pady=5)
# 开启事件主循环
root.mainloop()
目录
相关文章
|
24天前
|
移动开发 JavaScript 小程序
uView Grid 宫格布局
uView Grid 宫格布局
23 0
|
5月前
|
Python
tkinter之grid布局
tkinter之grid布局
24 0
|
7月前
|
前端开发 容器
前端页面布局之【Grid布局】详解
前端页面布局之【Grid布局】详解
393 0
|
8月前
|
容器
Grid网格布局
Grid网格布局
|
19天前
|
开发者
【干货分享】Grid 布局和 Flex 布局
【干货分享】Grid 布局和 Flex 布局
|
4月前
|
前端开发 容器
CSS布局模式之Flex布局&Grid布局(三)
CSS布局模式之Flex布局&Grid布局
|
4月前
|
前端开发 开发者 UED
CSS布局模式之Flex布局&Grid布局(一)
CSS布局模式之Flex布局&Grid布局
|
4月前
|
前端开发 开发者 容器
CSS布局模式之Flex布局&Grid布局(二)
CSS布局模式之Flex布局&Grid布局
|
8月前
|
前端开发 容器
css3-grid:grid 布局 / 基础使用
css3-grid:grid 布局 / 基础使用
31 0
css3-grid:grid 布局 / 基础使用
|
前端开发 容器
Grid网格布局学习笔记
Grid网格布局学习笔记
77 0
Grid网格布局学习笔记