-
Notifications
You must be signed in to change notification settings - Fork 0
/
searchpage.py
54 lines (40 loc) · 1.3 KB
/
searchpage.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
import tkinter as tk
from PIL import Image, ImageTk
import zmq
def show_search_page():
search_root.deiconify()
def hide_search_page():
search_root.withdraw()
def main():
global search_root
window_width, window_height = 800, 500
search_root = tk.Tk()
search_root.title("Search Page")
search_root.geometry("800x700")
# initially hide
search_root.withdraw()
bg_image = Image.open("background.png")
image_width, image_height = bg_image.size
ratio = max(window_width / image_width, window_height / image_height)
new_size = (int(image_width * ratio), int(image_height * ratio))
bg_image = bg_image.resize(new_size, Image.Resampling.BILINEAR)
bg_photo = ImageTk.PhotoImage(bg_image)
# create bg label
bg_label = tk.Label(search_root, image = bg_photo)
bg_label.place(x = 0, y = 0, relwidth = 1, relheight= 1)
# add code for search page
# zeromq context and socket
context = zmq.Context()
socket = context.socket(zmq.PAIR)
socket.bind("tcp://*:5555")
while True:
message = socket.recv()
if message == b"open_search":
show_search_page()
break
elif message != b"open_search":
pass
search_root.mainloop()
socket.close()
if __name__ == "__main__":
main()