Can this be reversed (Tkinter)?
John J. Lee
jjl at pobox.com
Fri Jan 2 18:19:22 EST 2004
"mark" <mark at diversiform.com> writes:
> I am looking at the format used by root.geometry(). The string returned
> from root.geometry() is "%dx%d+%d+%d". Is there a quick and painless
> way to extract the values from that string (i.e., "100x150+25+25" =>
> (100,150,25,25))?
def geometry_tuple_from_string(text):
a, rest = text.split("x")
b, c, d = rest.split("+")
return tuple([int(x) for x in (a, b, c, d)])
print geometry_tuple_from_string("100x150+25+25")
John
More information about the Python-list
mailing list