Форум сайта python.su
Не могу понять как вывести файл во фрейм. Скрин программы вкладываю.
from tkinter import* from tkinter import ttk from tkinter.filedialog import* import sys def Quit(ev): global root root.destroy() def OpenFile(ev): name = askopenfilename(filetypes =(("Текст", "*.txt"),("All Files","*.*")),title = "Открытие файла...") print(name) try: with open(name,'r') as UseFile: textFrame=print(UseFile.read()) except: print("No file exists") root=Tk() textFrame = Frame(root,height = 10, width = 60) textFrame.pack(side = 'top', expand = False) textbox = Text(textFrame, font='Arial 14', wrap='word') textbox.pack(side = 'left',expand = False) label = ttk.Label(root,width=650,text =" Откройте файл, который хотите просмотреть",foreground="black",background="light blue",font=("Helvetica", 16)) label.pack() panelFrame=Frame(root,height=100,bg='gray') panelFrame.pack(side='top',fill='x',expand=True) root["bg"] = "grey" root.state("zoomed") label = ttk.Label(root,width=600,text ="",foreground="black",background="light blue",font=("Helvetica", 16)) label.pack() Title = root.title( "Просмотрщик документов") loadBtn=Button(panelFrame,text='Завантаження') quitBtn=Button(panelFrame,text='Вихід') loadBtn.bind("<Button-1>",OpenFile) quitBtn.bind("<Button-1>",Quit) loadBtn.place(x=10,y=10,width=90,height=90) quitBtn.place(x=1270,y=10,width=90,height=90) root.mainloop()
Отредактировано Artemkadollar (Окт. 22, 2017 23:21:19)
Прикреплённый файлы: 123123.jpg (67,4 KБ)
Офлайн
вот это что?
textFrame=print(UseFile.read())
textbox.insert(END,UseFile.read())
[code python][/code]
Отредактировано PEHDOM (Окт. 23, 2017 10:22:25)
Офлайн
Спасибо огромное!)
Офлайн