问题遇到的现象和发生背景
需要构建一个小程序用于pdf文件模糊搜索,搜到的结果合并成一个pdf文件。
窗的左边做搜索以及项目复选框(用户可直接勾选),勾选/搜索出的结果在窗的右边直接生成pdf合并版文件,用户可直接下载。
问题相关代码,请勿粘贴截图
代码请见下方
运行结果及报错内容
目前运行结果为小程序窗口的弹出,左侧内容设计了几个项目类别及复选框,尚未实现用户可直接勾选触发后续操作。
我的解答思路和尝试过的方法
使用tkinter designer直接生成了小程序布局的代码。
我想要达到的结果
用户点击左侧窗口的项目类别可直接查看相关文件分类,右侧窗口能够生成用户所选中pdf文件的合并版并可直接下载。
import tkinter as tk
import tkinter.font as tkFont
class App:
def __init__(self, root):
# setting title
root.title("dbzhny")
# setting window size
width = 1400
height = 800
screenwidth = root.winfo_screenwidth()
screenheight = root.winfo_screenheight()
alignstr = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
root.geometry(alignstr)
root.resizable(width=False, height=False)
GCheckBox_309 = tk.Checkbutton(root)
ft = tkFont.Font(family='Times', size=16)
GCheckBox_309["font"] = ft
GCheckBox_309["fg"] = "#333333"
GCheckBox_309["justify"] = "left"
GCheckBox_309["text"] = "其他"
GCheckBox_309.place(x=45, y=65, width=80, height=52)
GCheckBox_309["offvalue"] = "0"
GCheckBox_309["onvalue"] = "1"
GCheckBox_309["command"] = self.GCheckBox_309_command
GCheckBox_125 = tk.Checkbutton(root)
ft = tkFont.Font(family='Times', size=16)
GCheckBox_125["font"] = ft
GCheckBox_125["fg"] = "#333333"
GCheckBox_125["justify"] = "left"
GCheckBox_125["text"] = "双碳"
GCheckBox_125.place(x=45, y=115, width=80, height=52)
GCheckBox_125["offvalue"] = "0"
GCheckBox_125["onvalue"] = "1"
GCheckBox_125["command"] = self.GCheckBox_125_command
GCheckBox_150 = tk.Checkbutton(root)
ft = tkFont.Font(family='Times', size=16)
GCheckBox_150["font"] = ft
GCheckBox_150["fg"] = "#333333"
GCheckBox_150["justify"] = "left"
GCheckBox_150["text"] = "新能源并网"
GCheckBox_150.place(x=45, y=165, width=143, height=52)
GCheckBox_150["offvalue"] = "0"
GCheckBox_150["onvalue"] = "1"
GCheckBox_150["command"] = self.GCheckBox_150_command
GCheckBox_77 = tk.Checkbutton(root)
ft = tkFont.Font(family='Times', size=16)
GCheckBox_77["font"] = ft
GCheckBox_77["fg"] = "#333333"
GCheckBox_77["justify"] = "left"
GCheckBox_77["text"] = "人工智能"
GCheckBox_77.place(x=45, y=215, width=123, height=52)
GCheckBox_77["offvalue"] = "0"
GCheckBox_77["onvalue"] = "1"
GCheckBox_77["command"] = self.GCheckBox_77_command
GCheckBox_13 = tk.Checkbutton(root)
ft = tkFont.Font(family='Times', size=16)
GCheckBox_13["font"] = ft
GCheckBox_13["fg"] = "#333333"
GCheckBox_13["justify"] = "left"
GCheckBox_13["text"] = "信息通信"
GCheckBox_13.place(x=45, y=265, width=123, height=52)
GCheckBox_13["offvalue"] = "0"
GCheckBox_13["onvalue"] = "1"
GCheckBox_13["command"] = self.GCheckBox_13_command
GCheckBox_174 = tk.Checkbutton(root)
ft = tkFont.Font(family='Times', size=16)
GCheckBox_174["font"] = ft
GCheckBox_174["fg"] = "#333333"
GCheckBox_174["justify"] = "left"
GCheckBox_174["text"] = "大电网分析"
GCheckBox_174.place(x=45, y=315, width=143, height=52)
GCheckBox_174["offvalue"] = "0"
GCheckBox_174["onvalue"] = "1"
GCheckBox_174["command"] = self.GCheckBox_174_command
GCheckBox_422 = tk.Checkbutton(root)
ft = tkFont.Font(family='Times', size=16)
GCheckBox_422["font"] = ft
GCheckBox_422["fg"] = "#333333"
GCheckBox_422["justify"] = "left"
GCheckBox_422["text"] = "网络安全"
GCheckBox_422.place(x=45, y=365, width=123, height=52)
GCheckBox_422["offvalue"] = "0"
GCheckBox_422["onvalue"] = "1"
GCheckBox_422["command"] = self.GCheckBox_422_command
GCheckBox_142 = tk.Checkbutton(root)
ft = tkFont.Font(family='Times', size=16)
GCheckBox_142["font"] = ft
GCheckBox_142["fg"] = "#333333"
GCheckBox_142["justify"] = "left"
GCheckBox_142["text"] = "项目07"
GCheckBox_142.place(x=45, y=415, width=104, height=52)
GCheckBox_142["offvalue"] = "0"
GCheckBox_142["onvalue"] = "1"
GCheckBox_142["command"] = self.GCheckBox_142_command
GCheckBox_317 = tk.Checkbutton(root)
ft = tkFont.Font(family='Times', size=16)
GCheckBox_317["font"] = ft
GCheckBox_317["fg"] = "#333333"
GCheckBox_317["justify"] = "left"
GCheckBox_317["text"] = "项目08"
GCheckBox_317.place(x=45, y=465, width=104, height=52)
GCheckBox_317["offvalue"] = "0"
GCheckBox_317["onvalue"] = "1"
GCheckBox_317["command"] = self.GCheckBox_317_command
GCheckBox_160 = tk.Checkbutton(root)
ft = tkFont.Font(family='Times', size=16)
GCheckBox_160["font"] = ft
GCheckBox_160["fg"] = "#333333"
GCheckBox_160["justify"] = "left"
GCheckBox_160["text"] = "项目09"
GCheckBox_160.place(x=45, y=515, width=104, height=52)
GCheckBox_160["offvalue"] = "0"
GCheckBox_160["onvalue"] = "1"
GCheckBox_160["command"] = self.GCheckBox_160_command
GLineEdit_165 = tk.Entry(root)
GLineEdit_165["borderwidth"] = "1px"
ft = tkFont.Font(family='Times', size=16)
GLineEdit_165["font"] = ft
GLineEdit_165["fg"] = "#333333"
GLineEdit_165["justify"] = "center"
GLineEdit_165["text"] = "输入关键字进行过滤"
GLineEdit_165.place(x=30, y=20, width=240, height=40)
def GCheckBox_309_command(self):
print("command")
def GCheckBox_125_command(self):
print("command")
def GCheckBox_150_command(self):
print("command")
def GCheckBox_77_command(self):
print("command")
def GCheckBox_13_command(self):
print("command")
def GCheckBox_174_command(self):
print("command")
def GCheckBox_422_command(self):
print("command")
def GCheckBox_142_command(self):
print("command")
def GCheckBox_317_command(self):
print("command")
def GCheckBox_160_command(self):
print("command")
if __name__ == "__main__":
root = tk.Tk()
app = App(root)
root.mainloop()