# кнопочки для проверки белого списка dispatch_dictionary = { ' Егорьевск ': button1, ' Раменское ': button2, ' Шатура ': button3, ' МАП4 ': button4, ' Конверт ': button5 } # кнопки для конкретно гуи layout = [[sg.Text('Добро пожаловать!', auto_size_text=True, justification='center', size=(34,2) )], [sg.Text('1.для начала cконвертируйте отчет РНИСа и сохраните его.', auto_size_text=True, justification='center', size=(34,0) )], [sg.Text('2. затем выбирайте какие листы создавать. Загрузите файл и затем сохраните.', auto_size_text=True, justification='center', size=(34,3) )], [sg.Button(' Егорьевск ', size=(10,2), border_width=(5), pad=((0, 0), 0)), sg.Button(' Раменское ', size=(10,2), border_width=(5), pad=((0, 0), 0)), \ sg.Button(' Шатура ', size=(10,2), border_width=(5), pad=((0, 0), 0))], [sg.Button(' МАП4 ', size=(34,2), border_width=(5), pad=((0, 0), 0)) ], \ [sg.Button(' Конверт ', size=(34,2), border_width=(5), pad=((0, 0), 0))], [sg.Quit(' Выход ', size=(6,2), pad=((230, 0), 3))]] # титульное окно window = sg.Window('RNISka Reports', layout) # белый список while True: # ифелс event, value = window.read() if event in (' Выход ', sg.WIN_CLOSED): break # белый список в действии
def main(): sg.theme("LightGreen") # Define the window layout layout = [ [sg.Text("OpenCV Demo", size=(60, 1), justification="center")], [sg.Image(filename="", key="-IMAGE-")], [sg.Radio("None", "Radio", True, size=(10, 1))], [ sg.Radio("threshold", "Radio", size=(10, 1), key="-THRESH-"), sg.Slider( (0, 255), 128, 1, orientation="h", size=(40, 15), key="-THRESH SLIDER-", ), ], [ sg.Radio("canny", "Radio", size=(10, 1), key="-CANNY-"), sg.Slider( (0, 255), 128, 1, orientation="h", size=(20, 15), key="-CANNY SLIDER A-", ), sg.Slider( (0, 255), 128, 1, orientation="h", size=(20, 15), key="-CANNY SLIDER B-", ), ], [ sg.Radio("canny", "Radio", size=(10, 1), key="-CANNY-"), sg.Slider( (0, 255), 128, 1, orientation="h", size=(20, 15), key="-CANNY SLIDER A-", ), sg.Slider( (0, 255), 128, 1, orientation="h", size=(20, 15), key="-CANNY SLIDER B-", ), ], [ sg.Radio("blur", "Radio", size=(10, 1), key="-BLUR-"), sg.Slider( (1, 11), 1, 1, orientation="h", size=(40, 15), key="-BLUR SLIDER-", ), ], [ sg.Radio("hue", "Radio", size=(10, 1), key="-HUE-"), sg.Slider( (0, 225), 0, 1, orientation="h", size=(40, 15), key="-HUE SLIDER-", ), ], [ sg.Radio("enhance", "Radio", size=(10, 1), key="-ENHANCE-"), sg.Slider( (1, 255), 128, 1, orientation="h", size=(40, 15), key="-ENHANCE SLIDER-", ), ], [ sg.Radio("enhance", "Radio", size=(10, 1), key="-ENHANCE-"), sg.Slider( (1, 255), 128, 1, orientation="h", size=(40, 15), key="-ENHANCE SLIDER-", ), ], [sg.Button("Exit", size=(10, 1))], ] # Create the window and show it without the plot window = sg.Window("OpenCV Integration", layout, location=(800, 400)) cap = cv2.VideoCapture(0) while True: event, values = window.read(timeout=20) if event == "Exit" or event == sg.WIN_CLOSED: break ret, frame = cap.read() if values["-THRESH-"]: frame = cv2.cvtColor(frame, cv2.COLOR_BGR2LAB)[:, :, 0] frame = cv2.threshold(frame, values["-THRESH SLIDER-"], 255, cv2.THRESH_BINARY)[1] elif values["-CANNY-"]: frame = cv2.Canny(frame, values["-CANNY SLIDER A-"], values["-CANNY SLIDER B-"]) elif values["-BLUR-"]: frame = cv2.GaussianBlur(frame, (21, 21), values["-BLUR SLIDER-"]) elif values["-HUE-"]: frame = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) frame[:, :, 0] += int(values["-HUE SLIDER-"]) frame = cv2.cvtColor(frame, cv2.COLOR_HSV2BGR) elif values["-ENHANCE-"]: enh_val = values["-ENHANCE SLIDER-"] / 40 clahe = cv2.createCLAHE(clipLimit=enh_val, tileGridSize=(8, 8)) lab = cv2.cvtColor(frame, cv2.COLOR_BGR2LAB) lab[:, :, 0] = clahe.apply(lab[:, :, 0]) frame = cv2.cvtColor(lab, cv2.COLOR_LAB2BGR) imgbytes = cv2.imencode(".png", frame)[1].tobytes() window["-IMAGE-"].update(data=imgbytes) window.close()
sg.InputText(URL, size=INPUT_SIZE) ], [sg.Text('Query', size=LABEL_SIZE), sg.InputText(QUERY, size=INPUT_SIZE)], [ sg.Text('Page Count', size=LABEL_SIZE), sg.Slider(range=(1, 10), orientation='h', default_value=5) ], [ sg.Table(res, headings=['Job Title', 'Date', 'URL'], key='out', num_rows=10, def_col_width=50, max_col_width=50, enable_events=True) ], [sg.Button('Scrape')]] # Create the Window window = sg.Window('InternSG Scraper', layout) # Event Loop to process "events" and get the "values" of the inputs while True: event, values = window.read() if event == sg.WIN_CLOSED or event == 'Cancel': # if user closes window or clicks cancel break elif event == 'Scrape': url, query, page_amount, *_ = list(values.values()) res = scrape(url, query, int(page_amount)) window['out'].update(res) else: #copies selected url url = res[values['out'][0]][2]
import pandas as pd sg.theme('DarkAmber') # Add a touch of color # All the stuff inside your window. layout = [[sg.Text('Tableau Clustering Tool')], [sg.In("Browse For Input File Location(CSV)..."), sg.FileBrowse()], [sg.In("Browse For Output File Location..."), sg.SaveAs()], [ sg.Text("Desired Clusters Per Territory: "), sg.Slider(range=(5, 30), default_value=10, size=(15, 20), orientation='horizontal') ], [sg.Button('Ok'), sg.Button('Validate'), sg.Button('Exit')], [ sg.ProgressBar(200, orientation='h', size=(20, 20), key='progbar'), sg.Text("Clustering Progress", key='cpg') ], [ sg.Text("Created by Hunter Barcello : [email protected]", font='Helvetica, 7') ]] # Create the Window
def dl(m_id): scrap = cs.create_scraper() print(m_id) try: scrapped = scrap.get(f"https://mangadex.org/api/manga/{m_id}/") m_info = json.loads(scrapped.text) except (json.decoder.JSONDecodeError, ValueError) as e: sg.popup_ok("An error occured!") return try: title = m_info['manga']['title'] desc = m_info['manga']['description'] #Now, we get all chapters in our required language and sort cinfo = {} chap = [] chap_data = [] for c in m_info["chapter"]: if (m_info["chapter"][str(c)]["lang_code"] == "gb"): cinfo["chap_no"] = m_info["chapter"][str(c)]["chapter"] cinfo["chap_id"] = c chap.append(m_info["chapter"][str(c)]["chapter"]) chap_data.append(cinfo) cinfo = {} chap = list(set(chap)) chap.sort(key=to_float) for c in chap: if (c == ""): c = "Oneshot" if (not chap): sg.popup_ok("No Chapters available!") guiplace = [] temp = [] counter = 0 for c in chap: temp.append(sg.Checkbox(str(c), default=True, key=c)) counter += 1 if (not counter % 15): guiplace.append(temp) temp = [] guiplace.append(temp) #turned off resizeable because elements don't resize themselves unlike CSS in PSG layout = [ [sg.Text(text=title, font='comic 18', justification='center')], #use multiline until I can get text wrapping to work properly [ sg.Multiline(default_text=desc, font='comic 13', size=(60, 15), justification='center', key="desc") ], [ sg.Text(text="Available chapters:", font='comic 16', justification='center') ], [ sg.Button("Download"), sg.Button("Cancel"), sg.Button("Check/Uncheck all", key="-CHECK-") ] ] for listt in guiplace: layout.append(listt) win = sg.Window("Manga info", layout) dl = False dl_chapters = [] dl_cinfo = [] while 1: event, values = win.read() if (event == "Download"): dl = True for v in values: if (v != "desc" and values[v]): dl_chapters.append(int(v)) for a in dl_chapters: for c in chap_data: if (c['chap_no'] == str(a)): dl_cinfo.append(c) dl_cinfo.sort(key=lambda x: to_float(x['chap_no'])) sg.PopupOK('downloading chapters, please wait') actually_download(dl_cinfo, title, scrap) sg.PopupOK("done!") break if (event == "Cancel" or event == sg.WIN_CLOSED): break if (event == "-CHECK-"): for c in chap: if (values[c]): win[c].update(False) else: win[c].update(True) except: sg.popup("an error occured :(")
sg.Slider((0, 225), 0, 1, orientation='h', size=(40, 15), key='hue_slider') ], [ sg.Radio('enhance', 'Radio', size=(10, 1), key='enhance'), sg.Slider((1, 255), 128, 1, orientation='h', size=(40, 15), key='enhance_slider') ], [sg.Button('Exit', size=(10, 1))]] # 窗口设计 window = sg.Window('OpenCV实时图像处理', layout, location=(800, 400), finalize=True) # 打开内置摄像头 cap = cv2.VideoCapture(0) while True: event, values = window.read(timeout=0, timeout_key='timeout') # 实时读取图像 ret, frame = cap.read() if values['thresh']: frame = cv2.cvtColor(frame, cv2.COLOR_BGR2LAB)[:, :, 0] frame = cv2.threshold(frame, values['thresh_slider'], 255, cv2.THRESH_BINARY)[1] if values['canny']:
log_file = 'run_log.txt' logging.basicConfig( level=logging.DEBUG, format='%(name)s, %(asctime)s, [%(levelname)s], %(message)s', filename=log_file, filemode='w') buffer = '' ch = Handler() ch.setLevel(logging.INFO) logging.getLogger('').addHandler(ch) layout = [ [sg.Text('Number:'), sg.Input(key='input')], [sg.Button('Run')], [sg.Output(size=(100, 10), key='log')], [sg.Button('Exit')], ] window = sg.Window('Window Title', layout) while True: # Event Loop event, values = window.read() if event == sg.WIN_CLOSED or event == 'Exit': break if event == 'Run': logging.info('Running...') window.close()
# GUI initialization sg.theme('LightBlue') sg.SetOptions(icon=iconWindow, font='Helvetica', text_justification='center') layout = [[ sg.TabGroup([[ sg.Tab('Converter', layout=converter_layout()), sg.Tab('Telegram', layout=telegram_layout()), sg.Tab('Help', layout=help_layout()) ]], font=('Helvetica', 9)) ], [ sg.Button('', key='Exit', image_filename="./static/exit.png", button_color=('#E3F2FD', '#E3F2FD')) ]] window = sg.Window('IEC 104 Address Converter', layout, location=(500, 500), use_default_focus=True, element_padding=(1, 1), return_keyboard_events=True) while True: event, values = window.read() # get element who has focus elem = window.find_element_with_focus() print(event)
if ml_service_query[2] == 0: print("stopped") return ("stopped") else: print("running") return ("running") sg.theme("Black") layout = [[sg.Text('Process Status:'), sg.Text('Running')], [sg.Text('Service Status:'), sg.Text('Running')], [sg.Button('Start'), sg.Button('Stop'), sg.Button('Cancel')]] # Create the Window window = sg.Window('Mystic Light Disabler', layout) # Event Loop to process "events" and get the "values" of the inputs while True: event, values = window.read() if event == sg.WIN_CLOSED or event == 'Cancel': # if user closes window or clicks cancel break elif event == 'Start': start_ml() elif event == 'Stop': stop_ml()
import PySimpleGUI as sg sg.theme('Dark Blue 3') # please make your windows colorful layout = [[sg.Text('Pretty cool')], [sg.Input()], [sg.Button('Read')]] window = sg.Window('Bro I made changes', layout) while True: event, values = window.read() if event == sg.WIN_CLOSED: break print(event, values) window.close()
# count = 0 else: hero_checkboxes.append(line) layout = [[ sg.Text('Number of units in team'), sg.Input('3', size=(3, 1), key='num_units') ], [ sg.Text('Number of comps to display'), sg.Input('10', size=(3, 1), key='num_comps_to_display') ], [ sg.Text('Max cost of unit'), sg.Input('5', size=(3, 1), key='max_cost') ], [sg.Button('Reset Heros', key='RESET')]] layout += hero_checkboxes layout.append([ sg.Button('Generate comps', key='GENERATE COMPS'), sg.Checkbox('Show synergies', key='show_synergies') ]) w = sg.Window('Comp Generator v1.0').Layout(layout) comp_gen = cg.CompGenerator('tft') while True: event, values = w.Read() if event == None: break
import PySimpleGUI as sg layout = [ [sg.Text('POPUPS TEST !!!')], [sg.Button('EXECUTE: popup_get_text("NAMASTE !!!")', key='-get_text-')], [sg.Button('EXECUTE: popup_get_file("NAMASTE !!!")', key='-get_file-')], [ sg.Button('EXECUTE: popup_get_folder("NAMASTE !!!")', key='-get_folder-') ], [sg.Button('EXECUTE: popup_get_date("NAMASTE !!!")', key='-get_date-')], ] window = sg.Window("Popups Test", layout=layout, finalize=True) window.maximize() while True: event, values = window.read() print(event) print(values) if event == None: break elif event == '-get_text-': print(sg.popup_get_text("Enter Some Text")) elif event == '-get_file-': print(sg.popup_get_file("Enter Some file")) elif event == '-get_folder-': print(sg.popup_get_folder("Enter Some folder")) elif event == '-get_date-': print(sg.popup_get_date())
wid, hght = inf_gui.get_scr_size(scale) maxsize = (wid, hght) # Define image files, which should be used in later definitions file_types = [("JPEG (*.jpg)", ".jpg"), ("All files (*.*)", "*.*")] # Define a list, emulating reading different parking lot list_of_parking_lot, avail_flag = ff_manip.file_open_avail_parklot(parent_path) size_of_list_parklot = len(list_of_parking_lot) ### Define layouts # --------------------------------------------------------------------------------------------------------------------- # Layout 1/layout_open: Opening layout of the program layout_open = [[sg.Text('IMAGE CALIBRATION', font='Arial')], [sg.Button('Define new parking lot', key='-DEFNEW-')], [sg.Button('Run automatically', key='-RUNAUTO-')]] # Layout 2/layout_defnew_1: Define new parking lot name layout layout_defnew_1 = [[sg.Text('DEFINE NEW PARKING LOT')], [sg.Text('Please input new parking lot name')], [sg.InputText(key='-NEW_PARKLOT_NAME-')], [sg.Button('Enter new name', key='-ENTER_NAME-')], [sg.Text("This parking lot has been defined, select Redefine or Run auto instead", key='-RET_MSG_DEFNEW1-', visible=False)], [sg.Text("Parking lot name is blank, please try again", key='-NAME_BLANK-', visible=False)], [sg.Button('Back', key='-BACK_2-')], [sg.Button('Next', key='-DEFINE_01-', visible=False), sg.Button('Redefine', key='-REDEFINE_DEF-', visible=False), sg.Button('Run auto', key='-RUN_DEF-', visible=False)] ]
import sys, os.path, time, random from tkinter.constants import DISABLED import PySimpleGUI as sg sys.path.insert(0, os.path.join("..", "2021-06-24")) import Piskvorky rozmer = 3 hra = Piskvorky.Piskvorky(3, 3, 3) rozmisteni = [[sg.Button("", key=(radek, sloupec), size=(2, 1)) for sloupec in range(rozmer)] for radek in range(rozmer)] okno = sg.Window("Piškvorky", rozmisteni) KRIZEK, KOLECKO = ("x", "o") while True: if hra.vrat_indexy_volnych_poli() == []: break udalost, hodnoty = okno.read() if udalost == sg.WINDOW_CLOSED: break hra.vepis_do_pole(udalost, KRIZEK) okno[udalost].update(KRIZEK, disabled=True) okno.refresh() vitezny_znak = hra.zjisti_vyhru() if vitezny_znak != " ": sg.Popup("Vyhrál", vitezny_znak)
import time import PySimpleGUI as sg def blink(): while stopflag == False and runningflag: print('コマンド送信: d2 1') time.sleep(1) print('コマンド送信: d2 0') time.sleep(1) layout = [[sg.Text('IPアドレス'), sg.InputText(size=(15, 1), key='-IPADDRESS-')], [sg.Button('OPEN'), sg.Text('未接続', size=(10, 1), key='-STATUS-')], [sg.Button('LED ON'), sg.Button('LED OFF')], [sg.Button('点滅開始'), sg.Button('点滅終了')], [sg.Exit()]] window = sg.Window('GUI LED DUMMY', layout, auto_size_buttons=False, default_button_element_size=(12, 1)) runningflag = True stopflag = True while True: event, values = window.read() print(event, values)
import PySimpleGUI as sg from functools import partial from core.visualize import get_window from tasks.task01 import run_task_01 from tasks.task02 import run_task_02 from tasks.task03 import run_task_03, run_task_03_uniqueness from tasks.saveFeatures import save_features from tasks.room_calibration import run_room_calibration # create a window with all tasks listed and set theme sg.theme('DefaultNoMoreNagging') layout = [ [sg.Text('Choose a task', font=('Helvetica', 12, ''))], [sg.Button('Run task 1', font=('Helvetica', 10, ''))], [sg.Button('Run task 2 (dataset pictures)', font=('Helvetica', 10, ''))], [sg.Button('Run task 2 (test pictures)', font=('Helvetica', 10, ''))], [sg.Button('Run task 3 (uniqueness)', font=('Helvetica', 10, ''))], [sg.Button('Run task 3 (dataset pictures)', font=('Helvetica', 10, ''))], [sg.Button('Run task 3 (test pictures)', font=('Helvetica', 10, ''))], [sg.Button('Save features (no task)', font=('Helvetica', 10, ''))], [sg.Button('Calibrate rooms (no task)', font=('Helvetica', 10, ''))], ] window = get_window('Tasks', layout) switcher = { 'Run task 1': run_task_01, 'Run task 2 (dataset pictures)': partial(run_task_02, 'dataset_pictures_msk', True, True), 'Run task 2 (test pictures)': partial(run_task_02, 'test_pictures_msk', True, True), 'Run task 3 (uniqueness)': partial(run_task_03_uniqueness, True, True), 'Run task 3 (dataset pictures)': partial(run_task_03, 'dataset_pictures_msk', True, True),
sg.Text( 'Click on a color square to see both white and black text on that color', text_color='blue', font='Any 15') ]] row = [] layout = [] # -- Create primary color viewer window -- for rows in range(40): row = [] for i in range(12): try: color = COLORS[rows + 40 * i] row.append( sg.Button(color, button_color=('black', color), key=color)) except: pass layout.append(row) window = sg.Window('Color Viewer', layout, grab_anywhere=False, font=('any 9')) # -- Event loop -- while True: event, values = window.read() if event == sg.WIN_CLOSED: break # -- Create a secondary window that shows white and black text on chosen color layout2 = [[ sg.DummyButton(event, button_color=('white', event)), sg.DummyButton(event, button_color=('black', event))
], [ sg.Text('What placement did you get?', size=(21, 1)), sg.Combo([i for i in range(1, 101)][::-1], key='_PLACEMENT_') ], [ sg.Text('Summarize your death.', size=(21, 1)), sg.Multiline(key='_DEATH_SUMMARY_') ], [ sg.Text('How can you prevent this?', size=(21, 1)), sg.Multiline(key='_PREVENTION_') ], [ sg.Button('Submit'), sg.Button('ResetDF'), sg.Button('Cancel') ]] layout = [[sg.Frame('Input', data_entry_layout)]] window = sg.Window('FNCoach', layout) ### PANDAS ### # CREATE DATAFRAME user_data_dict = { 'death_location': [], 'death_weapon': [], 'placement': [], 'death_summary': [],
import pandas as pd import webbrowser import requests import json import os load_dotenv() api_key = os.getenv("DPLA_API_KEY") # GUI sg.theme("DarkRed1") search_layout = [[ sg.Text('What would you like to search?'), sg.InputText(key='Term', size=(20, 50)) ], [sg.Button('Search')]] main_layout = [[sg.Frame('Input', search_layout)]] enter_data_window = sg.Window('DPLA Search', main_layout) def get_data_based_on_search_term(term): # request the data search_url = f'https://api.dp.la/v2/items?q={term}&api_key={api_key}' r = requests.get(search_url) if r.status_code == 200 and term != '': # convert to json and extract "docs" list search_data = json.loads(r.text) total_data_list = search_data["docs"] return total_data_list
def col(pLayout, pKey): return sg.Column(pLayout, size=screen, key=pKey, visible=False) # ------------------------------------------------------------------ # # --------------------------- Layouts ------------------------------ # # ------------------------------------------------------------------ # menu_def = [['Clientes',['Consultar cartelera::pm1', 'Consultar asientos::pm2', 'Comprar tiquetes::pm3']], ['Agente de teatro',['Consultar cartelera::gm1', 'Consultar asientos::gm2', 'Vender tiquetes::gm3']], ['Administrador de teatro',['Definir nueva producción::tm1', 'Definir calendario producción::tm2', 'Definir precios producción::tm3', 'Cambiar estado de producción::tm4', 'Incluir agente autorizado::tm5']], ['Administrador del sistema', ['Agregar teatro::sm1', 'Agregar administrador teatro::sm2']]] login_layout = [input_info('Username', 'lab_username','usuario_login'), [sg.Text('Password', key='lab_password'), sg.Input(key='password_login', password_char='*'), sg.Button('Login', key='blogin')]] # --------------------------------- Layouts público --------------------------------- # layout_pf1 = [input_info('Fecha inicio', 'pfi', 'pfie'), input_info('Fecha fin', 'pff', 'pffe')+[sg.Button('Consultar cartelera', key='pb1')]] layout_pf2 = [input_info('Título', 'pttl1', 'pttl1e'), input_info('Fecha presentación', 'pfp1', 'pfp1e'), input_info('Bloque', 'pbl1', 'pbl1e') + [sg.Button('Consultar disponibilidad', key='pb2')]] layout_pf3 = [input_info('Título', 'pttl2', 'pttl2e'), input_info('Fecha', 'pfp2', 'pfp2e'), input_info('Bloque', 'pbl2', 'pbl2e'), input_info('Fila', 'pf', 'pfe'), input_info('Números', 'pn', 'pne'), input_info('Nombre', 'pnom', 'pnome'),
import wolframalpha client = wolframalpha.Client("AA2VH3-PA98T59LH5") import PySimpleGUI as sg import wikipedia import pyttsx3 engine = pyttsx3.init() sg.theme('DarkAmber') layout = [[sg.Text('Enter a command'), sg.InputText()], [sg.Button('Ok'), sg.Button('Cancel')]] window = sg.Window('Py AI', layout) while True: event, values = window.read() if event in (None, 'Cancel'): break try: wiki_res = wikipedia.summary(values[0], sentences=2) wolfram_res = next(client.query(values[0]).results).text engine.say(wolfram_res) sg.PopupNonBlocking("Wolfram Results: " + wolfram_res, "Wikipedia Result: " + wiki_res) except wikipedia.exceptions.DisambiguationError: wolfram_res = next(client.query(values[0]).results).text engine.say(wolfram_res) sg.PopupNonBlocking(wolfram_res) except wikipedia.PageError:
return 'Obesidade Grau I' elif(imc >= 35 and imc <= 39.9): return 'Obesidade Grau II' elif(imc >= 40): return 'Obesidade Grau III ou Mórbida' sg.theme('Default1') layout = [ [sg.Text('Calcular IMC', font=('Helvetica', 25))], [sg.Text('Peso '), sg.Input(key='peso', size=(10, 1))], [sg.Text('Altura'), sg.Input(key='altura', size=(10, 1))], [sg.Text('IMC'), sg.Input(default_text='', disabled=True, key='IMC')], [sg.Text('Resultado: ', size=(30,1), key='resultado')], [sg.Button('Calcular', size=(10,2)), sg.Button('Limpar', size=(10,2))], [sg.Text('Desenvolvido por Brenno Luan')] ] window = sg.Window('Cálculo do IMC', layout) while True: event, values = window.read() if event == sg.WIN_CLOSED: break if event == 'Calcular' and values['peso'] and values['altura']: peso = float(values['peso'].replace(",", ".")) altura = float(values['altura'].replace(",", ".")) calculo = peso/(altura*altura)
def input_window(): # Create an Input Window input_layout = [ # Define layout of input window. [ Sg.Text( "The width and height are the two values used to make the 2D gym in the simulation." ) ], [ Sg.Text( "The number of simulations is determined by the length and radius of the softball." ) ], [ Sg.Text( "If you are unsure of what to do, just use the default values already entered" ) ], [ Sg.Text( "and press the Q key to start the auto simulation. If you don't want to wait a long time" ) ], [ Sg.Text( " change the length of the gym to a smaller number. Also, when the simulation opens," ) ], [Sg.Text("try pressing the ` key (top left of keyboard).")], [ Sg.Text("Units: "), Sg.Radio("Meters", group_id='units', key='m', default=True), Sg.Radio("Pixels", group_id='units', key='p') ], [ Sg.Text("Width of Gym: "), Sg.Input("15", key='width', size=(5, 1)), Sg.Text("Height of Gym"), Sg.Input("7", key='height', size=(5, 1)) ], [ Sg.Text("Length of Gym: "), Sg.Input("28", key='length', size=(5, 1)) ], [ Sg.Text("Ball Radius: "), Sg.Input("0.35", key='softball', size=(5, 1)) ], [ Sg.Text( "If you entered a ball radius less than 0.35m (350px) then select the multiple simulations per section" " option below.") ], [ Sg.Text("Multiple Simulations Mode:"), Sg.Radio("On", group_id='multi_mode', key='multi_on'), Sg.Radio("Off", group_id='multi_mode', key='multi_off') ], [Sg.Button("Submit", key='submit', bind_return_key=True), Sg.Cancel()] ] input_win = Sg.Window('Input', input_layout) while True: event, values = input_win.read() if event in (None, 'Cancel'): # If user closes window, kill program. sys.exit() if event == 'submit': input_win.close() if float(values['softball']) == 3.1415: exec(open('Setup.py', encoding="utf-8").read(), globals()) elif values[ 'm']: # If metric, convert values to pixels, otherwise only calculate # of simulations needed. return [ int(float(values['width']) * 1000), int(float(values['height']) * 1000), int( float(values['length']) / (2 * float(values['softball']))), int(float(values['softball']) * 1000), values['multi_on'] ] return [ int(values['width']), int(values['height']), int(float(values['length']) / (2 * float(values['softball']))), int(values['softball']), values['multi_on'] ]
def create_main_window(theme): sg.theme(theme) sg.set_options( font = FONT_MTSERRAT, element_padding=(0, 0) #button_color=('Blue', 'White') ) # Right Click Menu layout rc_menu = ['RightClickMenu', ['Tema', THEME_MENU[1], 'Versão']] # main layout layout = [ [ # no default title bar, this is the custom one sg.Text('Assinaturas', font=FONT_GRANDSTANDER, pad=((10, 0), (0, 0))), sg.Push(), # sg.Image( # 'resources/img/cross_16px.png', # enable_events=True, # key = '-CLOSE-', # ) sg.Image(source='resources/img/logo.png', subsample=14, pad=((0, 20), (1, 5))) ], [sg.HorizontalSeparator(pad=((0, 0), (0, 10)))], [ sg.Text('Nome *'), sg.Push(), sg.Input(size=(32, 1), pad=((0, 0), (0, 5)), key='-NOME-') ], [ sg.Text('Setor/Cargo *'), sg.Push(), sg.Input(size=(32, 1),pad=((0, 0), (0, 5)), key='-SETOR-') ], [ sg.Text('Telefone particular'), sg.Push(), sg.Input(size=(32, 1), pad=((0, 0), (0, 5)),key='-TELEFONE1-', tooltip="Opcional, se ficar em branco será selecionado a assinatura com apenas 1 ícone de telefone.") ], [ sg.Text('Telefone secundário'), sg.Push(), sg.Input(size=(32, 1), pad=((0, 0), (0, 5)), key='-TELEFONE2-', tooltip="Opcional, caso fique vazio será usado o número da empresa automaticamente.") ], [ sg.Text('Email *'), sg.Push(), sg.Input(size=(32, 1), pad=((0, 0), (0, 5)), key='-EMAIL-') ], [ sg.Button('Gerar nova assinatura', size=(22, 1), key='-GERAR-', pad=(0, 5)), sg.Push(), sg.Button('Gerar assinaturas em massa', size=(22, 1), key='-GERAR_MASSA-') ] ] return sg.Window( title='Assinaturas', layout=layout, return_keyboard_events=True, grab_anywhere=True, right_click_menu=rc_menu, icon='resources\img/assinatura_64px.ico' #no_titlebar = True, )
import PySimpleGUI as sg sg.theme('BluePurple') layout = [[ sg.Text('Your typed chars appear here:'), sg.Text(size=(15, 1), key='-OUTPUT-') ], [sg.Input(key='-IN-')], [sg.Button('Show'), sg.Button('Exit')]] window = sg.Window('Pattern 2B', layout) while True: # Event Loop event, values = window.read() print(event, values) if event == sg.WIN_CLOSED or event == 'Exit': break if event == 'Show': # Update the "output" text element to be the value of "input" element window['-OUTPUT-'].update(values['-IN-']) window.close()
def __init__(self): # Window Column Definitions progress_bar = [ [ sg.ProgressBar(100, size=(40, 20), pad=(0, 0), key='Progress Bar'), sg.Text(" 0%", size=(4, 1), key='Percent'), ], ] # Settings and Filetypes settings_controls_column = [ [ sg.Text('Comma separated list of file types'), ], [ sg.In( default_text="pdf,jpeg,zip,java,jar,docx,rar,txt,rtf,tar", key="-FILETYPES-"), ], [ sg.HSeparator(), ], [ sg.Text('HTTP Auth Credentials'), ], [ sg.Text("Username"), sg.In(size=(25, 1), enable_events=True, key="-HTTP User-"), ], [ sg.Text("Password"), sg.In(size=(25, 1), enable_events=True, key="-HTTP Pass-", password_char="*"), ], [ sg.HSeparator(), ], [sg.Text("Settings:")], [sg.Text("Load from saved settings or save current.")], [ sg.Button(button_text="Load", enable_events=True, key="-SETTINGS LOAD-"), sg.Button(button_text="Save", enable_events=True, key="-SETTINGS SAVE-"), ], ] # URL Input and Remote Dir List web_url_column = [ [ sg.Text('HTTP Directory URL'), sg.In(size=(25, 1), enable_events=True, key="-URL-"), sg.Button(button_text="Search", enable_events=True, key="-URL Search-") ], [ sg.Text("Remote: "), sg.Text(size=(40, 1), key="-Remote Text-"), ], [ sg.Listbox(values=[], enable_events=True, size=(40, 20), key="-Remote DIR LIST-") ], ] # Local Directory search and list file_list_column = [ [ sg.Text("Folder"), sg.In(size=(25, 1), enable_events=True, key="-FOLDER-"), sg.FolderBrowse(), ], [ sg.Listbox(values=[], enable_events=True, size=(40, 20), key="-FILE LIST-") ], ] # Sync Button and output remote_sync_column = [ [ sg.Button("Sync", enable_events=True, key="-SYNC-"), sg.pin(sg.Column(progress_bar, key='Progress', visible=False)) ], [sg.Text("Output:")], [sg.Output(size=(110, 20), font=('Helvetica 10'), key="-TOUT-")], ] # ----- Full layout ----- layout = [ [ sg.Column(settings_controls_column), sg.VSeparator(), sg.Column(web_url_column), sg.VSeparator(), sg.Column(file_list_column), ], [ sg.HSeparator(), ], [ sg.Text(size=(15, 0)), sg.Column(remote_sync_column), ], ] # Add Layout to window self.window = sg.Window("HTTP Directory Sync", layout) self.sync = HttpDirectorySync() self.downloading = False
], [ sg.InputText(S.init_margins['l'], size=(5, 1), key='crop-l'), sg.Text('', size=(5, 1)), sg.InputText( S.init_margins['r'], size=(5, 1), key='crop-r') ], [ sg.Text('', size=(5, 1)), sg.InputText( S.init_margins['b'], size=(5, 1), key='crop-b') ]]), sg.Column([ [sg.Button('Crop', size=(7, 1))], [ sg.Button('Open original in Sumatra', key='sumatraorig', size=(25, 1)) ], [ sg.Button('Open cropped in Sumatra', key='sumatra', size=(25, 1)) ], ]), ], [ sg.Text('', size=(49, 1)), sg.Text(f"{__version__} by Xtotdam",
from frozendict import frozendict # Change some gui element colors sg.theme_input_background_color('black') sg.theme_input_text_color('green') # Browse for the questions file to be used to make the quiz questions_file = sg.popup_get_file( 'Choose the questions file you wish to generate a quiz from.') # Create the quiz window layout = [[(sg.Text('Please type a, b, c, or d for your answers!', size=(40, 1)))], [sg.Output(size=(80, 20))], [ sg.Multiline(size=(70, 0), enter_submits=True), sg.Button('SUBMIT', button_color=(sg.YELLOWS[0], sg.BLUES[0])), sg.Button('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0])) ]] window = sg.Window('Quiz', layout, default_element_size=(30, 2)) # Lists that will contain questions and answers questions_list = [] answers_list = [] # Opens the questions from the questions folder and appends each question to a list and answer to a separate list with open(questions_file) as questions: if len( (questions.readlines() )) % 2 != 0: # Check if the file contains the correct amount of lines print(len(questions.readlines()))
import numpy as np import PySimpleGUI as sg import pathlib import sys sg.theme('LightGreen6') SAVE = "save" choice1, choice2 = sg.Button("A", key="A"), sg.Button("B", key="B") sort_layout = [[sg.Text("Which is better?")], [choice1, choice2], [sg.Button(SAVE)]] def take_input(a, b): choice1.update(text=str(a)) choice2.update(text=str(b)) input_choice = "" while input_choice not in ["A", "B"]: event, values = window.read() if event == SAVE: np.save( input_file.absolute().parent.joinpath( f"saved_{input_file.name}"), sorting_matrix) input_choice = event return -1 if input_choice == "A" else 1 load_file_layout = [[ sg.Text('Input', size=(8, 1)), sg.Input(), sg.FileBrowse() ], [sg.Button("Sort ascending"),
if isfile(nombre_archivo): datos = extraer_datos() if nombre in datos.keys(): cnt2 = Counter(datos[nombre]) cnt2 += cnt datos[nombre] = cnt2 else: datos[nombre] = cnt else: datos[nombre] = cnt guardar_datos(nombre_archivo, datos) layout = [[sg.Text('Nombre y Apellido'), sg.InputText(), sg.Button('Read')], [sg.Text('¿A que juego quiere jugar?')], [sg.Listbox(values=lista_box, size=(30, 3)), sg.Button('Ok')], [sg.Button('Guardar'), sg.Button('Salir')]] sg.ChangeLookAndFeel('Dark2') window = sg.Window('Bienvenido').Layout(layout) while True: event, values = window.Read() if event is None or event == 'Salir': break elif event is 'Read': nombre = values[0].lower() elif event is 'Ok': juego_elegido = values[1] if juego_elegido == ['Ahorcado']: