simple pango hebrew program problem. trivial modification of Grobgeld tutorial

2005-11-05 Thread Mitchell Laks

Hi,
I am trying to play with writing a simple gtk2-perl hebrew program. I
I took dov grobgelds simple tutorial example program and I modified it 
trivially. 

Instead of writing hebrew utf8 text directly into the file, I took a hebrew 
text file and read in some text using the idiom
open(IN,"out");
my $string =;
where the file is a file of 3 lines of bible text that I have in utf8 
encoding. The text is easily read using kedit.

and i get this error on command line (however the program runs and displays 
widgets with funny box characters)

[EMAIL PROTECTED]:~/hebrew$ ./perl.pl
Gdk-WARNING **: locale not supported by Xlib at /usr/lib/perl5/Gtk2.pm line 
59.
Gdk-WARNING **: cannot set locale modifiers at /usr/lib/perl5/Gtk2.pm line 59.

The program runs and displays the widgets,  however 
the text that is displayed is funny looking- funny looking boxes with numbers 
in them 
00
93.
surrounded by square box.

I tried the program with either calling 

BEGIN { $ENV{LC_ALL} = "he_IL.utf8"; }
or setting 
BEGIN { $ENV{LC_ALL} = "he_IL"; }

my own environment background is en_US.UTF-8
i also did
export LANG=he_IL.utf8;./perl.pl
and no improvement
i append the sample program and the file i used
Thank you very much for your help!
Mitchell Laks

י ר מ י ה ו
ירמיהו א,א דברי ירמיהו, בן~חלקייהו, 
מן~הכוהנים אשר בענתות, בארץ בנימין.
ירמיהו א,ב אשר היה דבר~יהוה אליו, בימי 
יאשייהו בן~אמון מלך יהודה, בשלוש~עשרה שנה, 
למולכו.
ירמיהו א,ג ויהי, בימי יהויקים בן~יאשייהו מלך 
יהודה, עד~תום עשתי עשרה שנה, לצדקייהו 
בן~יאשייהו מלך יהודה--עד~גלות ירושלים, בחודש 
החמישי.  }פ{


perl.pl
Description: Perl program
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


Re: simple pango hebrew program problem. trivial modification of Grobgeld tutorial

2005-11-05 Thread Mitchell Laks
On Saturday 05 November 2005 10:24 pm, Mitchell Laks wrote:
> Hi,
> I am trying to play with writing a simple gtk2-perl hebrew program. I
> I took dov grobgelds simple tutorial example program and I modified it
> trivially.
>
> Instead of writing hebrew utf8 text directly into the file, I took a hebrew
> text file and read in some text using the idiom
> open(IN,"out");

sorry: I did not understand perl unicode IO.
I modified my code to 

open(IN, ">:utf8","out)
and all was wonderful!

thank you all for a wonderful set of programs and tutorials!
Mitchell
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


can we combile gtk2-perl with gtkmm in an application?

2006-03-25 Thread Mitchell Laks
Hi,

I am designing an open source application to display medical images (MRI and 
CT etc).

I have read about the idea of splitting the functionality so that the core 
user interface issues are controlled via a gui that is designed with a 
scripting language like perl, and thus can be easily customized, while the 
parts of the application such as the opengl window that will deal with the 
display images would be done in C++ for speed. People need to load over 1000 
images at a time and I have had difficulties with java applications being too 
slow for that aspect of the program.

How had is it to make an application with the central Object being gtkmm 
object. 

Ideal would be high level integration with the gtk-perl interface, but I could 
even survive perhaps with sending signals between somewhat "independent" 
applications...

Mitchell
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


Re: can we combile gtk2-perl with gtkmm in an application?

2006-03-26 Thread Mitchell Laks
On Sunday 26 March 2006 02:36, you wrote:

> Surely the lowest level of making the images is fastest done with C or
> perhaps C++, but I guess in this case the speed of disk and network (are
> those images on a network disk?) and amount of memory (are those images
> to be open at the same time?) are important. But in general I think it
> is very sensible to divide the functionality between Perl and C, it
> makes many things much easier.
>
> 'So far I've been looking at only a few images but in near future I
> expect to work with spatio-temporal data and then the number of images
> increases substantially.
>
> > How had is it to make an application with the central Object being gtkmm
> > object.
>
> I'm a bit puzzled with this. I haven't used gtkmm at all, in fact I had
> to look it up now to see what it is. I've been using simple gdk pixbufs,
> which are easy to make and easy to use in GUI (although the memory
> management took a while to learn). Right now I'm considering starting to
> use Cairo and Cairo objects as the central image.
Medical images "slice" a patient into thousands of consecutive images.

Images will typically be stored on local disk as well as streamed over the 
network to the workstation. They are then loaded in memory. 

It is not unusual to be looking at 2000-3000 images at a time, each 512x512 
matrix with depth of  12-16 bits of data. We will scroll through the images 
while dragging the mouse as the images are flipped onto the screen.

You also want to have 3d visualization built in.

You do not want to reinvent the display image wheel. 
You want to use Opengl. You want to use VTK.

Take a look at a similar project that is very-very-very Mac centric. It has 
done a marvelous job.

http://homepage.mac.com/rossetantoine/osirix/Index2.html

It annoys me that it is so mac centric that I must reinvent the entire project 
from scratch to do it right for linux.

Mitchell

>
> > Ideal would be high level integration with the gtk-perl interface, but I
> > could even survive perhaps with sending signals between somewhat
> > "independent" applications...
>
> What kind of functionality do people want from the software? Compare
> images? Overlay them? Zoom in/out? See animations?
>
> Ari
>
> > Mitchell
> > ___
> > gtk-perl-list mailing list
> > gtk-perl-list@gnome.org
> > http://mail.gnome.org/mailman/listinfo/gtk-perl-list
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


Gtk2::CellRendererText vs TextView right alignment on hebrew text

2008-01-24 Thread Mitchell Laks
Hi,

I have been using gtk2-perl with hebrew according to the wonderful Dov Grobgeld 
tutorial.

Now, I am trying to display text with a Gtk2::CellRendererText in a 
TreeViewColumn in a TreeView.
 
However I notice that the text is displayed 'left justified' which is wrong 
since hebrew is written from right to left.

However with the same code, text in a  Gtk2::TextView is displayed correctly, 
ie 'right justified' ie flush with right 
border.

Is this difference a bug? If so how to report it?

If not a bug, how to work around it to change to 'right justified' text in this 
TreeViewColumn?

Note that I set (as in Dov Grobgeld tutorial)

#!/usr/bin/perl -w
use strict;
use File::Find;
BEGIN { $ENV{LC_ALL} = "he_IL"; }
use open ':utf8';
use utf8;   # Needed for Hebrew  
use Gtk2 '-init';
use Gtk2::Pango;
use Glib qw/TRUE FALSE/;

Do I have to set properties of the CellRendererText language to hebrew? (how to 
do that?) (why not for textview?).



I love gtk2-perl! It is great fun to use!

Thank you!

Mitchell Laks
 
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


Re: Gtk2::CellRendererText vs TextView right alignment on hebrew text

2008-01-24 Thread Mitchell Laks
On 12:21 Thu 24 Jan , Mitchell Laks wrote:
> Hi,
> 
> I have been using gtk2-perl with hebrew according to the wonderful Dov 
> Grobgeld tutorial.
> 
> Now, I am trying to display text with a Gtk2::CellRendererText in a 
> TreeViewColumn in a TreeView.
>  
> However I notice that the text is displayed 'left justified' which is wrong 
> since hebrew is written from right to left.
> 

I love that I can answer my own questions, 
because that means there is  alot of available data to be mined with google!

Ok the answer is


$renderer->set_property('xalign',1.0);

where $renderer is the Gtk2::CellRendererText.


---

Now how did I figure this out?

I grepped through the gtkmmlist for TreeView

here is what i found on the gtkmm list

From: Matt Galloway <[EMAIL PROTECTED]>
User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051029)
Date: Wed, 08 Feb 2006 23:48:11 +
To: [EMAIL PROTECTED]
Subject: TreeView Queries




I've just started gtkmm programming and I have a couple of queries
regarding Gtk::TreeView. They are as follows:

1) Is there anyway I can set the columns to have central alignment
within the columns? i.e. Like this:
  Col 1  |  Col 2
8|   455
  Instead of:
  Col 1  |  Col 2
  8  |  455

2) Is there anyway I can set the width of the columns at startup? I
don't want the user to be able to change them and that's fine, I've got
that bit done.

Any help would be much appreciated!

Many thanks,
Matt Galloway



From: Bob Caryl <[EMAIL PROTECTED]>
Reply-to: [EMAIL PROTECTED]
User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317)
Date: Mon, 13 Feb 2006 09:20:09 -0600
To: Matt Galloway <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Subject: Re: TreeView Queries

[-- Attachment #1 --]
[-- Type: text/plain, Encoding: 7bit, Size: 1.2K --]

Hey Matt,

To set the alignment you must first get the cell renderer
(Gtk::TreeView::Column::get_first_cell_renderer) and then set
Gtk::CellRenderer::property_xalign to 0.5;

http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1CellRenderer
.html#c94be538d1c46649d7030771ef054f00


note that in gtkmm

Gtk::CellRenderer<--Gtk::CellRendererText



well how to set the property in perl?
so I looked in the pygtk documentation and found this 

http://www.moeraki.com/pygtktutorial/pygtk2tutorial/examples/treeviewcolumn.py
self.cell1 = gtk.CellRendererText()
self.cell1.set_property('cell-background', 'pink')

and then i guessed what would work here.

Because perl object methods are inherited down the chain without a cast.

I guess if I would have looked in 
gtk2-perl-study/sample-programs_17_02_2006/sample_programs

I would have found

$renderer->set_property('editable' => TRUE);

in 

sample_programs/gtk2_treeview_edit.pl.

which is fine.

which uses the following code, which I find puzzling:

#Attach a 'renderer_number' value to the renderer.
#This can be used to differentiate between renderers
#when we have a few renderers which can be edited
$renderer->{'renderer_number'} = RENDERER_FIRST_TEXT;

Looks like he is arbitrarily extending the renderer perl base hash for his own 
nefarious purposes.
which seem cool.
Am  I right?


Mitchell
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


Gnome2::DateEdit cant turn off time section

2008-01-27 Thread Mitchell Laks
Hi,

The Gome2::DateEdit widget has two sections, date and time. For my application
the only relevant issue is the date. I don't want to display the time as it is 
not relevant
and will confuse the users.

I noticed that when I set up a gui with glade-3 and succeeded in turning off 
the time section
however when I invoked it with my gtk2-perl driver it stil displayed the time.

So, I said, maybe a bug in gtk2-perl, well let me shut downt the time section 
with an explicit
flag after display. Thus I tried: 

***

#!/usr/bin/perl -w
use strict;
use Gtk2 '-init';
use Gtk2::GladeXML;

my $gui=Gtk2::GladeXML->new('mefilm2.glade');

my $window = $gui->get_widget('window1');

my $dateedit=$gui->get_widget('gnomedateedit1');
$dateedit->set_flags('show-time',0);
$gui->signal_autoconnect_from_package('main');


$window->show_all();

Gtk2->main;

sub on_window1_delete_event {

Gtk2->main_quit;
}

*
this did not work, it still displayed the time:

So I did an explicit construction from scratch:

#! /usr/bin/perl -w

use strict;
use Gtk2 '-init';
use Glib qw/TRUE FALSE/;
use Gnome2;

#standard window creation, placement, and signal connecting
my $window = Gtk2::Window->new('toplevel');
$window->signal_connect('delete_event' => sub { Gtk2->main_quit; });
$window->set_border_width(5);
$window->set_position('center_always');


my $dateedit =Gnome2::DateEdit->new(0,0,0);
my $scalar = $dateedit->get_flags;
print "my scalar is $scalar \n";
$window->add($dateedit);
$window->show_all();
Gtk2->main();

*

notice I set the flag to 0.

This also displays the time.
It seems to ignore the flag about showing time!
Why?

How do I stop time :)?

Thanks for all your wonderful work and help !,

Mitchell
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


Re: Gnome2::DateEdit cant turn off time section

2008-01-28 Thread Mitchell Laks
On 22:37 Sun 27 Jan , muppet wrote:
>
> On Jan 27, 2008, at 1:21 PM, Mitchell Laks wrote:
>
>> Hi,
>>
>> The Gome2::DateEdit widget has two sections, date and time. For my  
>> application
>> the only relevant issue is the date. I don't want to display the time 
>> as it is not relevant
>> and will confuse the users.
>>
>> I noticed that when I set up a gui with glade-3 and succeeded in  
>> turning off the time section
>> however when I invoked it with my gtk2-perl driver it stil displayed  
>> the time.
>>
>> So, I said, maybe a bug in gtk2-perl, well let me shut downt the time 
>> section with an explicit
>> flag after display. Thus I tried:
>>
>> ***
>>
>> #!/usr/bin/perl -w
>> use strict;
>> use Gtk2 '-init';
>> use Gtk2::GladeXML;
>>
>> my $gui=Gtk2::GladeXML->new('mefilm2.glade');
>> my $window = $gui->get_widget('window1');
>>
>> my $dateedit=$gui->get_widget('gnomedateedit1');
>> $dateedit->set_flags('show-time',0);
>
> I created a simple glade file with only a DateEdit in it, with the  
> show-time flag turned off, and your script fails with
>
>   Usage: Gnome2::DateEdit::set_flags(gde, flags) at mltime.pl line 12.
>
> This is an actual bug in your code.  You have
>
>   $dateedit->set_flags ('show-time', 0);
>
> but the proper signature is Gnome2::DateEdit::set_flags(gde, flags),  
> where flags is a Gnome2::DateEditFlags enumeration value.  I think what 
> you want to pass here is the empty flagset "[]", since you want none of 
> those options, only the date.

>
> $dateedit->set_flags ([]);
>
> However, that still doesn't give me a window with only the date,  
> because...
>
>> $gui->signal_autoconnect_from_package('main');
>>
>>
>> $window->show_all();
>
> gtk_widget_show_all() shows the widget and all its children.  Widget  
> implementations can opt out of this by setting the flag "no-show-all" or 



Dear Muppet,

Thank you very much for your very clear and informative message. 
Indeed setting the function
set_no_show_all(1); 

(or with use Glib qw(TRUE FALSE);  set_no_show_all(TRUE)

works perfectly. 

I also noticed that glade-3 comes to the rescue!!! 
Even if GnomeDateEdit is broken.

Within the "Common"properties tab of glade-3 there is a "No show all" 
choice. 
Thus if I select that, then indeed it does not show the time section!!
Yay!!!

Now as you mention, I do not understand the flags bit at all.

In my direct trial 

my $dateedit =Gnome2::DateEdit->new(0,0,0);
my $scalar = $dateedit->get_flags;
print "my scalar is $scalar \n";

I got printed out to console:

my scalar is [  ]

which is cute, but certaily cryptic to me :(.

So do you simply put an anonymous array reference [] with the selected
flags, sort of like
[ flag1, flag2, flag3 ] ie like ['show-time','24-hr','week-starts-on-monday']
turns them on and [] alone will turn them off?

(question to self: What is the corresponding structure of this in Gtk+) 


Can you point out to me where flags are talked about in
/gtk2-perl/Gtk+/ 
documentation.

This business with enums/properties/flags is not fully clear in my mind.
In my first app last week  I was able to figure out how to use 

set_property. Thus:

$renderer->set_property('width-chars',95); 
$renderer->set_property('wrap-width',780)
$renderer->set_property('wrap-mode','word');

or 
$renderer1->set_property('xalign',1.0);
$renderer1->set_property('width-chars',1);
$renderer1->set_property('wrap-width',20);


after I was able to find in different Gtk documents the list of properties
of the CellRendererText

I had more trouble for instance, sort of winging it with


my $tree_store = Gtk2::TreeStore->new(qw/Glib::String Glib::String Glib::String 
Glib::Int /);

where I was putting an integer into the fourth column of the tree store.
Thus what would i use for float or doubles if I wanted to store them in 
the table? The Gtk2::TreeStore documentation is cryptic on this. 


Thus in general Where to get a list of acceptable entries for a 'thing'.

I saw code in the beautiful gtk2-study book that uses
 

   foreach my $s_type (Glib::Type->list_values ('Gtk2::SelectionMode')){

$cmb_box->append_text($s_type->{'nick'});

to full a combobox with the nicknames of the types, which I thought very
clever, and I use this method to print out info to console too while debugging.


So to illustrate my ignorance. 

For instance for TreeStore the

Re: object_browser 0.008

2008-01-31 Thread Mitchell Laks
On 23:05 Mon 28 Jan , muppet wrote:
> I just noticed that versions of gtk+ >= 2.10.0 break my old  
> object_browser; a simple one-line hack makes it work again.
> 
>   http://asofyet.org/muppet/software/gtk2-perl/object_browser-0.008
> 
> object_browser is a little utility which lets you browse the  
> Glib::Object inheritance tree.  If you have Gavin Brown's excellent  
> Gtk2::PodBrowser installed, you even have nicely formatted manual  
> pages.  The tool attempts to be useful with any stable versions of  
> Gtk2 and gtk+ 2.x, but i recommend at least Gtk2 >= 1.040.
> 
> A while back, evil data pixies destroyed the hard disk which contained  
> the CVS repository for this program.  This 0.008 release is built off  
> of the "methodscraper" variant, which contained an attempt to list  
> methods on the object by scraping the symbol table for subroutines.

I like it very much. Unfortunately I see something strange.
I set it up at home and at work in the hospital, where I work as a doctor. Both 
machines
run debian sid.

i install standard debian latest sid packages
1. podbrowser
2. libgtk2-ex-podviewer-perl
and chmod 755 your script object_brower

1. podviewer:

now when I invoke podviewer such as
podviewer Gtk2
it shows nicely a page and I can see the document in the Document window
and if I type Gtk2::index in the Document Entry tab for instance, it is 
equivalent to command line:
podviewer Gtk2::index and I see syntax highlighting of 'hyperlinks to other 
nodes' 
which shows the other nodes in the pages, but I can't click on some of them :(
or better some I can and some I cant.
It is weird buggy and intermittent. The first click often does not work
but the click on a second different hyperlink then works :( very strange.
however when you hover over a 'hyperlinks': down in the status bar it says 'Go 
to Gtk2::TreeStore'
but it wont take you to it, if you click it
 unless you type Gtk2::TreeStore directly in the Document entry tab... 
or __sometimes__ if you chose a second one then it might go to it. strange.
or it might not go to it even then. strange. intermittent behavior.

wait: I notice: in 
podviewer Gtk2
look in the See Also section:
a) if you hover over Gtk2::index it shows in the status button 
Go to Gtk2::Gdk::X11 
but wont take you there.
b) if you hover on Gtk2::Pango it shows in the status section Gtk2::Gdk::Screen
and if you click repeatedly 
sometimes, it does nothing, 
sometimes it takes you to Gtk2::Gdk::Screen!!
sometimes it takes you to Gtk2::Pango (sometimes after showing status 
Gtk2::Pango!!

the status box contents are random and unpredictable! sometimes are unrelated 
to where you end up,
and are randomly associated with either the destination or the hyperlink blue 
text.
Thus Gtk2 hyperlink in see also sometimes leads to something totally different 
from Gtk2 
or may not even click at all! 
Thus look at Document Gtk2::Gdk::Screen and click the Gtk2 link
may do nothing, may lead to Gtk2::Gdk::PangoRenderer

which is amazing and bizarre.

note that podviewer (in libgtk2-ex-podviewer-perl) is a debian prerequisite for 
podviewer.

2. podbrowser:

is very beautiful nice highlighting and color emphasis of shows me the subsets 

Functions
Modules
Pod Documents
Pragmas

subsets and is quite beautiful: I can learn all about perl from it!
and the Modules sections has all of our wonderful documents
including all of Glib (including my new friend 'this is now that" that I am 
trying to grock)
and Glib::Object etc
including my new friend :)
Gnome2::DateEdit

Now this inherits some of the bizarro behavior of podviewer. 
Off the bat here is an example:
The see also sections Gtk2 links are particularly iffy:(.
example:
Go to Gtk2::Gdk::X11  
"see also" section look at link Gtk2
hover over it: 
the about box says
Glib::Param::String
while the click of it takes you to
Gtk2::Builder :(

In Gtk2::builder 
the two early Glib::Error hyperlinks 
hover to show in the status bar
Glib::Param::Double and Glib::Param::String respectively, 
but bizarrely when you click them they take you to
Gtk2::Alignment and Gtk2::Param::String

(oy vey).

3. object_browser-0.008.
which i downloaded from your asofyet link.


./object_browser-0.008
GLib-GObject-WARNING **: /tmp/buildd/glib2.0-2.14.5/gobject/gsignal.c:1617: 
signal `link_clicked' is invalid for instance `0xba6000' at 
./object_browser-0.008 line 137.
tossing non-object Gtk2::TreeModel
tossing non-object Gtk2::TreeModel
tossing non-object Gtk2::TreeModel
tossing non-object Gtk2::Editable
tossing non-object Gtk2::CellEditable
tossing non-object Gtk2::FileChooser
tossing non-object Gtk2::FileChooser
tossing non-object Gtk2::FileChooser
asked to lazy-load Gtk2::Gdk::Bitmap, but that package is not registered at 
/usr/lib/perl5/Glib.pm line 190.

Help says to me:

You don't have Gtk2::PodViewer installed; falling back to plain text. This
could be very ugly and had to read. Please consider getting Gtk2::Podviewer 
from cpan.

(perhaps it means to carp abo

ToggleButton seems to suppress pointer-motion-mask events

2008-02-03 Thread Mitchell Laks
Hi,

I was trying to capture events such as button1-motion-mask or
button2-motion-mask or pointer-motion-mask with pointer-motion-hint-mask 
on an OpenGL widget. This is to be able to use window and level and pan and 
zoom for display of medical CT and MRI images 

I noticed that initially I could not seem to capture the events. 
I am a beginner so I was modifying the examples I found in the 
distribution files; Thus I 
was using a widget that a modification of the default
example in the Gtk2-GLext package which is composed of a

OpenGL endowed DrawingArea that was placed into vbox, (together with a
label) and then placed into a ToggleButton.

When I tried to add motion-mask or motion-hint-masks 
via set_events or add_events to the DrawingArea, it never reported the
events.

I could only get the events when I thought to get rid of the ToggleButton.

Now it naively 'makes sense' to me that the togglebutton would not report
pointer-motion stuff, but I would have thought that the inheritance
goes in teh other direction;
ie that the propogation of events is from the child to the parent
and since the DrawingArea is in the vbox in the ToggleButton in the Window
how is the ToggleButton preventing the pointer-motion-event from
manifesting itself?

Here are two  examples I concocted. One with a togglebox and one with a vbox.

toggle.pl

 #!/usr/bin/perl -w
use strict;
use Gtk2 '-init';
my  $window = Gtk2::Window->new ('toplevel');

my $button= Gtk2::ToggleButton->new;
my $draw =  Gtk2::DrawingArea->new;
 $draw->add_events ([qw/exposure-mask
 leave-notify-mask
 button-press-mask
 pointer-motion-mask
 pointer-motion-hint-mask
 /]);
 $draw->signal_connect (motion_notify_event => \&motion_notify_event);
sub motion_notify_event {
my $widget=shift;
my $event=shift;

 my ($x, $y, $state);

  if ($event->is_hint) {
(undef, $x, $y, $state) = $event->window->get_pointer;
  } else {
$x = $event->x;
$y = $event->y;
$state = $event->state;
  }

  if ($state >= "button1-mask" ) {
print "value of x and y and button1 are $x and $y \n" ;
  }
  if ($state >= "button2-mask" ) {
print "value of x and y and button2 are $x and $y \n" ;
  }


  return 1; #was TRUE in source (was scribble.pl)

}

$button->add($draw);
$window->add($button);
 $window->signal_connect (delete_event => sub {Gtk2->main_quit; 1});

$window->show_all;
Gtk2->main;

and here is 

nontoggle.pl

#!/usr/bin/perl -w
use strict;
use Gtk2 '-init';
my  $window = Gtk2::Window->new ('toplevel');

my $button= Gtk2::VBox->new;
my $draw =  Gtk2::DrawingArea->new;
 $draw->add_events ([qw/exposure-mask
 leave-notify-mask
 button-press-mask
 pointer-motion-mask
 pointer-motion-hint-mask
 /]);
 $draw->signal_connect (motion_notify_event => \&motion_notify_event);
sub motion_notify_event {
my $widget=shift;
my $event=shift;

 my ($x, $y, $state);

  if ($event->is_hint) {
(undef, $x, $y, $state) = $event->window->get_pointer;
  } else {
$x = $event->x;
$y = $event->y;
$state = $event->state;
  }

  if ($state >= "button1-mask" ) {
print "value of x and y and button1 are $x and $y \n" ;
  }
  if ($state >= "button2-mask" ) {
print "value of x and y and button2 are $x and $y \n" ;
  }


  return 1; #was TRUE in source (was scribble.pl)

}

$button->add($draw);
$window->add($button);
 $window->signal_connect (delete_event => sub {Gtk2->main_quit; 1});

$window->show_all;
Gtk2->main;

**

So that is how it works. The second works and I get the output.

What is the mechanism behind it?

Thanks,
Mitchell

___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


cellrenderer_spinbutton.pl example. Gtk2::Entry where from?

2008-02-04 Thread Mitchell Laks
Hi group,

I have been puzzling over the cellrenderer_spinbutton.pl example
in the Gtk2-1.153 distribution
and can't seem to figure this out.

If you hover over the window with your mouse, without clicking on any cell,
then type a keyboard entry such as any letter, then a Gtk2::Entry widget
 opens up below the main window and your typed info goes into it.

What line in the code creates a Gtk2::Entry widget that sits outside of
the main window?? 
This Gtk2::Entry  goes away completely if you remove the mouse
from hovering over the window, or type enter. Puzzling.

Thank you,

Mitchell 
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


Re: Gtk2::DrawingArea

2008-02-04 Thread Mitchell Laks
On 02:50 Tue 05 Feb , Mitchell Laks wrote:

I just noticed that if I modified this code
> 
> Here is a simple example:
> 
> --drawingarea.pl--
> 
> #!/usr/bin/perl -w
> use strict;
> use Gtk2 '-init';
> my  $window = Gtk2::Window->new ('toplevel');
> 
> my $button= Gtk2::VBox->new;
> my $draw =  Gtk2::DrawingArea->new;
>  $draw->add_events ([qw/exposure-mask
>  leave-notify-mask
>  button-press-mask
>  pointer-motion-mask
>  pointer-motion-hint-mask
>  key-press-mask
>  /]);
>  $draw->signal_connect (motion_notify_event => \&motion_notify_event);
> $draw->signal_connect (key_press_event => \&key_press_event);
> 
> sub key_press_event {
> my $widget=shift ;
> my $event=shift;
> print "we got called \n";
> my $keyval= $event->keyval;
> if ($keyval == $Gtk2::Gdk::KeySyms{Up}) {
> print "we got an up arrow yay!!! \n";
> 
> }
> 
> }
> 
> 
> sub motion_notify_event {
> my $widget=shift;
> my $event=shift;
> 
>  my ($x, $y, $state);
> 
>   if ($event->is_hint) {
> (undef, $x, $y, $state) = $event->window->get_pointer;
>   } else {
> $x = $event->x;
> $y = $event->y;
> $state = $event->state;
>   }
> 
>   if ($state >= "button1-mask" ) {
> print "value of x and y and button1 are $x and $y \n" ;
>   }
>   if ($state >= "button2-mask" ) {
> print "value of x and y and button2 are $x and $y \n" ;
>   }
> 
> 
>   return 1; #was TRUE in source (was scribble.pl)
> 
> }
> 
> $button->add($draw);
> $window->add($button);
>  $window->signal_connect (delete_event => sub {Gtk2->main_quit; 1});
> 
> $window->show_all;
> Gtk2->main;
> 
> -
>

to this:

 
#!/usr/bin/perl -w
use strict;
use Gtk2 '-init';
my  $window = Gtk2::Window->new ('toplevel');

my $button= Gtk2::VBox->new;
my $draw =  Gtk2::DrawingArea->new;
 $draw->add_events ([qw/exposure-mask
 leave-notify-mask
 button-press-mask
 pointer-motion-mask
 pointer-motion-hint-mask
 key-press-mask
 /]);
 $window->add_events ([qw/
  key-press-mask
 /]);

 $draw->signal_connect (motion_notify_event => \&motion_notify_event);
$window->signal_connect (key_press_event => \&key_press_event);

sub key_press_event {
my $widget=shift ;
my $event=shift;
print "we got called \n";
my $keyval= $event->keyval;
if ($keyval == $Gtk2::Gdk::KeySyms{Up}) {
print "we got an up arrow yay!!! \n";

}

}


sub motion_notify_event {
my $widget=shift;
my $event=shift;

 my ($x, $y, $state);

  if ($event->is_hint) {
(undef, $x, $y, $state) = $event->window->get_pointer;
  } else {
$x = $event->x;
$y = $event->y;
$state = $event->state;
  }

  if ($state >= "button1-mask" ) {
print "value of x and y and button1 are $x and $y \n" ;
  }
  if ($state >= "button2-mask" ) {
print "value of x and y and button2 are $x and $y \n" ;
  }


  return 1; #was TRUE in source (was scribble.pl)

}

$button->add($draw);
$window->add($button);
 $window->signal_connect (delete_event => sub {Gtk2->main_quit; 1});

$window->show_all;
Gtk2->main;



then it works
(i get 

Name "Gtk2::Gdk::KeySyms" used only once: possible typo at ./toggle2.pl line 27.
we got called
Use of uninitialized value in numeric eq (==) at ./toggle2.pl line 27.
we got called
Use of uninitialized value in numeric eq (==) at ./toggle2.pl line 27.
we got called
Use of uninitialized value in numeric eq (==) at ./toggle2.pl line 27.
we got called
Use of uninitialized value in numeric eq (==) at ./toggle2.pl line 27.
we got called
Use of uninitialized value in numeric eq (==) at ./toggle2.pl line 27.


because I did not use Gtk2::Gdk::Keysyms;

but why is this only setup-able for the enclosing window and not for the
drawingarea window itself?

Thanks,

Mitchell
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


Gtk2::DrawingArea

2008-02-04 Thread Mitchell Laks
Hi,

I wanted to modify the response of my program based upon keyboard entry.
Thus I would like the key_press_event to capture which key was entered.

Now I saw some of the example code in the examples section, such as
histogram.pl do not set up a key-press-mask.

1. Is that event automatic for a Gtk2::DrawingArea, and only needed for a 
Gtk2::Window? 
(also I notice that Gtk2::DrawingArea isn't in object-browser)

2.
I tried the following code in my application
and I got no output. :(

  $drawing_area->set_events ([qw/exposure-mask
 leave-notify-mask
 button-press-mask
 pointer-motion-mask
 key-press-mask
 pointer-motion-hint-mask/]);
$drawing_area->signal_connect (key_press_event => \&key_press_event);

sub key_press_event {
my $widget=shift ;
my $event=shift;
print "we got called \n";
my $keyval= $event->keyval;
if ($keyval == $Gtk2::Gdk::KeySyms{Up}) {
print "we got an up arrow yay!!! \n";

}

}

and nothing happened with any key press events :(.

Here is a simple example:

--drawingarea.pl--

#!/usr/bin/perl -w
use strict;
use Gtk2 '-init';
my  $window = Gtk2::Window->new ('toplevel');

my $button= Gtk2::VBox->new;
my $draw =  Gtk2::DrawingArea->new;
 $draw->add_events ([qw/exposure-mask
 leave-notify-mask
 button-press-mask
 pointer-motion-mask
 pointer-motion-hint-mask
 key-press-mask
 /]);
 $draw->signal_connect (motion_notify_event => \&motion_notify_event);
$draw->signal_connect (key_press_event => \&key_press_event);

sub key_press_event {
my $widget=shift ;
my $event=shift;
print "we got called \n";
my $keyval= $event->keyval;
if ($keyval == $Gtk2::Gdk::KeySyms{Up}) {
print "we got an up arrow yay!!! \n";

}

}


sub motion_notify_event {
my $widget=shift;
my $event=shift;

 my ($x, $y, $state);

  if ($event->is_hint) {
(undef, $x, $y, $state) = $event->window->get_pointer;
  } else {
$x = $event->x;
$y = $event->y;
$state = $event->state;
  }

  if ($state >= "button1-mask" ) {
print "value of x and y and button1 are $x and $y \n" ;
  }
  if ($state >= "button2-mask" ) {
print "value of x and y and button2 are $x and $y \n" ;
  }


  return 1; #was TRUE in source (was scribble.pl)

}

$button->add($draw);
$window->add($button);
 $window->signal_connect (delete_event => sub {Gtk2->main_quit; 1});

$window->show_all;
Gtk2->main;

-

here is output 


./toggle2.pl
Name "Gtk2::Gdk::KeySyms" used only once: possible typo at ./toggle2.pl line 23.
value of x and y and button1 are 85 and 64
value of x and y and button1 are 85 and 65
value of x and y and button1 are 85 and 67
value of x and y and button1 are 85 and 69
value of x and y and button1 are 84 and 71
value of x and y and button1 are 84 and 72
value of x and y and button1 are 84 and 74
value of x and y and button1 are 84 and 76
value of x and y and button1 are 84 and 77
value of x and y and button1 are 84 and 78
value of x and y and button1 are 84 and 80
value of x and y and button1 are 84 and 82
value of x and y and button1 are 84 and 84
value of x and y and button1 are 84 and 8

nothing when i press a key :(.

Thank you,

Mitchell Laks


___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


Re: Gtk2::DrawingArea

2008-02-05 Thread Mitchell Laks
On 02:56 Tue 05 Feb , Mitchell Laks wrote:

Put another way, in terms of my rereading of earlier message from
muppet on ToggleButton.

Why is the Gtk2::Window eating the 
key-press events,
but not eating the 
pointer-motion events or 
button-press events
which seem to propagate nicely to the child Gtk2::DrawingArea.

Thus if I try the following code, 
returning 0 (or even 1, I tried both) from the 
signal handler at 
at the Window level, I still only get one "print line" per key press.
ie it does not propogate  up to the child Gdkwindow ie the Gtk2::DrawingArea

Thanks,
Mitchell

**
sample.pl

#!/usr/bin/perl -w
use strict;
use Gtk2 '-init';
my  $window = Gtk2::Window->new ('toplevel');

my $button= Gtk2::VBox->new;
my $draw =  Gtk2::DrawingArea->new;
 $draw->add_events ([qw/exposure-mask
 leave-notify-mask
 button-press-mask
 pointer-motion-mask
 pointer-motion-hint-mask
 key-press-mask

/]);

$window->add_events ([qw/
  key-press-mask
 /]);


$draw->signal_connect (motion_notify_event => \&motion_notify_event);
$window->signal_connect (key_press_event => \&key_press_event);
$draw->signal_connect (key_press_event => \&key_press_event);

sub key_press_event {
my $widget=shift ;
my $event=shift;
print "we got called \n";
return 0;
}


sub motion_notify_event {
my $widget=shift;
my $event=shift;

 my ($x, $y, $state);

  if ($event->is_hint) {
(undef, $x, $y, $state) = $event->window->get_pointer;
  } else {
$x = $event->x;
$y = $event->y;
$state = $event->state;
  }

  if ($state >= "button1-mask" ) {
print "value of x and y and button1 are $x and $y \n" ;
  }
  if ($state >= "button2-mask" ) {
print "value of x and y and button2 are $x and $y \n" ;
  }


  return 1; #was TRUE in source (was scribble.pl)

}

$button->add($draw);
$window->add($button);
 $window->signal_connect (delete_event => sub {Gtk2->main_quit; 1});

$window->show_all;
Gtk2->main;
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


Re: cellrenderer_spinbutton.pl example. Gtk2::Entry where from?

2008-02-05 Thread Mitchell Laks
On 08:35 Tue 05 Feb , muppet wrote:
> 
> Mitchell Laks wrote:
> > If you hover over the window with your mouse, without clicking on any cell,
> > then type a keyboard entry such as any letter, then a Gtk2::Entry widget
> >  opens up below the main window and your typed info goes into it.
> >
> > What line in the code creates a Gtk2::Entry widget that sits outside of
> > the main window??
> 
> This sounds like the built-in "typeahead find" feature of GtkTreeView.
> 

Aha! 
(Last night I was looking for applications that captured keystrokes anywhere
in the window).

> 
> > This Gtk2::Entry  goes away completely if you remove the mouse
> > from hovering over the window, or type enter. Puzzling.
> 
> Are you using focus-follows-mouse in your window manager, by chance?

Couldn't live without it :)

Thank you very much muppet!

Mitchell



___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


Re: Gtk2::DrawingArea

2008-02-05 Thread Mitchell Laks
On 08:30 Tue 05 Feb , muppet wrote:
> 
> By virtue of adding the key-press-event mask to the widget's event set,
> the drawing area is set up to monitor key-press-event, but is not allowed to
> take keyboard focus until you enable it.  You need to do
> 
>   $draw->can_focus (TRUE);
> 

Now that works!

Ah! 

Now I see why it worked in the histogram.pl example in the Gtk2-1.153/examples.

You set it there as well. I did not think/know about focus.

I just sat down and read about focus in the Havoc Pennington GTK+/Gnome 
application development book.

Now, this was really good to know. 

I will have to think about focus for a bit.

Q1. Is the can_focus(TRUE) (as opposed to set_focus)
 typically needed only for widgets like DrawingArea
that don't have a 'place' to put text? I guess I can always
try the function  if I find I need it :).

***


I notice  that I can capture modifier masks for the 
GdkEventButton directly using the state member
so I can do 

 if ($state >= ["button2-mask","control-mask" ])

while doing a pointer-motion, in the 
sub motion_notify_event {
}.


This works for Control/Alt/Caps-Lock/Shift modifiers of a pointer-motion
or a button-press-event. 

On the other hand I would have to use the 
signal from a key-press or key-release event  (together with can_focus),
if I wanted to capture more obscure key  presses like "A" together
with pointer motion.

Mitchell
 

(Dear muppet - sorry I sent the original letters to you and not to the list. 
I hit r instead of L in mutt :(. 
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


I wrote a gtk2-perl application, need advice

2008-05-19 Thread Mitchell Laks
Hi,

I wrote a gtk2-perl application (cybergaon) that I would like to distribute via 
sourceforge. It will be GPL (v3 I think).

I have a number of questions. This is my first application and it is a little 
messy. 

The application takes as input an archive of hebrew texts (such as the Bible 
and Mishna and Talmud and works of the 
medieval sage Maimonides) that are freely distributed on the web. That archive 
of texts, which store 
the texts with the  hebrew written in old IBM PC hebrew encoding CP862, also 
comes with an old Dos program to 
do searches for text. www.mechon-mamre.org/mtrpromo.htm.

1. I converted the directories of files of CP862 text to files of utf-8 (a 
simple perl script employing the iconv program).

2. I used gtk2-perl to essentially wrap grep. One can search for a REGEXP in 
the textentry 
and then there is a notebook with 2 tabs: 
in one tab I display the list of results in a treeview
and then I display full corresponding text in a textview in the other tab.
Thus when we click on a result in the list in the treeview, we display the full 
text of the corresponding 
file in the textview,  with the text prescrolled to the proper location in the 
file in the textview .

3. This is of course a general purpose grep display, and might be useful for 
others.

I am not sure how to set this up as an application for others to use. Ie: it is 
not structured right.
At present I just search through a list of subdirectories in my current 
directory.

I do my development on my debian sid box.


My problems:


1) A professional software engineer would know where to put things in a 
/usr/share and /usr/bin. I have all the code 
and data  in my current directory and subdirectories. What is the next step?

Perhaps I want to write my data to /usr/share/Cybergaon/MTR/*, and the 
application to /usr/bin/cybergaon.pl
or something like /usr/share/local/bin/cybergaon.pl. Suggestions?

I think that I can redistribute the raw data - ie the hebrew texts as they are 
free. However I sense
that sourceforge is not happy to have data rather than programs distributed via 
there site. 
On the other hand the texts are freely redistributable. Do I distribute a 
script that assumes the user
has downloaded the data file of texts from the mechon-mamre website?

The only modules I use are Gtk2 Gtk2::Pango Glib and Cwd.

2) I wanted to put up the application and code on sourceforge and I can't 
understand how to get it onto cvs. I am having
difficulty figuring out how to do the ssh-keygen and I really dont know what I 
am doing over there, and nothing
seems to be going up to sourceforge. Note that i have used ssh-keygen when I 
wanted to set up
a cron job to anonymous backup between machines in the past. I just cant  
figure out what to do here. I would like
to zero my key and start over and upload the files for others to use.

Thanks,

Mitchell Laks 


___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


Idea: Can we modify Devel::REPL or combine with Perl Object Environment to have programmatic interaction with a gtk2-perl process like in other languages?

2009-04-19 Thread Mitchell Laks

Hi,

I like perl and gtk2  and   would rather use it than  xyz (other languages :)). 

Can we set up a working interactive REPL with gtk2-perl as with pygtk for 
instance. I can use Devel::REPL to start and  build the gui
but then I lose the interaction control once I start Gtk2->main;

I would like to redefine callbacks, change widgets on the fly etc as we 
continue the interaction using Devel::REPL. I have done it with pygtk of course 
using the program
pygtkconsole.py. Do we modify Devel::REPL or set up something with perl POE?


I think we should be able to do this with gtk2-perl, although I am still 
learnining some of this stuff so I wanted your opinions on the details. Could 
we use perl POE?


Hw to keep access to the working program? Now I know that there are issues with 
gui threads. However can you imagine doing something with perl POE?

Thanks

Mitchell

Here for instance is what they do in pygtk:

In the pygtk tutorial: 

http://www.pygtk.org/pygtk2tutorial/ch-Introduction.html#sec-ExploringPygtk

you can set up a pygtk window and dynamically from the interactive shell drop 
child widgets
and add new ones to replace them and then change callbacks etc.

here is pygtkconsole.py

#!/usr/bin/env python
# -*- Mode: python; c-basic-offset: 4 -*-
#
# Interactive PyGtk Console, Johan Dahlin 2002
#

import os
import signal
import sys
import string
import socket, select
from code import InteractiveInterpreter, InteractiveConsole

import gtk
import gobject

# For compatibility, instead of using GDK.INPUT_READ or
# gtk.gdk.INPUT_READ depending on the PyGtk version
GDK_INPUT_READ = 1

class Mainloop(InteractiveInterpreter):
def __init__(self, read_fd, sock):
InteractiveInterpreter.__init__(self)
self._rfd = os.fdopen(read_fd, 'r')
self._sock = sock
gobject.io_add_watch(read_fd, GDK_INPUT_READ, self.input_func)

def read_message(self):
length = ord(self._rfd.read(1))
return self._rfd.read(length)

def input_func(self, fd, cond):
data = self.read_message()
more = self.runsource(data)
self._sock.send(chr(more))
return True

def run(self):
gtk.main()

class Console(InteractiveConsole):
def __init__(self, write_fd, sock, pid):
InteractiveConsole.__init__(self)
self._wfd = os.fdopen(write_fd, 'w')
self._sock = sock
self.pid = pid

def send_message(self, message):
self._wfd.write('%c%s' % (len(message), message))
self._wfd.flush()

def interact(self, banner=None):
InteractiveConsole.interact(self, banner)
# Die child die
os.kill(self.pid, 9)

def runsource(self, source, filename):
self.send_message(source)
# wait for notification from parent
select.select([self._sock],[],[])
more = ord(self._sock.recv(1))
return more

class GtkInterpreter(Console):
def __init__(self):
rfd, wfd = os.pipe()
# set up socket for returning command result
sigsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock_addr = None
for port in range(4321,5321):
try:
sigsock.bind(('', port))
sock_addr = ('', port)
except:
pass
if not sock_addr:
print "Can't open socket"
sigsock.listen(1)

parent_pid = os.getpid()
child_pid = os.fork()
if not child_pid:
# connect to command return socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(sock_addr)
g = Mainloop(rfd, sock)
g.run()
else:
# Wait for command return socket connection
sock, addr = sigsock.accept()
Console.__init__(self, wfd, sock, child_pid)

def interact():
try:
import readline
import rlcompleter
readline.parse_and_bind('tab: complete')
except ImportError:
pass

gi = GtkInterpreter()
gi.push("from gtk import *")

python_version = string.split(sys.version)[0]
try:
pygtk_version = string.join(map(str, gtk.pygtk_version), '.')
gtk_version = string.join(map(str, gtk.gtk_version), '.')
except:
pygtk_version = '0.6.x'
gtk_version = '1.2.x'

banner = """Python %s, PyGTK %s (Gtk+ %s)
Interactive console to manipulate GTK+ widgets.""" % (python_version,
   pygtk_version,
   gtk_version)
gi.interact(banner)

if __name__ == '__main__':
interact()








I would like to be able to interact programmatically with a working gtk2-perl 
program through a REPL, as one might in lisp or in python. Thus redefine 
callbacks etc.
change baby widgets whatever one wanted to do. It seems like a cool thing to be 
able to do. I read a story somewhere about progammers who attached to a live 
lisp process to debug a satellite in orbit, and this would be nice for us 

Re: Re: Segfault in Gtk2::Ex::Simple::List 0.50

2009-04-21 Thread Mitchell Laks
On 13:19 Tue 21 Apr , jeffrey.ratcli...@gmail.com wrote:
> On Apr 21, 2009 3:17pm, Emmanuel Rodriguez  
> wrote:
>> Sadly the bug affects the standard Perl distributed in Debian Lenny :(
>
> And Ubuntu Intrepid.

And is still the current one in sid-squeeze as well
:(
Mitchell


> ___
> gtk-perl-list mailing list
> gtk-perl-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-perl-list

___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


Re: Idea: Can we modify Devel::REPL or combine with Perl Object Environment to have programmatic interaction with a gtk2-perl process like in other languages?

2009-04-21 Thread Mitchell Laks
On 22:09 Sun 19 Apr , Sergei Steshenko wrote:
> > 
> 
> Well, I do not know Python except for vewry basic/primitive stuff.
> 
> However, Perl is a "strategically" different from Python language, i.e. it
> has fundamental features Python doesn't have or has them in a very
> rudimentary form.

I think you misunderstood. I like perl and would like to have an interactive 
perl shell for gtk2-perl

> 
> The features are:
> 
> * closures;
> * lexical scoping;
> * anonimyty.

I am familiar with perl :).

> 
> I.e. its functional features.
> 
> So, to add something to a running Perl program is different from the same
> in Python.
> 
> For example, the following (AFAIK) cannot be translated into Python without
> adding extra names:

I know about closures. I use perl.
I am not interested in  perl vs python advocacy. 
We can pick features from other languages and see if we can have them too.
The more we know from other cultures, the more we can develop new ideas in our 
own.
See the well written article at the Perl.com site: 
Mark Dominus: "Why I hate advocacy"
http://www.perl.com/pub/a/2000/12/advocacy.html

> 
>   { 
>   my $parent = $this; 
>  
>   my $on_text  = "On"; 
>   my $off_text = "Off"; 
>  
>   my $this = Gtk2::ToggleButton->new($off_text); 
>  
>   $this->signal_connect 
> ( 
> clicked => 
>   sub 
> { 
> if($this->get_active) 
>   { 
>   $this->set_label($on_text); 
>   } 
> else 
>   { 
>   $this->set_label($off_text); 
>   } 
>  
> # do the real stuff here 
> } # sub 
> ); # $this->signal_connect 
>  
>   $parent->pack_start($this, FALSE, FALSE, 0); 
>  
>   $this->show; 
>   }
> .
> 
> Note there is a number of hierarchy levels, and each of them has its own
> $this, $parent.
> 
> Using lexical scoping you can easily add as many nested levels as you
> wish, still just using
> 
>   {
>   my $parent = $this; # this $this belongs to outer scope
>   ...
>   my $this = SomeClass->new(...); # this $this belongs to this scope and
>   # defines a new widget/instance/etc.
>   ...
>   }
> 
> I.e. in Perl it's very easy to add things from inside, and lexical scoping
> provided excellent encapsulation/data protection, so it's impossible by
> normal means to access inner data from outside.
> 
> Adding code from inside is simple - either you just write it, or you
> do it this way:
> 
>   {
>   ... # existing stuff
>   do "file_with_new_stuff.pl"; # code in the file is evaluated in the
># current scope, so all lexical variable are
># accessible
>   ... # existing stuff
>   }
> 

Sergei, you have pretty code here, I agree, but it doesn't do what I was 
thinking of...

I would like to play and refactor my code as I work. 
I dont want to have to plan my alternatives in advance.

Take a look at the work done on Devel::REPL and compare it with the perl shells
in 

1) the perl debugger
2) Nice code approaches of muppet and Remco Wouts that he pointed to in his 
letter.
3) Code base of Devel::REPL and the plug ins there.
4) Stylish::REPL derived from that...

and take a look at this perl code
http://blog.jrock.us/articles/Stylish REPL.pod

and see this amazing video made by Jonathan Rockway:

http://www.iinteractive.com/stylish-repl-screencast.ogv

who has created a full 'Slime like environment' (that is Slime as in common 
lisp!!!)  to do perl coding from emacs
called Stylish!!!


To appreciate the video, you should realize that he is mimicking the famous 
SBCL-Slime Lisp interaction mode - Emacs video by Marco Baringer 
http://www.archive.org/details/UsingtheSLIMELispInteractionModeforEmacs.

It is amazing to do that for perl!

Mitchell



 



___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


Re: Idea: Can we modify Devel::REPL or combine with Perl Object Environment to have programmatic interaction with a gtk2-perl process like in other languages?

2009-04-21 Thread Mitchell Laks
On 17:36 Mon 20 Apr , muppet wrote:
> 
> Remco Wouts did something along those lines:
> http://mail.gnome.org/archives/gtk-perl-list/2005-January/msg00128.html
> 
> as did i:
> http://asofyet.org/muppet/software/gtk2-perl/gish.html
> http://asofyet.org/muppet/software/gtk2-perl/gws.html
> 
> 
> There should be some ideas in there on how to fix the mainloop issue.  :-)
> 

Thank you muppet, that is exactly what I was thinking of.

1. 

Of course, when I wrote my email I was still very hazy in my thinking.
I knew what I wanted, (to work with gtk2-perl with a REPL) but had not thought 
it out what was involved. 
Yes, as you said, I wanted to have access to get into the mainloop.. 

2.

Of course, what Remco and you  have done is essentially running eval on the 
command line input, either via Term::Readline::Gnu 
or in gish via your Tk package (which I haven't figured out yet, his is more 
straight forward for me to grasp).
Can you explain what is going on in your Tk magic... Also in view of the work 
of Ryan below...

Conceptually, what you are doing is, essentially, 180 degree ANTI 'Taint' mode. 
Instead of sanitizing, we anti-sanitize
we just eval the input directly from the Terminal::Readline!

Then another approach is to set up a text buffer window (can be multiple!)  
with gtk2-perl and some buttons and then
when we hit a button eval the text (or subset of the text) in the corresponding 
buffer(s). 
That would work as well I guess. 
I think that is the idea of what you do in your GWS application.

3. 

Your method (and Remco) reminds me of the perldl shell 
which comes with PDL mathematical methods package. Or possibly perl debugger.
I have used them...

4.

I am still reading about  Devel::REPL and compared it to these direct eval 
methods? 
He creates a persistent lexical environment so my works.
http://chainsawblues.vox.com/library/post/a-perl-read-excute-print-loop-repl.

Now I will play with  Ryans REPL/Plugin/Glib.pm and see how it works.

5.

I just also found the Stylish::REPL emacs plugin method of Jonathan Rockway. 
http://blog.jrock.us/articles/Stylish REPL.pod
See his amazing video
http://www.iinteractive.com/stylish-repl-screencast.ogv
which is a counterpart to the  common lisp Slime Emacs video
http://www.archive.org/details/UsingtheSLIMELispInteractionModeforEmacs

 I will be playing with that too.. Have you tried it?

6.
I guess the POE is another way (besides GUI windows) to allow multiple 
processes to get access to resources and thus execute. I am still
reading about that...


Thanks once again!

Mitchell
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


Re: Idea: Can we modify Devel::REPL or combine with Perl Object Environment to have programmatic interaction with a gtk2-perl process like in other languages?

2009-04-21 Thread Mitchell Laks
On 22:47 Tue 21 Apr , Sergei Steshenko wrote:
> 
> Mitchell, I think you misunderstood my point - it wasn't about advocacy.
> 
> It was about automated code generation vs language features and personal
> preferences WRT the features.
> 
> So, an automatically generated code for one language may look natural for
> that language and the "same" (up to syntax differences) code for another
> language looks unnatural and unnecessarily hardly maintainable.

I see your point, and agree about automatically generated code. I am sorry I 
misunderstood... 

However I am talking about something else entirely.
 
I would like to develop my code without having to knock down my application 
and rerun each time I make a change. I will explain below why. 

If you can, take a look at Ryans plugin!!! It is exactly what I had in mind. 
His plugin works
directly on my Debian box.  Also in his POD, he gives an example to code
 the exact steps I wanted to do, such as to add and then remove a widget in a 
running application!

Moreover, if I can figure out the Stylish emacs setup of Jonathan Rockway (see 
the video link I gave you)
it will be awesome!


Consider this. I am writing a complex gui application to display medical 
images. My code will operate on a stack of
a 500 - 1000 images.  I use many libraries - PDL POGL gtk2-perl and other C++ 
and java libraries to get at the raw data. 
It takes time to start the application and load the images. 

Currently, each time I do a change in my opengl code I exit
from a working instance and  need to reload all that crap. I would rather just 
change a callback in a REPL
and keep working on a live instance.

This is normal behavior in Lisp development (according to Lispers). We should 
have this in perl too! Now we do
with Stylish and now with this plugin in Gtk2-perl I need to check to see 
how it works out.

Look at the Stylish REPL Emacs video! It is cool!

I am very optimistic and excited!

Mitchell




___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


Re: Idea: Can we modify Devel::REPL or combine with Perl Object Environment to have programmatic interaction with a gtk2-perl process like in other languages?

2009-04-22 Thread Mitchell Laks
On 23:26 Tue 21 Apr , Sergei Steshenko wrote:
> 
> Of course, Perl allows dynamic compilation/binding, i.e. one can add some
> new piece of code to a running instance.
> 
> Has anyone verified absence of memory leaks doing such things frequently ?
> 
> WRT memory leaks I prefer to be on the safe side - in a GUI of mine I do not 
> even destroy/recreate widgets, just hide/show them. And the GUI has no
> dynamic binding whatsoever.
> 
> Again regarding memory leaks - gtk+ folks have a nerve to claim gtk+ has no
> memory leaks - even after the fact that in a number of releases they had
> memory leaks fixed - this was in their release announcements. So, I wish
> you luck - I am an "old" skeptical guy ;-).

Interesting points. Your point is very important to exercise caution  if I 
forsaw writing 
code that will make heavy use of dynamic changes in the gtk2-perl gui. 

On the other hand, I am only dealing with developing a felicitous  development 
environment, 
thus I would like the convenience of just changing my callbacks/widgets around,
without just restarting my program from scratch. 

After the program works correctly, I can then use the resulting code
 and then do any long term stability/ memory leak testing separately. 

Thanks,

Mitchell
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


Re: Is there anyone out there?

2009-05-13 Thread Mitchell Laks
I agree with all that has been said.

This is an active helpful group and you clearly have not reviewed the resources 
adequately.

Another must is Grant McLeans wonderful gtk2-perl glade tutorial talk.

http://gtk2-perl.sourceforge.net/links/
how can that web site not suffice?

MItchell
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list