Python Forum
how to create a tool with tkinter to convert img to text
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to create a tool with tkinter to convert img to text
#1
hello!
i created a script who pyautogui.locatOnScreen() for a specific image and takes automatically a screenshot, . and he convert the image to text automatically .

but i want a simple tool with tkinter . when i click print buttom the script works and shows me the text that is converted on a Labell . but i don't know how to make this tool .

this is my code

import pyautogui as py
import time
from PIL import Image
from pytesseract import *

pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'

while 1:
    


    indice1 = py.locateOnScreen("image3.png",confidence=.8)
    



    if indice1:
        


        print("indice see it ")

        

        myScreenshot = py.screenshot(region=(626, 3398, 285, 119))
        myScreenshot.save(r'C:\Users\rachidel07\Desktop\ok\venv\image.png')

        img=Image.open("image.png")
        output = pytesseract.image_to_string(img)
        print(output)

    else:
            print ("non")
        
Reply
#2
Take all the code from the script and place it in a function. Run the function to verify it is working correctly. Write a gui with a button. Have the button call the function when pressed. Sounds like you already have a working script. You also have an example simple GUI with a button. All you have to do is rewrite your script so it is all inside a function.
Reply
#3
(Feb-05-2021, 03:58 AM)deanhystad Wrote: Take all the code from the script and place it in a function. Run the function to verify it is working correctly. Write a gui with a button. Have the button call the function when pressed. Sounds like you already have a working script. You also have an example simple GUI with a button. All you have to do is rewrite your script so it is all inside a function.

i tired my times but i failed :(
could you give me an example code please
Reply
#4
Post your attempt at writing the function.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  make all text in Right to left alignment in tkinter widgets jalal0034 1 1,314 Sep-27-2022, 06:42 PM
Last Post: Larz60+
  is there any tool to convert negative base to int? Skaperen 7 2,393 May-27-2022, 07:30 AM
Last Post: Gribouillis
  Tkinter text overlap Frankduc 3 2,961 Apr-01-2022, 08:02 PM
Last Post: deanhystad
  Cannot convert the series to <class 'int'> when trying to create new dataframe column Mark17 3 8,497 Jan-20-2022, 05:15 PM
Last Post: deanhystad
  Separate text files and convert into csv marfer 6 2,859 Dec-10-2021, 12:09 PM
Last Post: marfer
  How to convert binary data into text? ZYSIA 3 2,622 Jul-16-2021, 04:18 PM
Last Post: deanhystad
  [split] How to convert the CSV text file into a txt file Pinto94 5 3,315 Dec-23-2020, 08:04 AM
Last Post: ndc85430
  Convert Excel file to Text file marvel_plato 6 19,644 Jul-17-2020, 01:45 PM
Last Post: marvel_plato
  create an array of each line of text macieju1974 7 3,387 Jun-07-2020, 06:30 PM
Last Post: Yoriz
  Python QGIS tool that replaces layout text labels with attributes from an input table geodenn92 1 2,661 Aug-13-2019, 06:05 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020