CustomTkinter
CustomTkinter copied to clipboard
If textbox.get("1.0",END)=="" doesnt work
Hello,
I did the update of ctktextbox but I still have an issue while I try to check if data in textbox, is it normal ?
the below check does not work : If .get("1.0",END)=="":
Regards,
I try to test the presence of data in a textbox
@sim2511 can you send a minimum reproducible example?
I just had the same problem today also Problem: my code: ans=textbox.get('0.0', 'end') Error code: AttributeError: 'CTkTextbox' object has no attribute 'get' But to solve it I went to ctk_textbox.py and added the get and delete methods My guess: The delete, insert and get methods are in the init.py but they need to be inherited/ called by the ctk_textbox.py file Example solution(in ctk_textbox.py): def get(self,*args, **kwargs): return self.textbox.get(*args, **kwargs) def delete(self,*args, **kwargs): return self.textbox.delete(*args, **kwargs)
PS: I don't know a lot about how Tom's code work so there may be more to it than this but this can be a simple solution until Tom fixes it
I just had the same problem today also Problem: my code: ans=textbox.get('0.0', 'end') Error code: AttributeError: 'CTkTextbox' object has no attribute 'get' But to solve it I went to ctk_textbox.py and added the get and delete methods My guess: The delete, insert and get methods are in the init.py but they need to be inherited/ called by the ctk_textbox.py file Example solution(in ctk_textbox.py): def get(self,*args, **kwargs): return self.textbox.get(*args, **kwargs) def delete(self,*args, **kwargs): return self.textbox.delete(*args, **kwargs)
PS: I don't know a lot about how Tom's code work so there may be more to it than this but this can be a simple solution until Tom fixes it
Nah this is essentially how its being done in the dev branch so you implemented it correctly.
To do this without altering the module just do:
ans = your_textbox_object.textbox.get('1.0', END) # If you have the constants imported, otherwise swap END for 'end'.
Id also avoid naming the actual textbox object 'textbox', otherwise your calls to get and such will look a bit verbose and confusing.
The get method is now implemented with version 5.0.0.