about.py 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import tkinter as tk
  2. from PIL import Image, ImageTk
  3. import webbrowser
  4. from utils.tools import resource_path
  5. class AboutUI:
  6. def init_ui(self, root=None, version=None):
  7. about_window = tk.Toplevel(root)
  8. about_window.title("关于")
  9. about_window_width = 430
  10. about_window_height = 480
  11. version_frame = tk.Frame(about_window)
  12. version_frame.pack(side=tk.TOP, fill=tk.X)
  13. version_label = tk.Label(version_frame, text=f"版本: {version}")
  14. version_label.pack()
  15. author_row = tk.Frame(about_window)
  16. author_row.pack()
  17. author_row_column1 = tk.Frame(author_row)
  18. author_row_column1.pack(side=tk.LEFT, fill=tk.Y)
  19. author_row_column2 = tk.Frame(author_row)
  20. author_row_column2.pack(side=tk.RIGHT, fill=tk.Y)
  21. author_label = tk.Label(author_row_column1, text="作者:")
  22. author_label.pack()
  23. author_name = tk.Label(
  24. author_row_column2, text="Govin", fg="blue", cursor="hand2"
  25. )
  26. author_name.pack()
  27. author_name.bind(
  28. "<Button-1>",
  29. lambda e: webbrowser.open_new_tab("https://github.com/Guovin"),
  30. )
  31. project_row = tk.Frame(about_window)
  32. project_row.pack()
  33. project_row_column1 = tk.Frame(project_row)
  34. project_row_column1.pack(side=tk.LEFT, fill=tk.Y)
  35. project_row_column2 = tk.Frame(project_row)
  36. project_row_column2.pack(side=tk.RIGHT, fill=tk.Y)
  37. project_label = tk.Label(project_row_column1, text="项目地址:")
  38. project_label.pack()
  39. project_link = tk.Label(
  40. project_row_column2,
  41. text="https://github.com/Guovin/iptv-api",
  42. fg="blue",
  43. cursor="hand2",
  44. )
  45. project_link.pack()
  46. project_link.bind(
  47. "<Button-1>",
  48. lambda e: webbrowser.open_new_tab("https://github.com/Guovin/iptv-api"),
  49. )
  50. disclaimer_label = tk.Label(
  51. version_frame,
  52. text="本软件仅供学习交流用途,数据均来源于互联网,禁止商业行为,一切法律责任与作者无关。",
  53. wraplength=265,
  54. )
  55. disclaimer_label.pack()
  56. image = Image.open(resource_path("static/images/alipay.jpg"))
  57. resized_image = image.resize((250, 300))
  58. photo = ImageTk.PhotoImage(resized_image)
  59. image_label = tk.Label(about_window, image=photo)
  60. image_label.image = photo
  61. image_label.pack()
  62. appreciate_label = tk.Label(
  63. about_window, text="开发维护不易,请我喝杯咖啡☕️吧~"
  64. )
  65. appreciate_label.pack()
  66. confirm_button = tk.ttk.Button(
  67. about_window, text="确定", command=about_window.destroy
  68. )
  69. confirm_button.pack(side=tk.RIGHT, padx=5)
  70. main_width = root.winfo_width()
  71. main_height = root.winfo_height()
  72. main_x = root.winfo_x()
  73. main_y = root.winfo_y()
  74. pos_x = main_x + (main_width // 2) - (about_window_width // 2)
  75. pos_y = main_y + (main_height // 2) - (about_window_height // 2)
  76. about_window.geometry(
  77. f"{about_window_width}x{about_window_height}+{pos_x}+{pos_y}"
  78. )
  79. about_window.iconbitmap(resource_path("static/images/favicon.ico"))