ui_batch_task_detail.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. from tkinter import *
  2. from tkinter.ttk import *
  3. class WinGUIBatchTaskDetail(Tk):
  4. def __init__(self):
  5. super().__init__()
  6. self.__win()
  7. self.tk_label_frame_content = Frame_content(self)
  8. self.tk_label_frame_contact = Frame_contact(self)
  9. def __win(self):
  10. self.title("新建群发任务")
  11. # 设置窗口大小、居中
  12. width = 600
  13. height = 600
  14. screenwidth = self.winfo_screenwidth()
  15. screenheight = self.winfo_screenheight()
  16. geometry = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
  17. self.geometry(geometry)
  18. self.resizable(width=False, height=False)
  19. class Frame_content(LabelFrame):
  20. def __init__(self, parent):
  21. super().__init__(parent)
  22. self.__frame()
  23. self.tk_text_content = self.__tk_text_content()
  24. def __frame(self):
  25. self.configure(text="发送内容")
  26. self.place(x=20, y=10, width=560, height=130)
  27. def __tk_text_content(self):
  28. text = Text(self)
  29. text.place(x=5, y=5, width=550, height=100)
  30. return text
  31. class Frame_contact(LabelFrame):
  32. def __init__(self, parent):
  33. super().__init__(parent)
  34. self.__frame()
  35. self.tk_table_contact_list = self.__tk_table_contact_list()
  36. def __frame(self):
  37. self.configure(text="接收对象")
  38. self.place(x=20, y=150, width=560, height=400)
  39. def __tk_table_contact_list(self):
  40. # 表头字段 表头宽度
  41. columns = {"微信 ID": 112, "类型": 112, "昵称": 112, "发送时间": 112, "发送状态": 112}
  42. # 初始化表格 表格是基于Treeview,tkinter本身没有表格。show="headings" 为隐藏首列。
  43. tk_table = Treeview(self, show="headings", columns=list(columns))
  44. for text, width in columns.items(): # 批量设置列属性
  45. tk_table.heading(text, text=text, anchor='center')
  46. tk_table.column(text, anchor='center', width=width, stretch=False) # stretch 不自动拉伸
  47. # 插入数据示例
  48. # data = [
  49. # [1, "github", "https://github.com/iamxcd/tkinter-helper"],
  50. # [2, "演示地址", "https://www.pytk.net/tkinter-helper"]
  51. # ]
  52. #
  53. # # 导入初始数据
  54. # for values in data:
  55. # tk_table.insert('', END, values=values)
  56. tk_table.place(x=5, y=5, width=550, height=370)
  57. return tk_table