Skip to content Skip to sidebar Skip to footer

How To Get Values From Entry Box With Tkinter

I want to take the values from the entry box that opens and have them become the values in crop1. I'm new to tkinter and programming so I'm not sure on how to get the values into t

Solution 1:

There is probably a nicer way to do it, but this works. Add a button, and when that button is pressed get the input from the text entries and pass them to the crop function.

def crop(self):
    self.root = Tk()
    self.root.wm_title("Insert Coords")

    self.x0 = Entry(self.root)
    self.x0.grid()

    self.x1 = Entry(self.root)
    self.x1.grid()

    self.y0 = Entry(self.root)
    self.y0.grid()

    self.y1 = Entry(self.root)
    self.y1.grid()

    Button(self.root, text="Crop", command=self.close_crop).grid()

def close_crop(self):        
    self.crop1(self.x0.get(), self.x1.get(), self.y0.get(), self.y1.get())
    self.root.destroy()                

def crop1(self, x0, x1, y0, y1):
    print x0, x1, y0, y1

Post a Comment for "How To Get Values From Entry Box With Tkinter"