How can I create a python gooey that will display an image and as well zoom in on that image?
This is the script to create a python gooey that will display an image and as well zoom in on that image.
if you're using this script on linux don't forget to change the MouseWheel event to Button-4 and Button-5. And you obviously need to insert a .JPG path where it says "INSERT JPG FILE PATH".
from Tkinter import *
import Image, ImageTk
class LoadImage:
def __init__(self,root):
frame = Frame(root)
self.canvas = Canvas(frame,width=900,height=900)
self.canvas.pack()
frame.pack()
File = "INSERT JPG FILE PATH"
self.orig_img = Image.open(File)
self.img = ImageTk.PhotoImage(self.orig_img)
self.canvas.create_image(0,0,image=self.img, anchor="nw")
self.zoomcycle = 0
self.zimg_id = None
root.bind("<MouseWheel>",self.zoomer)
self.canvas.bind("<Motion>",self.crop)
def zoomer(self,event):
if (event.delta > 0):
if self.zoomcycle != 4: self.zoomcycle += 1
elif (event.delta < 0):
if self.zoomcycle != 0: self.zoomcycle -= 1
self.crop(event)
def crop(self,event):
if self.zimg_id: self.canvas.delete(self.zimg_id)
if (self.zoomcycle) != 0:
x,y = event.x, event.y
if self.zoomcycle == 1:
tmp = self.orig_img.crop((x-45,y-30,x+45,y+30))
elif self.zoomcycle == 2:
tmp = self.orig_img.crop((x-30,y-20,x+30,y+20))
elif self.zoomcycle == 3:
tmp = self.orig_img.crop((x-15,y-10,x+15,y+10))
elif self.zoomcycle == 4:
tmp = self.orig_img.crop((x-6,y-4,x+6,y+4))
size = 300,200
self.zimg = ImageTk.PhotoImage(tmp.resize(size))
self.zimg_id = self.canvas.create_image(event.x,event.y,image=self.zimg)
if __name__ == '__main__':
root = Tk()
root.title("Crop Test")
App = LoadImage(root)
root.mainloop()
How can I create a python gooey that will display an image and as well zoom...
I am new at prgraming in python and I was wondering how you can create a new line within a print statment. I tried using \n but i keep getting an error
How can I create a fractal spiral like a fibbonacci spiral in Python without turtle. I am working with object oriented programming/
in python how to I get python to display 1 of 3 message every 45 seconds in a graphics window
In python, within a class's method, how can I create an attribute (field) named _age and initialize its value to 47?
Hi, I wanted to know if it is possible to get information from Python and display onto a app made using MIT App Inventor. Currently the best solution I thought of is to create a web server using python that MIT App Inventor connects based on the video: "Easy Python tutorial 16: Android-PC communication" from youtube but I don't understand it fully. What would be the best and easiest way to display python data onto a app using MIT App...
In this exercise you should write a Python function that computes the histogram of an intensity (gray scale) image. Do not use specifific Python functions for histogram computation (like hist or imhist). Create a new function my_hist and start with the following lines: function [h] = my_hist(im) % H = MY_HIST(IM) computes the histogram for the intensity % image IM (with values from 0 to 255) and returns a vector H % with 256 dimensions % get the image size:...
Please help. I need to write a Python program that can display which axis is aligned with gravity based on Accelerometer readings. This is for a quadcopter drone if that helps.
in python create a program to display the cost of renting a smart car. the user must be able to enter the number of days he/she rents the cat and the number of miles driven. use constants for the flat rate per day and the flat rate per mile. the program will display the flat rate per day, flat rate per mile, and the total cost of the car rental.
Unity gaming question- How do I create a brown container such as
shown in this image so that it will have balls fall into it? I
believe it has to do with composite objects and linking gameObjects
to a single parent. Can someone explain step by step how to do
it?
EPersp
Create a program in Python to generate a binary image that identifies an object from the background--the pixels belonging to the object will take values of one and the pixels from background will take values of zero respectively. To do this, use the subtraction operator and a threshold to identify the differences between the first image and the second image that contains the object of interest.