|
|
import tkinter as tk
|
|
|
from tkinter import ttk
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
from controller.UIController import UIController
|
|
|
from entity.BilibiliVideo import BilibiliVideo
|
|
|
|
|
|
|
|
|
class TestUIController:
|
|
|
@pytest.mark.skip(reason="函数会展开UI窗口,请手动测试。")
|
|
|
def test_main(self):
|
|
|
UI = UIController()
|
|
|
##测试数据
|
|
|
data1 = BilibiliVideo(2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
|
|
|
data2 = BilibiliVideo(2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
|
|
|
text_date = [data1, data2]
|
|
|
UI.scRuslt_data=text_date
|
|
|
UI.main()
|
|
|
# # 创建主窗口
|
|
|
# root = tk.Tk()
|
|
|
# root.title("带表格的UI界面")
|
|
|
#
|
|
|
# # 使用grid布局定义按钮和输入框
|
|
|
# button1 = tk.Button(root, text="按钮1")
|
|
|
# button1.grid(row=0, column=0, padx=10, pady=10)
|
|
|
#
|
|
|
# button2 = tk.Button(root, text="按钮2")
|
|
|
# button2.grid(row=0, column=1, padx=10, pady=10)
|
|
|
#
|
|
|
# entry1 = tk.Entry(root)
|
|
|
# entry1.grid(row=1, column=0, padx=10, pady=10)
|
|
|
#
|
|
|
# entry2 = tk.Entry(root)
|
|
|
# entry2.grid(row=1, column=1, padx=10, pady=10)
|
|
|
#
|
|
|
# # 创建表格
|
|
|
# tree = ttk.Treeview(root, columns=('数据1', '数据2', '数据3'), show='headings')
|
|
|
# tree.heading('数据1', text='列1')
|
|
|
# tree.heading('数据2', text='列2')
|
|
|
# tree.heading('数据3', text='列3')
|
|
|
# tree.grid(row=2, column=0, columnspan=2, sticky='nsew')
|
|
|
#
|
|
|
# # 添加滚动条
|
|
|
# scrollbar_x = tk.Scrollbar(root, orient='horizontal', command=tree.xview)
|
|
|
# scrollbar_x.grid(row=3, column=0, columnspan=2, sticky='ew')
|
|
|
# tree.configure(xscrollcommand=scrollbar_x.set)
|
|
|
#
|
|
|
# scrollbar_y = tk.Scrollbar(root, orient='vertical', command=tree.yview)
|
|
|
# scrollbar_y.grid(row=2, column=2, sticky='ns')
|
|
|
# tree.configure(yscrollcommand=scrollbar_y.set)
|
|
|
#
|
|
|
# # 配置grid布局随窗口大小调整
|
|
|
# root.grid_rowconfigure(2, weight=1)
|
|
|
# root.grid_columnconfigure(1, weight=1)
|
|
|
#
|
|
|
# # 启动Tkinter事件循环
|
|
|
# root.mainloop()
|