Python Forum
[Tkinter] Image editor using Tkinter and PIL
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Image editor using Tkinter and PIL
#1
Hello! I have to make a project , more exactly an Image Editor using python and I have very very basics information about libraries in python and python and I understood than I can make it using tkinter and PIL. Now my problem is with the PIL and tkinter putting together. I have a simple interface made with some buttons and I need to add some PIL filters or whatever "rotate" , "flip" , "crop" functions from PIL . I don't know how to put the command for the buttons from the filters that PIL library gives you , I tried to put like
 button1 = Button(root , text="Filter" , command=#[there the function def] 
but it won't let me make this and if you can suggest me some filters I will be thankful!
There is what I tried to make:
from tkinter import *
from PIL import Image , ImageTk


root = Tk()
root.title('Program editare foto')
image = ImageTk.PhotoImage(Image.open("imagini/imag1.jpg"))


my_label = Label(image=image)
my_label.grid(row=1 , column=1 , columnspan=2)
my_label1 = Label(text=" ")
my_label2 = Label(text=" ")

my_label1.grid(row=0 ,column=0)
my_label2.grid(row=1 ,column=0)





button1 = Button(root , text="Filter1")
button2 = Button(root , text="Filter2")
button3 = Button(root , text="Filter3")
button4 = Button(root , text="Filter4")
button5 = Button(root , text="Filter5")
button6 = Button(root, text="Filter6")

button1.grid(row=3,column=0)
button2.grid(row=4,column=0)
button3.grid(row=5,column=0)
button4.grid(row=6,column=0)
button5.grid(row=7,column=0)
button6.grid(row=8,column=0)


root.mainloop() 
I appreciat if you help me and thank you for wasting your time seeing this! :)
Reply
#2
Quote:I have very very basics information about libraries in python
see: https://pypi.org/ and python docs
Reply
#3
you need a function check out :
tkinter button
it's also referred as a callback, if you add a command you need a function for it.
and it must be declared before you create your button.
def my_callback():
    print('filter button pushed')
button1 = Button(root , text="Filter" , command=my_callback)
button1.pack()
I suggest using guizero to start with lawsie has recipes and documentation here:
guizero documentation
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Tkinter: An image and label are not appearing. emont 7 396 Mar-21-2024, 03:00 PM
Last Post: deanhystad
  My Background Image Is Not Appearing (Python Tkinter) HailyMary 2 3,972 Mar-14-2023, 06:13 PM
Last Post: deanhystad
  simple tkinter question function call not opening image gr3yali3n 5 3,300 Aug-02-2022, 09:13 PM
Last Post: woooee
  [Tkinter] Tkinter don't change the image DQT 2 1,556 Jul-22-2022, 10:26 AM
Last Post: menator01
  How to redraw an existing image to a different image TkInter zazas321 6 5,744 Jul-08-2021, 07:44 PM
Last Post: deanhystad
  tkinter showing image in button rwahdan 3 5,516 Jun-16-2021, 06:08 AM
Last Post: Yoriz
  tkinter button image Nick_tkinter 4 3,954 Mar-04-2021, 11:33 PM
Last Post: deanhystad
  how to resize image in canvas tkinter samuelmv30 2 17,547 Feb-06-2021, 03:35 PM
Last Post: joe_momma
  Latex image too big on tkinter using sympy 4096 1 2,886 Nov-05-2020, 08:05 AM
Last Post: DPaul
Photo Tkinter TEXT background image _ShevaKadu 5 7,648 Nov-02-2020, 10:34 AM
Last Post: joe_momma

Forum Jump:

User Panel Messages

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