Mwyldnje2003 2022-09-14 16:32
浏览 29
已结题

pysimple 布局问题

问题遇到的现象和发生背景

我想做一个布局左边有一列,右边一列,左边列可以高度延伸,右边一列同时高度和宽度延伸,自动填充剩余空间。
可当我设置左边一列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()

运行结果及报错内容

img

我的解答思路和尝试过的方法

通过调整 justification="left" 不行,只有TabGroup,不设置expand_x=True时才行,
但是我想在调整窗口大小是TabGroup自动填充空余空间

我想要达到的结果

窗口放大和缩小不影响整体布局

img

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 9月22日
    • 创建了问题 9月14日

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度