88 lines
3.2 KiB
Python
88 lines
3.2 KiB
Python
"""
|
|
高级样式编辑器使用演示
|
|
"""
|
|
import tkinter as tk
|
|
from tkinter import ttk
|
|
from advanced_style_editor import open_advanced_editor
|
|
from style_manager import style_manager
|
|
|
|
def demo_advanced_editor():
|
|
"""演示高级样式编辑器的使用"""
|
|
print("=== 高级样式编辑器使用演示 ===")
|
|
|
|
# 创建主窗口
|
|
root = tk.Tk()
|
|
root.title("高级样式编辑器演示")
|
|
root.geometry("400x300")
|
|
|
|
# 说明标签
|
|
info_label = tk.Label(root, text="高级样式编辑器演示\n\n点击下面的按钮打开高级编辑器\n进行样式设计和保存",
|
|
font=("微软雅黑", 12), justify='center')
|
|
info_label.pack(pady=20)
|
|
|
|
# 样式选择
|
|
style_frame = ttk.Frame(root)
|
|
style_frame.pack(pady=10)
|
|
|
|
ttk.Label(style_frame, text="选择基础样式:").pack(side='left')
|
|
style_var = tk.StringVar(value="爆款文章风格")
|
|
style_combo = ttk.Combobox(style_frame, textvariable=style_var,
|
|
values=style_manager.get_style_names(),
|
|
state='readonly', width=20)
|
|
style_combo.pack(side='left', padx=10)
|
|
|
|
def open_editor():
|
|
"""打开高级编辑器"""
|
|
selected_style = style_var.get()
|
|
if selected_style:
|
|
try:
|
|
print(f"打开高级编辑器 - 基础样式: {selected_style}")
|
|
editor = open_advanced_editor(root, selected_style)
|
|
if editor:
|
|
print("高级编辑器打开成功!")
|
|
print("您现在可以:")
|
|
print("1. 修改字体、颜色、大小等属性")
|
|
print("2. 调整段落行距、缩进等设置")
|
|
print("3. 自定义1-3级标题样式")
|
|
print("4. 在右侧实时预览效果")
|
|
print("5. 保存或另存为新样式")
|
|
else:
|
|
print("高级编辑器打开失败")
|
|
except Exception as e:
|
|
print(f"打开编辑器时出现错误: {e}")
|
|
|
|
# 按钮
|
|
button_frame = ttk.Frame(root)
|
|
button_frame.pack(pady=20)
|
|
|
|
open_button = ttk.Button(button_frame, text="打开高级编辑器", command=open_editor)
|
|
open_button.pack(pady=10)
|
|
|
|
def show_styles():
|
|
"""显示当前所有样式"""
|
|
styles = style_manager.get_style_names()
|
|
print(f"\n当前可用样式(共{len(styles)}个):")
|
|
for i, style_name in enumerate(styles, 1):
|
|
print(f"{i}. {style_name}")
|
|
|
|
list_button = ttk.Button(button_frame, text="查看所有样式", command=show_styles)
|
|
list_button.pack(pady=5)
|
|
|
|
def close_demo():
|
|
"""关闭演示"""
|
|
print("关闭演示")
|
|
root.destroy()
|
|
|
|
close_button = ttk.Button(button_frame, text="关闭演示", command=close_demo)
|
|
close_button.pack(pady=5)
|
|
|
|
print("演示窗口已打开。您可以:")
|
|
print("1. 选择一个基础样式")
|
|
print("2. 点击'打开高级编辑器'进行样式编辑")
|
|
print("3. 在编辑器中修改样式并保存")
|
|
|
|
# 启动主循环
|
|
root.mainloop()
|
|
|
|
if __name__ == '__main__':
|
|
demo_advanced_editor() |