PySimpleGUI/Demo_Graph_Element_Sine_Wav...

18 lines
485 B
Python
Raw Normal View History

2018-09-21 04:45:21 +00:00
import math
import PySimpleGUI as sg
layout = [[sg.Graph(canvas_size=(400, 400), graph_bottom_left=(-100,-100), graph_top_right=(100,100), background_color='white', key='graph')],]
form = sg.FlexForm('Graph of Sine Function').Layout(layout)
form.Finalize()
graph = form.FindElement('graph')
2018-09-21 05:09:48 +00:00
graph.DrawLine((-100,0), (100,0))
graph.DrawLine((0,-100), (0,100))
2018-09-21 04:45:21 +00:00
for x in range(-100,100):
y = math.sin(x/20)*50
2018-09-21 05:09:48 +00:00
graph.DrawPoint((x,y), color='red')
2018-09-21 04:45:21 +00:00
button, values = form.Read()