Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to disable word wrap in Tkinter

Tags:

tkinter

I'm trying to write in a text window with word wrapping disabled & horizontal scrollbar, like this:

root = Toplevel()
root.geometry("%dx%d+0+0" % (350,400))
af=Frame(root)
chtext = Text(af, width=45, wrap=None,font=("Arial",12)) 
chxscrollbar=Scrollbar(chtext, orient=HORIZONTAL, command=chtext.xview)
chtext["xscrollcommand"]=chxscrollbar.set
af.pack(fill="both", expand=True)
chtext.pack(side="left", expand=1, fill="both")
chxscrollbar.pack(side="bottom", fill="x", expand=False)

my problem is that it still wordwraps what I write into it... am I missing something obvious???

thanks!

like image 689
alessandro Avatar asked Sep 26 '13 13:09

alessandro


1 Answers

None is not a valid value for the wrap option. You need to use the string "none" or the tkinter variable NONE. By specifying the python value None you are actually requesting the default value, which is "char"

chtext = Text(af, width=45, wrap="none", font=("Arial",12)) 
like image 96
Bryan Oakley Avatar answered Sep 28 '22 22:09

Bryan Oakley