最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

修改傻瓜閱讀軟件,顯示讀書內(nèi)容(I)

2020-03-29 11:46 作者:一心想當(dāng)網(wǎng)紅的李老師  | 我要投稿

修改了上次的傻瓜閱讀軟件。

import importlib,sys

importlib.reload(sys)


import tkinter

from tkinter.filedialog import askopenfilename

from docx import Document

from docx.shared import Inches

import pyttsx3

from tkinter import *

from tkinter import ttk

import os



l=[]

def openfile():

? ? global file_path

? ? file_path=askopenfilename() ??

? ? if os.path.splitext(str(file_path))[1]=='.txt': ?###對于TXT文件的處理

? ? ? ? f=open(file_path,encoding='utf-8')

? ? ? ? fread=f.read()

? ? ? ? f=str(fread)

? ? ? ? text.insert(END,f)

? ? ? ? engine=pyttsx3.init()

? ? ? ? engine.say(f)

? ? ? ? engine.runAndWait()

? ? elif os.path.splitext(str(file_path))[1]=='.docx': ###對于WORD文件處理

? ? ? ? f=Document(file_path)

? ? ? ? for para in f.paragraphs:

? ? ? ? ? ? l.append(para.text)

? ? ? ? text.insert(END,str(l))

? ? ? ? engine=pyttsx3.init()

? ? ? ? engine.say(str(l))

? ? ? ? engine.runAndWait()



if __name__=='__main__':

? ? root=Tk()

? ? root.title('讀書軟件')

? ? root.geometry("720x480")

? ? root.configure(bg="white")

? ? Button1=tkinter.Button(root, text ="選擇文件", command = openfile)

? ? Button1.grid(row=0,column=0,padx=20,pady=20)

? ? text=tkinter.Text(root,bg="yellow")

? ? text.grid(row=0,column=1,padx=20,pady=20) ??

? ? root.mainloop()


修改傻瓜閱讀軟件,顯示讀書內(nèi)容(I)的評論 (共 條)

分享到微博請遵守國家法律
安顺市| 永靖县| 中江县| 巨鹿县| 廊坊市| 安陆市| 定兴县| 太原市| 宁夏| 紫云| 久治县| 东阿县| 荃湾区| 望城县| 天台县| 金乡县| 同江市| 文山县| 古浪县| 丁青县| 洛隆县| 清流县| 海晏县| 乌拉特中旗| 颍上县| 巴林左旗| 丁青县| 张北县| 屯留县| 昭通市| 乐陵市| 临沭县| 宣汉县| 邢台县| 阿勒泰市| 盐源县| 福鼎市| 满洲里市| 鹿邑县| 高雄县| 定日县|