3

I want to print an output something like this by using pysimplegui

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

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

enter image description here

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ı

Layla
  • 117
  • 2
  • 7

1 Answers1

2

In PySimpleGUI the parameter to look for when you want to set the titlebar text is title. All of the popups have a title parameter like the Window object does.

This popup window has a title:

enter image description here

the code used to make it is:

sg.popup('This is a popup.....Make sure it is long enough to see title.', title='My own title')

You can find a description of the popup parameters in the main documentation, http://www.PySimpleGUI.org.

Mike from PSG
  • 5,312
  • 21
  • 39
  • Thanks for your answer. However I also have one more question – Layla Dec 06 '19 at 15:56
  • In the code that I am sahred there are some variable in the print statement, which seperated by the commas. So when put it in the popup. Everytime it seems a comma it begins a new line. However I need those varible names to shown on the GUI so how can I solve that problem ? – Layla Dec 06 '19 at 15:58
  • Once you exceed the capabilities of the popup function, you create your own window where you can control everything including newlines. Popup is a convenience kind of function that works at a high level. Sounds like you need to create a custom window that works the way you want. – Mike from PSG Dec 06 '19 at 17:33
  • There is also a Print function that outputs to a scrolling "debug window". This acts more like a traditional print function. It too is a high-level function that can be recreated by users if it doesn't do what you want. – Mike from PSG Dec 06 '19 at 17:34
  • Maybe I should open another question for that. I am not sure how to create such window... Is it written in the document that you shared ? – Layla Dec 06 '19 at 17:39
  • In short, yes, the documentation has everything you need including links to other documents and sample code. You'll need to spend a little time learning this GUI SDK like any other GUI package. But instead of days it'll be hours most likely. – Mike from PSG Dec 06 '19 at 18:32