Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8877511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:29:07+00:00 2026-06-14T19:29:07+00:00

I want to take the values from the entry box that opens and have

  • 0

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 the function. Sorry for two questions in a short period of time, this is my last one for today.

    from Tkinter import *
from PIL import Image, ImageTk, ImageFilter, ImageEnhance

class Application(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)
        master.wm_title("Image examples")
        self.pack()
        self.createWidgets()
        master.bind('s', self.sharpen)
        master.bind('b', self.brighten)
        master.bind('d', self.darken)
        master.bind('B', self.blur)
        master.bind('r', self.rotate)
        master.bind('I', self.brighten)
        master.bind('c', self.cool)
        master.bind('w', self.warm)
        master.bind('<BackSpace>', self.undo)

def createWidgets(self):
    self.img = Image.open("lineage.jpg")
    self.photo1 = ImageTk.PhotoImage(self.img.convert("RGB"))
    self.label1 = Label(self, image=self.photo1)
    self.label1.grid(row=0, column=0, padx=5, pady=5, rowspan=10)

    self.photo2 = ImageTk.PhotoImage(self.img.convert("RGB"))
    self.label2 = Label(self, image=self.photo2)
    self.label2.grid(row=0, column=1, padx=5, pady=5, rowspan=10)

    button1 = Button(self, text="Brighten", command=self.brighten)
    button1.grid(row=0, column= 2)
    button2 = Button(self, text="Darken", command=self.darken)
    button2.grid(row=1, column= 2, sticky=N)
    button3 = Button(self, text="Warm", command=self.warm)
    button3.grid(row=2, column= 2, sticky = N)
    button4 = Button(self, text="Cool", command=self.cool)
    button4.grid(row=3, column= 2, sticky = N)
    button5 = Button(self, text="Sharpen", command=self.sharpen)
    button5.grid(row=4, column= 2, sticky = N)
    button6 = Button(self, text="Blur", command=self.blur)
    button6.grid(row=5, column= 2, sticky = N)
    button7 = Button(self, text="Rotate", command=self.rotate)
    button7.grid(row=6, column= 2, sticky = N)
    button8 = Button(self, text="Crop", command=self.crop)
    button8.grid(row=7, column= 2, sticky = N)
    button9 = Button(self, text="W/B Levels", command=self.brighten)
    button9.grid(row=8, column= 2, sticky = N)
    button10 = Button(self, text="Undo", command=self.undo)
    button10.grid(row=9, column= 2, sticky = N)



def brighten(self, event = None):
    img2 = self.img.point(lambda p: p * 1.9)
    self.photo2 = ImageTk.PhotoImage(img2)
    self.label2 = Label(self, image=self.photo2)
    self.label2.grid(row=0, column=1, padx=5, pady=5, rowspan=10)

def darken(self, event = None):
    img2 = self.img.point(lambda p: p * 0.5)
    self.photo2 = ImageTk.PhotoImage(img2)
    self.label2 = Label(self, image=self.photo2)
    self.label2.grid(row=0, column=1, padx=5, pady=5, rowspan=10)

def warm(self, event = None):
    img = Image.open("lineage.jpg").convert("RGB")
    (w, h) = (img.size[0], img.size[1])
    img2 = img.copy()
    pixels = img2.load()
    for x in range(w):
        for y in range(h):
            (r, g, b) = pixels[x,y]
            r = int(r*1.3)
            pixels[x,y] = (r, g, b)
    self.photo2 = ImageTk.PhotoImage(img2)
    self.label2 = Label(self, image=self.photo2)
    self.label2.grid(row=0, column=1, padx=5, pady=5, rowspan=10)

def cool(self, event = None):
    img = Image.open("lineage.jpg").convert("RGB")
    (w, h) = (img.size[0], img.size[1])
    img2 = img.copy()
    pixels = img2.load()
    for x in range(w):
        for y in range(h):
            (r, g, b) = pixels[x,y]
            r = int(r/1.3)
            pixels[x,y] = (r, g, b)
    self.photo2 = ImageTk.PhotoImage(img2)
    self.label2 = Label(self, image=self.photo2)
    self.label2.grid(row=0, column=1, padx=5, pady=5, rowspan=10)

def sharpen(self, event = None):
    img2 = self.img.filter(ImageFilter.SHARPEN)
    self.photo2 = ImageTk.PhotoImage(img2)
    self.label2 = Label(self, image=self.photo2)
    self.label2.grid(row=0, column=1, padx=5, pady=5, rowspan=10)

def blur(self, event = None):
    img2 = self.img.filter(ImageFilter.BLUR)
    self.photo2 = ImageTk.PhotoImage(img2)
    self.label2 = Label(self, image=self.photo2)
    self.label2.grid(row=0, column=1, padx=5, pady=5, rowspan=10)

def rotate(self, event = None):
    img2 = self.img.rotate(270)
    self.photo2 = ImageTk.PhotoImage(img2)
    self.label2 = Label(self, image=self.photo2)
    self.label2.grid(row=0, column=1, padx=5, pady=5, rowspan=10)

def undo(self, event = None):
    img2 = self.img
    self.photo2 = ImageTk.PhotoImage(img2)
    self.label2 = Label(self, image=self.photo2)
    self.label2.grid(row=0, column=1, padx=5, pady=5, rowspan=10)



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
    img = Image.open("lineage.jpg").convert("RGB")
    (w, h) = (img.size[0], img.size[1])
    img2 = self.img
    img2 = img2.crop((self.x0,self.x1,self.y0,self.y1))
    self.photo2 = ImageTk.PhotoImage(img2)
    self.label2 = Label(self, image=self.photo2)
    self.label2.grid(row=0, column=1, padx=5, pady=5, rowspan=10)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:29:09+00:00Added an answer on June 14, 2026 at 7:29 pm

    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
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Requirement is like: I want to take input values from user in frame but
I want to take two lists and find the values that appear in both.
I want to take an array and use that array's values to populate an
Well ,thats my code.I want to take values from a DatePicker from a custom
I want to take the values from this site for the country table in
I Want get Param values(src) from Html to AS3 that allows us to maintain
I want to take the values from the URL and perform a currency conversion
I want real example about dynamic site map take it's value from database
I want to take the values if the variable I define are not equal
I want to take a math expression that takes variables and print (assign to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.