PySimpleGui Output Title Bar Name Problem

  • Context: Python 
  • Thread starter Thread starter Arman777
  • Start date Start date
  • Tags Tags
    Output
Arman777
Insights Author
Gold Member
Messages
2,163
Reaction score
191
Python:
import PySimpleGUI as sg
print("The age of the universe is", age_of_universe, "Gyr")
print("The age of universe at z = ", z, "is", age_of_universe_at_z,)
print("Lookback time is", lookback_time , "Gyr")
print("Comoving distance to an object at z =", z , "is" , comoving_distance, "Mpc")
print("Luminosity distance to an object at z =", z, "is", luminosity_distance, "Mpc")
print("Angular diameter distance to an object at z =", z, "is", angular_distance, "Mpc")

I tried to use the popup method. However this time the thing that written inside the popup becomes the name of the title bar

Python:
   sg.popup('This is the modified LightGreen3 Theme', 'It has black button text')

1575636600821.png


So how can I print these things and can name the title bar whatever I want.

Thanks.

Note: I can accept solutions offered by using tkinter but I prefer pysimpleguı
Note 2: Also there are some variables inside the print statements. So that's also important
 
Last edited:
on Phys.org
Did you try going to the documentation? You just need to add a title keyword
Python:
sg.popup('This is the modified LightGreen3 Theme', 'It has black button text', title='MyTitle')
 
  • Like
Likes   Reactions: Arman777
phyzguy said:
Did you try going to the documentation? You just need to add a title keyword
Python:
sg.popup('This is the modified LightGreen3 Theme', 'It has black button text', title='MyTitle')
Yes kind of but appreantly I missed it.

Okay that works. Thanks. But I also want to ask something else. Do you have idea how can I print one statement in single line ?
For instance If I write something like this,

Python:
import PySimpleGUI as sg

z = 12
sg.popup("The age of the universe is",z,"Gyr", title="CoSmoS")

1575642427304.png


Which is not a good way to show the output. The problem is everytime I put "," between the text and data itseld it goes to new line. How I can print each stament in one line ?
 
You need to learn to use formatting:
Python:
import PySimpleGUI as sg
z=13.8
sg.popup("The age of the universe is %.2f Gyr"%z, title="MyTitle")
 
  • Like
Likes   Reactions: Arman777
phyzguy said:
You need to learn to use formatting:
Python:
import PySimpleGUI as sg
z=13.8
sg.popup("The age of the universe is %.2f Gyr"%z, title="MyTitle")
I know that format but I never use it. But it seems working in this case. Thanks a lot :)
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 22 ·
Replies
22
Views
8K
  • · Replies 40 ·
2
Replies
40
Views
6K