Python Subscript problem for greek letters in python print function

  • Thread starter Thread starter Arman777
  • Start date Start date
  • Tags Tags
    Function Python
Click For Summary
The discussion focuses on creating a graphical user interface (GUI) using PySimpleGUI for a physics project that requires subscripts in LaTeX format. The user encounters issues where certain Greek letters and subscripts, specifically `B` and `lambda`, do not display correctly, while others like `M` and `phi` do. Suggestions include checking for spelling errors in the Unicode representation and exploring alternatives like PyLaTeX for better handling of LaTeX formatting. The conversation also highlights the lack of subscript Unicode for some letters, indicating a limitation in the available character set. Additionally, a recommendation is made to use MathJax for improved mathematical typesetting in Python markdown.
Arman777
Insights Author
Gold Member
Messages
2,163
Reaction score
191
I am trying to create a GUI for a phyiscs project and I need subscripts of these things.
`H_0`,
`Omega_b`,
`Omega_dm`,
`Omega_\Lambda`
`Omega_r`
in the form of latex

My code is something like this


Python:
    import PySimpleGUI as sg

    sg.change_look_and_feel('Topanga')     

    layout = [
        [sg.Text('Enter the Parameters')],
        [sg.Text("H\N{SUBSCRIPT ZERO}", size=(15, 1)), sg.InputText()],
        [sg.Text("\N{GREEK CAPITAL LETTER OMEGA}\N{LATIN SUBSCRIPT SMALL LETTER B}", size=(15, 1)), sg.InputText()],
        [sg.Text("\N{GREEK CAPITAL LETTER OMEGA}\N{LATIN SUBSCRIPT SMALL LETTER R}", size=(15, 1)), sg.InputText()],
        [sg.Text("\N{GREEK CAPITAL LETTER OMEGA}\N{GREEK SUBSCRIPT SMALL LETTER LAMDA}", size=(15, 1)), sg.InputText()],
        [sg.Text("\N{GREEK CAPITAL LETTER OMEGA}\N{LATIN SUBSCRIPT SMALL LETTER DM}", size=(15, 1)), sg.InputText()],
        [sg.Text("z", size=(15, 1)), sg.InputText()],
        [sg.Submit(), sg.Cancel()]
    ]

    window = sg.Window('Simple data entry window', layout)
    event, values = window.read()
    window.close()
    print(event, values[0], values[1], values[2], values[3], values[4], values[5])

The most interesting thing is that it can print letters such as `M` or `R` but it cannot print `B` ?? Or It can print `phi` but it cannot print `lambda` ?

You can try this to see that this combination works.


Python:
import PySimpleGUI as sg

    sg.change_look_and_feel('Topanga')     

    layout = [
        [sg.Text('Enter the Parameters')],
        [sg.Text("H\N{SUBSCRIPT ZERO}", size=(15, 1)), sg.InputText()],
        [sg.Text("\N{GREEK CAPITAL LETTER OMEGA}\N{LATIN SUBSCRIPT SMALL LETTER M}", size=(15, 1)), sg.InputText()],
        [sg.Text("\N{GREEK CAPITAL LETTER OMEGA}\N{LATIN SUBSCRIPT SMALL LETTER R}", size=(15, 1)), sg.InputText()],
        [sg.Text("\N{GREEK CAPITAL LETTER OMEGA}\N{GREEK SUBSCRIPT SMALL LETTER PHI}", size=(15, 1)), sg.InputText()],
        [sg.Text("z", size=(15, 1)), sg.InputText()],
        [sg.Submit(), sg.Cancel()]
    ]

    window = sg.Window('Simple data entry window', layout)
    event, values = window.read()
    window.close()
    print(event, values[0], values[1], values[2], values[3], values[4], values[5])
Please help,
Thanks
 
Technology news on Phys.org
Hey Arman, I think that for programming questions you should ask on stackoverflow and not here. That community is humongous and extremely active, you could get answers within minutes.
https://stackoverflow.com/
 
  • Skeptical
Likes Greg Bernhardt
archaic said:
Hey Arman, I think that for programming questions you should ask on stackoverflow and not here. That community is humongous and extremely active, you could get answers within minutes.
https://stackoverflow.com/
I asked there but i didnt get an answer
 
  • Like
Likes Greg Bernhardt
Arman777 said:
Or It can print `phi` but it cannot print `lambda` ?
Well, for starters, you misspelled lambda in the line below.
Code:
[sg.Text("\N{GREEK CAPITAL LETTER OMEGA}\N{GREEK SUBSCRIPT SMALL LETTER LAMDA}", size=(15, 1)), sg.InputText()],

Why are there accents on many of your letters? In the first line I quoted there are accents on the p in phi and the l in lambda.
 
Mark44 said:
Well, for starters, you misspelled lambda in the line below.
https://www.fileformat.info/info/unicode/char/03bb/index.htm
Mark44 said:
Why are there accents on many of your letters? In the first line I quoted there are accents on the p in phi and the l in lambda.
Thats indeed strange. I don't know why it happened.
I guess I understand the problem. There is just not subscript unicode for lambda or for some letters.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
6K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
5K
Replies
0
Views
2K
  • · Replies 18 ·
Replies
18
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 9 ·
Replies
9
Views
4K