问题遇到的现象和发生背景
我想做一个布局左边有一列,右边一列,左边列可以高度延伸,右边一列同时高度和宽度延伸,自动填充剩余空间。
可当我设置左边一列expand_y=True,右边一列expand_x=True,expand_y=True,后,左边一列居中显示。
用代码块功能插入代码,请勿粘贴截图
import PySimpleGUI as sg
from PySimpleGUI import *
def main_windows():
element_maintain_layout = [[sg.Button("新增"),sg.Button("批量删除")],[sg.Table([[0,0,0,0],[1,1,1,1]],headings=["页面","元素名称","定位方式","定位值"],text_color="black",expand_y=True,expand_x=True,background_color="white")]]
# element_maintain_layout = [[sg.Col([[sg.Button("新增"),sg.Button("批量删除")]],expand_x=True,background_color="black")],[sg.Col([[sg.T("页面维护")]],background_color="black",expand_y=True,justification="left",size=(100,None)),sg.Table([[0,0,0,0],[1,1,1,1]],headings=["页面","元素名称","定位方式","定位值"],text_color="black",expand_y=True,expand_x=True,background_color="white")]]
testCase_maintain_layout = [[sg.Button("新增"),sg.Button("批量删除")],[sg.Table([[0,0,0,],[1,1,1,]],headings=["步骤","数据","预期结果",],text_color="black",expand_y=True,expand_x=True,background_color="white")]]
layout = [
[sg.Col([[sg.Cancel()]],background_color="red",expand_x=True,sbar_background_color="black",justification="left",vertical_alignment="Top")],
[sg.Col([[sg.Ok()]],background_color="red",expand_y=True,sbar_background_color="black",justification="left",vertical_alignment="Top",element_justification='c',size=(100,)),
sg.TabGroup([[sg.Tab('页面元素维护', element_maintain_layout),
sg.Tab('测试用例维护', testCase_maintain_layout),
]], key='-TAB GROUP-',expand_y=True,expand_x=True)],
[sg.Col([[sg.Cancel()]], background_color="red", expand_x=True, sbar_background_color="black",
justification="left", vertical_alignment="Top")],
]
# layout = [[top_layout], [[sg.VSeparator(),]],[left_layout, sg.VSeparator(), right_layout], [sg.Column(column1,expand_x=True)]]
window = sg.Window('爱创测试工具', layout, size=(1500, 800), resizable=True, background_color="white",
icon=windows_icon, margins=(0, 0), use_custom_titlebar=True, finalize=True, keep_on_top=True,element_padding=((0,0),(0,0)))
while True:
event, values = window.read() # 每隔10毫秒重新读一次界面
if event == None:
break
window.close()
main_windows()
运行结果及报错内容
我的解答思路和尝试过的方法
通过调整 justification="left" 不行,只有TabGroup,不设置expand_x=True时才行,
但是我想在调整窗口大小是TabGroup自动填充空余空间
我想要达到的结果
窗口放大和缩小不影响整体布局