Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tkinter - TagCloud - Höhe?, Breite?

11 views
Skip to first unread message

Thomas Lehmann

unread,
Sep 26, 2009, 5:21:28 AM9/26/09
to
Hallo,

Der nachfolgende Code erzeugt eine TagCloud (noch ohne links). Was ich
nun gerne erreichen würde ist, daß das Text widget soviel Platz
benutzt, wie es wirklich braucht. Wenn ich nun eine Breite eingestellt
habe möchte ich die Höhe so justieren, daß der Text möglichst genau
hineinpasst. Umgekehrt, wenn ich die Höhe eingestellt habe möchte ich
in der Lage sein die Breite so zu justieren....

Könnte da bitte jemand helfen?

Danke
Thomas


APPENDIX:

import Tkinter as tk

root = tk.Tk()
root.title("Tag Cloud")

text = tk.Text(root)
text["wrap"] = "word"
text.pack(expand = tk.YES, fill = tk.BOTH)

data = [ (8,"Commercial"), (14, "Freeware"), (10, "Editor"), (8,
"IDE"),\
(12, "Versioning"), (8, "FileManager"), (12, "Tool"),\
(7, "Backup"), (14, "Portable"), (8, "Linux"), (16,
"Windows"),\
(10, "Image"), (13, "Sound")]

for (fontSize, tag) in data:
text.tag_configure("font%d" % (fontSize), font=("Arial",
fontSize))
text.insert(tk.END, tag, "font%d" % (fontSize))
text.insert(tk.END, " ")

root.mainloop()

0 new messages