首页 > 解决方案 > 用于文本摘要的 tkinter

问题描述

我正在尝试制作一个简单的文本摘要 GUI,它接受输入文本并生成摘要。虽然程序运行得很好,但在将其转换为 exe 文件时出现错误。以下是 GUI 界面的两个主要程序 -

import tkinter
import gensim
from tkinter import 
from gensim.summarization import summarize

#create windows object
root=Tk()
root.geometry("1024x800") #set the window size using .geometry command
root.title("AUTOMATED TEXT SUMMARIZER")
h1=Label(root,text="AUTOMATED TEXT SUMMARIZER FOR ENGLISH",font= 
("arial",12,"bold"),fg="#26482B").pack()

#set the label, like 'enter text'  
l1 = Label(root,text="Enter Some Text", font= 
("arial",10,"bold"),fg="#26482B").place(x=10,y=50)
#take some text as input in the textbox
inp = Text(root,width=100,height=30,bg="white",font=("arial",8,"bold"))
inp.place(x=10,y=90)
#set another label that indicates the results
l2 = Label(root,text="Summary", font= 
("arial",10,"bold"),fg="#26482B").place(x=720,y=50)


opt = Text(root,width=50,height=20,bg="white",font=("arial",10,"bold"))
opt.place(x=640,y=90)

def sum():
    txt = inp.get("1.0", END)
    output = summarize(txt, ratio=0.2)
    opt.insert(0.0, output)

        button_a = Button(root,text="Generate 
         Summary",width=30,height=2,bg="#9B9D9C",fg="black",font= 
    ("arial",9,"bold"),command=sum)
 button_a.place(x=120,y=600)

def clear():
    inp.delete("1.0",END)
    opt.delete("1.0",END)

button_b= 
Button(root,text="Clear",width=18,height=2,bg="#9B9D9C",fg="black",font= 
("arial",9,"bold"),command=clear)
button_b.place(x=450,y=600)


root.mainloop()

这是 setup_file.py-

import os
import cx_Freeze
from cx_Freeze import setup, Executable
import sys


os.environ['TCL_LIBRARY'] = "C:/LOCAL_TO_PYTHON/PYTHON35-32/tcl/tcl86t.dll"
os.environ['TK_LIBRARY'] = "C:/LOCAL_TO_PYTHON/PYTHON35-32/tcl/tk86t.dll"

includefiles = ['C:/Users/praty/AppData/Local/Programs/Python/Python36- 
32/DLLs/tcl86t.dll','C:/Users/praty/AppData/Local/Programs/Python/Python36- 
32/DLLs/tk86t.dll']
includes = []
packages = ['tkinter','gensim']
additional_mods = ['numpy.core._methods', 'numpy.lib.format']
build_exe_options = 
{'includes':includes,'includes':additional_mods,'packages':packages, 
'include_files':includefiles}

base = None

if sys.platform == 'win32':
    base = "Win32GUI"
elif sys.platform == 'win64':
    base = 'Win64GUI'

setup(  name = 'text summarizer',
        version = '0.1',
        description = 'generate summary',
        options = {'build_exe': build_exe_options},
        executables = [Executable('Automated_Text_Summarizer.py', base=base)]
        )

这是我得到的错误:

这是与程序有关的错误

标签: pythonuser-interfacetkinternlppycharm

解决方案


推荐阅读