/_/                                                         /____/   
""")

try:
    sportsbetting.ODDS = pickle.load(open(PATH_DATA, "rb"))
except FileNotFoundError:
    pass


# All the stuff inside your window.
sg.set_options(enable_treeview_869_patch=False)
parsing_layout = [
    [
        sg.Listbox(sports, size=(20, 6), key="SPORT", enable_events=True),
        sg.Column([[sg.Listbox((), size=(27, 12), key='COMPETITIONS', select_mode='multiple')],
                   [sg.Button("Unselect all", key="SELECT_NONE_COMPETITION")],
                   [sg.Button("Current leagues", key="CURRENT_COMPETITIONS")],
                   [sg.Button("Main leagues", key="MAIN_COMPETITIONS")]]),
        sg.Column([[sg.Listbox(sites, size=(20, 12), key="SITES", select_mode='multiple')],
                   [sg.Button("Select all", key="SELECT_ALL")],
                   [sg.Button("Unselect all", key="SELECT_NONE_SITE")]])
    ],
    [sg.Col([[sg.Button('Start', key="START_PARSING")]]),
     sg.Col([[sg.Button('Stop', key="STOP_PARSING", button_color=("white", "red"), visible=False)]]),
     sg.Col([[sg.ProgressBar(max_value=100, orientation='h', size=(20, 20), key='PROGRESS_PARSING',
                             visible=False)]]),
     sg.Col([[sg.Text("Initialisation of selenium in progress", key="TEXT_PARSING", visible=False)]]),
     sg.Col([[sg.Text("8:88:88", key="REMAINING_TIME_PARSING", visible=False)]])],
    [sg.Col([[sg.ProgressBar(max_value=100, orientation='v', size=(10, 20),
                             key="PROGRESS_{}_PARSING".format(site), visible=False)],
             [sg.Text(site, key="TEXT_{}_PARSING".format(site), visible=False)]],
            element_justification="center") for site in sites]
예제 #2
0
                   size=(40, 20),
                   key='-SELLIST-',
                   select_mode='multiple'),
    ],
    [sg.Button('Remove Selected Items', key='-REMOVE-')],
    [
        sg.Text('Combined PDF file name:'),
    ],
    [
        sg.In(size=(25, 1), enable_events=True, key="-FN-"),
        sg.Button("Convert & Combine", key='-CC-'),
    ],
]

# ----- Full layout -----
first_col = sg.Column(file_list_column)

layout = [[
    first_col,
    sg.VSeperator(),
    sg.Column(selected_list_col),
]]


def import_with_auto_install(package):
    try:
        return importlib.import_module(package)
    except ImportError:
        pip.main(['install', package])
    return importlib.import_module(package)
예제 #3
0
def make_window():
    """
    Creates the main window
    :return: The main window object
    :rtype: (Window)
    """

    theme = get_theme()
    editor = get_editor()
    demo_files = get_demo_git_files()
    if not theme:
        theme = sg.OFFICIAL_PYSIMPLEGUI_THEME
    sg.theme(theme)
    # First the window layout...2 columns

    find_tooltip = "Find in file\nEnter a string in box to search for string inside of the files.\nFile list will update with list of files string found inside."
    filter_tooltip = "Filter files\nEnter a string in box to narrow down the list of files.\nFile list will update with list of files with string in filename."

    ML_KEY = '-ML-'  # Multline's key

    left_col = [[
        sg.Listbox(values=demo_files,
                   select_mode=sg.SELECT_MODE_EXTENDED,
                   size=(40, 20),
                   key='-DEMO LIST-')
    ],
                [
                    sg.Text('Filter:', tooltip=filter_tooltip),
                    sg.Input(size=(25, 1),
                             enable_events=True,
                             key='-FILTER-',
                             tooltip=filter_tooltip),
                    sg.T(size=(20, 1), k='-FILTER NUMBER-')
                ], [sg.Button('Run'),
                    sg.B('Edit'),
                    sg.B('Clear')],
                [
                    sg.Text('Find:', tooltip=find_tooltip),
                    sg.Input(size=(25, 1),
                             enable_events=True,
                             key='-FIND-',
                             tooltip=find_tooltip),
                    sg.T(size=(20, 1), k='-FIND NUMBER-')
                ]]

    right_col = [
        [
            sg.Multiline(size=(70, 21),
                         write_only=True,
                         key=ML_KEY,
                         reroute_stdout=True,
                         echo_stdout_stderr=True)
        ],
        [
            sg.Button('Edit Me (this program)'),
            sg.B('Settings'),
            sg.Button('Exit')
        ],
        [
            sg.T('PySimpleGUI ver ' + sg.version.split(' ')[0] +
                 '  tkinter ver ' + sg.tclversion_detailed,
                 font='Default 8',
                 pad=(0, 0))
        ],
    ]

    # ----- Full layout -----

    layout = [[sg.Text('Demo Programs Browser', font='Any 20')],
              [sg.T('Click settings to specify location of demo files')],
              sg.vtop([
                  sg.Column(left_col, element_justification='c'),
                  sg.Col(right_col, element_justification='c')
              ])]

    # --------------------------------- Create Window ---------------------------------
    window = sg.Window('PySimpleGUI Demo Program Browser', layout, icon=icon)

    sg.cprint_set_output_destination(window, ML_KEY)
    return window
예제 #4
0
    )
    conn.commit()
    sql.execute('''SELECT * FROM settings''')
    settings = list(sql.fetchall())
    for i in settings:
        defdir, deftheme = i

conn.close()

sg.theme(deftheme)

settab_textcol = [[sg.Text('Default download location:')], [sg.Text('Theme:')]]
settab_incol = [[sg.In(key='defdir'), sg.FolderBrowse()],
                [sg.In(key='deftheme'),
                 sg.Button('Browse themes')]]
final = [[sg.Column(settab_textcol),
          sg.Column(settab_incol)], [sg.B('Apply settings')]]


def apply(  #path=path,
        defdir='./Download', deftheme='SystemDefaultForReal'):
    conn = sqlite3.connect('/usr/share/StreamDownloader/media/database.db')
    sql = conn.cursor()
    sql.execute('DROP TABLE settings')
    sql.execute('''CREATE TABLE settings(defdir TEXT,deftheme TEXT)''')
    sql.execute(
        'INSERT INTO settings(defdir,deftheme) values ("{}","{}")'.format(
            defdir, deftheme))
    conn.commit()
    conn.close()
예제 #5
0
                visible=False,
                size=(48, 1))
    ], )

# general layout
layout = [
    [
        sg.Text(("This tool will give you the common actors "
                 "from a selection of given movies."))
    ],
    [
        sg.Text("How many movies would you like to enter? (Max 9)"),
        sg.InputText(key="-NUM-", size=(3, 1), enable_events=True),
    ],
    [
        sg.Column(col_Text, size=(150, 250)),
        sg.Column(
            col_Input,
            size=(300, 250),
        ),
        sg.Column(col_Result_Id, size=(90, 250)),
        sg.Column(col_Result_Cast, size=(460, 250)),
    ],
    [sg.Column(col_Common_Results, size=(1000, 50))],
    [sg.Button("Submit", key="-SUBMIT-"),
     sg.Button("Exit")],
]

# load window
window = sg.Window("Welcome to common-actors!", layout, size=(1000, 400))
예제 #6
0
    def GUI(self):
        with open('img.png', 'rb') as f:
            image = f.read() 
        f.close()
        base64_data = base64.b64encode(image)
        img = base64_data.decode('utf-8')
        img = bytes(img, encoding="utf8")
        sg.theme('LightGrey1')
        col = []
        for i in range(100):
            col.append([sg.Text('节点%d' % (i+1), justification='center', font=("Noto Serif SC", 10), size=(16, 1), key='NODE%s' % (str(i+1)), text_color='saddlebrown', background_color='powderblue'),
                        sg.Text('未知状态%d' % (i+1), justification='center', font=("Noto Serif SC", 10),
                                size=(24, 1), key='STATUS%s' % (str(i+1)), text_color='mediumblue', background_color='azure'),
                       sg.ProgressBar(100, orientation='h', size=(
                           42, 20), style='winnative', bar_color=('palegreen', 'pink'), relief=sg.RELIEF_RIDGE, key='progressbar-%d' % (i+1))]
            )

        layout = [[sg.Text('Simply Multi-Machine Collaborative Computing', size=(
            40, 1), text_color='green', border_width=1, justification='center', font=("Noto Serif SC",22), relief=sg.RELIEF_RIDGE)],
            [sg.Text('计算范围:', font=("Noto Serif SC", 16)), sg.InputText('100000', font=("Noto Serif SC", 16), size=(21, 2), key='-RANGE-'),
             sg.Text('节点数:', font=("Noto Serif SC", 16)), sg.InputText('10', font=("Noto Serif SC", 16), size=(21, 2), key='-NODENUM-')],
            [sg.Text('节点名', size=(12, 1), text_color='white', font=(
                "Noto Serif SC", 16), background_color='green', justification='center',relief=sg.RELIEF_RIDGE, pad=(0, 0)),
                sg.Text('节点状态', size=(15, 1), text_color='white', font=(
                    "Noto Serif SC", 16), background_color='green', justification='center', relief=sg.RELIEF_RIDGE, pad=(0, 0)),
                sg.Text('运算进度', size=(27, 1), text_color='white', font=("Noto Serif SC", 16), background_color='green', justification='center', relief=sg.RELIEF_RIDGE, pad=(0, 0))],
            [sg.Column(col, background_color='papayawhip', size=(700, 400),scrollable=True, justification="left", element_justification="center")],
                  [sg.Output(size=(100, 10))],
            [sg.Frame('加速比计算公式', [[sg.Image(data=img)]],
                      font=("Noto Serif SC", 20), title_color='Tomato')],
            [sg.Button('开始计算', font=(
                "Noto Serif SC", 10), size=(8, 1)), sg.Button('计算加速比', font=(
                    "Noto Serif SC", 10), size=(8, 1)), sg.Text(
                '暂无数据', font=("Noto Serif SC", 16), relief=sg.RELIEF_RIDGE,key='-JIASU-'), sg.Button('总运算时长', font=(
                    "Noto Serif SC", 10), size=(8, 1), button_color=('lawngreen', 'plum')), sg.Text(
                '暂无数据', font=("Noto Serif SC", 16),relief=sg.RELIEF_RIDGE,key='-TIME-')],
        ]  # button_color=(sg.YELLOWS[0], sg.BLUES[0]

        window = sg.Window(
            'SMMCC', layout, default_element_size=(30, 2), grab_anywhere=False, resizable=True, element_justification='center', text_justification='center')
        
        self.server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.server.bind((ip, port))  # 绑定要监听的端口
        self.server.listen(5)  # 开始监听 表示可以使用五个链接排队

        #conn, addr = server.accept()
        #print("连接建立,地址在%s" % (str(addr)))
        while True:
            event, value = window.read()
            if event == '开始计算':
                self.connectList = []
                global pos
                pos = 1
                global part_sum
                part_sum = []
                global who_pos
                who_pos = 1
                global compute_time
                compute_time = []
                global finish
                finish = False
                for i in range(100):
                    window['progressbar-%d' % (i+1)].update_bar(0)
                self.rng = int(value['-RANGE-'])
                self.m = int(value['-NODENUM-'])
                threading.Thread(target=self.main,args=(window,)).start()
                threading.Thread(target=self.SpeedupRatio,args=(window,)).start()
                print(time.strftime("[%Y-%m-%d %H:%M:%S] ",time.localtime()), "侦听器已启动!port:%d" % (port))
        window.close()
예제 #7
0
                                       )
         ''')
conn.commit()


#Grafikus felület
def bevitel(be):
    return [sg.Text(f'{be}:', size=(15, 1)), sg.Input(key=be)]


col1 = sg.Column([[sg.Text()],
                  bevitel('Név'),
                  bevitel('Email'),
                  bevitel('Github'),
                  bevitel('Referencia'),
                  bevitel('Végzettség'),
                  bevitel('Kompetenciák'),
                  bevitel('Egyéb'), [sg.Text()],
                  [sg.Button('Ment'),
                   sg.Button('Keres'),
                   sg.Button('Töröl')]])
col2 = sg.Column([
    [sg.Listbox([], size=(30, 15), key='eredmény')],
])

layout = [[col1, col2]]
window = sg.Window('Project',
                   layout,
                   font='Helvetica 14',
                   default_element_size=(20, 1),
                   auto_size_buttons=False)
예제 #8
0
                   [sg.Text('Insira sua senha')],
                   [sg.Input(password_char='*')]]

coluna_meio = [[sg.Output(size=(40, 10))]]

coluna_direita = [[sg.Text('Qual site automatizar?')],
                  [sg.Checkbox('Opção 1'),
                   sg.Checkbox('Opção 2')]]

# Layout Principal
# justification='center'/'left'/'right'
# element_justification='center'/'left'/'right'

layout_principal = [[
    sg.Frame('Configurações Login', coluna_esquerda),
    sg.Column(coluna_meio),
    sg.Frame('Configurações Automatização', coluna_direita)
], [sg.Button('Enviar')]]

# Criar janela
janela = sg.Window('Janela Inicial', layout=layout_principal)

# Ler os encentos
while True:
    evento, valores = janela.Read()

    if evento in (sg.WINDOW_CLOSED, None):
        janela.close()
        sys.exit()
    else:
        print(evento)
import PySimpleGUI as sg
"""
    Demo - Separator Elements

    Shows usage of both Horizontal and Vertical Separator Elements
    Vertical Separators are placed BETWEEN 2 elements ON the same row.  These work well when one
        of the elements is a Column or the element spans several rows

    Horizontal separators are placed BETWEEN 2 rows.  They will occupy the entire span of the row they
        are located on. If that row is constrained within a container, then it will spand the widget of
        the container.

    Copyright 2020 PySimpleGUI.org
"""

left_col = sg.Column([[sg.Listbox((1, 2, 3, 4, 5, 6), size=(6, 4))]])

right_col = sg.Column([
    [sg.Input(), sg.Input()],
    [sg.HorizontalSeparator()],
    [sg.Column([[sg.In()], [sg.HorizontalSeparator()]], pad=(0, 0))],
])

layout = [[sg.Text('Window with some separators')],
          [left_col, sg.VerticalSeparator(), right_col],
          [sg.Button('Go'), sg.Button('Exit')]]

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

while True:  # Event Loop
    event, values = window.read()
예제 #10
0

layout = [  [sg.Text('Android Logs, Events, And Protobuf Parser', font=("Helvetica", 22))],
            [sg.Text('https://github.com/abrignoni/ALEAPP', font=("Helvetica", 14))],
            [sg.Frame(layout=[
                [sg.Input(size=(0,1), enable_events=True,visible=False), sg.FileBrowse(button_text='Browse File', font=normal_font), 
                 sg.Input(enable_events=True, visible=False), sg.FolderBrowse(button_text='Browse Directory', font=normal_font),
                 sg.Text('Selected:',  font=normal_font, key='SText_i'), sg.Text(' ',  font=normal_font, background_color='white', size=(65,1), key='Argument')
                ]],
                title='Select the file type or directory of the target Android full file system extraction for parsing:')],
            [sg.Frame(layout=[[sg.Input(size=(0,1), enable_events=True,visible=False), sg.FolderBrowse(font=normal_font, button_text='Browse Output Folder'),
                               sg.Text('Selected:',  font=normal_font, key='SText_o'), sg.Text(' ',  font=normal_font, background_color='white', size=(73,1), key='Argument_o')]], 
                      title='Select Output Folder:')],
            [sg.Text('Available Modules')],
            [sg.Button('SELECT ALL'), sg.Button('DESELECT ALL')], 
            [sg.Column(mlist, size=(300,310), scrollable=True),  sg.Output(size=(85,20))] ,
            #[sg.Checkbox('Generate CSV output (Additional processing time)', size=(50, 1), default=False, font=normal_font)],
            [sg.ProgressBar(max_value=GuiWindow.progress_bar_total, orientation='h', size=(73, 7), key='PROGRESSBAR', bar_color=('DarkGreen', 'White'))],
            [sg.Submit('Process',font=normal_font), sg.Button('Close', font=normal_font)] ]
            
# Create the Window
window = sg.Window(f'ALEAPP version {aleapp_version}', layout)
GuiWindow.progress_bar_handle = window['PROGRESSBAR']




# Event Loop to process "events" and get the "values" of the inputs
while True:
    event, values = window.read()
    if event in (None, 'Close'):   # if user closes window or clicks cancel
예제 #11
0
    def create_ui(self):
        layout = [
            [
                sg.Text("General Details", size=(15, 1)),
                sg.Text("_" * 60, pad=(0, 15))
            ],
            [
                sg.Text("Anime URL", text_color="white", size=(25, 1)),
                sg.InputText(key="anime_url")
            ],
            [
                sg.Text("Animefillerlist URL",
                        text_color="white",
                        size=(25, 1)),
                sg.InputText(key="names_url")
            ],
            [
                sg.Text("Save To", size=(25, 1), text_color="white"),
                sg.InputText(key="location"),
                sg.FolderBrowse()
            ],
            [
                sg.Text("Episodes Details", size=(15, 1)),
                sg.Text("_" * 60, pad=(0, 15))
            ],
            [
                sg.Text("From", text_color="white", size=(8, 1)),
                sg.InputText(key="start_epi", size=(6, 1)),
                sg.Text("To", text_color="white", size=(8, 1)),
                sg.InputText(key="end_epi", size=(5, 1)),
                sg.Text("Download Fillers?", text_color="white"),
                sg.Combo(["Yes", "No"],
                         size=(4, 1),
                         default_value="Yes",
                         key="isFiller"),
                sg.Text("Threads", text_color="white"),
                sg.Spin([i for i in range(1, 21)],
                        initial_value=1,
                        size=(3, 1),
                        key="threads")
            ], [],
            [
                sg.Text("Resolution", text_color="white", size=(8, 1)),
                sg.Combo(["240", "360", "480", "720", "1080"],
                         size=(4, 1),
                         default_value="1080",
                         key="resolution"),
                sg.Text("Sub/Dub", text_color="white", size=(8, 1)),
                sg.Combo(["Sub", "Dub"],
                         size=(4, 1),
                         default_value="Sub",
                         key="is_dub")
            ], [],
            [
                sg.Text(
                    "Optional Settings (Fill this if you don't have 2captcha key)",
                    size=(45, 1)),
                sg.Text("_" * 25, pad=(0, 15))
            ],
            [
                sg.Text("Recaptcha Token (Optional)",
                        text_color="white",
                        size=(25, 1)),
                sg.Multiline(size=(45, 4), key="token")
            ],
            [
                sg.Column([[sg.Button("Download", size=(10, 1))]],
                          justification="right",
                          pad=(35, 5))
            ], [], [sg.Text("Messages")],
            [sg.Multiline(size=(None, 8), key="txt_msg", disabled=True)], [],
            [sg.Text("Progress"),
             sg.Text("_" * 74, pad=(0, 15))],
            [
                sg.ProgressBar(100,
                               key="progress",
                               orientation="h",
                               size=(45, 15))
            ]
        ]

        if sys.platform.lower() == "win32":
            self.window = sg.Window("Monkey-DL v1.0.4", layout, icon="app.ico")
        else:
            self.window = sg.Window("Monkey-DL v1.0.4", layout, icon="app.png")
예제 #12
0
df = pd.DataFrame(data)
table_data = df.values.tolist()

## MAIN GUI
gui_col = sg.Column(layout=[[sg.Frame('Add Data', layout=[[sg.Column([[sg.T("Click this button to ADD new data : ", font=("bold", 15),
                                                                    text_color="green", tooltip="To add new data to the database")],
                                                                [sg.Button("Add", size=(7, 1), font=("", 12))]]
                                                                , size=(500,70))]
                                                    ], title_color="green")
                            ],
                            [sg.Frame('View Data', layout=[[sg.Column([[sg.T("Click this button to VIEW or UPDATE the existing data : ", font=("bold", 15), 
                                                                    text_color="red", tooltip="To view and update the data")],
                                                                [sg.Button("View", size=(7, 1), font=("", 12))]]
                                                                , size=(500,70))]
                                                    ], title_color="red")
                            ],
                            [sg.Frame('Encrypted Vault', layout=[[sg.Column([[sg.T("Click this button to Open your Vault : ", font=("bold", 15), 
                                                                    text_color="purple", tooltip="To open your secure vault")],
                                                                [sg.Button("Vault", size=(7, 1), font=("", 12))]]
                                                                , size=(500,70))]
                                                    ], title_color="purple")
                            ],
                            [sg.Frame('Reset Password', layout=[[sg.Column([[sg.T("Click this button to Reset your password : "******"bold", 15), 
                                                                    text_color='blue', tooltip="To Reset your Password")],
                                                                [sg.Button("Reset", size=(7, 1), font=("", 12))]] 
                                                                , size=(500,70))]
                                                    ], title_color="blue")
                            ]])

layout = [
    [sg.Text("Password Manager\nV3.1", justification='center', size=(25, 2), font=("", 25), relief=sg.RELIEF_RIDGE)],
    [gui_col]]
def make_window():
    """
    Creates the main window
    :return: The main window object
    :rtype: (sg.Window)
    """
    theme = get_theme()
    if not theme:
        theme = sg.OFFICIAL_PYSIMPLEGUI_THEME
    sg.theme(theme)
    # First the window layout...2 columns

    find_tooltip = "Find in file\nEnter a string in box to search for string inside of the files.\nFile list will update with list of files string found inside."
    filter_tooltip = "Filter files\nEnter a string in box to narrow down the list of files.\nFile list will update with list of files with string in filename."
    find_re_tooltip = "Find in file using Regular Expression\nEnter a string in box to search for string inside of the files.\nSearch is performed after clicking the FindRE button."


    left_col = sg.Column([
        [sg.Listbox(values=get_file_list(), select_mode=sg.SELECT_MODE_EXTENDED, size=(50,20), bind_return_key=True, key='-DEMO LIST-')],
        [sg.Text('Filter (F1):', tooltip=filter_tooltip), sg.Input(size=(25, 1), focus=True, enable_events=True, key='-FILTER-', tooltip=filter_tooltip),
         sg.T(size=(15,1), k='-FILTER NUMBER-')],
        [sg.Button('Run'), sg.B('Edit'), sg.B('Clear'), sg.B('Open Folder'), sg.B('Copy Path')],
        [sg.Text('Find (F2):', tooltip=find_tooltip), sg.Input(size=(25, 1), enable_events=True, key='-FIND-', tooltip=find_tooltip),
         sg.T(size=(15,1), k='-FIND NUMBER-')],
    ], element_justification='l', expand_x=True, expand_y=True)

    lef_col_find_re = sg.pin(sg.Col([
        [sg.Text('Find (F3):', tooltip=find_re_tooltip), sg.Input(size=(25, 1),key='-FIND RE-', tooltip=find_re_tooltip),sg.B('Find RE')]], k='-RE COL-'))

    right_col = [
        [sg.Multiline(size=(70, 21), write_only=True, key=ML_KEY, reroute_stdout=True, echo_stdout_stderr=True, reroute_cprint=True)],
        [sg.B('Settings'), sg.Button('Exit')],
        [sg.T('Demo Browser Ver ' + __version__)],
        [sg.T('PySimpleGUI ver ' + sg.version.split(' ')[0] + '  tkinter ver ' + sg.tclversion_detailed, font='Default 8', pad=(0,0))],
        [sg.T('Python ver ' + sys.version, font='Default 8', pad=(0,0))],
        [sg.T('Interpreter ' + sg.execute_py_get_interpreter(), font='Default 8', pad=(0,0))],
    ]

    options_at_bottom = sg.pin(sg.Column([[sg.CB('Verbose', enable_events=True, k='-VERBOSE-', tooltip='Enable to see the matches in the right hand column'),
                         sg.CB('Show only first match in file', default=True, enable_events=True, k='-FIRST MATCH ONLY-', tooltip='Disable to see ALL matches found in files'),
                         sg.CB('Find ignore case', default=True, enable_events=True, k='-IGNORE CASE-'),
                         sg.CB('Wait for Runs to Complete', default=False, enable_events=True, k='-WAIT-')
                                           ]],
                                         pad=(0,0), k='-OPTIONS BOTTOM-',  expand_x=True, expand_y=False),  expand_x=True, expand_y=False)

    choose_folder_at_top = sg.pin(sg.Column([[sg.T('Click settings to set top of your tree or choose a previously chosen folder'),
                                       sg.Combo(sorted(sg.user_settings_get_entry('-folder names-', [])), default_value=sg.user_settings_get_entry('-demos folder-', ''), size=(50, 30), key='-FOLDERNAME-', enable_events=True, readonly=True)]], pad=(0,0), k='-FOLDER CHOOSE-'))
    # ----- Full layout -----

    layout = [[sg.Text('PySimpleGUI Demo Program & Project Browser', font='Any 20')],
              [choose_folder_at_top],
              # [sg.Column([[left_col],[ lef_col_find_re]], element_justification='l',  expand_x=True, expand_y=True), sg.Column(right_col, element_justification='c', expand_x=True, expand_y=True)],
              [sg.Pane([sg.Column([[left_col],[ lef_col_find_re]], element_justification='l',  expand_x=True, expand_y=True), sg.Column(right_col, element_justification='c', expand_x=True, expand_y=True) ], orientation='h', relief=sg.RELIEF_SUNKEN, k='-PANE-')],
              [options_at_bottom, sg.Sizegrip()]]

    # --------------------------------- Create Window ---------------------------------
    window = sg.Window('PSG Demo & Project Browser', layout, finalize=True,  resizable=True, use_default_focus=False, right_click_menu=sg.MENU_RIGHT_CLICK_EDITME_VER_EXIT)
    window.set_min_size(window.size)

    window['-DEMO LIST-'].expand(True, True, True)
    window[ML_KEY].expand(True, True, True)
    window['-PANE-'].expand(True, True, True)

    window.bind('<F1>', '-FOCUS FILTER-')
    window.bind('<F2>', '-FOCUS FIND-')
    window.bind('<F3>', '-FOCUS RE FIND-')
    if not advanced_mode():
        window['-FOLDER CHOOSE-'].update(visible=False)
        window['-RE COL-'].update(visible=False)
        window['-OPTIONS BOTTOM-'].update(visible=False)

    # sg.cprint_set_output_destination(window, ML_KEY)
    window.bring_to_front()
    return window
column1 = [[sg.ReadButton('Original list', size=(11, 1))],
           [sg.ReadButton('Default sort', size=(11, 1))],
           [sg.ReadButton('Sort: selection', size=(11, 1))],
           [sg.ReadButton('Sort: quick', size=(11, 1))],
           [sg.Text('_________________', font=('Calibri', 16))],
           [sg.ReadButton('Save data\ndisplayed', size=(11, 2))]]

layout = [
    [sg.Text('Search and Sort Demo', font=('Calibri', 20, 'bold'))],
    [
        sg.Listbox(values=[''],
                   size=(14, 11),
                   font=('Calibri', 12),
                   background_color='White',
                   key='_display_'),
        sg.Column(column1)
    ],
    [sg.Text('_' * 38, font=('Calibri', 16))],
    [
        sg.InputText(size=(11, 1), key='_linear_'),
        sg.Text('   '),
        sg.InputText(size=(11, 1), key='_binary_')
    ],
    [
        sg.ReadButton('Linear Search', size=(12, 1)),
        sg.Text('     '),
        sg.ReadButton('Binary Search', size=(11, 1))
    ],
]

window = sg.Window('Search and Sort Demo').Layout(layout)
def Configurar(reporte_pantalla, dic_config):
    '''
	recibe un diccionario como estructura base para los reportes en pantalla
	y un diccionario con configuracion previa
	devuelve un diccionario con los datos de las palabras
	los colores a usar para cada tipo de palabra
	si se mostrará ayuda en pantalla
	la orientacion de las palabras
	si las letras serán mayusculas o minusculas
	la tipografia de los titulos y cuerpos del reporte a mostrar en pantalla
	y si el color del juego dependerá de las oficinas o será el neutro
	'''
    if not os.path.exists(os.path.join(ruta_app, 'palabras anteriores')):
        os.mkdir(os.path.join(ruta_app, 'palabras anteriores'))
    try:
        archpalabras = open(
            os.path.join(ruta_app, 'palabras anteriores', 'palabras.json'),
            'r+')
    except FileNotFoundError:
        archpalabras = open(
            os.path.join(ruta_app, 'palabras anteriores', 'palabras.json'),
            'w+')
    try:
        dic_palabras = json.load(archpalabras)
    except json.decoder.JSONDecodeError:
        dic_palabras = {}
    archpalabras.close()
    if dic_config == {} or dic_config == None:
        config_estandar = {
            "ayuda": "sin",
            "orientacion": "horizontal",
            "cant_sustantivos": "3",
            "cant_adjetivos": "3",
            "cant_verbos": "3",
            "MayusOMinus": "mayusculas",
            "tipografia titulo": "Times ",
            "tipografia cuerpo": "Times ",
            "elegir estilo": "Sin",
            "oficina": "Elegir",
            "colores": {
                "Sustantivos": "red",
                "Adjetivos": "green",
                "Verbos": "yellow"
            }
        }
    else:
        config_estandar = dic_config
        if dic_palabras == {}:
            dic_palabras = config_estandar['palabras']
    if not os.path.exists(os.path.join(ruta_app, 'oficinas')):
        dic_oficinas = {}
    else:
        try:
            archofice = open(
                os.path.join(ruta_app, 'oficinas', 'oficinas.json'), 'r+')
            dic_oficinas = json.load(archofice)
            archofice.close()
        except FileNotFoundError:
            dic_oficinas = {}
    lista_oficinas = ['Elegir']
    lista_oficinas.extend(list(dic_oficinas.keys()))
    fontsize = '12'
    tipografia = config_estandar["tipografia titulo"]
    tipografia2 = config_estandar["tipografia cuerpo"]
    colores = {
        'Sustantivos': config_estandar['colores']["Sustantivos"],
        'Adjetivos': config_estandar['colores']["Adjetivos"],
        'Verbos': config_estandar['colores']["Verbos"]
    }
    columna = [
        [
            sg.Text('Sustantivos', size=(11, 1)),
            sg.InputText(default_text=config_estandar["cant_sustantivos"],
                         key='cant_sustantivos',
                         size=(4, 1))
        ],
        [
            sg.Text('Adjetivos', size=(11, 1)),
            sg.InputText(default_text=config_estandar["cant_adjetivos"],
                         key='cant_adjetivos',
                         size=(4, 1))
        ],
        [
            sg.Text('Verbos', size=(11, 1)),
            sg.InputText(default_text=config_estandar["cant_verbos"],
                         key='cant_verbos',
                         size=(4, 1))
        ],
    ]
    layout_config = [
        [sg.Button('Ingresar Palabras', key='B1', size=(50, 2))],
        [sg.Button('Elegir Colores', key='B2', size=(50, 2))],
        [
            sg.Text('Ayuda ', size=(35, 1)),
            sg.InputCombo(['sin', 'palabra', 'definicion', 'ambas'],
                          default_value=config_estandar['ayuda'],
                          key='ayuda',
                          size=(10, 1))
        ],
        [
            sg.Text('Orientacion ', size=(35, 1)),
            sg.InputCombo(['vertical', 'horizontal'],
                          default_value=config_estandar['orientacion'],
                          key='orientacion',
                          size=(10, 1))
        ],
        [sg.Text('Cantidad de palabras', size=(28, 1)),
         sg.Column(columna)],
        [
            sg.Text('Mayusculas/minusculas', size=(35, 1)),
            sg.InputCombo(['mayusculas', 'minusculas'],
                          default_value=config_estandar['MayusOMinus'],
                          key='MayusOMinus',
                          size=(10, 1))
        ],
        [
            sg.Text('Tipografia titulo', size=(11, 2)),
            sg.InputCombo(['Courier ', 'Helvetica ', 'Times '],
                          change_submits=True,
                          key='tipografia titulo',
                          size=(10, 1),
                          default_value=config_estandar['tipografia titulo']),
            sg.Text('Texto de Ejemplo',
                    font=tipografia + fontsize,
                    size=(20, 1),
                    key='ejemplo')
        ],
        [
            sg.Text('Tipografia texto', size=(11, 2)),
            sg.InputCombo(['Courier ', 'Helvetica ', 'Times '],
                          change_submits=True,
                          key='tipografia cuerpo',
                          size=(10, 1),
                          default_value=config_estandar['tipografia cuerpo']),
            sg.Text('Texto de Ejemplo',
                    font=tipografia2 + fontsize,
                    size=(20, 1),
                    key='ejemplo2')
        ],
        [
            sg.Text('Estilo', size=(11, 1)),
            sg.InputCombo(['normal', 'oficinas'],
                          disabled=len(lista_oficinas) == 1,
                          change_submits=True,
                          key='elegir estilo',
                          size=(10, 1)),
            sg.InputCombo(lista_oficinas,
                          disabled=True,
                          key='oficina',
                          size=(10, 1))
        ],
        [
            sg.Button('Guardar y salir', key='Guardar', size=(24, 2)),
            sg.Button('Salir', key='Salir', size=(24, 2))
        ],
    ]
    ventana_config = sg.Window('Configuración',
                               margins=(10, 30)).Layout(layout_config)
    fin = False
    while True:
        configurado = False
        event_config, values_config = ventana_config.Read()
        if event_config == None:
            return None
        if event_config == 'Salir':
            if sg.PopupYesNo('¿Salir sin guardar?') == 'Yes':
                break
        if tipografia != values_config['tipografia titulo']:
            tipografia = values_config['tipografia titulo']
            ventana_config.FindElement('ejemplo').Update(font=tipografia +
                                                         fontsize)
        if tipografia2 != values_config['tipografia cuerpo']:
            tipografia2 = values_config['tipografia cuerpo']
            ventana_config.FindElement('ejemplo2').Update(font=tipografia2 +
                                                          fontsize)
        if event_config == 'Guardar':
            if (not values_config['cant_adjetivos'].isdigit()
                    or not values_config['cant_sustantivos'].isdigit()
                    or not values_config['cant_verbos'].isdigit()):
                sg.Popup(
                    'Revise que las cantidades ingresadas para cada tipo de palabra\nSean numeros adecuados\n(Tenga cuidado con espacios que no se vean)'
                )
            else:
                configurado = True
                break
        if 'oficinas' == values_config['elegir estilo']:
            ventana_config.FindElement('oficina').Update(disabled=False)
        if 'normal' == values_config['elegir estilo']:
            ventana_config.FindElement('oficina').Update(disabled=True)
        if event_config == 'B1':
            ventana_config.Hide()
            mp.Ingresar_palabras(dic_palabras, reporte_pantalla)
        elif event_config == 'B2':
            ventana_config.Hide()
            mc.elegir_colores(colores)
        ventana_config.UnHide()
    if configurado:
        configuracion = values_config
        configuracion['palabras'] = dic_palabras
        configuracion['colores'] = colores
        if not os.path.exists(os.path.join(ruta_app, 'palabras anteriores')):
            os.mkdir(os.path.join(ruta_app, 'palabras anteriores'))
        archpalabras = open(
            os.path.join(ruta_app, 'palabras anteriores', 'palabras.json'),
            'w+')
        json.dump(dic_palabras, archpalabras)
        archpalabras.close()
        ventana_config.Close()
        return configuracion
    ventana_config.Close()
    return None
예제 #16
0
def juego(cargar=False):
    if sys.platform == "win32":
        layout = [[
            sg.Text("00:00"),
            sg.Text("texto", size=(60, 1), justification="center"),
            sg.Image(sys.path[0] + "\imagenes\playerlogo2.png"),
            sg.Text("9999"),
            sg.Image(sys.path[0] + "\imagenes\computerlogo2.png"),
            sg.Text("9999"),
            sg.Text("0:00"),
            sg.Button("Iniciar",
                      size=(15, 2),
                      font=("Impact", 12),
                      button_color=color_boton2)
        ], [sg.Column(crear_botones(15)) for i in range(15)],
                  [
                      sg.Button("Confirmar",
                                size=(28, 2),
                                font=("Impact", 11),
                                button_color=color_boton2),
                      sg.Button("Pasar",
                                size=(28, 2),
                                font=("Impact", 11),
                                button_color=color_boton2),
                      sg.Button("Posponer",
                                size=(28, 2),
                                font=("Impact", 11),
                                button_color=color_boton2),
                      sg.Button("Terminar",
                                size=(28, 2),
                                font=("Impact", 11),
                                button_color=color_boton2)
                  ],
                  [
                      sg.Button("A",
                                font=("Impact", 18),
                                size=(9, 1),
                                button_color=color_boton) for i in range(7)
                  ],
                  [
                      sg.Text("Letras en la bolsa: N", size=(80, 1)),
                      sg.Button("Cambiar (N)",
                                size=(25, 2),
                                font=("Impact", 12),
                                button_color=color_boton2)
                  ]]
    elif sys.platform == "linux":
        layout = [[
            sg.Text("00:00"),
            sg.Text("texto", size=(60, 1), justification="center"),
            sg.Image(sys.path[0] + "/imagenes/playerlogo2.png"),
            sg.Text("9999"),
            sg.Image(sys.path[0] + "/imagenes/computerlogo2.png"),
            sg.Text("9999"),
            sg.Text("0:00"),
            sg.Button("Iniciar",
                      size=(15, 2),
                      font=("Impact", 12),
                      button_color=color_boton2)
        ], [sg.Column(crear_botones(15)) for i in range(15)],
                  [
                      sg.Button("Confirmar",
                                size=(28, 2),
                                font=("Impact", 11),
                                button_color=color_boton2),
                      sg.Button("Pasar",
                                size=(28, 2),
                                font=("Impact", 11),
                                button_color=color_boton2),
                      sg.Button("Posponer",
                                size=(28, 2),
                                font=("Impact", 11),
                                button_color=color_boton2),
                      sg.Button("Terminar",
                                size=(28, 2),
                                font=("Impact", 11),
                                button_color=color_boton2)
                  ],
                  [
                      sg.Button("A",
                                font=("Impact", 18),
                                size=(9, 1),
                                button_color=color_boton) for i in range(7)
                  ],
                  [
                      sg.Text("Letras en la bolsa: N", size=(80, 1)),
                      sg.Button("Cambiar (N)",
                                size=(25, 2),
                                font=("Impact", 12),
                                button_color=color_boton2)
                  ]]
    else:
        layout = [[
            sg.Text("00:00"),
            sg.Text("texto", size=(60, 1), justification="center"),
            sg.Text("9999"),
            sg.Text("9999"),
            sg.Text("0:00"),
            sg.Button("Iniciar",
                      size=(15, 2),
                      font=("Impact", 12),
                      button_color=color_boton2)
        ], [sg.Column(crear_botones(15)) for i in range(15)],
                  [
                      sg.Button("Confirmar",
                                size=(28, 2),
                                font=("Impact", 11),
                                button_color=color_boton2),
                      sg.Button("Pasar",
                                size=(28, 2),
                                font=("Impact", 11),
                                button_color=color_boton2),
                      sg.Button("Posponer",
                                size=(28, 2),
                                font=("Impact", 11),
                                button_color=color_boton2),
                      sg.Button("Terminar",
                                size=(28, 2),
                                font=("Impact", 11),
                                button_color=color_boton2)
                  ],
                  [
                      sg.Button("A",
                                font=("Impact", 18),
                                size=(9, 1),
                                button_color=color_boton) for i in range(7)
                  ],
                  [
                      sg.Text("Letras en la bolsa: N", size=(80, 1)),
                      sg.Button("Cambiar (N)",
                                size=(25, 2),
                                font=("Impact", 12),
                                button_color=color_boton2)
                  ]]

    if cargar:
        layout[0][1] = sg.Text("Juego cargado, pulse iniciar para retomar.",
                               size=(60, 1),
                               justification="center")
    else:
        layout[0][1] = sg.Text("Pulse iniciar para comenzar un nuevo juego.",
                               size=(60, 1),
                               justification="center")

    window = sg.Window("ScrabbleAR", layout)

    while True:
        evento, valores = window.read()
        if evento == sg.WIN_CLOSED:
            break

    window.Close()
예제 #17
0
                   enable_events=True,
                   size=(40, 20),
                   key="-FILE LIST-")
    ],
]

# For now will only show the name of the file that was chosen
image_viewer_column = [
    [sg.Text("Choose an image from list on left:")],
    [sg.Text(size=(40, 1), key="-TOUT-")],
    [sg.Image(key="-IMAGE-")],
]

# ----- Full layout -----
layout = [[
    sg.Column(file_list_column),
    sg.VSeperator(),
    sg.Column(image_viewer_column),
]]

window = sg.Window("Image Viewer", layout)

# 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 == "-FOLDER-":
        folder = values["-FOLDER-"]
        try:
예제 #18
0
                    agent.set_velocity(TSP_World.random_velocity())
            for ind in self.population:
                ind.fitness = ind.compute_fitness()
            self.best_ind = None
        TSP_Agent.show_labels = gui_get('show_labels')
        super().step()


# ############################################## Define GUI ############################################## #
import PySimpleGUI as sg

col = [[sg.Button('Create Node', tooltip='Create a node')],
       [sg.Button('Delete Node', tooltip='Delete one random node')]]

frame_layout_node_buttons = [[
    sg.Column(col, pad=(None, None)),
    sg.Button('Reverse', tooltip='Reverse direction of motion')
]]

frame_layout_generators = [[sg.Checkbox('Greedy', key='Greedy', default=True)],
                           [
                               sg.Checkbox('Min spanning tree',
                                           key='Min spanning tree',
                                           default=True)
                           ]]

frame_layout_mutations = [[
    sg.Checkbox('Move element', key='Move element', default=True)
], [sg.Checkbox('2-Opt', key='2-Opt', default=True)]]

tsp_right_upper = [[
def demo_photo_picker3(default_folder, default_pic):
    menu_def = [
        ['&Help', '&About...'],
    ]

    folder = default_folder
    files_listing = get_image_files_list(folder)
    column1 = [[
        sg.Listbox(
            values=files_listing,
            change_submits=
            True,  # trigger an event whenever an item is selected 
            size=(40, 20),
            font=("Arial", 10),
            key="files_listbox")
    ]]
    column2 = [[
        sg.Image(data=get_image_as_data(default_pic, 340, 340),
                 key="image",
                 size=(340, 340))
    ]]

    layout = [
        [
            sg.Menu(menu_def, tearoff=False, pad=(200, 1)),
            sg.Text("Select your images folder"),
            sg.InputText(key="photo_folder", change_submits=True
                         ),  # trigger an event whenever the item is changed 
            sg.FolderBrowse(target="photo_folder")
        ],
        [sg.Column(column1), sg.Column(column2)],
        [
            sg.Button('',
                      image_data=classify_x_base64,
                      button_color=(sg.theme_background_color(),
                                    sg.theme_background_color()),
                      border_width=0,
                      key='-Classify-'),
            sg.T(' ' * 115),
            sg.Button('',
                      image_data=exit_x_base64,
                      button_color=(sg.theme_background_color(),
                                    sg.theme_background_color()),
                      border_width=0,
                      key='-Exit-')
        ],
    ]

    window = sg.Window('Acanthamoeba Group Classification Program',
                       layout,
                       icon="GUI\iconProgram.ico")  #.Layout(layout)

    while True:
        event, values = window.Read()
        if event == None:
            break

        print(event)
        print(values)
        if event == "photo_folder":
            if values["photo_folder"] != "":
                if os.path.isdir(values["photo_folder"]):
                    folder = values["photo_folder"]
                    image_files = get_image_files_list(values["photo_folder"])
                    window.FindElement("files_listbox").Update(
                        values=image_files)
                    if len(image_files) > 0:
                        full_filename = os.path.join(folder, image_files[0])
                        window.FindElement("image").Update(
                            data=get_image_as_data(full_filename, 340, 340))
        if event == "files_listbox":
            full_filename = os.path.join(folder, values["files_listbox"][0])
            abp = os.path.relpath(full_filename)
            window.FindElement("image").Update(
                data=get_image_as_data(full_filename, 340, 340))
        if event == '-Classify-':
            warnings.filterwarnings('ignore')
            test_size = 0.10
            seed = 9
            h5_data = 'output/data.h5'
            h5_labels = 'output/labels.h5'

            # import the feature vector and trained labels
            h5f_data = h5py.File("h5_data.hdf5", 'r')
            h5f_label = h5py.File("h5_labels.hdf5", 'r')

            global_features_string = h5f_data['dataset_1']
            global_labels_string = h5f_label['dataset_1']

            global_features = np.array(global_features_string)
            global_labels = np.array(global_labels_string)

            h5f_data.close()
            h5f_label.close()

            (trainDataGlobal, testDataGlobal, trainLabelsGlobal,
             testLabelsGlobal) = train_test_split(np.array(global_features),
                                                  np.array(global_labels),
                                                  test_size=test_size,
                                                  random_state=seed)

            clf = SVC(random_state=seed)
            clf.fit(trainDataGlobal, trainLabelsGlobal)
            images_classify = cv2.imread(abp)
            fixed_size = tuple((100, 100))
            image_resize = cv2.resize(images_classify, fixed_size)
            featurehog = hog_feature(image_resize)
            global_feature = np.hstack([featurehog])
            scaler = MinMaxScaler(feature_range=(0, 1))
            rescaled_feature = scaler.fit_transform([global_feature])
            prediction = clf.predict(global_feature.reshape(1, -1))[0]
            ans = prediction_table(prediction)
            sg.popup("Your selected image is in group:" + ans,
                     title="Classify",
                     icon=icon_x_base64)
            window.FindElement("image").Update(
                data=get_image_as_data(full_filename, 340, 340))

        if event is None or event == '-Exit-':
            return None

        if event is None or event == 'Exit':
            return None

        if event == 'About...':
            window.disappear()
            sg.popup(
                'About this program '
                'Version 1.0',
                'ข้อตกลงในการใช้ซอฟต์แวร์',
                'ซอฟต์แวร์นี้เป็นผลงานที่พัฒนาโดย นางสาวบุษกร ศุภกิจอำนวย นายไกรวิทย์ รูปโฉม และนางสาวชฎาภรณ์ เกื้อกูล จาก มหาวิทยาลัยศรีนครินทรวิโรฒ ภายใต้การดูแลของ นางสาวศรีสุภางค์ ทิ้วสุวรรณ ภายใต้โครงการ การพัฒนาระบบจำแนกกลุ่มอะแคนทามีบาโดยวิธีการเรียนรู้ของเครื่องและคอมพิวเตอร์วิทัศน์เพื่อการส่งเสริมสุขภาพ ซึ่งสนับสนุนโดย สำนักงานพัฒนาวิทยาศาสตร์และเทคโนโลยีแห่งชาติ โดยมีวัตถุประสงค์เพื่อส่งเสริมให้นักเรียนและนักศึกษาได้เรียนรู้และฝึกทักษะในการพัฒนาซอฟต์แวร์ ลิขสิทธิ์ของซอฟต์แวร์นี้จึงเป็นของผู้พัฒนา ซึ่งผู้พัฒนาได้อนุญาตให้สำนักงานพัฒนาวิทยาศาสตร์และเทคโนโลยีแห่งชาติเผยแพร่ซอฟต์แวร์นี้ตาม “ต้นฉบับ” โดยไม่มีการแก้ไขดัดแปลงใดๆ ทั้งสิ้น ให้แก่บุคคลทั่วไปได้ใช้เพื่อประโยชน์ส่วนบุคคลหรือประโยชน์ทางการศึกษาที่ไม่มีวัตถุประสงค์ในเชิงพาณิชย์ โดยไม่คิดค่าตอบแทนการใช้ซอฟต์แวร์ ดังนั้น สำนักงานพัฒนาวิทยาศาสตร์และเทคโนโลยีแห่งชาติ จึงไม่มีหน้าที่ในการดูแล บำรุงรักษา จัดการอบรมการใช้งาน หรือพัฒนาประสิทธิภาพซอฟต์แวร์ รวมทั้งไม่รับรองความถูกต้องหรือประสิทธิภาพการทำงานของซอฟต์แวร์ ตลอดจนไม่รับประกันความเสียหายต่างๆ อันเกิดจากการใช้ซอฟต์แวร์นี้ทั้งสิ้น',
                'License Agreement',
                'This software is a work developed by Miss Bussakon Supakitumnuay, Mr. Kraiwit Roopchom and Miss Chadaporn Kuakul from Srinakharinwirot University under the provision of Miss Srisupang Thewsuwan under A Morphological Identification of Acanthamoeba System using Machine Learning and Computer Vision approaches for Health Promotion, which has been supported by the National Science and Technology Development Agency (NSTDA), in order to encourage pupils and students to learn and practice their skills in developing software. Therefore, the intellectual property of this software shall belong to the developer and the developer gives NSTDA a permission to distribute this software as an “as is” and non-modified software for a temporary and non-exclusive use without remuneration to anyone for his or her own purpose or academic purpose, which are not commercial purposes. In this connection, NSTDA shall not be responsible to the user for taking care, maintaining, training or developing the efficiency of this software. Moreover, NSTDA shall not be liable for any error, software efficiency and damages in connection with or arising out of the use of the software.”',
                font=("Arial", 10))
            window.reappear()

    window.Close()
예제 #20
0
           [sg.Multiline('', size=(25, 4), key='cons2')]]

block_3 = [
    [sg.Text('Format + Save', font='Any 15')],
    [sg.T('Select the .txt file to be converted to pdf')],
    [sg.Input(key='convert'), sg.FileBrowse()],
    [
        sg.Text(' ', size=(18, 1)),
        sg.Button('Convert file'),
        sg.Button('Upload folder')
    ],
]

layout = [[
    sg.Column(top_banner,
              size=(710, 60),
              pad=(0, 0),
              background_color=DARK_HEADER_COLOR)
], [sg.Column(top, size=(650, 90), pad=BPAD_TOP)],
          [
              sg.Column([[
                  sg.Column(block_2, size=(650, 360), pad=BPAD_LEFT_INSIDE)
              ], [sg.Column(block_3, size=(440, 160), pad=BPAD_LEFT_INSIDE)]],
                        pad=BPAD_LEFT,
                        background_color=BORDER_COLOR),
          ]]

window = sg.Window('Dashboard PySimpleGUI-Style',
                   layout,
                   margins=(0, 0),
                   background_color=BORDER_COLOR,
                   no_titlebar=True,
def PlayGame():

    menu_def = [['&File', ['&Open PGN File', 'E&xit' ]],
                ['&Help', '&About...'],]

    # sg.SetOptions(margins=(0,0))
    sg.ChangeLookAndFeel('GreenTan')
    # create initial board setup
    board = copy.deepcopy(initial_board)
    # the main board display layout
    board_layout = [[sg.T('     ')] + [sg.T('{}'.format(a), pad=((23,27),0), font='Any 13') for a in 'abcdefgh']]
    # loop though board and create buttons with images
    for i in range(8):
        row = [sg.T(str(8-i)+'   ', font='Any 13')]
        for j in range(8):
            piece_image = images[board[i][j]]
            row.append(render_square(piece_image, key=(i,j), location=(i,j)))
        row.append(sg.T(str(8-i)+'   ', font='Any 13'))
        board_layout.append(row)
    # add the labels across bottom of board
    board_layout.append([sg.T('     ')] + [sg.T('{}'.format(a), pad=((23,27),0), font='Any 13') for a in 'abcdefgh'])

    # setup the controls on the right side of screen
    openings = ('Any', 'Defense', 'Attack', 'Trap', 'Gambit','Counter', 'Sicillian', 'English','French', 'Queen\'s openings', 'King\'s Openings','Indian Openings')

    board_controls = [[sg.RButton('New Game', key='Open PGN File'), sg.RButton('Draw')],
                      [sg.RButton('Resign Game'), sg.RButton('Set FEN')],
                      [sg.RButton('Player Odds'),sg.RButton('Training') ],
                      [sg.Drop(openings),sg.Text('Opening/Style')],
                      [sg.CBox('Play a White', key='_white_')],
                      [sg.Text('Move List')],
                      [sg.Multiline([], do_not_clear=True, autoscroll=True, size=(15,10),key='_movelist_')],]

    # layouts for the tabs
    controls_layout = [[sg.Text('Performance Parameters', font='_ 20')],
                       [sg.T('Put stuff like AI engine tuning parms on this tab')]]

    statistics_layout = [[sg.Text('Statistics', font=('_ 20'))],
                         [sg.T('Game statistics go here?')]]

    board_tab = [[sg.Column(board_layout)]]

    # the main window layout
    layout = [[sg.Menu(menu_def, tearoff=False)],
              [sg.TabGroup([[sg.Tab('Board',board_tab),
                             sg.Tab('Controls', controls_layout),
                             sg.Tab('Statistics', statistics_layout)]], title_color='red'),
               sg.Column(board_controls)],
              [sg.Text('Click anywhere on board for next move', font='_ 14')]]

    window = sg.Window('Chess', default_button_element_size=(12,1), auto_size_buttons=False, icon='kingb.ico').Layout(layout)

    # ---===--- Loop taking in user input --- #
    i = 0
    moves = None
    while True:
        button, value = window.Read()
        if button in (None, 'Exit'):
            break
        if button == 'Open PGN File':
            filename = sg.PopupGetFile('', no_window=True)
            if filename is not None:
                moves = open_pgn_file(filename)
                i = 0
                board = copy.deepcopy(initial_board)
                window.FindElement('_movelist_').Update(value='')
        if button == 'About...':
            sg.Popup('Powerd by Engine Kibitz Chess Engine')
        if type(button) is tuple and moves is not None and i < len(moves):
            move = moves[i]                 # get the current move
            window.FindElement('_movelist_').Update(value='{}   {}\n'.format(i+1, str(move)), append=True)
            move_from = move.from_square    # parse the move-from and move-to squares
            move_to = move.to_square
            row, col = move_from // 8, move_from % 8
            piece = board[row][col]         # get the move-from piece
            button = window.FindElement(key=(row,col))
            for x in range(3):
                button.Update(button_color = ('white' , 'red' if x % 2 else 'white'))
                window.Refresh()
                time.sleep(.05)
            board[row][col] = BLANK         # place blank where piece was
            row, col = move_to // 8, move_to % 8  # compute move-to square
            board[row][col] = piece         # place piece in the move-to square
            redraw_board(window, board)
            i += 1
예제 #22
0
    def begin(self):
         if self.filename is not None:
             if os.path.exists(self.filename):
                 with open(self.filename, "r") as infile:
                     reader = csv.reader(infile)
                     self.header_list = next(reader)
                     try:
                         self.data = list(reader)  # read everything else into a list of rows
                     except:
                         sg.popup_error('Error reading file')
                         return
             else:
                 with open(self.filename, 'w', encoding="utf-8", newline='') as infile:
                     infile_writer = csv.writer(infile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
                     infile_writer.writerow(['EV','H2O','Sol1','Sol2','Sol3','Sol4'])
                     infile_writer.writerow(['1A1','5','5','5','5','5'])
                     infile_writer.writerow(['1A2','5','5','5','5','5'])
                     infile_writer.writerow(['1A3','5','5','5','5','5'])
                     infile_writer.writerow(['1A4','5','5','5','5','5'])
                     infile_writer.writerow(['1B1','5','5','5','5','5'])
                     infile_writer.writerow(['1B2','5','5','5','5','5'])
                     infile_writer.writerow(['1B3','5','5','5','5','5'])
                     infile_writer.writerow(['1B4','5','5','5','5','5'])
                     infile_writer.writerow(['2A1','5','5','5','5','5'])
                     infile_writer.writerow(['2A2','5','5','5','5','5'])
                     infile_writer.writerow(['2A3','5','5','5','5','5'])
                     infile_writer.writerow(['2A4','5','5','5','5','5'])
                     infile_writer.writerow(['2B1','5','5','5','5','5'])
                     infile_writer.writerow(['2B2','5','5','5','5','5'])
                     infile_writer.writerow(['2B3','5','5','5','5','5'])
                     infile_writer.writerow(['2B4','5','5','5','5','5'])
                     infile_writer.writerow(['3A1','5','5','5','5','5'])
                     infile_writer.writerow(['3A2','5','5','5','5','5'])
                     infile_writer.writerow(['3A3','5','5','5','5','5'])
                     infile_writer.writerow(['3A4','5','5','5','5','5'])
                     infile_writer.writerow(['3B1','5','5','5','5','5'])
                     infile_writer.writerow(['3B2','5','5','5','5','5'])
                     infile_writer.writerow(['3B3','5','5','5','5','5'])
                     infile_writer.writerow(['3B4','5','5','5','5','5'])
                     infile_writer.writerow(['4A1','5','5','5','5','5'])
                     infile_writer.writerow(['4A2','5','5','5','5','5'])
                     infile_writer.writerow(['4A3','5','5','5','5','5'])
                     infile_writer.writerow(['4A4','5','5','5','5','5'])
                     infile_writer.writerow(['4B1','5','5','5','5','5'])
                     infile_writer.writerow(['4B2','5','5','5','5','5'])
                     infile_writer.writerow(['4B3','5','5','5','5','5'])
                     infile_writer.writerow(['4B4','5','5','5','5','5'])
                     infile_writer.writerow(['Ciclo (Min)','15','','','',''])
                 with open(self.filename, "r") as infile:
                     reader = csv.reader(infile)
                     self.header_list = next(reader)
                     try:
                         self.data = list(reader)  # read everything else into a list of rows
                     except:
                         sg.popup_error('Error reading file')
                         return

         self.total = self.getTotalIrrigationTime(self.data)
         self.cycleTime = self.data[-1][1]

         col1 = sg.Column([
                      [sg.Text('Grow Greens', size=(44, 1), justification='center', font=("Helvetica 30 bold"), relief=sg.RELIEF_RIDGE, border_width=5)],
                      [sg.Text('_' * 150)]
               ])

         col2 = sg.Column([
                      [sg.Frame(layout=[
                          #[sg.Text(' '*50, key='Error1', text_color='red')],
                          [sg.Text('Selección de piso a visualizar:')],
                          [sg.Radio('Piso 1             ', "PISO", key='Piso1', default=True, text_color='white'),
                           sg.Radio('Piso 2             ', "PISO", key='Piso2', text_color='white'),
                           sg.Radio('Piso 3             ', "PISO", key='Piso3', text_color='white'),
                           sg.Radio('Piso 4', "PISO", key='Piso4', text_color='white')],
                          [sg.Text('Selección de solución a visualizar:')],
                          [sg.Radio('Agua', "SOL", key='H2O', default=True, text_color='white'),
                           sg.Radio('Solución 1', "SOL", key='S1', text_color='white'),
                           sg.Radio('Solución 2', "SOL", key='S2', text_color='white'),
                           sg.Radio('Solución 3', "SOL", key='S3', text_color='white'),
                           sg.Radio('Solución 4', "SOL", key='S4', text_color='white')],
                          #[sg.Text('')],
                          [sg.Text('Selección de etapa a editar:'),
                          sg.Text('Tiempo (s)'),
                           sg.Slider(range=(5, 5), orientation='h', key='evTime', size=(10, 15), default_value=self.evTime),
                           #sg.Text(' '*10),
                           sg.Button('Actualizar', size=(8, 1), key="Actualizar", pad=(10,10), disabled=True, button_color=self.disable_color)],
                          [sg.Radio('Germinación A', "Etapa", key='GerminacionA', default=True, text_color='white'),
                           sg.Radio('Etapa 1 A  ', "Etapa", key='Etapa1A', text_color='white'),
                           sg.Radio('Etapa 2 A  ', "Etapa", key='Etapa2A', text_color='white'),
                           sg.Radio('Cosecha A', "Etapa", key='CosechaA', text_color='white')],
                          [sg.Text(self.data[0][1]+' s', key='GerminacionATxt', size=(13, 1), justification='center'),
                           sg.Text(self.data[1][1]+' s', key='Etapa1ATxt', size=(10, 1), justification='center'),
                           sg.Text(self.data[2][1]+' s', key='Etapa2ATxt', size=(13, 1), justification='center'),
                           sg.Text(self.data[3][1]+' s', key='CosechaATxt', size=(11, 1), justification='center')],
                          [sg.Image(data=self.get_img_data(self.paths[9], first=True))],
                          [sg.Text(self.data[7][1]+' s', key='CosechaBTxt', size=(13, 1), justification='center'),
                           sg.Text(self.data[6][1]+' s', key='Etapa2BTxt', size=(10, 1), justification='center'),
                           sg.Text(self.data[5][1]+' s', key='Etapa1BTxt', size=(13, 1), justification='center'),
                           sg.Text(self.data[4][1]+' s', key='GerminacionBTxt', size=(11, 1), justification='center')],
                          [sg.Radio('Cosecha B     ', "Etapa", key='CosechaB', text_color='white'),
                           sg.Radio('Etapa 2 B  ', "Etapa", key='Etapa2B', text_color='white'),
                           sg.Radio('Etapa 1 B  ', "Etapa", key='Etapa1B', text_color='white'),
                           sg.Radio('Germinación B', "Etapa", key='GerminacionB', text_color='white')],
                          #[sg.Table(values=self.data,
                         #           key='Table',
                         #           headings=self.header_list,
                         #           max_col_width=25,
                         #           auto_size_columns=True,
                         #           justification='center',
                         #           num_rows=min(len(self.data), 8))],
                          [sg.Text('Ciclo de riego:', size=(10, 1)),
                          sg.Text(self.data[-1][1]+' min', key='TiempoCiclo', size=(6,1), justification='center'),
                          sg.Slider(range=(int(self.total/30)+1, 20), key='cycleTime', orientation='h', size=(15, 15), default_value=self.cycleTime),
                          sg.Button('Actualizar Ciclo', size=(12, 1), key="Actualizar Ciclo", pad=(10,10), disabled=True, button_color=self.disable_color)],
                          #[sg.Text('Piso:'),
                           #sg.Text('Lado:'),
                           #sg.Text('Etapa:'),
                           #sg.Text('Solución:'),
                           #sg.Text(' '*40, key='Error2', text_color='red')],
                          #[sg.Combo(('', '1', '2', '3', '4'), key="Piso", default_value='', size=(4, 1)),
                           #sg.Combo(('', 'A', 'B'), key="Lado", default_value='', size=(4, 1)),
                           #sg.Combo(('', '1', '2', '3', '4'), key="Etapa", default_value='', size=(4, 1)),
                           #sg.Combo(('', 'H2O', '1', '2', '3', '4'), key="Sol", default_value='', size=(4, 1)),

                          ], title='Configuración de riego', relief=sg.RELIEF_SUNKEN)]
                ])

         colB1 = sg.Column([
                      [self.GraphicButton('','B_A4+',self.paths[11],maxsize=(30,30))],
                      [sg.Text(self.SeedValues['SA4'] ,key='B_A4')],
                      [self.GraphicButton('','B_A4-',self.paths[10],maxsize=(30,30))],
                      [sg.Text('')],
                      [self.GraphicButton('','B_A3+',self.paths[11],maxsize=(30,30))],
                      [sg.Text(self.SeedValues['SA3'],key='B_A3')],
                      [self.GraphicButton('','B_A3-',self.paths[10],maxsize=(30,30))],
                      [sg.Text('')],
                      [self.GraphicButton('','B_A2+',self.paths[11],maxsize=(30,30))],
                      [sg.Text(self.SeedValues['SA2'],key='B_A2')],
                      [self.GraphicButton('','B_A2-',self.paths[10],maxsize=(30,30))],
                      [sg.Text('')],
                      [self.GraphicButton('','B_A1+',self.paths[11],maxsize=(30,30))],
                      [sg.Text(self.SeedValues['SA1'],key='B_A1')],
                      [self.GraphicButton('','B_A1-',self.paths[10],maxsize=(30,30))],
         ])
         colB2 = sg.Column([
                      [self.GraphicButton('','B_B4+',self.paths[11],maxsize=(30,30))],
                      [sg.Text(self.SeedValues['SB4'],key='B_B4')],
                      [self.GraphicButton('','B_B4-',self.paths[10],maxsize=(30,30))],
                      [sg.Text('')],
                      [self.GraphicButton('','B_B3+',self.paths[11],maxsize=(30,30))],
                      [sg.Text(self.SeedValues['SB3'],key='B_B3')],
                      [self.GraphicButton('','B_B3-',self.paths[10],maxsize=(30,30))],
                      [sg.Text('')],
                      [self.GraphicButton('','B_B2+',self.paths[11],maxsize=(30,30))],
                      [sg.Text(self.SeedValues['SB2'],key='B_B2')],
                      [self.GraphicButton('','B_B2-',self.paths[10],maxsize=(30,30))],
                      [sg.Text('')],
                      [self.GraphicButton('','B_B1+',self.paths[11],maxsize=(30,30))],
                      [sg.Text(self.SeedValues['SB1'],key='B_B1')],
                      [self.GraphicButton('','B_B1-',self.paths[10],maxsize=(30,30))],
         ])

         col3 = sg.Column([
                      [sg.Frame(layout=[
                          [sg.Text('Presiona el botón de + o - para indicar en que piso se siembra', size = (56, 1), justification='center')],
                          [sg.Text('presiona la cantidad de veces que se haya sembrado', size = (56, 1), justification='center')],
                          [colB1,
                          sg.Image(data=self.get_img_data(self.paths[0], maxsize=(380,443), first=True), key='siembra'),
                          colB2],
                      ], title='Bitácora de siembra', relief=sg.RELIEF_SUNKEN)]
                ])

         layout = [[col1],[col2, col3]]

         self.window = sg.Window('GG GUI', layout, no_titlebar=False,
                            auto_size_text=True, finalize=True)

         self.str2log('GUI started correctly', level = 1)
예제 #23
0
파일: pizda.py 프로젝트: akerineth/-
                   size=(40, 20),
                   key="-FILE LIST-")
    ]
]

n = "\n".join(kt.CLASSES)

right = [[sg.Text(n)], [sg.Text(key="-TOUT-")]]
right1 = [
    [sg.Text("")],
    [sg.Text(size=(40, 1), key="-TOUT1-")],
    [sg.Image(key="-IMAGE-")],
]

layout = [[
    sg.Column(left),
    sg.VSeparator(),
    sg.Column(right),
    sg.VSeparator(),
    sg.Column(right1)
]]

window = sg.Window('Классификатор изображений', layout)

while True:
    event, values = window.read()
    if event == sg.WINDOW_CLOSED or event == 'Quit':
        break
    path = values["-INPUT1-"]
    path1 = path + "\\"
    obj = list(map(int, values["-INPUT2-"].split(" ")))
예제 #24
0
def Everything():
    sg.ChangeLookAndFeel('BlueMono')

    column1 = [[
        sg.Text('Column 1',
                background_color=sg.DEFAULT_BACKGROUND_COLOR,
                justification='center',
                size=(10, 1))
    ],
               [
                   sg.Spin(values=('Spin Box 1', '2', '3'),
                           initial_value='Spin Box 1',
                           key='spin1')
               ],
               [
                   sg.Spin(values=('Spin Box 1', '2', '3'),
                           initial_value='Spin Box 2',
                           key='spin2')
               ],
               [
                   sg.Spin(values=('Spin Box 1', '2', '3'),
                           initial_value='Spin Box 3',
                           key='spin3')
               ]]

    layout = [
        [
            sg.Text('All graphic widgets in one form!',
                    size=(30, 1),
                    font=("Helvetica", 25))
        ], [sg.Text('Here is some text.... and a place to enter text')],
        [sg.InputText('This is my text', key='in1', do_not_clear=True)],
        [
            sg.Checkbox('Checkbox', key='cb1'),
            sg.Checkbox('My second checkbox!', key='cb2', default=True)
        ],
        [
            sg.Radio('My first Radio!     ',
                     "RADIO1",
                     key='rad1',
                     default=True),
            sg.Radio('My second Radio!', "RADIO1", key='rad2')
        ],
        [
            sg.Multiline(
                default_text=
                'This is the default Text should you decide not to type anything',
                size=(35, 3),
                key='multi1',
                do_not_clear=True),
            sg.Multiline(default_text='A second multi-line',
                         size=(35, 3),
                         key='multi2',
                         do_not_clear=True)
        ],
        [
            sg.InputCombo(('Combobox 1', 'Combobox 2'),
                          key='combo',
                          size=(20, 1)),
            sg.Slider(range=(1, 100),
                      orientation='h',
                      size=(34, 20),
                      key='slide1',
                      default_value=85)
        ],
        [
            sg.InputOptionMenu(
                ('Menu Option 1', 'Menu Option 2', 'Menu Option 3'),
                key='optionmenu')
        ],
        [
            sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'),
                       size=(30, 3),
                       key='listbox'),
            sg.Slider(
                range=(1, 100),
                orientation='v',
                size=(5, 20),
                default_value=25,
                key='slide2',
            ),
            sg.Slider(
                range=(1, 100),
                orientation='v',
                size=(5, 20),
                default_value=75,
                key='slide3',
            ),
            sg.Slider(range=(1, 100),
                      orientation='v',
                      size=(5, 20),
                      default_value=10,
                      key='slide4'),
            sg.Column(column1, background_color='gray34')
        ], [sg.Text('_' * 80)], [sg.Text('Choose A Folder', size=(35, 1))],
        [
            sg.Text('Your Folder',
                    size=(15, 1),
                    auto_size_text=False,
                    justification='right'),
            sg.InputText('Default Folder', key='folder', do_not_clear=True),
            sg.FolderBrowse()
        ],
        [
            sg.ReadButton('Exit'),
            sg.Text(' ' * 40),
            sg.ReadButton('SaveSettings'),
            sg.ReadButton('LoadSettings')
        ]
    ]

    window = sg.Window('Form Fill Demonstration',
                       default_element_size=(40, 1),
                       grab_anywhere=False)
    # button, values = window.LayoutAndRead(layout, non_blocking=True)
    window.Layout(layout)

    while True:
        event, values = window.Read()

        if event == 'SaveSettings':
            filename = sg.PopupGetFile('Save Settings',
                                       save_as=True,
                                       no_window=True)
            window.SaveToDisk(filename)
            # save(values)
        elif event == 'LoadSettings':
            filename = sg.PopupGetFile('Load Settings', no_window=True)
            window.LoadFromDisk(filename)
            # load(form)
        elif event in ('Exit', None):
            break
예제 #25
0
def detect():

    sg.theme("DarkGrey")

    col1 = sg.Text("Occupancy : ", key="-OCCUP-")
    col2 = sg.Text("Crowd Estimation : ", key="-CROWD-")
    btn1 = sg.Button("Create ROI",
                     button_color=('black', 'white'),
                     size=(10, 1),
                     key="-CREATE-",
                     visible=True)
    btn2 = sg.Button("Finish Create ROI",
                     button_color=('black', 'white'),
                     size=(15, 1),
                     key="-FINISH-",
                     visible=False)

    # Define the window layout
    layout = [
        [sg.Column([[col1]]),
         sg.Column([[col2]]),
         sg.Column([[btn1, btn2]])],
        [sg.Column([[sg.Image(key="-IMAGE-")]], justification='center')],
        [sg.Button("Exit", button_color=('black', 'white'), size=(10, 1))],
    ]

    # Create the window and show it without the plot
    window = sg.Window("Nama Sistem", layout, resizable=True, finalize=True)
    window.Maximize()

    cap = cv2.VideoCapture(0)

    while True:
        event, values = window.read(timeout=20)
        if event in (None, 'Exit'):
            break
        if event == '-CREATE-':
            window.Element('-FINISH-').Update(visible=True)
            window.Element('-OCCUP-').Update(visible=False)
            window.Element('-CROWD-').Update(visible=False)
            window.Element('-CREATE-').Update(visible=False)

        if event == '-FINISH-':
            window.Element('-FINISH-').Update(visible=False)
            window.Element('-OCCUP-').Update(visible=True)
            window.Element('-CROWD-').Update(visible=True)
            window.Element('-CREATE-').Update(visible=True)

        ret, frame = cap.read()
        if ret == True:
            renew = cv2.resize(frame, (1600, 900),
                               fx=0,
                               fy=0,
                               interpolation=None)

        if event == "Exit" or event == sg.WIN_CLOSED:
            break

        imgbytes = cv2.imencode(".png", renew)[1].tobytes()
        window["-IMAGE-"].update(data=imgbytes)

    window.close()
예제 #26
0
def TableSimulation():
    """
    Display data in a table format
    """
    sg.SetOptions(element_padding=(0, 0))
    sg.PopupNoWait('Give it a few seconds to load please...', auto_close=True)

    menu_def = [
        ['File', ['Open', 'Save', 'Exit']],
        [
            'Edit',
            ['Paste', [
                'Special',
                'Normal',
            ], 'Undo'],
        ],
        ['Help', 'About...'],
    ]

    columm_layout = [[]]

    MAX_ROWS = 60
    MAX_COL = 10
    for i in range(MAX_ROWS):
        inputs = [sg.T('{}'.format(i), size=(4, 1), justification='right')] + [
            sg.In(size=(10, 1),
                  pad=(1, 1),
                  justification='right',
                  key=(i, j),
                  do_not_clear=True) for j in range(MAX_COL)
        ]
        columm_layout.append(inputs)

    layout = [
        [sg.Menu(menu_def)],
        [sg.T('Table Using Combos and Input Elements', font='Any 18')],
        [
            sg.
            T('Type in a row, column and value. The form will update the values in realtime as you type'
              ),
            sg.In(key='inputrow',
                  justification='right',
                  size=(8, 1),
                  pad=(1, 1),
                  do_not_clear=True),
            sg.In(key='inputcol',
                  size=(8, 1),
                  pad=(1, 1),
                  justification='right',
                  do_not_clear=True),
            sg.In(key='value',
                  size=(8, 1),
                  pad=(1, 1),
                  justification='right',
                  do_not_clear=True)
        ], [sg.Column(columm_layout, size=(800, 600), scrollable=True)]
    ]

    window = sg.Window('Table',
                       return_keyboard_events=True,
                       grab_anywhere=False).Layout(layout)

    while True:
        event, values = window.Read()
        # --- Process buttons --- #
        if event is None or event == 'Exit':
            break
        elif event == 'About...':
            sg.Popup('Demo of table capabilities')
        elif event == 'Open':
            filename = sg.PopupGetFile('filename to open',
                                       no_window=True,
                                       file_types=(("CSV Files", "*.csv"), ))
            # --- populate table with file contents --- #
            if filename is not None:
                with open(filename, "r") as infile:
                    reader = csv.reader(infile)
                    try:
                        data = list(
                            reader)  # read everything else into a list of rows
                    except:
                        sg.PopupError('Error reading file')
                        continue
                # clear the table
                [
                    window.FindElement((i, j)).Update('')
                    for j in range(MAX_COL) for i in range(MAX_ROWS)
                ]

                for i, row in enumerate(data):
                    for j, item in enumerate(row):
                        location = (i, j)
                        try:  # try the best we can at reading and filling the table
                            target_element = window.FindElement(location)
                            new_value = item
                            if target_element is not None and new_value != '':
                                target_element.Update(new_value)
                        except:
                            pass

        # if a valid table location entered, change that location's value
        try:
            location = (int(values['inputrow']), int(values['inputcol']))
            target_element = window.FindElement(location)
            new_value = values['value']
            if target_element is not None and new_value != '':
                target_element.Update(new_value)
        except:
            pass
예제 #27
0
col_a = [[sg.Button(i)]
         for i in ['Dairy', 'Vegetable', 'Fruit', 'Seafood', 'Meat']]
col_b = [[sg.Button(i)]
         for i in ['Grain', 'Herbs & Spices', 'Oils', 'Condiments', 'Sauces']]
col_c = [[sg.Button(i)]
         for i in ['Soups', 'Baking', 'Nuts & Legumes', 'Beverages', 'Other']]

# col_a += col_b this will make it a very long column
recipe_comp_layout = [[sg.T('You have these recipes in common:')],
                      [
                          sg.Listbox(values=[],
                                     size=(30, 15),
                                     enable_events=True,
                                     key='-recipe-list-box-')
                      ]]
columns_layout = [[sg.Column(col_a), sg.Column(col_b), sg.Column(col_c)]]
# creates three columns but as such it acts as three separate containers
ingredients_layout = [
    [
        sg.TabGroup([[
            sg.Tab('Ingredients', columns_layout, key='-ingredients-tab-'),
            sg.Tab('Recipes', recipe_comp_layout, key='-recipe-tab-')
        ]],
                    enable_events=True,
                    key='-tab-')
    ],
]
# --------

# set the windows theme
sg.theme('DarkAmber')
예제 #28
0
def Column(layout, scrollable=False):
    return sg.Column(layout,
                     scrollable=scrollable,
                     size=(540, 480),
                     vertical_scroll_only=True)
예제 #29
0
    [
        sg.Button('Zmniejsz', key="-REDUCE_SIZE-"),
        sg.Button('Powiększ', key="-INCREASE_SIZE-")
    ],
    [
        sg.Text('Jasność:'),
        sg.Button('+', key="-ADD_BRIGHTNESS-"),
        sg.Button('-', key="-UNDO_BRIGHTNESS-")
    ],
    #[sg.Slider((1,100), key='_SLIDER_', orientation='h', enable_events=True, disable_number_display=True),
    #        sg.T('     ', key='_RIGHT_')],
]

# ----- Wypełnienie układu okna -----
layout = [[
    sg.Column(left_column),
    sg.VSeperator(),
    sg.Column(center_column, element_justification='c'),
    sg.VSeperator(),
    sg.Column(right_column, element_justification='c'),
]]

window = sg.Window("Program", layout)

# Włączenie pętli zdarzeń
while True:
    event, values = window.read()
    if event == "Exit" or event == sg.WIN_CLOSED:
        if (os.path.exists("Resources/Results/plik_roboczy.PNG")):
            os.remove("Resources/Results/plik_roboczy.PNG")
        if (os.path.exists("Resources/Results/negatyw.PNG")):
예제 #30
0
def make_window():
    config = get_config()["DELIVERY"]
    navigator_column = [
        [
            sg.Col([[
                sg.Text("General",
                        enable_events=True,
                        key="-general-",
                        pad=((20, 5), (5, 5))),
            ]],
                   expand_x=True,
                   pad=((0, 0), (0, 0))),
        ],
        [
            sg.Col([[
                sg.Text("JSON/Ads",
                        enable_events=True,
                        key="-json-",
                        pad=((20, 5), (5, 5))),
            ]],
                   expand_x=True,
                   pad=((0, 0), (0, 0))),
        ],
        [
            sg.Col([[
                sg.Text("Email",
                        enable_events=True,
                        key="-email-",
                        pad=((20, 5), (5, 5))),
            ]],
                   expand_x=True,
                   pad=((0, 0), (0, 0))),
        ],
        [
            sg.Col([[
                sg.Text("After Effects",
                        enable_events=True,
                        key="-AE-",
                        pad=((20, 5), (5, 5))),
            ]],
                   expand_x=True,
                   pad=((0, 0), (0, 0))),
        ],
        [
            sg.Col([[
                sg.Text("Server Incoming",
                        size=(20, 1),
                        enable_events=True,
                        key="-incoming-",
                        pad=((20, 5), (10, 5))),
            ]],
                   expand_x=True,
                   pad=((0, 0), (0, 0))),
        ],
        [
            sg.Col([[
                sg.Text("Server delivery",
                        background_color="darkgrey",
                        enable_events=True,
                        key="-delivery-",
                        pad=((20, 5), (5, 5))),
            ]],
                   background_color="darkgrey",
                   expand_x=True,
                   pad=((0, 0), (0, 0))),
        ],
        [
            sg.Col([[
                sg.B('Back',
                     pad=((20, 10), (250, 0)),
                     button_color=("white", "black"),
                     highlight_colors=("red", "green"),
                     use_ttk_buttons=False)
            ]],
                   expand_x=True,
                   pad=((0, 0), (0, 20))),
        ],
    ]

    info_column = [
        [
            sg.Text("Select Protocal: "),
            sg.DD(values=["sFTP", "FTP"],
                  default_value=config["protocal"],
                  key="protocal",
                  enable_events=True)
        ],
        [
            sg.Text("FTP Server:"
                    if config["protocal"] == 'FTP' else "sFTP server",
                    pad=((22, 5), (5, 5)),
                    key="server_ident"),
            sg.I(config["server"], key="server", size=(30, 1))
        ],
        [
            sg.Text("Port:", pad=((57, 5), (5, 5))),
            sg.I(config["port"], key="port", size=(30, 1))
        ],
        [
            sg.Text("Username:"******"username"], key="username", size=(30, 1))
        ],
        [
            sg.Text("Password:"******"password"],
                 key="password",
                 size=(30, 1),
                 password_char="*")
        ],
        [
            sg.Text("path to private key" if not config.get("private_key_path")
                    else config.get("private_key_path"),
                    size=(40, 1),
                    pad=((32, 5), (5, 5))),
            sg.FileBrowse("Private Key",
                          disabled=config["protocal"] == 'FTP',
                          key="private_key_path")
        ], [sg.T(pad=((0, 400), (70, 0)))], [sg.T(pad=((0, 400), (70, 0)))],
        [
            sg.T("File Delivery Path:"),
            sg.I(config["delivery_path"], key="delivery_path", size=(38, 1))
        ], [sg.B("save", pad=((320, 20), (160, 5)))]
    ]
    # ----- Full layout -----
    layout = [[
        sg.Column(navigator_column,
                  vertical_alignment="t",
                  pad=((0, ), (15, 5))),
        sg.VSeperator(pad=(
            (0, 0),
            (0, 0),
        ), color="black"),
        sg.Column(
            info_column,
            vertical_alignment="t",
            pad=((0, ), (15, 5)),
        ),
    ]]

    # Create the window
    window = sg.Window("Settings", layout, margins=(0, 0), icon=apg_logo)
    return window