Setting allowed size of text object on canvas in Tkinter
Eric Brunel
eric.brunel at pragmadev.com
Tue Jun 10 08:27:13 EDT 2003
Mickel Grönroos wrote:
> No, the text is still wrapping. I would like to be able to se a "height"
> option too, so that only the text that fits in the area defined by "width"
> and "height" would be visible (and the rest simply not shown at all). Do
> you know how to ackomplish that?
OK, sorry, I misunderstood you. I don't know of any means to achieve that
simply, apart from using a canvas window with an inactive Text widget in it:
-------------------------------
from Tkinter import *
root = Tk()
c = Canvas(root)
c.pack()
t = Text(c, width=75, height=24, relief=FLAT, bd=0)
t.insert(1.0, 'spam spam spam spam spam\nspam spam spam and spam')
t.configure(state=DISABLED)
c.create_window(100, 100, window=t, width=75, height=24, anchor=NW)
c.create_rectangle(98, 98, 177, 126)
root.mainloop()
-------------------------------
However, you'll get the basic behaviour of the Text widget, which you may not
need (e.g., pressing the mouse in the text and dragging selects the text and
makes it scroll...)
HTH
--
- Eric Brunel <eric.brunel at pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com
More information about the Python-list
mailing list