Re: odd error message
- From: muppet <scott asofyet org>
- To: Zane C.B. <v velox vvelox net>
- Cc: gtk2-perl List <gtk-perl-list gnome org>
- Subject: Re: odd error message
- Date: Tue, 1 Jul 2008 21:12:27 -0400
On Jul 1, 2008, at 8:37 PM, Zane C.B. wrote:
Just writing a small program to and I need to pass multiple objects
to a function being ran by a signal, but I am currently running into a
small issue.
I am expecting the code snippet below to print out the first 3
characters of the text view, but it prints out the error below. Line
74 is 'my $text=$buffer->get_text(0, 3, 1);'.
The first two arguments of Gtk2::TextBuffer::get_text() are supposed
to be Gtk2::TextIter objects -- that is, blessed references. You're
passing integers.
http://gtk2-perl.sourceforge.net/doc/pod/Gtk2/TextBuffer.html#string_buffer_get_te
Iters are objects that move around by various rules of text encoding,
language rules, etc. To get the first three chars, you could do
something like this:
my $buffer = $textview->get_buffer ();
# get bounds will give you both begin and end. we only need begin.
my ($begin, $end) = $buffer->get_bounds ();
# now we want an iter that is three characters in. start with a
copy of begin...
my $last = $begin->copy;
# and advance it.
$last->forward_chars (3);
# now you can get the text.
my $string = $buffer->get_text ($begin, $last, 1);
Or, if you don't mind slinging around the whole contents of the buffer
(maybe you know it's small):
# get it all
my $text = $buffer->get_text ($buffer->get_bounds (), 1);
my $first_three = substr $text, 0, 3;
*** unhandled exception in callback:
*** expected a blessed reference at gzccrontab.pl line 74.
*** ignoring at gzccrontab.pl line 165.
Unfortunately, the code that does the argument checking doesn't really
know which argument it needs to complain about or what that variable
name is. Sorry.
--
me, while driving the car: Okay, girls, what do you want for lunch?
yvonne: I wan' noo-tulls!
zella: I want lavaloli! Can we go to the lavaloli store?
me: Um, where *is* the ravioli store?
zella: At the lavaloli store!
yvonne: I want noo-tulls! Let's go to the noo-tull store!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]