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 searchByLocationRouteResult(param):
    layout = [[sg.Text('We found an amazing route for you..')],
              [sg.Listbox(values=param, size=(30, 3))],
              [sg.Button("Show me on map"),
               sg.Button('Cancel')]]

    windowTextResults = sg.Window('HOLIday').Layout(layout)
    while True:
        event, values = windowTextResults.Read()
        if event in (None, 'Cancel'):
            windowTextResults.close()
            main()
            print("Goodbye")
            break
        elif event in ("Show me on map"):
            windowTextResults.close()
            showMeTheMap(param)
def searchByTextResultWindow(locations):
    layout = [[sg.Text('We found some great places for you..')],
              [sg.Listbox(values=locations, size=(30, 3))],
              [sg.Button("Find visiting route"),
               sg.Button('Cancel')]]

    windowTextResults = sg.Window('HOLIday').Layout(layout)
    while True:
        event, values = windowTextResults.Read()
        if event in (None, 'Cancel'):
            windowTextResults.close()
            main()
            print("Goodbye")
            break
        elif event in ("Find visiting route"):
            windowTextResults.close()
            searchRouteByLocationWindow(values[0])
DEFAULT_BASE64_ICON = b'R0lGODlhIQAgAPcAAAAAADBpmDBqmTFqmjJrmzJsnDNtnTRrmTZtmzZumzRtnTdunDRunTRunjVvnzdwnzhwnjlxnzVwoDZxoTdyojhzozl0ozh0pDp1pjp2pjp2pzx0oj12pD52pTt3qD54pjt4qDx4qDx5qTx5qj16qj57qz57rD58rT98rkB4pkJ7q0J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WBxBgYHHdgt0+cdnMJw5c+jQqYNnoARkAx04kPEvS4PTqBswuPIPUp06duzcuYMHT55wAjkwEahsQgqBNSQIHy582D9BePTs2dOnjx8/f1gJ9GXhRpTqApFQoDChu3cOAps///9D/g+gQvYGjrlw4cU/fUnYX6hAn34HgZMABQo0iJB/Qoe8UxAXOQiEg3wIXvCBQLUU4mAhh0R4SCLqJOSEBhhqkAEGHIYgUDaGICIiIoossogj6yBUTQ4htNgiCCB4oIJAtJTIyI2MOOLIIxMtQQIJIwQZpAgwCKRNI43o6Igll1ySSTsI7dOECSaUYOWVKwhkiyVMYuJlJpp0IpA6oJRTkBQopHnCmmu2IBA2mmQi5yZ0fgJKPP+0IwoooZwzkDQ2uCCoCywUyoIW/5DDyaKefOLoJ6LU8w87pJgDTzqmDNSMDpzqYMOnn/7yTyiglBqKKKOMUopA7JgCy0DdeMEjUDM71GqrrcH8QwqqqpbiayqToqJKLwN5g45A0/TAw7LL2krGP634aoopp5yiiiqrZLuKK+jg444uBIHhw7g+MMsDFP/k4wq22rririu4xItLLriAUxAQ5ObrwzL/0PPKu7fIK3C8uxz0w8EIIwzMP/cM7HC88hxEzBBCBGGxxT8AwQzDujws7zcJQVMEEUKUbPITAt1D78OSivSFEUXEXATKA+HTscC80CPSQNGEccQRYhjUDzfxcjPPzkgnLVBAADs='


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)
Example #5
0
 #[sg.Menu(menu_def, )],
 [
     sg.Text(
         SELECTED_DIR,  #font=15, 
         background_color=sg.LOOK_AND_FEEL_TABLE[THEME]["BACKGROUND"])
 ],
 [
     sg.Frame(
         "To do",
         [
             [
                 sg.Listbox(
                     values=todo_list,
                     key="todo_list",
                     size=(WIDTH, HEIGHT),
                     #no_scrollbar=True,
                     #font=("Times New Roman", 12),
                     enable_events=True,
                     #right_click_menu=['&Right', ["Done", "Copy", "Delete"]],
                     background_color='white',
                 )
             ],
             [sg.InputText(key="input_text_todo", size=(25, 1))],
         ],
         #font = 15,
         background_color='orange',
         element_justification='right',
         title_color='dark blue',
         title_location=sg.TITLE_LOCATION_TOP_RIGHT,
     )
 ],
 [
Example #6
0
     sg.Text('Notes about BAL variability',
             size=(40, 1),
             font=('Comic sans ms', 20),
             text_color='Orange',
             key='_TEXT_005'),
     sg.Text('Notes about quasar in general',
             font=('Comic sans ms', 20),
             text_color='Orange',
             size=(30, 1),
             key='_TEXT__004')
 ],
 [
     sg.Text('', size=(20, 1)),
     sg.Listbox(values=('Must get a follow up', 'May be interesting',
                        'Typical Source'),
                size=(20, 4),
                enable_events=True,
                key='_LIST_'),
     sg.Text('', size=(10, 1), key='_TEXT_002'),
     sg.Slider((1, 10),
               default_value=1,
               key='_SLIDER_',
               visible=True,
               enable_events=True),
     sg.Multiline('',
                  do_not_clear=True,
                  size=(40, 4),
                  enable_events=True,
                  key='_VAR_COMMENT_'),
     sg.Multiline('',
                  do_not_clear=True,
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()
Example #8
0
def mainloop(file, database, savedump, records, orderby, guimode):
    """Get user Janpanse input then parse it and record new words into database."""
    jmd = Jamdict()
    knp = KNP()

    jumandict = sqlite3.connect(database)
    dictcursor = jumandict.cursor()
    dictcursor.execute(
        "CREATE TABLE IF NOT EXISTS words (id INTEGER PRIMARY KEY, name TEXT UNIQUE, desc TEXT, count INTEGER)"
    )
    dumper = open(savedump, 'w')

    # Pass any command line argument for Web use
    if guimode == "web":  # if there is use the Web Interface
        import PySimpleGUIWeb as sg
        import socket
    elif guimode == "tk":  # default uses the tkinter GUI
        import PySimpleGUI as sg
    elif guimode == "qt":
        import PySimpleGUIQt as sg
    else:
        import PySimpleGUIWx as sg

    # All the stuff inside your window.
    header_list = [
        "ID", "词汇", "读法", "原形", "词性", "词性细分", "活用型", "活用形", "语义信息", "代表符号"
    ]
    uifont = "Ariel 32"
    left_column_layout = [
        [
            sg.T("输入日语"),
            sg.FolderBrowse(),
        ],
        [
            sg.Multiline("", size=(75, 10), key="nihongo"),
        ],
        [
            sg.Button("分析",
                      size=(30, 3),
                      font=uifont,
                      button_color=('white', 'green'),
                      key="submit"),
            sg.Button("退出",
                      size=(30, 3),
                      font=uifont,
                      button_color=('white', 'red'),
                      key="exit")
        ],
        [
            sg.Listbox(values=[],
                       enable_events=True,
                       size=(75, 20),
                       key="parsedwords")
        ],
    ]
    right_column_layout = [
        [sg.T("词汇意义")],
        [
            sg.Listbox(values=[],
                       enable_events=True,
                       size=(75, 33),
                       key="foundentries")
        ],
    ]
    layout = [[
        sg.VSeperator(),
        sg.Column(left_column_layout),
        sg.VSeperator(),
        sg.Column(right_column_layout),
    ]]
    # Create the Window
    if guimode == "web":
        hostname = socket.gethostname()
        local_ip = socket.gethostbyname(hostname)
        print("local_ip is " + local_ip)
        window = sg.Window('日语学习',
                           layout,
                           web_ip=local_ip,
                           web_port=8888,
                           web_start_browser=False)
    else:
        window = sg.Window('日语学习', layout)

    resultlist = []
    # Run the Event Loop
    while True:
        event, values = window.read()
        if event == "exit" or event == sg.WIN_CLOSED:
            break
        # Folder name was filled in, make a list of files in the folder
        if event == "submit":
            userinput = values["nihongo"]
            print("=================================")
            print(userinput)
            userinput = userinput.strip()
            userinput = userinput.encode('utf-8',
                                         'surrogatepass').decode('utf-8')

            dumper.write(userinput + "\n\n")

            result = knp.parse(userinput.replace("\n", ""))

            print("=================================")
            print("词素")
            resultlist = result.mrph_list()
            parsedwords = []
            for mrph in resultlist:  # 访问每个词素
                if mrph.midasi in {"、", "。", "「", "」", "\␣"}:
                    continue
                message = "\tID:{}, 词汇:{}, 读法:{}, 原形:{}, 词性:{}, 词性细分:{}, 活用型:{}, 活用形:{}, 语义信息:{}, 代表符号:{}".format(
                    mrph.mrph_id, mrph.midasi, mrph.yomi, mrph.genkei,
                    mrph.hinsi, mrph.bunrui, mrph.katuyou1, mrph.katuyou2,
                    mrph.imis, mrph.repname)
                print(message)
                dumper.write(message + "\n")
                parsedwords += [message]

                # use exact matching to find exact meaning
                dictcheck = jmd.lookup(mrph.genkei)
                if len(dictcheck.entries) == 0:
                    dictcheck = jmd.lookup(mrph.midasi)
                    if len(dictcheck.entries) == 0:
                        dictcheck = jmd.lookup(mrph.yomi)
                if len(dictcheck.entries) > 0:
                    desc = ""
                    for entry in dictcheck.entries:
                        desc = desc + entry.text(compact=False,
                                                 no_id=True) + "\n"
                    print("\n" + desc)
                    dumper.write("\n" + desc + "\n")
                    dictcursor.execute(
                        'INSERT INTO words (name, desc, count) VALUES ("{}", "{}", "{}") ON CONFLICT (name) DO UPDATE SET count = count + 1'
                        .format(mrph.genkei.replace('"', '""'),
                                desc.replace('"', '""'), 1))

            jumandict.commit()
            window["parsedwords"].update(parsedwords)

        elif event == "parsedwords":  # A file was chosen from the listbox
            selectedword = values["parsedwords"][0]
            print(selectedword)
            selectedid = int(selectedword.split(',')[0].split(':')[1].strip())
            print("selectedid=" + str(selectedid) + " among " +
                  str(len(resultlist)) + " entries")
            foundentries = []
            for mrph in resultlist:  # 访问每个词素
                if selectedid != mrph.mrph_id:
                    continue
                message = "\tID:{}, 词汇:{}, 读法:{}, 原形:{}, 词性:{}, 词性细分:{}, 活用型:{}, 活用形:{}, 语义信息:{}, 代表符号:{}".format(
                    mrph.mrph_id, mrph.midasi, mrph.yomi, mrph.genkei,
                    mrph.hinsi, mrph.bunrui, mrph.katuyou1, mrph.katuyou2,
                    mrph.imis, mrph.repname)
                print(message)
                # use exact matching to find exact meaning
                dictcheck = jmd.lookup(mrph.genkei)
                if len(dictcheck.entries) == 0:
                    dictcheck = jmd.lookup(mrph.midasi)
                    if len(dictcheck.entries) == 0:
                        dictcheck = jmd.lookup(mrph.yomi)
                foundentries += [message]
                foundentries += ["==================================="]
                if len(dictcheck.entries) > 0:
                    for entry in dictcheck.entries:
                        desc = entry.text(compact=False, no_id=True)
                        print("\n" + desc)
                        foundentries += [desc]

            window["foundentries"].update(foundentries)

    window.close()
    jumandict.close()
    dumper.close()
Example #9
0
def main():

    layout = [[sg.Text('Process Killer - Choose one or more processes',
                    size=(45, 1), font=('Helvetica', 15), text_color='red')],

              [sg.Listbox(values=[' '], size=(50, 30),
                          select_mode=sg.SELECT_MODE_EXTENDED,  font=('Courier', 12), key='_processes_')],

              [sg.Text('Click refresh once or twice.. once for list, second to get CPU usage')],
              [sg.Text('Filter by typing name', font='ANY 14'), sg.Input(
                  size=(15, 1), font='any 14', key='_filter_')],

              [sg.Button('Sort by Name', ),
               sg.Button('Sort by % CPU', button_color=('white', 'DarkOrange2')),
               sg.Button('Kill', button_color=('white', 'red'), bind_return_key=True),
               sg.Exit(button_color=('white', 'sea green'))]]

    window = sg.Window('Process Killer', layout,
                       keep_on_top=True, auto_size_buttons=False,
                       default_button_element_size=(12, 1), return_keyboard_events=True)

    display_list = None
    # ----------------  main loop  ----------------
    while True:
        # --------- Read and update window --------
        event, values = window.Read()
        if event in (None, 'Exit'):
            break

        # skip mouse, control key and shift key events entirely
        if 'Mouse' in event or 'Control' in event or 'Shift' in event:
            continue
        print(event, values)
        # --------- Do Button Operations --------
        if event == 'Sort by Name':
            psutil.cpu_percent(interval=.1)
            procs = psutil.process_iter()
            all_procs = [[proc.cpu_percent(), proc.name(), proc.pid]
                         for proc in procs]
            sorted_by_cpu_procs = sorted(
                all_procs, key=operator.itemgetter(1), reverse=False)
            display_list = [
                '{:5d} {:5.2f} {}\n'.format(
                    process[2], process[0] / 10, process[1]
                )
                for process in sorted_by_cpu_procs
            ]

            window['_processes_'].update(display_list)
            print(display_list)
        elif event == 'Kill':
            processes_to_kill = values['_processes_']
            for proc in processes_to_kill:
                pid = int(proc[0:5])
                # if sg.popupYesNo('About to kill {} {}'.format(pid, proc[12:]), keep_on_top=True) == 'Yes':
                try:
                    kill_proc_tree(pid=pid)
                except:
                    sg.popup_auto_close(
                        'Error killing process', auto_close_duration=1)
        elif event == 'Sort by % CPU':
            psutil.cpu_percent(interval=.1)
            procs = psutil.process_iter()
            all_procs = [[proc.cpu_percent(), proc.name(), proc.pid]
                         for proc in procs]
            sorted_by_cpu_procs = sorted(
                all_procs, key=operator.itemgetter(0), reverse=True)
            display_list = [
                '{:5d} {:5.2f} {}\n'.format(
                    process[2], process[0] / 10, process[1]
                )
                for process in sorted_by_cpu_procs
            ]

            window['_processes_'].update(display_list)
        else:           # was a typed character
            if display_list is not None:
                new_output = [
                    line
                    for line in display_list
                    if values['_filter_'] in line.lower()
                ]

                window['_processes_'].update(new_output)
    window.close()
Example #10
0
#
# col3 = sg.Column([
#     [sg.Button('Queue', font=('Futura', 18), key='QUEUE')],
#     [sg.Listbox('', [], key='TABLE', size=(600, 800), )],
# ])
#
# col4 = sg.Column([
#     [sg.Button('Render', font=('Futura', 18),pad=(0,100), size=(300,100),key='RENDER')],
#     [sg.Button('ABORT', font=('Futura', 18),button_color='yellow', key='QUEUE',pad=(0,(450,0)))]
# ])
# layout = [[sg.Frame('Watch Folder',[]),sg.InputText('', size=(65, 1), key='WATCHPATH')],[col1, col2, col3,col4]]

"""CELLPHONE"""
col1 = sg.Column([
    [sg.Button('Refresh Source', font=('Futura', 18), key='REFRESH')],
    [sg.Listbox('', [], size=(360, 200), key='SOURCEPATHS', enable_events=True)]
])

col2 = sg.Column([
    [sg.Button('Refresh Presets', font=('Futura', 18), key='REFRESHPR')],
    [sg.Checkbox('Custom only', key='CUSTOMPRESET', default=True, font=('Futura', 15))],
    [sg.Listbox(preset_list, key='RENDERPRESET', size=(360, 100))]
])

col3 = sg.Column([
    [sg.Button('Queue', font=('Futura', 18), key='QUEUE'), sg.Button('Clear', font=('Futura', 18), key='CLEAR')],
    [sg.Listbox('', [], key='TABLE', size=(360, 200), )],
])

col5 = sg.Column([
    [sg.Button('Render', font=('Futura', 18), pad=(5, 5), size=(360, 100), key='RENDER')],