Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83176 > unrolled thread
| Started by | John Culleton <john@wexfordpress.com> |
|---|---|
| First post | 2015-01-03 11:23 -0800 |
| Last post | 2015-01-03 20:32 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
Put float number in message. John Culleton <john@wexfordpress.com> - 2015-01-03 11:23 -0800
Re: Put float number in message. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-03 20:32 +0000
| From | John Culleton <john@wexfordpress.com> |
|---|---|
| Date | 2015-01-03 11:23 -0800 |
| Subject | Put float number in message. |
| Message-ID | <4e62c96c-aa5f-43fd-ba67-c147c5ef0b96@googlegroups.com> |
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
[toc] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2015-01-03 20:32 +0000 |
| Message-ID | <mailman.17358.1420317182.18130.python-list@python.org> |
| In reply to | #83176 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web