![]() It works in python 3.4+ (didn't test anything else). Here's a revised version of bigjim's answer. (wx.Colour(0, 0, 0))Īpp.SetOutputWindowAttributes(title='stdout') Self.canvas = M圜anvas(self, -1, filepath = filepath) Wx.Frame._init_(self, parent, id, title=filepath) Pos = self.CalcUnscrolledPosition(event.GetPosition())ĭc = wx.BufferedPaintDC(self, self.buffer, wx.BUFFER_VIRTUAL_AREA)ĭef _init_(self, parent=None, id=-1, filepath = None): ![]() Self.buffer = wx.EmptyBitmap(self.w, self.h)ĭc.SetBackground(wx.Brush(self.GetBackgroundColour())) Self.SetBackgroundColour(wx.Colour(0,0,0)) Self.bmp = wx.BitmapFromImage(self.image) Wx.ScrolledWindow._init_(self, parent, id, (0, 0), size=size, style=wx.SUNKEN_BORDER) import wxĭef _init_(self, parent, id = -1, size = wx.DefaultSize, filepath = None): (Uses Python 2.6.2, wxPython 2.8.10.1)Įnter the path to your image in the filepath variable at the bottom. This prints the mouse click coordinates to a separate output window. Here's a version I had cobbled together a while ago using wxPython and various wxPython tutorials. If you're new to tkinter google should be able to help you finish it from here :). To get the loaded picture dimension you would use canvas.bbox(ALL), and you might want to switch to using canvasx and canvasy coords instead of how it is. The canvas widget makes the top left corner the 0,0 point so you may have to mess around with the printcoords function. Unedited it will print using the default window coordinate system to the console. #function to be called when mouse is clicked Img = ImageTk.PhotoImage(Image.open(File))Ĭanvas.create_image(0,0,image=img,anchor="nw")Ĭnfig(scrollregion=canvas.bbox(ALL)) ![]() id(row=0, column=1, sticky=N+S)Ĭanvas = Canvas(frame, bd=0, xscrollcommand=t, yscrollcommand=t)Ĭid(row=0, column=0, sticky=N+S+E+W)įile = askopenfilename(parent=root, initialdir="C:/",title='Choose an image.') Xscroll = Scrollbar(frame, orient=HORIZONTAL) #setting up a tkinter canvas with scrollbars Yes it is possible and pretty easy once you understand tkinter, here's a quick script: from Tkinter import *
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |