3

I'm creating a textbox as follows:

sg.Text(size=(57, 10), background_color='white', text_color='red',
                 key='_console')

And it works fine, except the text isn't selectable! I want the user to be able to copy the message to clipboard (by mouse selection and "copy"). How can it be done? thx

Guy Barash
  • 470
  • 5
  • 17

1 Answers1

2

According to the git hub issue related to this, the way to go about doing this is to create a read-only input and format it to look like the normal text elements: https://github.com/PySimpleGUI/PySimpleGUI/issues/2928

import PySimpleGUI as sg

sg.theme('Dark Red')

layout = [  [sg.Text('My Window')],
            [sg.InputText('You can select this text', use_readonly_for_disable=True, disabled=True, key='-IN-')],
            [sg.Button('Go'), sg.Button('Exit')]  ]

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

window['-IN-'].Widget.config(readonlybackground=sg.theme_background_color())
window['-IN-'].Widget.config(borderwidth=0)

while True:             # Event Loop
    event, values = window.read()
    print(event, values)
    if event == sg.WIN_CLOSED or event == 'Exit':
        break

window.close()
ChungaBunga
  • 116
  • 1
  • 10