-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Description
Hi @chyok ,
First off—fantastic work on ollama-gui! I only discovered this project after building a similar Tkinter interface myself using chat gpt, and I thought I’d share a couple of features that I thought were missing in your:
1) Image pasting with removal button
Allow users to hit Ctrl+V to paste PNG/JPEG images from the clipboard see them and each pasted image gets a small “X” overlay to remove it:
from PIL import ImageGrab, Image, ImageTk
import os, tempfile, tkinter as tk
def add_image(path, image_frame, uploaded_images, image_paths):
image_paths.append(path)
fr = tk.Frame(image_frame)
fr.pack(side=tk.LEFT, padx=5)
img = Image.open(path)
img.thumbnail((150, 150))
img_tk = ImageTk.PhotoImage(img)
lbl = tk.Label(fr, image=img_tk)
lbl.image = img_tk
lbl.pack()
btn = tk.Button(fr, text='X', bd=1, command=lambda: remove_image(fr, path))
btn.place(x=130, y=0)
uploaded_images.append((img_tk, fr))
def paste_image(event=None):
clip = ImageGrab.grabclipboard()
# If clipboard returns file paths
if isinstance(clip, list):
for p in clip:
if os.path.isfile(p) and p.lower().endswith(('.png','.jpg','.jpeg')):
add_image(p, image_frame, uploaded_images, image_paths)
# If clipboard returns an image object
elif clip:
tmp = os.path.join(tempfile.gettempdir(),
f'pasted_img_{len(image_paths)+1}.png')
clip.save(tmp, format='PNG')
add_image(tmp, image_frame, uploaded_images, image_paths)2) Inline document previews
I noticed your UI already supports pasting Office files (e.g. .docx, .xlsx, .pptx) but it currently just inserts a file-path link into the chat. It’d be great to render them inline with a small file icon (📄) or filename preview plus an “X” removal button—just like the image previews. For example:
import os, tkinter as tk
def add_file(path, file_frame, file_paths):
file_paths.append(path)
fr = tk.Frame(file_frame)
fr.pack(side=tk.LEFT, padx=5)
icon = tk.Label(fr, text="📄")
icon.pack(side=tk.LEFT)
name_lbl = tk.Label(fr, text=os.path.basename(path), wraplength=100)
name_lbl.pack(side=tk.LEFT)
btn = tk.Button(fr, text='X', bd=1, command=lambda: remove_file(fr, path))
btn.place(x=90, y=0)
def paste_file(event=None):
clip = ImageGrab.grabclipboard()
if isinstance(clip, list):
for p in clip:
if os.path.isfile(p) and p.lower().endswith(('.docx','.xlsx','.pptx')):
add_file(p, file_frame, file_paths)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
