CustomTkinter icon indicating copy to clipboard operation
CustomTkinter copied to clipboard

If textbox.get("1.0",END)=="" doesnt work

Open sim2511 opened this issue 2 years ago • 4 comments

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,

sim2511 avatar Nov 18 '22 17:11 sim2511

I try to test the presence of data in a textbox

sim2511 avatar Nov 18 '22 17:11 sim2511

@sim2511 can you send a minimum reproducible example?

TheFallen-Cat avatar Nov 19 '22 05:11 TheFallen-Cat

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

Menace43 avatar Nov 19 '22 22:11 Menace43

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.

Evolution0 avatar Nov 20 '22 03:11 Evolution0

The get method is now implemented with version 5.0.0.

TomSchimansky avatar Dec 02 '22 11:12 TomSchimansky