Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PySimpleGui - Nesting Frames

enter image description here

How can I achieve nesting frames in this way. One left Frame (Frame 1), one Right (Frame 2). With another Frame (Frame 3) nested inside and but under the Left Frame contents?

Does the formatting allow for this?

like image 362
Andrea Mele Avatar asked May 04 '26 19:05

Andrea Mele


1 Answers

From outside to inside for your design

  • Left Frame1, right Frame2 in main layout
layout = [
    [sg.Frame("Frame1", ...), sg.Frame("Frame2", ...)],
]
  • Top Frame 4, bottom Frame 3 in Frame1
layout = [
    [sg.Frame("frame 4", ...],
    [sg.Frame("Frame 3", ...],
]
  • Again, Left Frame 5, right Frame 6 in Frame 4
layout = [
    [sg.Frame("Frame 5", ...), sg.Frame("Frame 6", ...)],
]

That's all !

import PySimpleGUI as sg

def blank_frame():
    return sg.Frame("", [[]], pad=(5, 3), expand_x=True, expand_y=True, background_color='#404040', border_width=0)

sg.theme('DarkGrey4')

layout_frame1 = [
    [blank_frame(), blank_frame()],
    [sg.Frame("Frame 3", [[blank_frame()]], pad=(5, 3), expand_x=True, expand_y=True, title_location=sg.TITLE_LOCATION_TOP)],
]

layout_frame2 = [[blank_frame()]]

layout = [
    [sg.Frame("Frame 1", layout_frame1, size=(280, 250)),
     sg.Frame("Frame 2", layout_frame2, size=(200, 250), title_location=sg.TITLE_LOCATION_TOP)],]

window = sg.Window("Title", layout, margins=(2, 2), finalize=True)

while True:

    event, values = window.read()
    if event == sg.WINDOW_CLOSED:
        break

window.close()

enter image description here

like image 97
Jason Yang Avatar answered May 06 '26 09:05

Jason Yang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!