On 4/19/08, Nathan <[EMAIL PROTECTED]> wrote:
>
> On Fri, Apr 18, 2008 at 5:10 PM, Alex Holkner <[EMAIL PROTECTED]> wrote:
> >
> > On 4/19/08, Nathan <[EMAIL PROTECTED]> wrote:
> > >
> > > Here's my first attempt at transitioning to the IncrementalTextLayout
> > > class. It's quite a bit more complicated than the Label.
> > >
> > > I'm creating the IncrementalTextLayout like this:
> > >
> > > self.log_layout = pyglet.text.layout.IncrementalTextLayout(
> > > pyglet.text.document.UnformattedDocument(""),
> > > dpi=72,
> > > multiline=True,
> > > width=100*self.col_spacing,
> > > height=40*self.row_spacing)
> > >
> > > with these values for the variables:
> > >
> > > self.log_font = pyglet.font.load('Monaco',12,dpi=72)
> > > self.col_spacing = pyglet.font.Text(self.font, 'a').width
> > > self.row_spacing = self.log_font.ascent - self.log_font.descent +
> self.leading
> > >
> > > and then I call this function to add the first line to the layout:
> > >
> > > def add_event(self, msg):
> > > prefix = time.strftime("%b %d %H:%M:%S ")
> > > self.log_layout.begin_update()
> > > for line in msg.split('\n'):
> > > self.log_layout.document.insert_text(-1, prefix+line)
> > > prefix = ""
> > > self.log_layout.end_update()
> >
> > Without reading the rest too closely, I'm going to just jump in and
> > guess the problem is that your insertion point is -1 (it doesn't
> > behave like a Python slice).
>
>
> Oh, well how do I specify "the end" then? I actually opened up the
> source and skimmed and it looked like it _was_ being used sort of like
> a slice, which is why I tried that.
len(log_layout.document.text)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---