简体   繁体   中英

Make string appear equal length

I am trying to make string appear as that same length, so that when joined they appear as columns.

    import PySimpleGUI as sg
    a = ('IIII'.rjust(6,'*'))
    b = ('OOOO'.rjust(6,'*'))
    layout = [[sg.Text(a), sg.Text(a), sg.Text(a)], [sg.Text(b), sg.Text(b), sg.Text(b)]]
    window = sg.Window('Test Window', layout)
    event, values = window.read()
    window.close()

Because the 'I' is narrower than the 'O' the columns do not line up. Ultimately, I want to use the strings as a list box. Thanks, for any help.

Wow, works like a charm. Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM