Bottom Page

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! :)
Quote
#2
Quote:I have very very basics information about libraries in python
see: https://pypi.org/ and python docs
Quote
#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
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Unable to put background image on Tkinter Frame jenkins43 2 125 Nov-27-2019, 11:38 AM
Last Post: jenkins43
  Zooming a tkinter image GalaxyCoyote 2 169 Nov-09-2019, 04:36 PM
Last Post: GalaxyCoyote
  Can't load a png image tkinter Pythenx 2 1,075 May-04-2019, 05:43 PM
Last Post: woooee
  how to insert image into Text widget Tkinter atlass218 5 1,873 Apr-17-2019, 05:28 AM
Last Post: atlass218
  Display image in tkinter dan789 9 9,179 Dec-09-2018, 08:17 PM
Last Post: dan789
  Tkinter Image Display Weird Tearing Upon Transforming Emerest 6 1,505 Sep-01-2018, 11:46 PM
Last Post: Emerest

Forum Jump:


Users browsing this thread: 1 Guest(s)