Feb-14-2019, 07:42 PM
Hello everybody,
I've searched for hours and I can't manage to find something, I hope that one of you may help me...
What I'm trying to do is to limit the height of a text box widget in Tkinter. Because for the moment with my code, I can set the height of the text box (25 lines for example). But when I type my text into the text box and I reach the line 25, if I keep on writing, it keeps creating new lines of text. What I would want is to lock the height so the user can just type 25 lines of text and cannot write infinitely.
Here is the GUI Part of my program :
I've searched for hours and I can't manage to find something, I hope that one of you may help me...
What I'm trying to do is to limit the height of a text box widget in Tkinter. Because for the moment with my code, I can set the height of the text box (25 lines for example). But when I type my text into the text box and I reach the line 25, if I keep on writing, it keeps creating new lines of text. What I would want is to lock the height so the user can just type 25 lines of text and cannot write infinitely.
Here is the GUI Part of my program :
import tkinter as tk
from tkinter import ttk
fenetre = Tk()
fenetre.title("test")
fenetre.tk.call('wm', 'iconphoto', fenetre._w, tk.PhotoImage(file='test.png'))
def lignevide() :
lignevide = Label(fenetre, text="" ,fg="red", font ="Arial" ,height ="1")
lignevide.pack()
scrollbar = Scrollbar(fenetre)
scrollbar.pack(side='right', fill='y')
texte1 = Label(fenetre, text="Tapez votre texte à imprimer :" ,fg="black", font =("Montserrat" ,22) ,height ="1",)
texte1.pack()
texte2 = Label(fenetre, text= "Attention, les chiffres, les majuscules et certains caractères spéciaux ne sont pas imprimables !" ,fg="red", font =("Montserrat" ,10) ,height ="1",)
texte2.pack()
lignevide()
saisie = Text(fenetre, width = 25 ,height = 23, font="Arial" ,highlightcolor = "black" ,highlightbackground = "yellow", relief="flat", yscrollcommand = scrollbar.set)
saisie.pack()
lignevide()
bouton = ttk.Button(fenetre, text="Confirmer", command=retrieve_input)
bouton.pack()
lignevide()
bouton2 = ttk.Button(fenetre, text="Annuler et quitter", command=fin)
bouton2.pack()
lignevide()
fenetre.mainloop()Thanks to anyone that would help me !
