Example #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()
def openWindowImageSearch():
    print('Image search')
    ROOT_DIR = os.path.dirname(
        os.path.abspath(__file__))[0:-7] + "\\data\\blohsaved.png"
    print(ROOT_DIR)
    image_elem = sg.Image(ROOT_DIR)
    layoutOperation = [[
        sg.Text('An image says what a thousand words can\'t..')
    ], [sg.Text('The image :'),
        sg.InputText('path'),
        sg.FileBrowse()], [image_elem],
                       [sg.Button('Search for me'),
                        sg.Button('Cancel')]]
    windowOperation = sg.Window('Text it out').Layout(layoutOperation)

    while True:
        eventOperation, valuesOperation = windowOperation.Read(timeout=50)
        if eventOperation in (None, 'Cancel'):
            windowOperation.close()
            main()
            break
        elif eventOperation in ('Search for me'):
            windowOperation.close()
            searchByImageAlgorithm(valuesOperation[0])

        if valuesOperation[0] != "path":
            image_elem.update(valuesOperation[0])
Example #3
0
def main():
    layout = [[sg.Text('Matplotlib Simple Plot', font='Any 20')],
              [sg.Image(key='-IMAGE-')], [sg.Button('Exit')]]

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

    fig = plt.figure()
    x = np.arange(0, 5, 0.1)
    y = np.sin(x)
    plt.plot(x, y)
    draw_figure(fig, window['-IMAGE-'])

    window.read(close=True)
Example #4
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()
sg.ChangeLookAndFeel('GreenTan')

layout =  [
            [sg.Text('PySimpleGUIWeb running on the web and in your browser!', size=(60,1), font=('Comic sans ms', 20), text_color='red')],
            [sg.Text('This program has been running for... ', size=(30,1)),sg.Text('', size=(30,1), key='_DATE_')],
            [sg.Text('', size=(30,1), key='_TEXT_')],
            [sg.Input('Single Line Input', do_not_clear=True, enable_events=True, size=(30,1))],
            [sg.Multiline('Multiline Input', do_not_clear=True, size=(40,4), enable_events=True)],
            [sg.Multiline('Multiline Output', size=(80,8),  key='_MULTIOUT_', font='Courier 12')],
            [sg.Checkbox('Checkbox 1', enable_events=True, key='_CB1_'), sg.Checkbox('Checkbox 2', default=True, enable_events=True, key='_CB2_')],
            [sg.Combo(values=['Combo 1', 'Combo 2', 'Combo 3'], default_value='Combo 2', key='_COMBO_',enable_events=True, readonly=False, tooltip='Combo box', disabled=False, size=(12,1))],
            [sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(10,3))],
            [sg.Slider((1,100), default_value=80, key='_SLIDER_', visible=True, enable_events=True, orientation='h')],
            [sg.Spin(values=(1,2,3),initial_value=2, size=(4,1))],
            [sg.Image(filename=r'dot:logo.jpg')],
            [sg.OK(), sg.Button('Exit', button_color=('white', 'red'))]
          ]

window = sg.Window('My PySimpleGUIWeb Window',
                   default_element_size=(30,1),
                   font='Helvetica 18',
                   background_image=r'dot:logo.jpg'
                   ).Layout(layout)

start_time = datetime.datetime.now()
while True:
    event, values = window.Read(timeout=10)
    if event != sg.TIMEOUT_KEY:
        print(event, values)
        window.Element('_MULTIOUT_').Update(str(event) + '\n' + str(values), append=True)
            tooltip='update data type',
            readonly=True),
    sg.Input('', size=(15, 1), key='ADR_EDIT', tooltip='update data address'),
    sg.Input('', size=(20, 1), key='ALIAS_EDIT', tooltip='update data alias'),
    sg.Drop(values=intervals,
            key='INTERVAL_EDIT',
            size=(6, 1),
            tooltip='update acquisition interval',
            readonly=True,
            default_value=intervals[3]),
    sg.Checkbox('Active', key='ACTIVATE_EDIT')
]
column1.append(data_row)
# add buttons to enable actions
column1.append([sg.Button("Update"), sg.Button('Delete')])
column2 = [[sg.Image(foto_PATH, pad=(200, 0))],
           [sg.Button("Show raw configuration file"),
            sg.Button('Exit', )]]

main_layout = [[sg.Column(column0)], [sg.Column(column1)],
               [sg.Column(column2)]]

window = sg.Window('Configuration').Layout(main_layout)

data_plc = None
'''
Main loop for GUI
'''
while (1):
    button, values = window.Read()
    if button == None or button == "Exit":
Example #7
0
masterrmag = ['{0:3.3f}'.format(srmag) for srmag in masterrmag]

# The GUI layout
layout = [
    [
        sg.Text('', size=(50, 1)),
        sg.Text('', size=(10, 1)),
        sg.Text('SDSS BAL Factory: Visual Inspection',
                size=(140, 2),
                font=('Comic sans ms', 40),
                text_color='red')
    ],
    [
        sg.Text('', size=(50, 1)),
        sg.Image(
            filename=
            '/Users/vzm83/SDSSIV_BALQSO/pngtree-creative-simple-dividing-line.png',
            visible=True)
    ],
    [
        sg.Text('', size=(30, 1)),
        sg.Button('Previous Quasar', font=('Comic sans ms', 20)),
        sg.Text('', size=(5, 1), key='_TEXT_008'),
        sg.Button('Next Quasar', font=('Comic sans ms', 20)),
        sg.Text('', size=(25, 1), key='_TEXT_009'),
        sg.Button('MARK for future', font=('Comic sans ms', 20)),
        sg.Text('', size=(25, 1)),
        sg.Button('WRITE to Database', font=('Comic sans ms', 20)),
        sg.Text('', size=(25, 1)),
        sg.Button('Reset', font=('Comic sans ms', 20)),
        sg.Text('', size=(20, 1)),
        sg.Text('', size=(5, 1)),
def main():

    fig_dict = {
        'Pyplot Simple': PyplotSimple,
        'Pyplot Formatstr': PyplotFormatstr,
        'PyPlot Three': Subplot3d,
        'Unicode Minus': UnicodeMinus,
        'Pyplot Scales': PyplotScales,
        'Axes Grid': AxesGrid,
        'Exploring Normalizations': ExploringNormalizations,
        'Different Scales': DifferentScales,
        'Pyplot Box Plot': PyplotBoxPlot,
        'Pyplot ggplot Style Sheet': PyplotGGPlotSytleSheet,
        'Pyplot Line Poly Collection': PyplotLinePolyCollection,
        'Pyplot Line Styles': PyplotLineStyles,
        'Pyplot Scatter With Legend': PyplotScatterWithLegend,
        'Artist Customized Box Plots': PyplotArtistBoxPlots,
        'Artist Customized Box Plots 2': ArtistBoxplot2,
        'Pyplot Histogram': PyplotHistogram
    }

    # define the layout

    col_listbox = [[
        sg.Listbox(values=fig_dict.keys(),
                   enable_events=True,
                   size=(25, len(fig_dict.keys())),
                   key='-LISTBOX-')
    ], [sg.Exit(size=(5, 2))]]

    layout = [
        [sg.Text('Matplotlib Plot Browser', font=('current 25'))],
        [
            sg.Text(
                'Choose a plot from the list to see the plot and the source code used to make it.'
            )
        ],
        [
            sg.Column(col_listbox, element_justification='c'),
            sg.Image(key='-IMAGE-'),
            sg.MLine(size=(40, 20), font='Courier 12', key='-MULTILINE-')
        ],
    ]

    # create the window
    window = sg.Window('Embedding Matplotlib In PySimpleGUIWeb', layout)

    while True:  # The event loop
        event, values = window.read()
        # print(event, values)                  # helps greatly when debugging
        if event in (sg.WIN_CLOSED,
                     'Exit'):  # if user closed window or clicked Exit button
            break

        choice = values['-LISTBOX-'][
            0]  # get first listbox item chosen (returned as a list)
        the_plotting_func = fig_dict[
            choice]  # get function to call from the dictionary
        window['-MULTILINE-'].update(inspect.getsource(
            the_plotting_func))  # show source code to function in multiline
        draw_figure(the_plotting_func(), window['-IMAGE-'])  # draw the figure
    window.close()
import cv2, PySimpleGUIWeb as sg
window, cap = sg.Window('Demo Application - OpenCV Integration', [
    [sg.Image(filename='', key='image')],
],
                        location=(800, 400)), cv2.VideoCapture(0)
while window(timeout=20)[0] is not None:
    window['image'](data=cv2.imencode('.png', cap.read()[1])[1].tobytes())
Example #10
0
def create_main_window(settings):
    sg.theme(settings['theme'])

    menu_def = [['&Menu', ['Settings']]]

    layout = [[sg.Menu(menu_def, tearoff=True)],
              [sg.Image('png/cw.png', size=(250, 100))],
              [
                  sg.Text('1 EUR  =', font=('Helvetica', 11)),
                  sg.Text('', size=(19, 1), font=('Helvetica', 11), key='es'),
                  sg.Text('',
                          size=(20, 1),
                          font=('Helvetica', 11),
                          key='_DATE_')
              ], [sg.Text('')],
              [
                  sg.Text('# ', font=('Helvetica', 13), size=(1, 1)),
                  sg.Text('Name', font=('Helvetica', 13), size=(24, 1)),
                  sg.Text(' Price USD', size=(15, 1), font=('Helvetica', 13)),
                  sg.Text(' Price EUR', size=(15, 1), font=('Helvetica', 13))
              ],
              [
                  sg.Text('1 ', font=('Helvetica', 12), size=(1, 1)),
                  sg.Image('png/bit.png', size=(30, 30)),
                  sg.Text('Bitcoin (BTC)',
                          font=('Helvetica', 12),
                          size=(20, 1)),
                  sg.Text('', size=(15, 1), font=('Helvetica', 12),
                          key='coin'),
                  sg.Text('',
                          size=(15, 1),
                          font=('Helvetica', 13),
                          key='btceu')
              ],
              [
                  sg.Text('2 ', font=('Helvetica', 12), size=(1, 1)),
                  sg.Image('png/eth.png', size=(30, 30)),
                  sg.Text('Ethereum (ETH)',
                          font=('Helvetica', 12),
                          size=(20, 1)),
                  sg.Text('', size=(15, 1), font=('Helvetica', 12),
                          key='ethe'),
                  sg.Text('',
                          size=(15, 1),
                          font=('Helvetica', 13),
                          key='eteuro')
              ],
              [
                  sg.Text('3 ', font=('Helvetica', 12), size=(1, 1)),
                  sg.Image('png/xrp.png', size=(30, 30)),
                  sg.Text('Ripple (XRP)', font=('Helvetica', 12),
                          size=(20, 1)),
                  sg.Text('', size=(15, 1), font=('Helvetica', 12), key='xrp'),
                  sg.Text('',
                          size=(15, 1),
                          font=('Helvetica', 13),
                          key='xrpeu')
              ],
              [
                  sg.Text('4 ', font=('Helvetica', 12), size=(1, 1)),
                  sg.Image('png/lite.png', size=(30, 30)),
                  sg.Text('Litecoin (LTC)',
                          font=('Helvetica', 12),
                          size=(20, 1)),
                  sg.Text('',
                          size=(15, 1),
                          font=('Helvetica', 12),
                          key='ltcusd'),
                  sg.Text('',
                          size=(15, 1),
                          font=('Helvetica', 13),
                          key='ltceur')
              ],
              [
                  sg.Text('5 ', font=('Helvetica', 12), size=(1, 1)),
                  sg.Image('png/bch.png', size=(30, 30)),
                  sg.Text('Bitcoin Cash (BCH)',
                          font=('Helvetica', 12),
                          size=(20, 1)),
                  sg.Text('',
                          size=(15, 1),
                          font=('Helvetica', 12),
                          key='bcusd'),
                  sg.Text('',
                          size=(15, 1),
                          font=('Helvetica', 13),
                          key='bceur')
              ],
              [
                  sg.Text('6 ', font=('Helvetica', 12), size=(1, 1)),
                  sg.Image('png/pax.png', size=(30, 30)),
                  sg.Text('Paxos Standard (PAX)',
                          font=('Helvetica', 12),
                          size=(20, 1)),
                  sg.Text('', size=(15, 1), font=('Helvetica', 12),
                          key='paxu'),
                  sg.Text('', size=(15, 1), font=('Helvetica', 13), key='paxe')
              ],
              [
                  sg.Text('7 ', font=('Helvetica', 12), size=(1, 1)),
                  sg.Image('png/stellar.png', size=(30, 30)),
                  sg.Text('Stellar (XLM)',
                          font=('Helvetica', 12),
                          size=(20, 1)),
                  sg.Text('', size=(15, 1), font=('Helvetica', 12),
                          key='xlmu'),
                  sg.Text('', size=(15, 1), font=('Helvetica', 13), key='xlme')
              ]]

    return sg.Window('CW',
                     layout=layout,
                     font='Helvetica 18',
                     web_ip='127.0.0.1',
                     web_port=8888)