test = launch.mod.get("{}".format(element[0])) print(launch.mod.get("Add-Computer")[1]) input_list = [] for x in test[2]: input_list.append(x) launch.layout.append( [Sg.InputText("{}".format(str(x)), key="{}".format(x))]) launch.layout_finals = [ [ Sg.Column([[ Sg.DropDown(launch.dropdown_list, enable_events=True, default_value=v[0]) ], [Sg.Button("Execute", size=(25, 1))]]) ], [Sg.Column(launch.layout_final)], [ Sg.DropDown(launch.mod.get("{}".format(element[0]))[3], key="dd_ex") ], [ Sg.Column(launch.layout), Sg.Column([[ Sg.Text(launch.mod.get("{}".format(element[0]))[1], size=(800, 200), key="{}".format(element[0]), auto_size_text=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()
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()
button_grid = [[ sg.Button('?', size=(4, 2), key=(i, j), pad=(0, 0)) for j in range(w) ] for i in range(h)] mode_toggle = [[ sg.Text("Click Mode: "), sg.Button('Mine', button_color=mode_off, key='mine_mode', pad=(0, 0)), sg.Button('Clear', button_color=mode_on, key='clear_mode', pad=(0, 0)) ]] top_row = [ sg.Text("Mines Remaining:"), sg.Text(f"{mines}", pad=(50, 0), text_color='red', background_color='686463', key='remaining'), sg.Column(mode_toggle) ] layout = [top_row, *button_grid] window = sg.Window('Minesweeper', layout) while True: event, values = window.read() if event in (None, 'Exit'): exited = True break if event in ('mine_mode', 'clear_mode'): clear_mode = event == 'clear_mode' window.FindElement('mine_mode').update( button_color=mode_off if clear_mode else mode_on) window.FindElement('clear_mode').update(
def main(): isGameRestart = True SelBtLayout = [ [sg.Button('不是雷',key='noTagMine')], \ [sg.Button('标注雷',key='tagMine')],\ [sg.Button('点按此格',key='clickCell')],\ [sg.Button('结束本局',key='showAll')],\ [sg.Text('本局成绩:',key='gameResult')], ] MinesLayout = [[ sg.Button('?', size=(4, 2), key=(i, j), pad=(0, 0), button_color=('white', 'green')) for j in range(MAX_COLS) ] for i in range(MAX_ROWS)] mainLayout=[[sg.Frame('雷区', MinesLayout, font='Any 20', title_color='green'),\ sg.Column(SelBtLayout)],\ [sg.Button('重新开始游戏',key='restartGame'),\ sg.Button('退出游戏',key='exitGame')] ] window = sg.Window('扫雷', mainLayout) while isGameRestart: minesInfo = getMineMap() selX = selY = -1 oldX = oldY = -1 isGameContinue = True while True: event, values = window.read() if event in (sg.WIN_CLOSED, 'Exit') or event == 'exitGame': isGameRestart = False #最后从屏幕上移除 window.close() break elif event == 'restartGame': showAllMines(window) for i in range(MAX_ROWS): for j in range(MAX_ROWS): window[(i, j)].update("?", button_color=('white', 'green')) successTags.clear() break if isGameContinue: if event == 'tagMine' and selX >= 0 and selY >= 0 and minesInfo[ selX][selY] == MINE_TAG: successTags.add((selX, selY)) elif event == 'noTagMine' and selX >= 0 and selY >= 0 and minesInfo[ selX][selY] == MINE_TAG: successTags.discard((selX, selY)) if event == 'tagMine' or event == 'noTagMine': if selX >= 0 and selY >= 0: if event == 'tagMine': if window[(selX, selY)].get_text() == '?': window[(selX, selY)].update('*') else: if window[(selX, selY)].get_text() == '*': window[(selX, selY)].update('?', button_color=('white', 'green')) elif event == 'clickCell': window[(selX, selY)].update(minesInfo[selX][selY], button_color=('yellow', 'blue')) if window[(selX, selY)].get_text() == MINE_TAG: window[(selX, selY)].update(minesInfo[selX][selY], button_color=('red', 'black')) elif event == 'showAll': showAllMines(window) isGameContinue = False else: if oldX >= 0 and oldY >= 0 and window[ (selX, selY)].get_text() != MINE_TAG: window[(oldX, oldY)].update(button_color=('white', 'green')) selX = event[0] selY = event[1] if window[(selX, selY)].get_text() != MINE_TAG: window[event].update(button_color=('Green', 'black')) oldX = selX oldY = selY
# ]) # # 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')],