I basically got the unwanted characters removed from the Text widget, but when I hit a line break and try to scroll the text with the keyboard or mouse, I just can't (it always stays in the same place). this is done in the "validate text" method
class NewNewsFrame(Frame):
def __init__(self, parent):
self.Parent = parent
self.initializecomponents()
pass
def validate_text(self, widger):
value = widger.get("1.0", "end-1c")
print value.fon
if not value.isalnum():
var = str()
for i in value:
print(f"({i})")
var += i if(i.isalpha() or i.isdigit() or i == "(" or i == ")" or i == " " or i == "," or i == "." or i == "\n")else ""
widger.delete("1.0", "end-1c")
widger.insert("end-1c", var)
pass
def initializecomponents(self):
Frame.__init__(self, self.Parent)
self.DescriptionLabel = Label(self)
self.DescriptionBox = Text(self)
# DescriptionLabel
self.DescriptionLabel.config(text="Description of the news:",bg=self["bg"], fg="#FFFFFF", font="none 15",anchor="nw")
self.DescriptionLabel.place(relwidth=1, relheight=0.1, relx=0, rely=0.11, anchor="nw")
# DescriptionBox
self.DescriptionBox.bind("<KeyPress>", lambda event: self.validate_text(self.DescriptionBox))
self.DescriptionBox.bind("<FocusOut>", lambda event: self.validate_text(self.DescriptionBox))
self.DescriptionBox.place(relheight=0.4, relwidth=1, relx=0, rely=0.16, anchor="nw")
pass
I tried to find how keyboard scrolling works, but I still don't know how to do it