-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
57 lines (42 loc) · 1.79 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import tkinter as tk
from PIL import ImageTk, Image
from model import Model
class ImageGeneratorApp:
def __init__(self, master):
self.master = master
master.title("Image Generator")
# Создаем элементы
self.prompt_label = tk.Label(master, text="Prompt:")
self.prompt_entry = tk.Entry(master, width=50)
self.negative_prompt_label = tk.Label(master, text="Negative Prompt:")
self.negative_prompt_entry = tk.Entry(master, width=50)
img = Image.open("res/question.jpg")
img = img.resize((250, 250), Image.ANTIALIAS)
img = ImageTk.PhotoImage(img)
self.panel = tk.Label(root, image=img)
self.panel.image = img
self.generate_button = tk.Button(master, text="Generate", command=self.generate_image)
# Упаковываем элементы в окне
self.prompt_label.pack()
self.prompt_entry.pack()
self.negative_prompt_label.pack()
self.negative_prompt_entry.pack()
self.panel.pack()
self.generate_button.pack()
self.model = Model()
def generate_image(self):
prompt = self.prompt_entry.get() + " ." + "No " + self.negative_prompt_entry.get()
self.model.generate_image(prompt)
img = Image.open("res/generation.png")
img = img.resize((250, 250), Image.ANTIALIAS)
img = ImageTk.PhotoImage(img)
self.panel.image = img
self.panel.config(image=img)
# Создаем главное окно
root = tk.Tk()
root.geometry("650x400+300+150")
root.resizable(width=True, height=True)
# Запускаем приложение
app = ImageGeneratorApp(root)
# Запускаем цикл обработки событий
root.mainloop()