Put float number in message.

Mark Lawrence breamoreboy at yahoo.co.uk
Sat Jan 3 15:32:38 EST 2015


On 03/01/2015 19:23, John Culleton wrote:
> Here is my last line in a simple program that is a scribus script.
> end = scribus.messageBox('Book Spine Width', 'dummy', ICON_WARNING, BUTTON_OK)
>
> This works. Now I want to put a float number called S instead of 'dummy'.
> If I just put S in the command I get an error. If I convert S to a string with
> SS = str(S)
> first and then
> and substitute SS for 'dummy' I get what appears to be the ASCII numbers representing the characters, not the characters I want.
>
> I am a total newbie with Python. Anyone have a suggestion? Can I use a print command instead?
>
> John Culleton
>

I think you just want some string formatting so (untested) either

end = scribus.messageBox('Book Spine Width', '{}'.format(S), 
ICON_WARNING, BUTTON_OK)

or

end = scribus.messageBox('Book Spine Width', '%f' % S, ICON_WARNING, 
BUTTON_OK)

For all the formatting options see 
https://docs.python.org/3/library/string.html#string-formatting or 
https://docs.python.org/3/library/stdtypes.html#old-string-formatting 
respectively.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list