scrollbar
zyziu
zyziu at interia.pl
Thu Apr 17 05:51:15 EDT 2003
----- Original Message -----
From: "Lee Harr" <missive at frontiernet.net>
Newsgroups: comp.lang.python
Sent: Thursday, April 17, 2003 1:22 AM
Subject: Re: scrollbar
> In article <b7kh3g$51u$1 at nemesis.news.tpi.pl>, zyziu wrote:
> > Hello. I made lanChat in Python. I have problem with Text widget. I want
to
> > text from Entry goes to Text widget and scrollbar goes down, because I
can't
> > see what write another user. Now I must do it manually. How do it to
> > scrollbar goes down automatically? Thanks for answer. Zyziu from Poland.
> >
> >
>
> You should probably be a little bit more specific, and maybe include
> some of the code around where you are having the problem.
>
> That said, if this is Tkinter, maybe something here will help:
>
>
> self.wout = Tkinter.Tk()
> self.frame = Tkinter.Frame(self.wout, bg='brown')
>
>
> self.frame.sc = Tkinter.Scrollbar(self.frame,
orient=Tkinter.VERTICAL)
>
> self.frame.tout = Tkinter.Text(self.frame,
yscroll=self.frame.sc.set,
> bg='black', fg='white')
>
> self.frame.sc['command'] = self.frame.tout.yview
> self.frame.sc.pack(side='right', fill='y')
>
>
> t = self.c.read_eager().replace('\r','')
>
> if t:
> self.w.frame.tout.config(state='normal')
> self.w.frame.tout.insert(Tkinter.END, t)
> self.w.frame.tout.config(state='disabled')
> self.w.frame.tout.yview(Tkinter.END)
>
>
>
>
> This is just bits and pieces of a file I wrote a couple of years ago...
> I remember having trouble with the same thing. Hope this helps.
>
>
Oops! Sorry. I use Python 2.2.2 with Idle 0.8. You wrote:
t = self.c.read_eager().replace('\r','')
What is 'c'? Is it scrollbar? Is 't' read position of scrollbar? Look at my
code and tell me where I must put it into my code. Please correct my code
and send me back if you can, please. Thanks. Zyziu from Poland.
# Tkinter
from Tkinter import *
from time import *
import string
class App(Frame):
def __init__(self, master=None):
Frame.__init__(self,master)
self.master.title('Zyziu123 wzywa')
self.grid(row=2, column=2)
self.konstrukcja() #wywolanie funkcji
def konstrukcja(self):
self.scrollbar = Scrollbar(self, orient=VERTICAL)
self.okno = Text(self, yscrollcommand=self.scrollbar.set)
self.scrollbar.config(command=self.okno.yview)
self.scrollbar.grid(row=0, column=2,sticky=S+N+W+E)
self.okno.grid(row=0,column=0,columnspan=2)
self.tekst=Entry(self)
self.tekst.grid(row=1,column=0,columnspan=3,sticky=W+E)
self.guzik=Button(self, text='send', command=self.Pisz)
self.guzik.grid(row=1,column=3,sticky=E)
def Pisz(self):
self.dane = self.tekst.get()
self.tekst.delete(0,'end')
if (self.dane<>''):
self.okno.insert('end',strftime("%H:%M:%S")+'\n')
self.okno.insert('end',self.dane+'\n'+'\n')
ap = App()
ap = mainloop()
More information about the Python-list
mailing list