Search code examples
pythontkinterttk

how to create tkinter entry box with multiline


How to create large extry box in python tkinter? I have tried to use height in ttk.entry() but the error show :

_tkinter.TclError: unknown option "-height"

from tkinter import *
from tkinter import ttk
GUI = Tk()
GUI.title("myTest")
GUI.geometry("700x700")

S_NOTE = StringVar()
E_NOTE = ttk.Entry(GUI, textvariable = S_NOTE, font = FONT1, width = 40, height = 20)
E_NOTE.grid(row = 0, column = 0, columnspan = 2, rowspan = 2)

GUI.mainloop()

I also need to get the StringVar from the entrybox and fix the position (such as using grid)


Solution

  • Looks like you are using a bad way to do this.. see.. You can use the Text widget to do the same.. Example:

    from tkinter import *
    GUI = Tk()
    GUI.title("myTest")
    GUI.geometry("700x700")
    
    def set_text_to_variable():
        global E_NOTE
        global S_NOTE
        S_NOTE = E_NOTE.get(1.0,END)
        print("S_NOTE = ",S_NOTE)
    
    E_NOTE = Text(GUI, font = "Segoe", width = 40, height = 20)
    E_NOTE.grid(row = 0, column = 0, columnspan = 2, rowspan = 2)
    
    Change_variable = Button(GUI, text = "CHANGE THE \"S_NOTE\" VARIABLE", command = set_text_to_variable)
    Change_variable.grid()
    
    GUI.mainloop()