Why is Tkinter for Windows NT much faster?

Ken Kinder kkinder at tridog.com
Fri Aug 25 11:38:45 EDT 2000


The formatting of that file was mangled. Is there anyway you can post it pritty
printed?

yanivk at my-deja.com wrote:

> Hi Richard! First, I really appreciate your help. I added the code to run and
> any comments are welcome. I tried to remove all unnecessary line code to make
> it as easy for you as possible. Best of all, Yaniv Kaplan.
>
> from Tkinter import *
> from ScrolledText import ScrolledText
>
> class form(Frame):
>     def __init__(self, master=None):
>         Frame.__init__(self, master)
>         self.expand_list = []
>         self.text = ScrolledText(self)
>         self.text.pack(fill=BOTH, expand=1)
>         self.pack(fill=BOTH, expand=1)
>
>   def setformulas(self, personss):      text = self.text        pos = 1
>   for first, last, exp in persons:          start = text.index(CURRENT)
> text.insert(END, 'Person number %d. status: ' % (pos,), 't')
> text.insert(END, 'Unknown', ('st%d' % (pos,), 'st'))    if not (pos%2): #Add
> some buttons to simulate real behaviour          text.insert(END, ' '*30)
>            text.window_create(END, window = Button(text, text='Show house'))
>              text.insert(END, '\n')    else:                 text.insert(END,
> '\n')    text.insert(END, 'First name: ', 'en')          text.insert(END,
> first+'\n')    text.insert(END, 'Last name: ', 'su')
> text.insert(END, last+'\n')     l = Label(text, text='+', fg='blue') #chage
> '+' to an arrow bitmap      text.window_create(END, window=l)       exd =
> 'ex%d' % (pos,)           text.insert(END, 'EXPAND:', (exd, 'ex'))
> text.insert(END, '\n', 'exs%d' % (pos,))        text.insert(END, '\n',
> 'exe%d' % (pos,))        text.tag_bind(exd, '<Button-1>', lambda event,
> self=self, text=text, l=l, n=pos: self.showexpand(n, text, l))
> l.bind('<Button-1>', lambda event, self=self, text=text, l=l, n=pos:
> self.showexpand(n, text, l))       self.expand_list.append((exp, NO))
> pos = pos+1     pass  text.tag_bind('ex', '<Enter>', lambda event, text=text:
> text.config(cursor='hand2'))    text.tag_bind('ex', '<Leave>', lambda event,
> text=text: text.config (cursor='right_ptr'))  self.bind_class("Label",
> '<Enter>', lambda event, text=text: text.config (cursor='hand2'))
> self.bind_class("Label", '<Leave>', lambda event, text=text: text.config
> (cursor='right_ptr'))  text.tag_config('st', foreground='red')
> text.tag_config('ex', foreground='blue')        text.tag_config('t',
> foreground='red')  text.tag_config('su', foreground='blue')
> text.tag_config('en', foreground='blue')
>
>     def showexpand(self, person, text, l):
>     #-------------------------------------------
>         exp, opened = self.expand_list[person-1]
>         pos = text.index('exs%d.last' % (person,))
>         if not opened:
>             text.insert(pos, exp+'\n')
>             l.config(text='-')
>         else:
>             text.delete(pos,'exe%d.first' % (person,))
>             l.config(text='+')
>             pass
>         self.expand_list[person-1] = (exp, not opened)
>
> if __name__=='__main__':  f = form()  # create some persons to add to list
> persons = []  for i in range(200):  persons.append( ('first name for person
> number '+`i+1`+'.', 'Last name for person '+`i+1`+'.', 'expand information
> for person '+`i+1`+'.\n This information is viewed after clicking the EXPAND
> text.') )  f.setformulas(persons)  f.mainloop()
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
> --
> http://www.python.org/mailman/listinfo/python-list

--
Ken Kinder
Staff Engineer - Tridog Interactive, Inc.
kkinder at tridog.com
http://www.tridog.com/ - 303-415-2538


-------------- next part --------------
A non-text attachment was scrubbed...
Name: kkinder.vcf
Type: text/x-vcard
Size: 257 bytes
Desc: Card for Ken Kinder
URL: <http://mail.python.org/pipermail/python-list/attachments/20000825/a5cdcfab/attachment.vcf>


More information about the Python-list mailing list