![]() Imageid = _image(max(bbox2, bbox1), max(bbox2, bbox1), Imagetk = ImageTk.PhotoImage(image.resize((int(x2 - x1), int(y2 - y1)))) Image = ((int(x1 / self.imscale), int(y1 / self.imscale), x, y)) Y = min(int(y2 / self.imscale), self.height) #. X = min(int(x2 / self.imscale), self.width) # sometimes it is larger on 1 pixel. If bbox 0 and int(y2 - y1) > 0: # show image if it in the visible area _dragto(event.x, event.y, gain=1)ībox = (ntainer) # get image area ''' Drag (move) canvas to the new position ''' ''' Remember previous coordinates for scrolling with the mouse ''' ''' Scroll canvas horizontally and redraw the image ''' ''' Scroll canvas vertically and redraw the image ''' _rectangle(x0, y0, x1, y1, fill=color, activefill='black') Y1 = y0 + random.randint(minsize, maxsize)Ĭolor = ('red', 'orange', 'yellow', 'green', 'blue') X1 = x0 + random.randint(minsize, maxsize) Y0 = random.randint(0, self.height - maxsize) X0 = random.randint(0, self.width - maxsize) # Plot some optional random rectangles for the test purposes ntainer = _rectangle(0, 0, self.width, self.height, width=0) # Put image into container rectangle and use it to set proper coordinates to the image Self.imscale = 1.0 # scale for the canvaas image Self.image = Image.open(path) # open image (' ', self.wheel) # only with Linux, wheel scroll up (' ', self.wheel) # only with Linux, wheel scroll down (' ', self.wheel) # with Windows and MacOS, but not Linux (' ', self.show_image) # canvas is resized nfigure(command=self.scroll_y) # bind scrollbars to the canvas Self.canvas = tk.Canvas(self.master, highlightthickness=0, Hbar = AutoScrollbar(self.master, orient='horizontal') Vbar = AutoScrollbar(self.master, orient='vertical') # Vertical and horizontal scrollbars for canvas Raise tk.TclError('Cannot use place with this widget') Raise tk.TclError('Cannot use pack with this widget') Works only if you use the grid geometry manager ''' ''' A scrollbar that hides itself if it's not needed. # constant memory and not crams it with a huge resized image for the large zooms. # It zooms only a tile, but not the whole image. No olvide colocar una ruta a su imagen al final del guión. Probado en Windows 7 de 64 bits y Python 3.6.2. Para el ejemplo de zoom simplificado, mire aquí. Por lo tanto, el mosaico ampliado ocupa memoria constante y no lo atasca con una gran imagen redimensionada para los grandes zooms. Amplía solo un mosaico, pero no toda la imagen. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |