Exemple #1
0
def main():
    dictionary_of_figures = {
        'Axis Grid': create_axis_grid,
        'Subplot 3D': create_subplot_3d,
        'Scales': create_pyplot_scales,
        'Basic Figure': create_figure
    }

    layout = [
        [sg.T('Matplotlib Example', font='Any 20')],
        [
            sg.Listbox(dictionary_of_figures.keys(), size=(15, 5), key='-LB-'),
            sg.Image(key='-IMAGE-')
        ],
        [sg.B('Draw'), sg.B('Exit')],
    ]

    window = sg.Window('Title', layout, finalize=True)

    image_element = window['-IMAGE-']  # type: sg.Image

    while True:
        event, values = window.read()
        if event == 'Exit' or event == sg.WIN_CLOSED:
            break
        if event == 'Draw':
            func = dictionary_of_figures[values['-LB-'][0]]
            draw_figure(func(), image_element)
    window.close()
Exemple #2
0
def main():

    layout = [
        [sg.T('Matplotlib Example', font='Any 20')],
        [sg.Image(key='-IMAGE-')],
        [sg.B('Draw'), sg.B('Exit')],
    ]

    window = sg.Window('Title', layout)

    while True:
        event, values = window.read()
        if event == 'Exit' or event == sg.WIN_CLOSED:
            break
        if event == 'Draw':
            draw_figure(create_figure(), window['-IMAGE-'])
    window.close()
Exemple #3
0

# -------------------  Build and show the GUI Window -------------------
graph_elem = sg.Graph((600, 400), (0, 400), (600, 0),
                      enable_events=True,
                      key='_GRAPH_',
                      background_color='lightblue')

layout = [
    [
        sg.Text('Ball Test'),
        sg.T('My IP {}'.format(socket.gethostbyname(socket.gethostname())))
    ],
    [graph_elem],
    # [sg.Up(), sg.Down()],
    [sg.B('Kick'), sg.Button('Exit')]
]

window = sg.Window(
    'Window Title',
    layout,
).Finalize()

area = Playfield()
area.add_balls()

# ------------------- GUI Event Loop -------------------
while True:  # Event Loop
    event, values = window.Read(timeout=0)
    # print(event, values)
    if event in (None, 'Exit'):
            ball.gui_circle_figure = graph_elem.DrawCircle((x, y),
                                                           r,
                                                           fill_color='black',
                                                           line_color='red')


# -------------------  Build and show the GUI Window -------------------
graph_elem = sg.Graph((600, 400), (0, 400), (600, 0),
                      enable_events=True,
                      key='_GRAPH_',
                      background_color='lightblue')

layout = [[
    sg.Text('Ball Test'),
    sg.T('My IP {}'.format(socket.gethostbyname(socket.gethostname())))
], [graph_elem], [sg.B('Kick'), sg.Button('Exit')]]

window = sg.Window(
    'Window Title',
    layout,
).Finalize()

area = Playfield()
area.add_balls()

# ------------------- GUI Event Loop -------------------
while True:  # Event Loop
    event, values = window.Read(timeout=0)
    # print(event, values)
    if event in (None, 'Exit'):
        break