Python PIL.ImageTk.PhotoImage() Examples

The following are 30 code examples of PIL.ImageTk.PhotoImage(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PIL.ImageTk , or try the search function .
Example #1
Source File: window.py    From LPHK with GNU General Public License v3.0 8 votes vote down vote up
def popup(self, window, title, image, text, button_text, end_command=None):
        popup = tk.Toplevel(window)
        popup.resizable(False, False)
        if MAIN_ICON != None:
            if os.path.splitext(MAIN_ICON)[1].lower() == ".gif":
                dummy = None
                #popup.call('wm', 'iconphoto', popup._w, tk.PhotoImage(file=MAIN_ICON))
            else:
                popup.iconbitmap(MAIN_ICON)
        popup.wm_title(title)
        popup.tkraise(window)

        def run_end():
            popup.destroy()
            if end_command != None:
                end_command()

        picture_label = tk.Label(popup, image=image)
        picture_label.photo = image
        picture_label.grid(column=0, row=0, rowspan=2, padx=10, pady=10)
        tk.Label(popup, text=text, justify=tk.CENTER).grid(column=1, row=0, padx=10, pady=10)
        tk.Button(popup, text=button_text, command=run_end).grid(column=1, row=1, padx=10, pady=10)
        popup.wait_visibility()
        popup.grab_set()
        popup.wait_window() 
Example #2
Source File: fisheye.py    From DualFisheye with MIT License 6 votes vote down vote up
def update_preview(self, psize):
        # Safety check: Ignore calls during construction/destruction.
        if not self.init_done: return
        # Copy latest user settings to the lens object.
        self.lens.fov_deg = self.f.get()
        self.lens.radius_px = self.r.get()
        self.lens.center_px[0] = self.x.get()
        self.lens.center_px[1] = self.y.get()
        # Re-scale the image to match the canvas size.
        # Note: Make a copy first, because thumbnail() operates in-place.
        self.img_sc = self.img.copy()
        self.img_sc.thumbnail(psize, Image.NEAREST)
        self.img_tk = ImageTk.PhotoImage(self.img_sc)
        # Re-scale the x/y/r parameters to match the preview scale.
        pre_scale = float(psize[0]) / float(self.img.size[0])
        x = self.x.get() * pre_scale
        y = self.y.get() * pre_scale
        r = self.r.get() * pre_scale
        # Clear and redraw the canvas.
        self.preview.delete('all')
        self.preview.create_image(0, 0, anchor=tk.NW, image=self.img_tk)
        self.preview.create_oval(x-r, y-r, x+r, y+r,
                                 outline='#C00000', width=3)

    # Make a combined label/textbox/slider for a given variable: 
Example #3
Source File: videoextensoConfig.py    From crappy with GNU General Public License v2.0 6 votes vote down vote up
def resize_img(self,sl):
    rimg = cv2.resize(self.img8[sl[1],sl[0]],tuple(reversed(self.img_shape)),
        interpolation=0)
    if self.select_box[0] > 0:
      lbox = [0]*4
      for i in range(4):
        n = self.select_box[i]-self.zoom_window[i%2]*self.img.shape[i%2]
        n /= (self.zoom_window[2+i%2]-self.zoom_window[i%2])
        lbox[i] = int(n/self.img.shape[i%2]*
                      self.img_shape[i%2])
      self.draw_box(lbox,rimg)
    if self.boxes:
      for b in self.boxes:
        lbox = [0]*4
        for i in range(4):
          n = b[i]-self.zoom_window[i%2]*self.img.shape[i%2]
          n /= (self.zoom_window[2+i%2]-self.zoom_window[i%2])
          lbox[i] = int(n/self.img.shape[i%2]*
                        self.img_shape[i%2])
        self.draw_box(lbox,rimg)

    self.c_img = ImageTk.PhotoImage(Image.fromarray(rimg)) 
Example #4
Source File: surface.py    From License-Plate-Recognition with MIT License 6 votes vote down vote up
def show_roi(self, r, roi, color):
		if r :
			roi = cv2.cvtColor(roi, cv2.COLOR_BGR2RGB)
			roi = Image.fromarray(roi)
			self.imgtk_roi = ImageTk.PhotoImage(image=roi)
			self.roi_ctl.configure(image=self.imgtk_roi, state='enable')
			self.r_ctl.configure(text=str(r))
			self.update_time = time.time()
			try:
				c = self.color_transform[color]
				self.color_ctl.configure(text=c[0], background=c[1], state='enable')
			except: 
				self.color_ctl.configure(state='disabled')
		elif self.update_time + 8 < time.time():
			self.roi_ctl.configure(state='disabled')
			self.r_ctl.configure(text="")
			self.color_ctl.configure(state='disabled') 
Example #5
Source File: surface.py    From License-Plate-Recognition with MIT License 6 votes vote down vote up
def get_imgtk(self, img_bgr):
		img = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2RGB)
		im = Image.fromarray(img)
		imgtk = ImageTk.PhotoImage(image=im)
		wide = imgtk.width()
		high = imgtk.height()
		if wide > self.viewwide or high > self.viewhigh:
			wide_factor = self.viewwide / wide
			high_factor = self.viewhigh / high
			factor = min(wide_factor, high_factor)
			wide = int(wide * factor)
			if wide <= 0 : wide = 1
			high = int(high * factor)
			if high <= 0 : high = 1
			im=im.resize((wide, high), Image.ANTIALIAS)
			imgtk = ImageTk.PhotoImage(image=im)
		return imgtk 
Example #6
Source File: __init__.py    From 3DGCN with MIT License 6 votes vote down vote up
def ShowMol(mol, size=(300, 300), kekulize=True, wedgeBonds=True, title='RDKit Molecule', **kwargs):
    """ Generates a picture of a molecule and displays it in a Tkinter window
    """
    global tkRoot, tkLabel, tkPI
    try:
        import Tkinter
    except ImportError:
        import tkinter as Tkinter
    try:
        import ImageTk
    except ImportError:
        from PIL import ImageTk

    img = MolToImage(mol, size, kekulize, wedgeBonds, **kwargs)

    if not tkRoot:
        tkRoot = Tkinter.Tk()
        tkRoot.title(title)
        tkPI = ImageTk.PhotoImage(img)
        tkLabel = Tkinter.Label(tkRoot, image=tkPI)
        tkLabel.place(x=0, y=0, width=img.size[0], height=img.size[1])
    else:
        tkPI.paste(img)
    tkRoot.geometry('%dx%d' % (img.size)) 
Example #7
Source File: window.py    From LPHK with GNU General Public License v3.0 6 votes vote down vote up
def make():
    global root
    global app
    global root_destroyed
    global redetect_before_start
    root = tk.Tk()
    root_destroyed = False
    root.protocol("WM_DELETE_WINDOW", close)
    root.resizable(False, False)
    if MAIN_ICON != None:
        if os.path.splitext(MAIN_ICON)[1].lower() == ".gif":
            root.call('wm', 'iconphoto', root._w, tk.PhotoImage(file=MAIN_ICON))
        else:
            root.iconbitmap(MAIN_ICON)
    app = Main_Window(root)
    app.raise_above_all()
    app.after(100, app.connect_lp)
    app.mainloop() 
Example #8
Source File: window.py    From LPHK with GNU General Public License v3.0 6 votes vote down vote up
def popup_choice(self, window, title, image, text, choices):
        popup = tk.Toplevel(window)
        popup.resizable(False, False)
        if MAIN_ICON != None:
            if os.path.splitext(MAIN_ICON)[1].lower() == ".gif":
                dummy = None
                #popup.call('wm', 'iconphoto', popup._w, tk.PhotoImage(file=MAIN_ICON))
            else:
                popup.iconbitmap(MAIN_ICON)
        popup.wm_title(title)
        popup.tkraise(window)
        
        def run_end(func):
            popup.destroy()
            if func != None:
                func()

        picture_label = tk.Label(popup, image=image)
        picture_label.photo = image
        picture_label.grid(column=0, row=0, rowspan=2, padx=10, pady=10)
        tk.Label(popup, text=text, justify=tk.CENTER).grid(column=1, row=0, columnspan=len(choices), padx=10, pady=10)
        for idx, choice in enumerate(choices):
            run_end_func = partial(run_end, choice[1])
            tk.Button(popup, text=choice[0], command=run_end_func).grid(column=1 + idx, row=1, padx=10, pady=10)
        popup.wait_visibility()
        popup.grab_set()
        popup.wait_window() 
Example #9
Source File: window.py    From LPHK with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, master=None):
        tk.Frame.__init__(self, master)
        self.master = master
        self.init_window()
        
        self.about_image = ImageTk.PhotoImage(Image.open(PATH + "/resources/LPHK-banner.png"))
        self.info_image = ImageTk.PhotoImage(Image.open(PATH + "/resources/info.png"))
        self.warning_image = ImageTk.PhotoImage(Image.open(PATH + "/resources/warning.png"))
        self.error_image = ImageTk.PhotoImage(Image.open(PATH + "/resources/error.png"))
        self.alert_image = ImageTk.PhotoImage(Image.open(PATH + "/resources/alert.png"))
        self.scare_image = ImageTk.PhotoImage(Image.open(PATH + "/resources/scare.png"))
        self.grid_drawn = False
        self.grid_rects = [[None for y in range(9)] for x in range(9)]
        self.button_mode = "edit"
        self.last_clicked = None
        self.outline_box = None 
Example #10
Source File: setup_selectarea.py    From PiPark with GNU General Public License v2.0 6 votes vote down vote up
def get_image_scaled(image):
    # Calculate the aspect ratio of the image
    image_aspect = float(image.size[1]) / float(image.size[0])

    # Scale the image
    image_scaled = (s.WINDOW_WIDTH, int(s.WINDOW_WIDTH * image_aspect))
    
    if image_aspect > 1:
        image_scaled = (int(s.WINDOW_HEIGHT / image_aspect), s.WINDOW_HEIGHT)

    coords = ((s.WINDOW_WIDTH - image_scaled[0])/2,
              (s.WINDOW_HEIGHT - image_scaled[1])/2,
              image_scaled[0], image_scaled[1])

    # Creat the resized image and return it and the co-ordinates.
    return ImageTk.PhotoImage(
        image.resize(image_scaled, Image.ANTIALIAS)), coords

# -----------------------------------------------------------------------------
# Function to output the co-ordinates of the boxes
# ----------------------------------------------------------------------------- 
Example #11
Source File: user_interface.py    From PcapXray with GNU General Public License v2.0 5 votes vote down vote up
def load_image(self):
        self.canvas = Canvas(self.ThirdFrame, width=900,height=500, bd=0, bg="navy", xscrollcommand=self.xscrollbar.set, yscrollcommand=self.yscrollbar.set)
        #self.canvas.grid(row=0, column=0, sticky=N + S + E + W)
        self.canvas.grid(column=0, row=0, sticky=(N, W, E, S))
        #self.canvas.pack(side = RIGHT, fill = BOTH, expand = True)
        self.img = ImageTk.PhotoImage(Image.open(self.image_file).resize(tuple(self.zoom),Image.ANTIALIAS))#.convert('RGB'))
        self.canvas.create_image(0,0, image=self.img)
        self.canvas.config(scrollregion=self.canvas.bbox(ALL))
        self.xscrollbar.config(command=self.canvas.xview)
        self.yscrollbar.config(command=self.canvas.yview)
        #self.canvas.rowconfigure(0, weight=1)
        #self.canvas.columnconfigure(0, weight=1) 
Example #12
Source File: main.py    From WxConn with MIT License 5 votes vote down vote up
def _resize_ads_qrcode(self, path, size=(100,100)):
        image_qr = Image.open(path)
        image_qr = image_qr.resize(size, Image.ANTIALIAS)
        return ImageTk.PhotoImage(image=image_qr) 
Example #13
Source File: environment.py    From 2019-OSS-Summer-RL with MIT License 5 votes vote down vote up
def load_images(self):
        rectangle = PhotoImage(
            Image.open("../../Images/rectangle.png").resize((65, 65)))
        triangle = PhotoImage(
            Image.open("../../Images/triangle.png").resize((65, 65)))
        circle = PhotoImage(
            Image.open("../../Images/circle.png").resize((65, 65)))

        return rectangle, triangle, circle 
Example #14
Source File: display.py    From epd-library-python with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, dims=(800,600)):
        AutoDisplay.__init__(self, dims[0], dims[1])

        self.root = tk.Tk()
        self.pil_img = self.frame_buf.copy()
        self.tk_img = ImageTk.PhotoImage(self.pil_img)
        self.panel = tk.Label(self.root, image=self.tk_img)
        self.panel.pack(side="bottom", fill="both", expand="yes") 
Example #15
Source File: userInterface.py    From PcapXray with GNU General Public License v2.0 5 votes vote down vote up
def load_image(self):
        self.canvas = Canvas(self.ThirdFrame, width=700,height=600, bd=0, bg="navy", xscrollcommand=self.xscrollbar.set, yscrollcommand=self.yscrollbar.set)
        self.canvas.grid(row=0, column=0, sticky=N + S + E + W)
        self.img = ImageTk.PhotoImage(Image.open("Report/"+self.filename+self.option.get()+".png").resize(tuple(self.zoom),Image.ANTIALIAS).convert('RGB'))
        self.canvas.create_image(0,0, image=self.img)
        self.canvas.config(scrollregion=self.canvas.bbox(ALL))
        self.xscrollbar.config(command=self.canvas.xview)
        self.yscrollbar.config(command=self.canvas.yview) 
Example #16
Source File: discorrelConfig.py    From crappy with GNU General Public License v2.0 5 votes vote down vote up
def resize_img(self,sl):
    rimg = cv2.resize(self.img8[sl[1],sl[0]],tuple(reversed(self.img_shape)),
        interpolation=0)
    if self.box[0] > 0:
      lbox = [0]*4
      for i in range(4):
        n = self.box[i]-self.zoom_window[i%2]*self.img.shape[i%2]
        n /= (self.zoom_window[2+i%2]-self.zoom_window[i%2])
        lbox[i] = int(n/self.img.shape[i%2]*
                      self.img_shape[i%2])
      self.draw_box(lbox,rimg)

    self.c_img = ImageTk.PhotoImage(Image.fromarray(rimg)) 
Example #17
Source File: cameraConfig.py    From crappy with GNU General Public License v2.0 5 votes vote down vote up
def update_histogram(self):
    while not self.hist_pipe.poll():
      pass
    h = self.hist_pipe.recv()
    if self.auto_range.get():
      lo = int(self.low/2**self.detect_bits()*h.shape[1])
      hi = int(self.high/2**self.detect_bits()*h.shape[1])
      if lo < h.shape[1]:
        h[:,lo] = 127
      if hi < h.shape[1]:
        h[:,hi] = 127
    self.hist = ImageTk.PhotoImage(Image.fromarray(h))
    self.hist_label.configure(image=self.hist)
    self.hist_pipe.send(((80,self.label_shape[1]),(0,2**self.detect_bits()),
      self.img)) 
Example #18
Source File: cameraConfig.py    From crappy with GNU General Public License v2.0 5 votes vote down vote up
def resize_img(self,sl):
    self.c_img = ImageTk.PhotoImage(Image.fromarray(
        cv2.resize(self.img8[sl[1],sl[0]],tuple(reversed(self.img_shape)),
        interpolation=0)))
    # Interpolation=0 means nearest neighbor
    # Resize somehow takes x,y when EVERYTHING else takes y,x thanks numpy !

# =============== Update functions =============== 
Example #19
Source File: cameraConfig.py    From crappy with GNU General Public License v2.0 5 votes vote down vote up
def convert_img(self):
    """Converts the image to uint if necessary, then to a PhotoImage"""
    if len(self.img.shape) == 3:
      self.img = self.img[:,:,::-1] # BGR to RGB
    if self.img.dtype != np.uint8:
      #if self.auto_range.get():
      #Ok, this is not a very clean way, but at first auto_range is not defined
      try:
        assert self.auto_range.get()
        # ar=True, 16bits
        self.low = np.percentile(self.img,1)
        self.high = np.percentile(self.img,99)
        self.img8 = ((np.clip(self.img,self.low,self.high)-
                    self.low)*256/self.high).astype(np.uint8)
      except (AssertionError,AttributeError):
        # ar=False, 16 bits
        self.img8 = (self.img/2**(self.detect_bits()-8)).astype(np.uint8)
    else:
      try:
        assert self.auto_range.get()
        # ar=True, 8bits
        self.low = np.percentile(self.img,1)
        self.high = np.percentile(self.img,99)
        self.img8 = ((np.clip(self.img,self.low,self.high)-
                        self.low)*256/self.high)
      except (AssertionError,AttributeError):
        # ar=False, 8bits
        self.img8 = self.img
    slx = slice(int(self.img.shape[0]*self.zoom_window[0]),
        int(self.img.shape[0]*self.zoom_window[2]))
    sly = slice(int(self.img.shape[1]*self.zoom_window[1]),
        int(self.img.shape[1]*self.zoom_window[3]))
    self.resize_img((sly,slx)) 
Example #20
Source File: extended_pyGISS.py    From pyGISS with MIT License 5 votes vote down vote up
def __init__(self, path_app):
        super().__init__()
        self.title('Extended PyGISS')
        path_icon = abspath(join(path_app, pardir, 'images'))
        
        # generate the PSF tk images
        img_psf = ImageTk.Image.open(join(path_icon, 'node.png'))
        selected_img_psf = ImageTk.Image.open(join(path_icon, 'selected_node.png'))
        self.psf_button_image = ImageTk.PhotoImage(img_psf.resize((100, 100)))
        self.node_image = ImageTk.PhotoImage(img_psf.resize((40, 40)))
        self.selected_node_image = ImageTk.PhotoImage(selected_img_psf.resize((40, 40)))

        for widget in (
                       'Button',
                       'Label', 
                       'Labelframe', 
                       'Labelframe.Label', 
                       ):
            ttk.Style().configure('T' + widget, background='#A1DBCD')

        self.map = Map(self)
        self.map.pack(side='right', fill='both', expand=1)

        self.menu = Menu(self)
        self.menu.pack(side='right', fill='both', expand=1)

        menu = tk.Menu(self)
        menu.add_command(label="Import shapefile", command=self.map.import_map)
        self.config(menu=menu)

        # if motion is called, the left-click button was released and we 
        # can stop the drag and drop process
        self.bind_all('<Motion>', self.stop_drag_and_drop)
        self.drag_and_drop = False

        self.image = None
        self.bind_all('<B1-Motion>', lambda _:_) 
Example #21
Source File: show_progress.py    From stn-ocr with GNU General Public License v3.0 5 votes vote down vote up
def image(self, value):
        image = ImageTk.PhotoImage(value)
        self._image = image
        self._sprite = self.canvas.create_image(value.width // 2, value.height // 2, image=self._image)
        self.canvas.config(width=value.width, height=value.height) 
Example #22
Source File: photoboothapp.py    From OpenCV-Python-Tutorial with MIT License 5 votes vote down vote up
def videoLoop(self):
        # DISCLAIMER:
        # I'm not a GUI developer, nor do I even pretend to be. This
        # try/except statement is a pretty ugly hack to get around
        # a RunTime error that  throws due to threading
        try:
            # keep looping over frames until we are instructed to stop
            while not self.stopEvent.is_set():
                # grab the frame from the video stream and resize it to
                # have a maximum width of 300 pixels
                self.frame = self.vs.read()
                self.frame = imutils.resize(self.frame, width=300)

                #  represents images in BGR order; however PIL
                # represents images in RGB order, so we need to swap
                # the channels, then convert to PIL and ImageTk format
                image = cv2.cvtColor(self.frame, cv2.COLOR_BGR2RGB)
                image = Image.fromarray(image)
                image = ImageTk.PhotoImage(image)

                # if the panel is not None, we need to initialize it
                if self.panel is None:
                    self.panel = tki.Label(image=image)
                    self.panel.image = image
                    self.panel.pack(side="left", padx=10, pady=10)

                # otherwise, simply update the panel
                else:
                    self.panel.configure(image=image)
                    self.panel.image = image

        except RuntimeError as e:
            print("[INFO] caught a RuntimeError") 
Example #23
Source File: smartmirror.py    From Smart-Mirror with MIT License 5 votes vote down vote up
def __init__(self, parent, event_name=""):
        Frame.__init__(self, parent, bg='black')

        image = Image.open("assets/Newspaper.png")
        image = image.resize((25, 25), Image.ANTIALIAS)
        image = image.convert('RGB')
        photo = ImageTk.PhotoImage(image)

        self.iconLbl = Label(self, bg='black', image=photo)
        self.iconLbl.image = photo
        self.iconLbl.pack(side=LEFT, anchor=N)

        self.eventName = event_name
        self.eventNameLbl = Label(self, text=self.eventName, font=('Helvetica', small_text_size), fg="white", bg="black")
        self.eventNameLbl.pack(side=LEFT, anchor=N) 
Example #24
Source File: environment.py    From 2019-OSS-Summer-RL with MIT License 5 votes vote down vote up
def load_images(self):
        rectangle = PhotoImage(
            Image.open("../../Images/rectangle.png").resize((30, 30)))
        triangle = PhotoImage(
            Image.open("../../Images/triangle.png").resize((30, 30)))
        circle = PhotoImage(
            Image.open("../../Images/circle.png").resize((30, 30)))

        return rectangle, triangle, circle 
Example #25
Source File: PlatformManagerWindows.py    From lackey with MIT License 5 votes vote down vote up
def __init__(self, root, rect, frame_color, screen_cap):
        """ Accepts rect as (x,y,w,h) """
        self.root = root
        tk.Toplevel.__init__(self, self.root, bg="red", bd=0)

        ## Set toplevel geometry, remove borders, and push to the front
        self.geometry("{2}x{3}+{0}+{1}".format(*rect))
        self.overrideredirect(1)
        self.attributes("-topmost", True)

        ## Create canvas and fill it with the provided image. Then draw rectangle outline
        self.canvas = tk.Canvas(
            self,
            width=rect[2],
            height=rect[3],
            bd=0,
            bg="blue",
            highlightthickness=0)
        self.tk_image = ImageTk.PhotoImage(Image.fromarray(screen_cap[..., [2, 1, 0]]))
        self.canvas.create_image(0, 0, image=self.tk_image, anchor=tk.NW)
        self.canvas.create_rectangle(
            2,
            2,
            rect[2]-2,
            rect[3]-2,
            outline=frame_color,
            width=4)
        self.canvas.pack(fill=tk.BOTH, expand=tk.YES)

        ## Lift to front if necessary and refresh.
        self.lift()
        self.update() 
Example #26
Source File: environment.py    From 2019-OSS-Summer-RL with MIT License 5 votes vote down vote up
def load_images(self):
        PhotoImage = ImageTk.PhotoImage
        up = PhotoImage(Image.open("../../Images/up.png").resize((13, 13)))
        right = PhotoImage(Image.open("../../Images/right.png").resize((13, 13)))
        left = PhotoImage(Image.open("../../Images/left.png").resize((13, 13)))
        down = PhotoImage(Image.open("../../Images/down.png").resize((13, 13)))
        rectangle = PhotoImage(
            Image.open("../../Images/rectangle.png").resize((65, 65)))
        triangle = PhotoImage(
            Image.open("../../Images/triangle.png").resize((65, 65)))
        circle = PhotoImage(Image.open("../../Images/circle.png").resize((65, 65)))
        return (up, down, left, right), (rectangle, triangle, circle) 
Example #27
Source File: environment.py    From 2019-OSS-Summer-RL with MIT License 5 votes vote down vote up
def load_images(self):
        up = PhotoImage(Image.open("../../Images/up.png").resize((13, 13)))
        right = PhotoImage(Image.open("../../Images/right.png").resize((13, 13)))
        left = PhotoImage(Image.open("../../Images/left.png").resize((13, 13)))
        down = PhotoImage(Image.open("../../Images/down.png").resize((13, 13)))
        rectangle = PhotoImage(Image.open("../../Images/rectangle.png").resize((65, 65)))
        triangle = PhotoImage(Image.open("../../Images/triangle.png").resize((65, 65)))
        circle = PhotoImage(Image.open("../../Images/circle.png").resize((65, 65)))
        return (up, down, left, right), (rectangle, triangle, circle) 
Example #28
Source File: environment.py    From 2019-OSS-Summer-RL with MIT License 5 votes vote down vote up
def load_images(self):
        rectangle = PhotoImage(
            Image.open("../../Images/rectangle.png").resize((65, 65)))
        triangle = PhotoImage(
            Image.open("../../Images/triangle.png").resize((65, 65)))
        circle = PhotoImage(
            Image.open("../../Images/circle.png").resize((65, 65)))

        return rectangle, triangle, circle 
Example #29
Source File: environment.py    From 2019-OSS-Summer-RL with MIT License 5 votes vote down vote up
def load_images(self):
        rectangle = PhotoImage(
            Image.open("../../Images/rectangle.png").resize((65, 65)))
        triangle = PhotoImage(
            Image.open("../../Images/triangle.png").resize((65, 65)))
        circle = PhotoImage(
            Image.open("../../Images/circle.png").resize((65, 65)))

        return rectangle, triangle, circle 
Example #30
Source File: environment.py    From reinforcement-learning with MIT License 5 votes vote down vote up
def load_images(self):
        up = PhotoImage(Image.open("../img/up.png").resize((13, 13)))
        right = PhotoImage(Image.open("../img/right.png").resize((13, 13)))
        left = PhotoImage(Image.open("../img/left.png").resize((13, 13)))
        down = PhotoImage(Image.open("../img/down.png").resize((13, 13)))
        rectangle = PhotoImage(Image.open("../img/rectangle.png").resize((65, 65)))
        triangle = PhotoImage(Image.open("../img/triangle.png").resize((65, 65)))
        circle = PhotoImage(Image.open("../img/circle.png").resize((65, 65)))
        return (up, down, left, right), (rectangle, triangle, circle)