Weirdness with percentage values

Discussion about using Python with libRocket.

Weirdness with percentage values

Postby rcdailey on Sun Jun 01, 2008 5:13 pm


In RCSS, when I set the following property:

width: 100%

And then when I try to obtain this percent in python, I get a number like "100.0000%". Why is this number a decimal number? Why not make it an integer? Are decimal percentage values allowed in CSS? Would it be possible to make libRocket only use decimal digits when an integral isn't being used? This isn't much of a problem, but it would clean up my python code a little, since I have to take extra measures to convert this string to an integral value.
Posts: 113
Joined: Mon Feb 04, 2008 8:04 pm

Re: Weirdness with percentage values

Postby peterc on Mon Jun 02, 2008 10:27 pm

For simplicity, all numerical values are stored and accessed as floating-point, rather than switching between integer and floating-point where possible. When accessing the properties through '', everything is returned as a string as you could be accessing keyword values, or pixel values, etc. If you know you're getting back a percentage, then int(float([:-1])) will get you back the truncated integer percentage.
Rocket Engineer
Rocket Engineer
Posts: 237
Joined: Wed Jan 16, 2008 12:00 am

Return to libRocket and Python