Python - Trying to get user inputs from entries in tkinter

Viewed 26

I'm trying to get a user input from this code so that a user can input a file directory from their documents into the entry and then display that image but im not show how to link the entry to the "img" variable. Thanks a lot for any help

import numpy as np
import cv2
import matplotlib.pyplot as plt
from tkinter import *

def directory():
    def submit_scan_press():
        img = input("Input file directory here: ")
        image = cv2.imread(img)

        cv2.imshow("image", image)
        cv2.waitKey(0)
        cv2.destroyAllWindows()

    dir = Tk()

    dir.geometry("200x400")
    dir.title("DIRECTORY")

    Button(dir, text="Submit", padx=10, pady=1, command=submit_scan_press).pack()

    entry_file = Entry(dir)
    entry_file.pack()

    text1 = Label(dir, text="Input file directory here")
    text1.pack()

    dir.mainloop()

directory()
0 Answers
Related