Advertisement
Najeebsk

SEARCH-PICTURES2.py

Mar 15th, 2024
673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.03 KB | None | 0 0
  1. import tkinter as tk
  2. from tkinter import ttk
  3. import webbrowser
  4.  
  5. class ImageSearchApp:
  6.     def __init__(self, root):
  7.         self.root = root
  8.         self.root.title("Image Search App")
  9.        
  10.         self.search_label = ttk.Label(root, text="Enter image URL:")
  11.         self.search_label.pack(pady=5)
  12.        
  13.         self.search_entry = ttk.Entry(root, width=30)
  14.         self.search_entry.pack(pady=5)
  15.        
  16.         self.search_button_google = ttk.Button(root, text="Search (Google)", command=self.search_images_google)
  17.         self.search_button_google.pack(pady=5)
  18.        
  19.         self.search_button_bing = ttk.Button(root, text="Search (Bing)", command=self.search_images_bing)
  20.         self.search_button_bing.pack(pady=5)
  21.        
  22.         self.search_button_tineye = ttk.Button(root, text="Search (TinEye)", command=self.search_images_tineye)
  23.         self.search_button_tineye.pack(pady=5)
  24.        
  25.         self.result_text = tk.Text(root, wrap="word", width=50, height=10)
  26.         self.result_text.pack(pady=5)
  27.        
  28.     def search_images_google(self):
  29.         query = self.search_entry.get()
  30.         if query:
  31.             url = f"https://www.google.com/searchbyimage?image_url={query}"
  32.             webbrowser.open_new_tab(url)
  33.         else:
  34.             self.result_text.insert(tk.END, "Please enter an image URL.")
  35.    
  36.     def search_images_bing(self):
  37.         query = self.search_entry.get()
  38.         if query:
  39.             url = f"https://www.bing.com/images/searchbyimage?url={query}"
  40.             webbrowser.open_new_tab(url)
  41.         else:
  42.             self.result_text.insert(tk.END, "Please enter an image URL.")
  43.    
  44.     def search_images_tineye(self):
  45.         query = self.search_entry.get()
  46.         if query:
  47.             url = f"https://www.tineye.com/search/?url={query}"
  48.             webbrowser.open_new_tab(url)
  49.         else:
  50.             self.result_text.insert(tk.END, "Please enter an image URL.")
  51.  
  52. if __name__ == "__main__":
  53.     root = tk.Tk()
  54.     app = ImageSearchApp(root)
  55.     root.mainloop()
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement