Python GUI布局尺寸适配方法

yipeiwu_com5年前Python基础

如下所示:

#coding=utf-8
 
#布局自定义尺寸
from tkinter import *
 
class App:
	def __init__(self,master):
		frame=Frame(master)
		frame.pack(fill=BOTH,expand=1)
		listbox=Listbox(frame)  #listbox=Listbox(frame,height=3,selectmode=BROWSE) #curselection()
		for item in ['red','green','blue','yellow','pink']:
			listbox.insert(END,item)
		listbox.grid(row=0,column=0,sticky=W+E+N+S) # sticky 适配
		text=Text(frame,relief=SUNKEN)
		text.grid(row=0,column=1,sticky=W+E+N+S)
		text.insert(END,'word'*1000)
		frame.columnconfigure(1,weight=1) #尺寸适配 
		frame.rowconfigure(0,weight=1)  #尺寸适配
		
		#Spinbox(frame,values=('a','b','c')).grid(row=3) #get()
 
root=Tk()
root.wm_title('尺寸适配')
app=App(root)
root.geometry("400x300+0+0")  #尺寸适配
root.mainloop()
 

以上这篇Python GUI布局尺寸适配方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

Python实现PS图像调整黑白效果示例

Python实现PS图像调整黑白效果示例

本文实例讲述了Python实现PS图像调整黑白效果。分享给大家供大家参考,具体如下: 这里用Python 实现 PS 里的图像调整–黑白,PS 里的黑白并不是简单粗暴的将图像转为灰度图,...

python 多维高斯分布数据生成方式

python 多维高斯分布数据生成方式

我就废话不多说了,直接上代码吧! import numpy as np import matplotlib.pyplot as plt def gen_clusters():...

python字典setdefault方法和get方法使用实例

这篇文章主要介绍了python字典setdefault方法和get方法使用实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 在pyt...

python生成九宫格图片

python生成九宫格图片

本文实例为大家分享了Python九宫格图片生成的具体代码,供大家参考,具体内容如下 利用Image类将一张图片分割成9张,发朋友圈利器,打包成EXE后,长期使用。 效果大致是: 库:p...

python验证码识别实例代码

本文研究的主要是Python验证码识别的相关代码,具体如下。 Talk is cheap, show you the Code! import numpy as np import...