public inbox for guile-gtk@sourceware.org
 help / color / mirror / Atom feed
* Newbie pleading for help...
@ 2002-02-19 20:55 Alex Kim
  0 siblings, 0 replies; 8+ messages in thread
From: Alex Kim @ 2002-02-19 20:55 UTC (permalink / raw)
  To: guile-gtk; +Cc: theseven222

Dear guile (and guile-gtk) experts,

I understand that my question may irritate some of you
since it has been discussed here before. Nevertheless,
I am asking the question with desperation and as a 
last resort.  Many apologies.

I was given a task a couple of months ago.  After a
long serious thinking, I came up with an idea which
made use of a lot of stack and list operations (which
scheme is good at) and wanted to verify my idea as
quickly as possible.  Fortunately (or unfortunately, I
can't say for sure yet), I know just enough scheme to
write moderate size programs. So, I started coding in
scheme.


My intension was to implement the idea in guile scheme
and the GUI in c with X or gtk providing one simple
line drawing function for guile to call so that I can
draw lines as they are computed from scheme code
(similar to tortoise example). And it worked great.

Then, I wanted to add event processing to the GUI and
this is where I got stuck---it also required its own
event loop in addition to gh_repl.  At first, I
naively thought I could resolve the problem using
pthread, which didn't work.  With pitiful and (of
course) unsuccessful debugging of many days, I looked
up the list's archive and found out that the question
has been discussed previously and someone successfully
solved the problem using event-repl stuff coming with
guile-gtk.  Nevertheless, with my short knowledge of
guile, the discussions were hard to follow and I ended
up with a conclusion of rewriting the whole thing in
c.

However, I still desperately want to stay with scheme
since it will make further improvement of my idea
extremely easier.  So, before I begin to rewriting, I
thought I might ask you, the guile experts, for help
as a last resort.  Would anyone out there generously
provide me some pointers or simple example codes that
work just like tortoise example, but with added event
handling ability (either X or gtk)?  I would be very
grateful to you.

Please accept my sincere apology if you got upset by
my posting of what has been discussed before.
Thank you very much.

Sincerely,







__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Newbie pleading for help...
  2002-02-20 13:02       ` Brett Viren
@ 2002-02-23 23:48         ` Alex Kim
  0 siblings, 0 replies; 8+ messages in thread
From: Alex Kim @ 2002-02-23 23:48 UTC (permalink / raw)
  To: guile-gtk, guile-user

Dear guile experts,

I just wanted to say thank you for all your help,
especially, to Brett, Neil, Bo, and Hilaire.
Neil's article "GUIfying the Guile REPL" was very
helpful to understand the issue.  Unfortunately, I
was not able to try his guile-gui (I couldn't get
guile-gtk-0.19 compiled with guile-core cvs which has
the necessary buffered-input; My naive impression 
during a month of using guile is that everything is
depending on everything else).

Luckily, I followed Brett's suggestion and it worked.
So, I kind of solved my problem, although it's not
quite what I imagined when I first learned about guile
a month ago.  Nevertheless, it serves my purpose and
I can develop my toolkit using scheme as I desperately
wanted.  So, I am very happy now.

I sincerely appreciate you for all your help and many
thanks to those who devote their time to THE GUILE
project.
Thank you very much.


--- Brett Viren <bv@bnl.gov> wrote:
> Alex Kim writes:
>  > The problem with doing everything in guile-gnome
> is
>  > that the toolkit contains too many stuffs already
>  > written in c, X, and gl.  And I was hoping that
> some
>  > modification on GUI code will allow me to easily
> add
>  > more features written in guile (in the way
> plug-ins
>  > work; I thought this was what guile was for when
> I
>  > first started learning it---although I now
> realize it
>  > is much more than that).
> 
> Ah, okay.  Also, I reread your past posting and saw
> you wanted to use
> gh_repl().  I don't think this will work so well to
> combine gh_repl()
> and some GUI's main loop (maybe it could be made to
> work with
> guile-gtk, maybe not).  So I would abandon gh_repl
> and instead read in
> scheme using the native GUI's text widget and
> calling gh_eval_str() on
> the result and/or load in the scheme as a file with
> gh_eval_file().
> (Or, rather their scm_ equivalents, because I think
> gh_ interface is
> going away sometime, but gh_ is all *I* know right
> now....)
> 
> I successfully used this in a C++/Gtkmm/Guile
> application that had to
> handle interactive users as well as servicing
> network requests.  BTW,
> when passing unkown scheme code into guile, I used
> the _catch versions
> of the functions so that a typo in the scheme code
> wouldn't bring down
> the whole app.
> 
>  > In the mean time, I will
>  > study your code to get better understaning in
> this
>  > world. 
> 
> Well I am not a great scheme coder, so don't study
> it too hard! <grin>
> 
> Luck,
> -Brett.
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Newbie pleading for help...
  2002-02-20  9:20 ` Alex Kim
  2002-02-20  9:48   ` Brett Viren
  2002-02-20 13:13   ` Neil Jerram
@ 2002-02-21  1:56   ` Hilaire Fernandes
  2 siblings, 0 replies; 8+ messages in thread
From: Hilaire Fernandes @ 2002-02-21  1:56 UTC (permalink / raw)
  To: Alex Kim; +Cc: Bo Forslund, guile-gtk, guile-user

Alex,

Not sure this can help but I have just release DrGenius 0.6.0 which is
an interactive geometry software (Gnome/GTK+ based) where guile script
can be dropped in the figure. Basicly an user decides to create a script
on a figure then input the guile code in a dialog. The code is then
evaluated using gh_eval_str when update is needed.
You can check at http://www.ofset.org/drgenius

Hilaire


On Wed, 2002-02-20 at 18:20, Alex Kim wrote:
> Hello,
> 
> Thank you very much for your reply.  If you wouldn't
> mind, I would like to ask you some more questions.
> 
> Guile ref. manual says that "An application can use
> Guile as an extension language..." and this is exactly
> what I want to do.  I am writing a simple image
> processing toolkit with GUI in c. The GUI displays an
> image and waits for input.  The input is an array of
> points and the GUI draws lines connecting the points
> on top of the image.  The input, ie, the array of
> points, can be generated using various algorithms and
> this is where I am trying to use GUILE as an extension
> language: the toolkit provides to GUILE one simple
> function that draws a line given two points; the
> various algorithms are implemented in GUILE calling
> the line drawing function to display their results.
> This way, I can easily add new algorithms to the
> toolkit without touching any other parts of the code.
> And I got it work this far following mainly the
> tortoise example written by David Drysdale.
> 
> Then, I wanted to add event processing loop for the
> GUI itself to respond to the mouse interaction so
> that I can interactively modify the lines as needed.
> As I described in the previous message, this
> turned out to be very hard for me to achieve since two
> event loops that never return are required (one for
> gh_repl and the other for GUI).  After many days
> of struggling with pthread, I learned from the list's
> archive that pthread can't solve the problem and also
> learned that guile and gtk may give me the solution.
> So, I am looking for some example codes or any
> pointers that can help me solve my problem.  Simply
> put, I am looking for something that works just like
> the tortoise example (found on GUILE tutorial at
> http://www.gnu.org/software/guile/docs/docs.html),
> but with added event handling ability for mouse
> interaction with GUI.
> 
> I hope I described my problem a bit clearer this time.
> Do you think what I am trying to do can be achievable?
> Again, I sincerely appreciate your reply and any
> further advice/helps.
> Thank you very much.
> 
> Sincerely,
> ---
> 
> Alex Kim
> 
> 
> 
> 
> 
> --- Bo Forslund <bo.forslund@abc.se> wrote:
> > Hello!
> > 
> > 
> > I'm afraid I can't say that I understand what You
> > are asking, but I shall try to give an answer.
> > 
> > I think I understand that You want a graphic
> > interface to scheme. You can have the interface
> > written entirely in scheme using guile-gtk, or in
> > C and use guile-gtk  glue functions to to call
> > scheme functions.
> > I managed to get a deck of cards written in scheme
> > into a gtk interface some while ago. I also managed
> > to do a little prog with the Glade GUI builder that
> > called a scheme function.
> > Unfortunate it got lost when I had a a crach and had
> > to reinstall Linux from scratch. It was 4 - 5
> > months ago so I don't remember very well what I did
> > either.
> > 
> > I started out by reading the examples in guile-gtk
> > (guile-1.5.4 and guile-gtk-0.21pre4). It was
> > difficult to get them compile due to some errors in
> > the Makefile.am.
> > 
> > I also read this pages I found on web.
> > 
> > 
> > http://www.lilypond.org/wiki/?Guile
> >
> http://www.nada.kth.se/~mdj/guile-ref/guile-ref_toc.html#TOC10
> > 
> > 
> > 
> > I hope that tihs is to any help
> > Bo Forslund
> > 
> > 
> > Alex Kim wrote:
> > 
> > > Dear guile (and guile-gtk) experts,
> > >
> > > I understand that my question may irritate some of
> > > you since it has been discussed here before.
> > > Nevertheless, I am asking the question with 
> > > desperation and as a last resort.
> > > Many apologies.
> > >
> > > I was given a task a couple of months ago.  After
> > > a long serious thinking, I came up with an idea
> > > which made use of a lot of stack and list 
> > > operations (which scheme is good at) and wanted to
> > > verify my idea as quickly as possible. Fortunately
> > > (or unfortunately, I can't say for sure yet),
> > > I know just enough scheme to write moderate size
> > > programs. So, I started coding in scheme.
> > >
> > > My intension was to implement the idea in guile
> > > scheme and the GUI in c with X or gtk providing
> > > one simple line drawing function for guile to call
> > > so that I can draw lines as they are computed from
> > > scheme code (similar to tortoise example). And it
> > > worked great.
> > >
> > > Then, I wanted to add event processing to the GUI
> > > and this is where I got stuck---it also required
> > > its own event loop in addition to gh_repl. At
> first,
> > > I naively thought I could resolve the problem
> > > using pthread, which didn't work.  With pitiful
> > > and (of course) unsuccessful debugging of many
> > > days, I looked up the list's archive and found out
> > > that the question has been discussed previously
> > > and someone successfully  solved the problem using
> > > event-repl stuff coming with guile-gtk.
> > > Nevertheless, with my short knowledge of guile,
> > > the discussions were hard to follow and I ended
> > > up with a conclusion of rewriting the whole thing
> > > in c.
> > >
> > > However, I still desperately want to stay with
> >
> > > scheme since it will make further improvement of
> > > my idea extremely easier.  So, before I begin to
> > > rewriting, I thought I might ask you, the guile
> > > experts, for help as a last resort.  Would anyone
> > > out there generously provide me some pointers or
> > > simple example codes that work just like tortoise
> > > example, but with added event handling ability 
> > > (either X or gtk)?  I would be very grateful to
> > >  you.
> > >
> > > Please accept my sincere apology if you got upset
> > > by my posting of what has been discussed before.
> > > Thank you very much.
> > >
> > > Sincerely,
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Sports - Coverage of the 2002 Olympic Games
> http://sports.yahoo.com
> 
> _______________________________________________
> Guile-user mailing list
> Guile-user@gnu.org
> http://mail.gnu.org/mailman/listinfo/guile-user
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Newbie pleading for help...
  2002-02-20  9:20 ` Alex Kim
  2002-02-20  9:48   ` Brett Viren
@ 2002-02-20 13:13   ` Neil Jerram
  2002-02-21  1:56   ` Hilaire Fernandes
  2 siblings, 0 replies; 8+ messages in thread
From: Neil Jerram @ 2002-02-20 13:13 UTC (permalink / raw)
  To: Alex Kim; +Cc: Bo Forslund, guile-gtk, guile-user

>>>>> "Alex" == Alex Kim <theseven222@yahoo.com> writes:

    Alex> Then, I wanted to add event processing loop for the
    Alex> GUI itself to respond to the mouse interaction so
    Alex> that I can interactively modify the lines as needed.
    Alex> As I described in the previous message, this
    Alex> turned out to be very hard for me to achieve since two
    Alex> event loops that never return are required (one for
    Alex> gh_repl and the other for GUI).

Hi Alex,

I wrote a short essay on this once, but lost it when my box crashed;
but it may still be available in the Guile mail archive somewhere.  I
think I called it "GUIfying the Guile REPL", so you could try
searching for that.

If you are happy to have the Guile REPL entry line in a Gtk widget
(rather than from the terminal that you ran the program from), then
you can do something very similar to my guile-gui package (available
from http://www.ossau.uklinux.net/guile/).  If you need more help to
understand what this is done, I'd be happy to provide it.

One caveat with guile-gui is that I haven't tried running it since the
guile-gtk package (which you will also need) was at version 0.18; so
it might need some tweaking for the last guile-gtk.

Regards,
        Neil

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Newbie pleading for help...
  2002-02-20 12:46     ` Alex Kim
@ 2002-02-20 13:02       ` Brett Viren
  2002-02-23 23:48         ` Alex Kim
  0 siblings, 1 reply; 8+ messages in thread
From: Brett Viren @ 2002-02-20 13:02 UTC (permalink / raw)
  To: Alex Kim; +Cc: guile-gtk, guile-user

Alex Kim writes:
 > The problem with doing everything in guile-gnome is
 > that the toolkit contains too many stuffs already
 > written in c, X, and gl.  And I was hoping that some
 > modification on GUI code will allow me to easily add
 > more features written in guile (in the way plug-ins
 > work; I thought this was what guile was for when I
 > first started learning it---although I now realize it
 > is much more than that).

Ah, okay.  Also, I reread your past posting and saw you wanted to use
gh_repl().  I don't think this will work so well to combine gh_repl()
and some GUI's main loop (maybe it could be made to work with
guile-gtk, maybe not).  So I would abandon gh_repl and instead read in
scheme using the native GUI's text widget and calling gh_eval_str() on
the result and/or load in the scheme as a file with gh_eval_file().
(Or, rather their scm_ equivalents, because I think gh_ interface is
going away sometime, but gh_ is all *I* know right now....)

I successfully used this in a C++/Gtkmm/Guile application that had to
handle interactive users as well as servicing network requests.  BTW,
when passing unkown scheme code into guile, I used the _catch versions
of the functions so that a typo in the scheme code wouldn't bring down
the whole app.

 > In the mean time, I will
 > study your code to get better understaning in this
 > world. 

Well I am not a great scheme coder, so don't study it too hard! <grin>

Luck,
-Brett.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Newbie pleading for help...
  2002-02-20  9:48   ` Brett Viren
@ 2002-02-20 12:46     ` Alex Kim
  2002-02-20 13:02       ` Brett Viren
  0 siblings, 1 reply; 8+ messages in thread
From: Alex Kim @ 2002-02-20 12:46 UTC (permalink / raw)
  To: Brett Viren; +Cc: guile-gtk, guile-user, theseven222


--- Brett Viren <bv@bnl.gov> wrote:
> 
> Consider doing everything in guile-gnome using the
> Gnome Canvas widget

Thank you very much for your reply.
The problem with doing everything in guile-gnome is
that the toolkit contains too many stuffs already
written in c, X, and gl.  And I was hoping that some
modification on GUI code will allow me to easily add
more features written in guile (in the way plug-ins
work; I thought this was what guile was for when I
first started learning it---although I now realize it
is much more than that).  In the mean time, I will
study your code to get better understaning in this
world.  Again, I sincerely appreciate your help.
Thank you.


__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Newbie pleading for help...
  2002-02-20  9:20 ` Alex Kim
@ 2002-02-20  9:48   ` Brett Viren
  2002-02-20 12:46     ` Alex Kim
  2002-02-20 13:13   ` Neil Jerram
  2002-02-21  1:56   ` Hilaire Fernandes
  2 siblings, 1 reply; 8+ messages in thread
From: Brett Viren @ 2002-02-20  9:48 UTC (permalink / raw)
  To: Alex Kim; +Cc: Bo Forslund, guile-gtk, guile-user

Alex Kim writes:
 > Then, I wanted to add event processing loop for the
 > GUI itself to respond to the mouse interaction so
 > that I can interactively modify the lines as needed.

Consider doing everything in guile-gnome using the Gnome Canvas widget
for the drawings.  You'll be hard pressed to find a better way to draw
and manipulate graphical objects.

See 

  http://superk.physics.sunysb.edu/~bviren/play/gtkin/gtkin.scm 

for *partial* inspiration.  I wrote this a long time ago but it still
runs with libguilegtk/libguilegnome v0.20 (which is the latest on my
Debian system).

This little toy doesn't have any interaction between the canvas
objects and the mouse pointer like you want, but it does show how to
use the gnome canvas with guile and how to manipulate the graphical
objects with some sliders.

But, going further, canvas objects can receive events just like
regular widgets.  (At least this is true in the underlying C canvas,
never tried with the guile bindings.)  By attaching to these events,
you can add the interactivity you want.  How to do that is left as an
exercise to the reader ('cause I don't know).

-Brett.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Newbie pleading for help...
       [not found] <3C73B6EF.D482F76C@abc.se>
@ 2002-02-20  9:20 ` Alex Kim
  2002-02-20  9:48   ` Brett Viren
                     ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Alex Kim @ 2002-02-20  9:20 UTC (permalink / raw)
  To: Bo Forslund; +Cc: guile-gtk, guile-user, theseven222

Hello,

Thank you very much for your reply.  If you wouldn't
mind, I would like to ask you some more questions.

Guile ref. manual says that "An application can use
Guile as an extension language..." and this is exactly
what I want to do.  I am writing a simple image
processing toolkit with GUI in c. The GUI displays an
image and waits for input.  The input is an array of
points and the GUI draws lines connecting the points
on top of the image.  The input, ie, the array of
points, can be generated using various algorithms and
this is where I am trying to use GUILE as an extension
language: the toolkit provides to GUILE one simple
function that draws a line given two points; the
various algorithms are implemented in GUILE calling
the line drawing function to display their results.
This way, I can easily add new algorithms to the
toolkit without touching any other parts of the code.
And I got it work this far following mainly the
tortoise example written by David Drysdale.

Then, I wanted to add event processing loop for the
GUI itself to respond to the mouse interaction so
that I can interactively modify the lines as needed.
As I described in the previous message, this
turned out to be very hard for me to achieve since two
event loops that never return are required (one for
gh_repl and the other for GUI).  After many days
of struggling with pthread, I learned from the list's
archive that pthread can't solve the problem and also
learned that guile and gtk may give me the solution.
So, I am looking for some example codes or any
pointers that can help me solve my problem.  Simply
put, I am looking for something that works just like
the tortoise example (found on GUILE tutorial at
http://www.gnu.org/software/guile/docs/docs.html),
but with added event handling ability for mouse
interaction with GUI.

I hope I described my problem a bit clearer this time.
Do you think what I am trying to do can be achievable?
Again, I sincerely appreciate your reply and any
further advice/helps.
Thank you very much.

Sincerely,
---

Alex Kim





--- Bo Forslund <bo.forslund@abc.se> wrote:
> Hello!
> 
> 
> I'm afraid I can't say that I understand what You
> are asking, but I shall try to give an answer.
> 
> I think I understand that You want a graphic
> interface to scheme. You can have the interface
> written entirely in scheme using guile-gtk, or in
> C and use guile-gtk  glue functions to to call
> scheme functions.
> I managed to get a deck of cards written in scheme
> into a gtk interface some while ago. I also managed
> to do a little prog with the Glade GUI builder that
> called a scheme function.
> Unfortunate it got lost when I had a a crach and had
> to reinstall Linux from scratch. It was 4 - 5
> months ago so I don't remember very well what I did
> either.
> 
> I started out by reading the examples in guile-gtk
> (guile-1.5.4 and guile-gtk-0.21pre4). It was
> difficult to get them compile due to some errors in
> the Makefile.am.
> 
> I also read this pages I found on web.
> 
> 
> http://www.lilypond.org/wiki/?Guile
>
http://www.nada.kth.se/~mdj/guile-ref/guile-ref_toc.html#TOC10
> 
> 
> 
> I hope that tihs is to any help
> Bo Forslund
> 
> 
> Alex Kim wrote:
> 
> > Dear guile (and guile-gtk) experts,
> >
> > I understand that my question may irritate some of
> > you since it has been discussed here before.
> > Nevertheless, I am asking the question with 
> > desperation and as a last resort.
> > Many apologies.
> >
> > I was given a task a couple of months ago.  After
> > a long serious thinking, I came up with an idea
> > which made use of a lot of stack and list 
> > operations (which scheme is good at) and wanted to
> > verify my idea as quickly as possible. Fortunately
> > (or unfortunately, I can't say for sure yet),
> > I know just enough scheme to write moderate size
> > programs. So, I started coding in scheme.
> >
> > My intension was to implement the idea in guile
> > scheme and the GUI in c with X or gtk providing
> > one simple line drawing function for guile to call
> > so that I can draw lines as they are computed from
> > scheme code (similar to tortoise example). And it
> > worked great.
> >
> > Then, I wanted to add event processing to the GUI
> > and this is where I got stuck---it also required
> > its own event loop in addition to gh_repl. At
first,
> > I naively thought I could resolve the problem
> > using pthread, which didn't work.  With pitiful
> > and (of course) unsuccessful debugging of many
> > days, I looked up the list's archive and found out
> > that the question has been discussed previously
> > and someone successfully  solved the problem using
> > event-repl stuff coming with guile-gtk.
> > Nevertheless, with my short knowledge of guile,
> > the discussions were hard to follow and I ended
> > up with a conclusion of rewriting the whole thing
> > in c.
> >
> > However, I still desperately want to stay with
>
> > scheme since it will make further improvement of
> > my idea extremely easier.  So, before I begin to
> > rewriting, I thought I might ask you, the guile
> > experts, for help as a last resort.  Would anyone
> > out there generously provide me some pointers or
> > simple example codes that work just like tortoise
> > example, but with added event handling ability 
> > (either X or gtk)?  I would be very grateful to
> >  you.
> >
> > Please accept my sincere apology if you got upset
> > by my posting of what has been discussed before.
> > Thank you very much.
> >
> > Sincerely,


__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2002-02-24  7:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-19 20:55 Newbie pleading for help Alex Kim
     [not found] <3C73B6EF.D482F76C@abc.se>
2002-02-20  9:20 ` Alex Kim
2002-02-20  9:48   ` Brett Viren
2002-02-20 12:46     ` Alex Kim
2002-02-20 13:02       ` Brett Viren
2002-02-23 23:48         ` Alex Kim
2002-02-20 13:13   ` Neil Jerram
2002-02-21  1:56   ` Hilaire Fernandes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).