PySimpleGui Output Title Bar Name Problem

  • Context: Python 
  • Thread starter Thread starter Arman777
  • Start date Start date
  • Tags Tags
    Output
Click For Summary

Discussion Overview

The discussion revolves around using PySimpleGUI to create popups with customized title bars and formatting output in a single line. Participants explore solutions to specific coding issues related to displaying variable values in a user-friendly manner.

Discussion Character

  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant expresses a desire to customize the title bar of a PySimpleGUI popup while displaying multiple variable outputs.
  • Another participant suggests referring to the documentation and provides a solution involving the addition of a title keyword in the popup function.
  • A participant acknowledges the solution and seeks further assistance on how to print statements in a single line without line breaks caused by commas.
  • Multiple participants recommend using string formatting to achieve the desired output format in the popup.

Areas of Agreement / Disagreement

Participants generally agree on the use of string formatting for output, and there is a consensus on the solution for customizing the title bar. However, there is no disagreement noted, as the discussion focuses on clarifying coding techniques rather than contesting views.

Contextual Notes

Participants reference specific coding practices and the importance of formatting in Python, but the discussion does not delve into the underlying principles of PySimpleGUI or string formatting beyond the immediate context of the problem.

Who May Find This Useful

Individuals interested in Python programming, particularly those working with PySimpleGUI and seeking to enhance their GUI applications with formatted outputs.

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:
Technology news 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
5K