input
Posts: 221
Joined: Sun Nov 02, 2014 9:18 am
Location: Netherlands

pythonscript for translation into Tkinter

Sat Aug 08, 2020 9:31 am

I would like to translate this pythonscript to Tkinter.
I got this python script from youtube and I searched for a similar Tkinterscript on the internet but couldn't find anything.
I also have some Ebooks from Tkinter, but I don't have a similar Tkinter script.
Is there anyone who can translate this script for me into a Tkinter script

Code: Select all

 fh = open ("c:\Worddatabase\info.txt ", "r")
word = input("Enter word to search:")
s = " "
count = 1
L = fh.readlines()
for i in L:
    L2 = i.split()
    if word in L2:
        print ("Line number", count,":",i)
    count+=1

			

User avatar
joelostinspace
Posts: 86
Joined: Sat Aug 10, 2019 2:51 pm
Location: Earth

Re: pythonscript for translation into Tkinter

Sun Aug 09, 2020 5:39 pm

hey your script has bugs, it doesn't detect or find the last word in a sentence or first word in quote or capitalized words, here's a sentence from my text file.

Code: Select all

“Never tell the truth to people who are not worthy of it.”Mark Twain
doesn't detect Never, it or Mark
to clean it up try:
maybe add a rstrip https://python-reference.readthedocs.io ... strip.html
or strip https://python-reference.readthedocs.io ... strip.html
or string to change to all lower or upper case,
here's a book to help your programming gui https://www.oreilly.com/library/view/pr ... 449398712/
but to start out with gui's is the hard way, you need to get the python basics down first..
best of luck

To travel is to discover that everyone is wrong about other countries.


--- Aldous Huxley

Return to “Python”