Вот код:
Код:
#!/usr/bin/python
# -*- coding: utf8 -*-
import os, re
from Tkinter import *
class ManReader:
def getman(self, manpage, sn):
bschar='\b'
Auto = 3
tmp = os.popen('man %s %s 2>/dev/null' % (sn, manpage)).read()
if tmp:
tmp = re.sub(r'(.)%c\1' % bschar, r'\1', tmp)
tmp = tmp.replace('_%c' % bschar, '')
else:
tmp = 'Pages "%s" in sections "%c" not found' % (manpage, sn or Auto)
return tmp
def pressBtn(self):
sn = sectno.get()[0]
if sn == '-': sn = ''
tx.delete = (1.0, END)
tx.insert = (1.0, self.getman(ent.get(), sn))
#tx.insert = (1.0, 'Test')
def DrawFace(self):
global tx, ent, sectno
win = Tk()
win.title('Переглядач man-сторінок')
sectno = StringVar()
sectno.set('---Auto---')
fcmd = Frame(win)
fcmd.pack(side=TOP, fill=X)
lbl1 = Label(fcmd, text='Read about')
lbl1.pack(side=LEFT)
ent = Entry(fcmd)
ent.bind('<Return>', (lambda event: self.pressBtn()))
ent.pack(side=LEFT)
lbl2 = Label(fcmd, text='is section ')
lbl2.pack(side=LEFT)
slt = OptionMenu(fcmd, sectno,
'---Auto---',
'1 User Utilities',
'2 System Calls',
'3 Library Functions',
'4 Devices & Kernel'
'5 File Formats',
'6 Games',
'7 Macros & SQL Commands',
'8 System Utilities',
'9 X Window',
'n Built-In commands',
)
slt.pack(side=LEFT)
btn1 = Button(fcmd, command=win.quit, text='Quit')
btn1.pack(side=RIGHT)
btn2 = Button(fcmd, command=self.pressBtn, text='Open')
btn2.pack(side=RIGHT)
fview = Frame(win)
fview.pack(side=BOTTOM, fill=BOTH, expand=YES)
sb = Scrollbar(fview)
tx = Text(fview, relief=SUNKEN)
sb.config(command=tx.yview)
tx.config(yscrollcommand=sb.set)
sb.pack(side=RIGHT, fill=Y)
tx.pack(side=TOP, expand=YES, fill=BOTH)
tx.pack(expand=YES, fill=BOTH)
tx.focus_get()
tx.insert = (END, 'Test')
win.mainloop()
if __name__ == '__main__':
test = ManReader()
test.DrawFace()Окно рисуется, но текстовое поле не получает данные
( tx.insert = (1.0, self.getman(ent.get(), sn)) )
Где я накосячил??