I searched a lot but till i am not getting Graphs and Tables working in PySimpleGUI
inside same frame.
What i achieved so far:
i have one dropdown menu
where symbol of shares come. next to it is graph button
and one table button
. here different graph is comming.
What i want: what i want is a sigle frame
below buttons
where graph will come and inside same frame when i press table button
table should be shown.
So i want single frame destroying every time and generating.
Most of time, it's very difficult to understand what you mean by some simple sentences.
Maybe following example code OK for you,
import PySimpleGUI as sg
headings = ['President', 'Date of Birth']
data = [
['Ronald Reagan', 'February 6'],
['Abraham Lincoln', 'February 12'],
['George Washington', 'February 22'],
['Andrew Jackson', 'March 15'],
['Thomas Jefferson', 'April 13'],
]
width, height = 353, 100
sg.theme('DarkBlue')
sg.set_options(font=('Courier New', 12))
column_layout = [
[sg.Table(data, headings=headings, pad=(0, 0), auto_size_columns=False,
col_widths=(20, 15), num_rows=5, hide_vertical_scroll=True,
justification='left', key='TABLE')],]
frame_layout = [
[sg.Graph((width, height), (0, 0), (width, height), pad=(0, 0),
background_color='green', key='GRAPH')],
[sg.Column(column_layout, pad=(0, 0), visible=True, key='COLUMN',
metadata=True)],]
layout = [
[sg.Button('Frame Visible'), sg.Button('Table Visible')],
[sg.Column(frame_layout, pad=(0, 0), key='FRAME', visible=True,
metadata=True)],]
window = sg.Window("Title", layout, size=(375, 265), finalize=True)
frame = window['FRAME']
column = window['COLUMN']
while True:
event, values = window.read()
if event == sg.WINDOW_CLOSED:
break
elif event == 'Frame Visible':
visible = not frame.metadata
frame.update(visible=visible)
frame.metadata = visible
elif event == 'Table Visible':
if frame.metadata:
visible = not column.metadata
column.update(visible=visible)
column.metadata = visible
window.close()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.