Esempio n. 1
0
def getEvent():

    # variables
    database = '/Users/DavidBailey/db/pythonsqlite.db'
    table = "events_pt"
    value = 'urban'

    # connect to sqlite
    conn = sqlite3.connect(database)
    BASE_DIR = os.path.dirname(os.path.abspath(__file__))
    db_path = os.path.join(BASE_DIR, database)
    with sqlite3.connect(db_path) as db:

        # gui layout
        sg.SetOptions(
            button_color=sg.COLOR_SYSTEM_DEFAULT
            , text_color=sg.COLOR_SYSTEM_DEFAULT
        )
        layout = [[sg.Text('Enter text here', size=(40, 1), font=800)],
                  [sg.Text('What type of event?', size=(15, 1), font=800),
                   # values in event column in database
                   sg.InputCombo(('urban', 'outdoors - hike', 'outdoors - no hike', 'outdoors - hard hike', '13er',
                                  '14er', 'backpacking'), size=(20, 1))],
                  [sg.Button('Submit')]]

        window = sg.Window('Digital Bucket').Layout(layout)
        button, values = window.Read()
        value = ''.join(values)

        # select query on database
        cursor = conn.cursor()
        cursor.execute("SELECT event FROM %s where complete = 'N' and type = '%s'" % (table, value))
        event_list = []
        for record in cursor:
            event_list.append(record)
        main_value_list = random.choice(event_list)
        main_value = ''.join(main_value_list)
        print value
        print main_value

        # update query on database
        cursor.execute("UPDATE %s SET complete = 'Y' where event = '%s' and type = '%s'" % (table, main_value, value))
        conn.commit()

        # show value in gui popup
        sg.Popup('You are going to....', main_value, font='800', size=(40, 1))
def DownloadSubtitlesGUI():
    sg.ChangeLookAndFeel('Dark')

    combobox = sg.InputCombo(values=['',], size=(10,1), key='lang')
    layout =  [
                [sg.Text('Subtitle Grabber', size=(40, 1), font=('Any 15'))],
                [sg.T('YouTube Link'),sg.In(default_text='',size=(60,1), key='link', do_not_clear=True) ],
                [sg.Output(size=(90,20), font='Courier 12')],
                [sg.ReadButton('Get List')],
                [sg.T('Language Code'), combobox, sg.ReadButton('Download')],
                [sg.Button('Exit', button_color=('white', 'firebrick3'))]
                ]

    window = sg.Window('Subtitle Grabber launcher', text_justification='r', default_element_size=(15,1), font=('Any 14')).Layout(layout)

    # ---===--- Loop taking in user input and using it to query HowDoI --- #
    while True:
        (button, gui) = window.Read()
        if button in ('EXIT', None):
            break           # exit button clicked
        link = gui['link']
        if button is 'Get List':
            print('Getting list of subtitles....')
            window.Refresh()
            command = [f'C:/Python/PycharmProjects/GooeyGUI/youtube-dl --list-subs {link}',]
            output = ExecuteCommandSubprocess(command, wait=True, quiet=True)
            lang_list = [o[:5].rstrip() for o in output.split('\n') if 'vtt' in o]
            lang_list = sorted(lang_list)
            combobox.Update(values=lang_list)
            print('Done')

        elif button is 'Download':
            lang = gui['lang']
            if lang is '':
                lang = 'en'
            print(f'Downloading subtitle for {lang}...')
            window.Refresh()
            command = (f'C:/Python/PycharmProjects/GooeyGUI/youtube-dl --sub-lang {lang} --write-sub {link}',)
            ExecuteCommandSubprocess(command, wait=True)
            print('Done')
layout = [
    [sg.Text('Where would you like to fly to?')],
    [
        sg.Text('User ID', size=(22, 1), tooltip='Input your User ID'),
        sg.InputText('')
    ],
    [
        sg.Text('Country/City Destination',
                size=(22, 1),
                tooltip='Where do you want to go?'),
        sg.InputText('')
    ],
    [
        sg.Text('Travel Type', size=(22, 1)),
        sg.InputCombo(
            ('Solo traveler', 'Couple', 'Group', 'Family with older children',
             'Family with young children'),
            size=(20, 3))
    ],
    [
        sg.Text('Type of Stay', size=(22, 1)),
        sg.InputCombo(('Leisure trip', 'Business trip'), size=(20, 3))
    ],
    [
        sg.Text('Room Type', size=(22, 1)),
        sg.InputCombo(('Single Room', 'Twin Room', 'Double Room', 'Queen Room',
                       'King Room', 'Studio'),
                      size=(20, 3))
    ], [sg.Text(' ', size=(22, 1))],
    [
        sg.Text('Select Norm', size=(22, 1)),
        sg.InputCombo(('none', 'minmax', 'l1 norm', 'l2 norm', 'z score'),
Esempio n. 4
0
                          sg.Radio('My second Radio!', "RADIO1")
                      ]],
              title='Options',
              title_color='red',
              relief=sg.RELIEF_SUNKEN,
              tooltip='Use these to set flags')
 ],
 [
     sg.Multiline(
         default_text=
         'This is the default Text should you decide not to type anything',
         size=(35, 3)),
     sg.Multiline(default_text='A second multi-line', size=(35, 3))
 ],
 [
     sg.InputCombo(('Combobox 1', 'Combobox 2'), size=(20, 1)),
     sg.Slider(range=(1, 100),
               orientation='h',
               size=(34, 20),
               default_value=85)
 ],
 [sg.InputOptionMenu(('Menu Option 1', 'Menu Option 2', 'Menu Option 3'))],
 [
     sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'),
                size=(30, 3)),
     sg.Frame('Labelled Group', [[
         sg.Slider(range=(1, 100),
                   orientation='v',
                   size=(5, 20),
                   default_value=25),
         sg.Slider(range=(1, 100),
Esempio n. 5
0
def Everything():
    sg.ChangeLookAndFeel('TanBlue')

    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:
        button, values = window.Read()

        if button is 'SaveSettings':
            filename = sg.PopupGetFile('Save Settings',
                                       save_as=True,
                                       no_window=True)
            window.SaveToDisk(filename)
            # save(values)
        elif button is 'LoadSettings':
            filename = sg.PopupGetFile('Load Settings', no_window=True)
            window.LoadFromDisk(filename)
            # load(form)
        elif button in ['Exit', None]:
            break
Esempio n. 6
0
             font=("Calibri", 11))
 ],
 [
     sg.Text("Tweet Geolocation: " + tweet_geolocation,
             font=("Calibri", 11))
 ], [sg.Text("Tweet:\n" + noemoji, font=("Calibri", 11))],
 [sg.Text(russian_trans, font=("Calibri", 11))],
 [sg.Text(english_trans, font=("Calibri", 11))],
 [sg.ReadButton('Copy Original Tweet')],
 [sg.ReadButton('Copy Russian translation')],
 [sg.ReadButton('Copy English translation')],
 [
     sg.Text('Geolocation',
             size=(15, 1),
             font=("Calibri", 11)),
     sg.InputCombo(['0', '1'])
 ],
 [
     sg.Text('Relevance', size=(15, 1), font=("Calibri", 11)),
     sg.InputCombo(['0', '1'])
 ],
 [
     sg.Text('Time', size=(15, 1), font=("Calibri", 11)),
     sg.InputCombo(['none', 'f', 'p'])
 ],
 [
     sg.Text('Spain', size=(15, 1), font=("Calibri", 11)),
     sg.InputCombo(['yes', 'no', 'undefined'])
 ],
 [
     sg.Text('Narrow Geolocation',