SaveText.Ru

Quest
  1. import tkinter as tk
  2. from tkinter import ttk
  3. from PIL import Image, ImageTk
  4.  
  5.  
  6. def press_first():
  7.         update_window('kek.png', 'Lolsyvdbufyvsduyb')
  8.  
  9.  
  10. def press_second():
  11.         update_window('some.png', 'srjudbgoiersngoiern')
  12.  
  13.  
  14. def update_window(path_to_image, new_description):
  15.         photo = ImageTk.PhotoImage(Image.open(path_to_image).resize((300, 300), Image.ANTIALIAS))
  16.         photoLabel.configure(image=photo)
  17.         photoLabel.image = photo
  18.  
  19.         descLabel.configure(text=new_description)
  20.  
  21. if __name__ == '__main__':
  22.         global root
  23.         global imageFrame
  24.         global photoLabel
  25.         global descLabel
  26.         global firstBut
  27.         global secondBut
  28.         global currentNumber
  29.  
  30.         root = tk.Tk()
  31.         root.title('Quest')
  32.  
  33.         imageFrame = tk.Frame(root, padx=10, pady=10)
  34.         imageFrame.pack()
  35.  
  36.         photo = ImageTk.PhotoImage(Image.open('some.png').resize((300, 300), Image.ANTIALIAS))
  37.         photoLabel = ttk.Label(imageFrame, image=photo)
  38.         photoLabel.pack()
  39.  
  40.         description = 'Some text... Some text... Some text... Some text... Some text... '
  41.         descLabel = tk.Label(root, text=description, height=2, wraplength=300, justify='center')
  42.         descLabel.pack(padx=10, pady=10, fill='x')
  43.  
  44.         frame = tk.Frame(root, padx=10, pady=10)
  45.         frame.pack(side='bottom')
  46.  
  47.         firstBut = ttk.Button(frame, text='Yes', command=press_first, state='enable' )
  48.         firstBut.pack(side='left')
  49.         secondBut = ttk.Button(frame, text='No', command=press_second, state='enable')
  50.         secondBut.pack(side='left')
  51.  
  52.         root.mainloop()
  53.  

Share with your friends:

Print