當前位置: 首頁>>代碼示例>>Python>>正文


Python PySimpleGUI.Multiline方法代碼示例

本文整理匯總了Python中PySimpleGUI.Multiline方法的典型用法代碼示例。如果您正苦於以下問題:Python PySimpleGUI.Multiline方法的具體用法?Python PySimpleGUI.Multiline怎麽用?Python PySimpleGUI.Multiline使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PySimpleGUI的用法示例。


在下文中一共展示了PySimpleGUI.Multiline方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Multiline [as 別名]
def main():
    layout = [
        [sg.Multiline(size=(110, 30), font='courier 10', background_color='black', text_color='white', key='-MLINE-')],
        [sg.T('Promt> '), sg.Input(key='-IN-', focus=True, do_not_clear=False)],
        [sg.Button('Run', bind_return_key=True), sg.Button('Exit')]]

    window = sg.Window('Realtime Shell Command Output', layout)

    while True:  # Event Loop
        event, values = window.read()
        # print(event, values)
        if event in (sg.WIN_CLOSED, 'Exit'):
            break
        elif event == 'Run':
            runCommand(cmd=values['-IN-'], window=window)
    window.close() 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:18,代碼來源:Demo_Script_Launcher_ANSI_Color_Output.py

示例2: get_layout

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Multiline [as 別名]
def get_layout(cls):
        return sg.Column(
            [
                [
                    sg.Multiline(
                        key='logger',
                        font=('Courier New', 9),
                        autoscroll=True,
                        size=(92, 34),
                        pad=(0, (15, 0)),
                        background_color='grey20',
                        disabled=False)],
                [
                    cls.generate_clear_btn('logger')
                ]
            ],
            key='gui_tab_log',
            size=cls.PRIMARY_COL_TAB_SIZE,
            visible=False
        ) 
開發者ID:mrmin123,項目名稱:kcauto,代碼行數:22,代碼來源:runtime_logger.py

示例3: sg_show_hex_buffer

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Multiline [as 別名]
def sg_show_hex_buffer(buf):
    import PySimpleGUI as sg
    layout = [ [sg.OK(), sg.Cancel()],
               [sg.Multiline(buf.dump(),
                             enter_submits=True,
                             disabled=True, 
                             size=(80, 25))]
             ]
    sg.Window(str(buf), layout, font=('monospace', 12)).Read() 
開發者ID:pynvme,項目名稱:pynvme,代碼行數:11,代碼來源:test_utilities.py

示例4: ChatBotWithHistory

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Multiline [as 別名]
def ChatBotWithHistory():
    # -------  Make a new Window  ------- #
    sg.ChangeLookAndFeel('GreenTan')            # give our form a spiffy set of colors

    layout =  [[sg.Text('Your output will go here', size=(40, 1))],
                [sg.Output(size=(127, 30), font=('Helvetica 10'))],
                [sg.T('Command History'), sg.T('', size=(20,3), key='history')],
                [sg.Multiline(size=(85, 5), enter_submits=True, key='query', do_not_clear=False),
                sg.Button('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0]), bind_return_key=True),
                sg.Button('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]]

    window = sg.Window('Chat window with history', default_element_size=(30, 2), font=('Helvetica',' 13'), default_button_element_size=(8,2), return_keyboard_events=True).Layout(layout)

    # ---===--- Loop taking in user input and using it  --- #
    command_history = []
    history_offset = 0
    while True:
        (event, value) = window.Read()
        if event == 'SEND':
            query = value['query'].rstrip()
            # EXECUTE YOUR COMMAND HERE
            print('The command you entered was {}'.format(query))
            command_history.append(query)
            history_offset = len(command_history)-1
            window.FindElement('query').Update('')                       # manually clear input because keyboard events blocks clear
            window.FindElement('history').Update('\n'.join(command_history[-3:]))
        elif event in (None, 'EXIT'):            # quit if exit event or X
            break
        elif 'Up' in event and len(command_history):
            command = command_history[history_offset]
            history_offset -= 1 * (history_offset > 0)      # decrement is not zero
            window.FindElement('query').Update(command)
        elif 'Down' in event and len(command_history):
            history_offset += 1 * (history_offset < len(command_history)-1) # increment up to end of list
            command = command_history[history_offset]
            window.FindElement('query').Update(command)
        elif 'Escape' in event:
            window.FindElement('query').Update('')

    sys.exit(69) 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:42,代碼來源:Demo_Chat_With_History.py

示例5: main

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Multiline [as 別名]
def main():
    sg.theme('Dark Blue 3')
    layout = [[sg.Text('Send an Email', font='Default 18')],
              [sg.T('From:', size=(8,1)), sg.Input(key='-EMAIL FROM-', size=(35,1))],
              [sg.T('To:', size=(8,1)), sg.Input(key='-EMAIL TO-', size=(35,1))],
              [sg.T('Subject:', size=(8,1)), sg.Input(key='-EMAIL SUBJECT-', size=(35,1))],
              [sg.T('Mail login information', font='Default 18')],
              [sg.T('User:', size=(8,1)), sg.Input(key='-USER-', size=(35,1))],
              [sg.T('Password:', size=(8,1)), sg.Input(password_char='*', key='-PASSWORD-', size=(35,1))],
              [sg.Multiline('Type your message here', size=(60,10), key='-EMAIL TEXT-')],
              [sg.Button('Send'), sg.Button('Exit')]]

    window = sg.Window('Send An Email', layout)

    while True:  # Event Loop
        event, values = window.read()
        if event in (sg.WIN_CLOSED, 'Exit'):
            break
        if event == 'Send':
            if sg.__name__ != 'PySimpleGUIWeb':     # auto close popups not yet supported in PySimpleGUIWeb
                sg.popup_quick_message('Sending your message... this will take a moment...', background_color='red')
            send_an_email(from_address=values['-EMAIL FROM-'],
                          to_address=values['-EMAIL TO-'],
                          subject=values['-EMAIL SUBJECT-'],
                          message_text=values['-EMAIL TEXT-'],
                          user=values['-USER-'],
                          password=values['-PASSWORD-'])

    window.close() 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:31,代碼來源:Demo_Email_Send.py

示例6: HowDoI

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Multiline [as 別名]
def HowDoI():
    '''
    Make and show a window (PySimpleGUI form) that takes user input and sends to the HowDoI web oracle
    Excellent example of 2 GUI concepts
        1. Output Element that will show text in a scrolled window
        2. Non-Window-Closing Buttons - These buttons will cause the form to return with the form's values, but doesn't close the form
    :return: never returns
    '''
    # -------  Make a new Window  ------- #
    sg.ChangeLookAndFeel('GreenTan')            # give our form a spiffy set of colors

    layout =  [
                [sg.Text('Ask and your answer will appear here....', size=(40, 1))],
                [sg.Output(size=(127, 30), font=('Helvetica 10'))],
                [ sg.Spin(values=(1, 2, 3, 4), initial_value=1, size=(2, 1), key='Num Answers', font='Helvetica 15'),
                  sg.Text('Num Answers',font='Helvetica 15'), sg.Checkbox('Display Full Text', key='full text', font='Helvetica 15'),
                sg.T('Command History', font='Helvetica 15'), sg.T('', size=(40,3), text_color=sg.BLUES[0], key='history')],
                [sg.Multiline(size=(85, 5), enter_submits=True, key='query', do_not_clear=False),
                sg.ReadButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0]), bind_return_key=True),
                sg.Button('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]
              ]

    window = sg.Window('How Do I ??',
                       default_element_size=(30, 2),
                       font=('Helvetica',' 13'),
                       default_button_element_size=(8,2),
                       icon=DEFAULT_ICON,
                       return_keyboard_events=True).Layout(layout)

    # ---===--- Loop taking in user input and using it to query HowDoI --- #
    command_history = []
    history_offset = 0
    while True:
        (button, value) = window.Read()
        if button == 'SEND':
            query = value['query'].rstrip()
            print(query)
            QueryHowDoI(query, value['Num Answers'], value['full text'])  # send the string to HowDoI
            command_history.append(query)
            history_offset = len(command_history)-1
            window.FindElement('query').Update('')                       # manually clear input because keyboard events blocks clear
            window.FindElement('history').Update('\n'.join(command_history[-3:]))
        elif button in (None, 'EXIT'):            # if exit button or closed using X
            break
        elif 'Up' in button and len(command_history):                                # scroll back in history
            command = command_history[history_offset]
            history_offset -= 1 * (history_offset > 0)      # decrement is not zero
            window.FindElement('query').Update(command)
        elif 'Down' in button and len(command_history):                              # scroll forward in history
            history_offset += 1 * (history_offset < len(command_history)-1) # increment up to end of list
            command = command_history[history_offset]
            window.FindElement('query').Update(command)
        elif 'Escape' in button:                            # clear currently line
            window.FindElement('query').Update('') 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:56,代碼來源:PySimpleGUI-HowDoI.py

示例7: Everything

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Multiline [as 別名]
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.Button('Exit'),
         sg.Text(' ' * 40), sg.Button('SaveSettings'), sg.Button('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

    # window.CloseNonBlocking() 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:56,代碼來源:Demo_Fill_Form.py

示例8: main

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Multiline [as 別名]
def main():

    MLINE_KEY = '-ML-'+sg.WRITE_ONLY_KEY        # multiline element's key. Indicate it's an output only element
    MLINE_KEY2 = '-ML2-'+sg.WRITE_ONLY_KEY        # multiline element's key. Indicate it's an output only element
    MLINE_KEY3 = '-ML3-'+sg.WRITE_ONLY_KEY        # multiline element's key. Indicate it's an output only element

    output_key = MLINE_KEY


    layout = [  [sg.Text('Multiline Color Print Demo', font='Any 18')],
                [sg.Multiline('Multiline\n', size=(80,20), key=MLINE_KEY)],
                [sg.Multiline('Multiline2\n', size=(80,20), key=MLINE_KEY2)],
                [sg.Text('Text color:'), sg.Combo(list(color_map.keys()), size=(12,20), key='-TEXT COLOR-'),
                 sg.Text('on Background color:'), sg.Combo(list(color_map.keys()), size=(12,20), key='-BG COLOR-')],
                [sg.Input('Type text to output here', size=(80,1), key='-IN-')],
                [sg.Button('Print', bind_return_key=True), sg.Button('Print short'),
                 sg.Button('Force 1'), sg.Button('Force 2'),
                 sg.Button('Use Input for colors'), sg.Button('Toggle Output Location'), sg.Button('Exit')]  ]

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

    sg.cprint_set_output_destination(window, output_key)

    while True:             # Event Loop
        event, values = window.read()
        if event == sg.WIN_CLOSED or event == 'Exit':
            break
        if event == 'Print':
            sg.cprint(values['-IN-'], text_color=values['-TEXT COLOR-'], background_color=values['-BG COLOR-'])
        elif event == 'Print short':
            sg.cprint(values['-IN-'], c=(values['-TEXT COLOR-'], values['-BG COLOR-']))
        elif event.startswith('Use Input'):
            sg.cprint(values['-IN-'], colors=values['-IN-'])
        elif event.startswith('Toggle'):
            output_key = MLINE_KEY if output_key == MLINE_KEY2 else MLINE_KEY2
            sg.cprint_set_output_destination(window, output_key)
            sg.cprint('Switched to this output element', c='white on red')
        elif event == 'Force 1':
            sg.cprint(values['-IN-'], c=(values['-TEXT COLOR-'], values['-BG COLOR-']), key=MLINE_KEY)
        elif event == 'Force 2':
            sg.cprint(values['-IN-'], c=(values['-TEXT COLOR-'], values['-BG COLOR-']), key=MLINE_KEY2)

    window.close() 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:45,代碼來源:Demo_Multiline_cprint_Printing.py

示例9: main

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Multiline [as 別名]
def main():

    layout = [
            [sg.Multiline(size=(50, 15), key='-LOG-')],
            [sg.Button('Start', bind_return_key=True, key='-START-'), sg.Button('Exit')]
        ]

    window = sg.Window('Log window', layout,
            default_element_size=(30, 2),
            font=('Helvetica', ' 10'),
            default_button_element_size=(8, 2),)

    appStarted = False

    # Setup logging and start app
    logging.basicConfig(level=logging.DEBUG)
    log_queue = queue.Queue()
    queue_handler = QueueHandler(log_queue)
    logger.addHandler(queue_handler)
    threadedApp = ThreadedApp()

    # Loop taking in user input and querying queue
    while True:
        # Wake every 100ms and look for work
        event, values = window.read(timeout=100)

        if event == '-START-':
            if appStarted is False:
                threadedApp.start()
                logger.debug('App started')
                window['-START-'].update(disabled=True)
                appStarted = True
        elif event in  (None, 'Exit'):
            break

        # Poll queue
        try:
            record = log_queue.get(block=False)
        except queue.Empty:
            pass
        else:
            msg = queue_handler.format(record)
            window['-LOG-'].update(msg+'\n', append=True)

    window.close() 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:47,代碼來源:Demo_Multithreaded_Logging.py

示例10: main

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Multiline [as 別名]
def main():
    """ main program and GUI loop """
    sg.ChangeLookAndFeel('BrownBlue')

    tab1 = sg.Tab('Raw Code',
                  [[sg.Multiline(key='INPUT', pad=(0, 0), font=(sg.DEFAULT_FONT, 12))]],
                  background_color='gray', key='T1')
    tab2 = sg.Tab('Clean Code',
                  [[sg.Multiline(key='OUTPUT', pad=(0, 0), font=(sg.DEFAULT_FONT, 12))]],
                  background_color='gray25', key='T2')

    stat_col = sg.Column([
        [stat('Lines of code'), stat(0, 8, 'sunken', 'right', 'LINES'),
         stat('Total chars'), stat(0, 8, 'sunken', 'right', 'CHARS')],
        [stat('Chars per line'), stat(0, 8, 'sunken', 'right', 'CPL'),
         stat('Mean'), stat(0, 8, 'sunken', 'right', 'MEAN')],
        [stat('Median'), stat(0, 8, 'sunken', 'right', 'MEDIAN'),
         stat('PStDev'), stat(0, 8, 'sunken', 'right', 'PSTDEV')],
        [stat('Max'), stat(0, 8, 'sunken', 'right', 'MAX'),
         stat('Min'), stat(0, 8, 'sunken', 'right', 'MIN')]], pad=(5, 10), key='STATS')

    lf_col = [
        [btn('Load FILE'), btn('Clipboard'), btn('RESET')],
        [sg.TabGroup([[tab1, tab2]], title_color='black', key='TABGROUP')]]

    rt_col = [
        [sg.Text('LOAD a file or PASTE code from Clipboard', pad=(5, 15))],
        [sg.Text('Statistics', size=(20, 1), pad=((5, 5), (15, 5)),
                 font=(sg.DEFAULT_FONT, 14, 'bold'), justification='center')],
        [stat_col],
        [sg.Text('Visualization', size=(20, 1),
                 font=(sg.DEFAULT_FONT, 14, 'bold'), justification='center')],
        [sg.Canvas(key='IMG')]]

    layout = [[sg.Column(lf_col, element_justification='left', pad=(0, 10), key='LCOL'),
               sg.Column(rt_col, element_justification='center', key='RCOL')]]

    window = sg.Window('Code Counter', layout, resizable=True, size=WINDOW_SIZE, finalize=True)

    for elem in ['INPUT', 'OUTPUT', 'LCOL', 'TABGROUP']:
        window[elem].expand(expand_x=True, expand_y=True)

    # main event loop
    while True:
        event, values = window.read()
        if event is None:
            break
        if event == 'Load FILE':
            click_file(window)
            process_data(window)
        if event == 'Clipboard':
            click_clipboard(window)
            process_data(window)
        if event == 'RESET':
            click_reset(window) 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:57,代碼來源:Code Counter.py


注:本文中的PySimpleGUI.Multiline方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。