Python Forum
[Tkinter] THow to search a string in a file and display it in listbox by Tkinter - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [Tkinter] THow to search a string in a file and display it in listbox by Tkinter (/thread-3756.html)



THow to search a string in a file and display it in listbox by Tkinter - mosavit - Jun-21-2017

I was wondering how I can write a python code using Tkinter to search a string in an external txt file and display the lines in which the string appears in a listbox, highlighting the same string in each line. By the way, I am a new learner in the field.
Can anybody help me with coding on this issue?
Thanks in advance.


RE: THow to search a string in a file and display it in listbox by Tkinter - Barrowman - Jun-21-2017

Have a look at
https://www.tutorialspoint.com/python/python_strings.htm

https://stackoverflow.com/questions/3277503/how-do-i-read-a-file-line-by-line-into-a-list

and
http://effbot.org/tkinterbook/listbox.htm


RE: THow to search a string in a file and display it in listbox by Tkinter - buran - Jun-21-2017

Welcome to the forum. While we a happy to help to solve any problems you may have, we are not going to do this for you. You need to show effort, post your code (and eventually traceback - the error message you get) in relevant tags and ask specific question.
As to the problem - split it in small parts and solve it one by one. In my opinion the GUI is the last element. Start with reading txt file, then expand the code to search for the string and return the line if found, at the end - start developing the GUI and if you have the functionality you can easy integrate it in the GUI.