Re: Fwd: bug on TextBuffer and TextView
- From: Mario Kemper <mario kemper googlemail com>
- To: gtk-perl-list gnome org
- Subject: Re: Fwd: bug on TextBuffer and TextView
- Date: Mon, 19 Jan 2009 16:22:16 +0100
Here is a simple example that works (I've used most of your code
snippet).
Maybe it would be useful to attach an example that shows the
misbehaviour you've described.
-------------------Example-----------------------------------
#! /usr/bin/perl -w
use Gtk2 '-init';
my $window = Gtk2::Window->new('toplevel');
my $view = Gtk2::TextView->new();
my $buffer = $view->get_buffer();
$view->set_size_request(200,200);
$view->set_editable (FALSE);
our $textmark = $buffer->create_mark('end_mark',
$buffer->get_end_iter,FALSE);
my $scrolls = Gtk2::ScrolledWindow->new();
$scrolls->set_policy('automatic','always');
$scrolls->set_shadow_type('in');
$scrolls->add ($view);
my $button = Gtk2::Button->new('Insert text');
$button->signal_connect('clicked' => sub{
#printing the output on textview
my $text_tag = $buffer->create_tag(undef,'font',"Sans Italic
12",'foreground','#680000');
$buffer->insert_with_tags($buffer->get_end_iter,"<Test>\n",$text_tag);
$buffer->insert ($buffer->get_end_iter,'Another little test');
$view->scroll_mark_onscreen($textmark);
});
my $vbox = Gtk2::VBox->new(0, 0);
$vbox->pack_start_defaults($scrolls);
$vbox->pack_start ($button, 0, 0, 0);
$window->add($vbox);
$window->show_all;
Gtk2->main;
0;
-------------------Example-----------------------------------
Greetings
Mario
Am Montag, den 19.01.2009, 16:53 +0200 schrieb Dafna Hirschfeld:
---------- Forwarded message ----------
From: Dafna Hirschfeld <dafna3 gmail com>
Date: Mon, Jan 19, 2009 at 4:51 PM
Subject: Re: bug on TextBuffer and TextView
To: Emmanuel Rodriguez <emmanuel rodriguez gmail com>
the code is very simple, copied from the tutorials of gtk
in one place of the program I declare the textView and the associated
buffer:
my $view = Gtk2::TextView->new();
my $buffer = $view->get_buffer();
$view->set_size_request(850,500);
$view->set_editable (FALSE);
our $textmark = $buffer->create_mark('end_mark',
$buffer->get_end_iter,FALSE);
my $scrolls = Gtk2::ScrolledWindow->new();
$scrolls->set_policy('automatic','always');
$scrolls->set_shadow_type('in');
$scrolls->add ($view);
on a function that run according to a specific button click I insert
the text:
#printing the output on textview
my $text_tag = $buffer->create_tag(undef,'font',"Sans Italic
12",'foreground','#680000');
$buffer->insert_with_tags($buffer->get_end_iter,"<$command_num>\n",
$text_tag);
$buffer->insert ($buffer->get_end_iter,$out);
$view->scroll_mark_onscreen($textmark);
On Mon, Jan 19, 2009 at 12:34 PM, Emmanuel Rodriguez
<emmanuel rodriguez gmail com> wrote:
2009/1/19 Dafna Hirschfeld <dafna3 gmail com>:
> I have a textView with a textBuffer associated with it.
>
> When I start running my program and insert text to the
buffer, it doesn't
> appear on the textView, only after I click the textView with
the mouse or
> add another text, it appears.
That's a strange behaviour.
>
> I don't know why is it, maybe its a problem of the
buffering, I thought
> maybe there is a flush function, to flush the buffer to the
view but I
> didn't find one, does anyone can help me?
Could you share some code?
Emmanuel
_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]