Question about Prolog/XPCE

Hi,
after a long break, I’ve restarted playing with SWI-prolog and its graphical object-oriented extension XPCE lately and I would like to know: is there a way of adding information to the general clause

send(Obj, open)

in such a way that the Obj window doesn’t open randomly (or following the default values), but rather in a precise part of the screen? Because if I don’t set specific parameters I always get the window opened in the wrong place (overlapping other windows for example).
Thanks for your answer and thank you all for the development of SWI-Prolog during all these years.
Marco

Sorry about the late answer, XPCE is old and it has a small number of users, it is mainly used in the GUI of Swi-Prolog.development tools

This example should work from the command line

new(Frame,frame),new(P,point(400,300)), send(Frame, open(position := P)).

Thank you PasiK! So the trick is to create two objects (a frame/window and a point) and then add that the window should open at that point with the specification (position := ObjRef) to the send(Obj, open) clause. Apropos XPCE: I also had the impression that it is no longer developed/maintained, but I don’t know why I was interested in it. Thanks a lot!

XPCE looks visually like from 1990’s, but I have began to really appreciate it. Eric Zinda in his blog wrote about it as fast prototyping tool.

Yes a professional tool and in the old days professional tools didn’t care much about visual bling bling :slight_smile:

Ok. Thanks a lot for the reference to Eric Zinda’s blog. Excuse me…but I’m learning to do stuff :sweat_smile:

1 Like

Actually the idea that I’d like to work on is to use xpce and its drawing capabilities to build a little system that draws syntactic labelled parse trees out of prolog compound terms/lists representing parsed sentences with their syntactic structure (S, NP, VP, Det… and so on…) and then with the lexical items. But I don’t know: a) is it possible (in principle it doesn’t seem impossible at least), b) will I be patient enough to carry out the task? I’ll let you know if I make any progress :wave:

A common way of doing this is to use GraphViz by generating a description of the graph in DOT. And there are other tools such as https://www.tomsawyer.com/ .

Thank you. I imagined that someone might have already developed something similar. I’ll give a look at those things.

Jan actually have provided some of the basic tools in SWISH. But there is still value in XPCE, I hope you will succeed with your task.

2 Likes

At the moment I’m trying with the dot language which peter ludemann suggested because the syntax is very simple and it doesn’t seem impossible to build a pipeline in three steps: prolog file > .gv file > .svg file. At least that’s what I have in mind. I’ll let you know. Swish is really a great thing. I agree

Well, I’m quite happy to say that it worked! I’m a happy man :sweat_smile:
The grammar is really primitive: it only tackles simple sentences with a subject, a verb and an optional adverbial modifier like [a, boy, eats, slowly] or [the, cat, silently, sleeps] and so on. The basic ideas are contained in Bramer’s Logic programming with Prolog and Learn Prolog Now! by Blackburn, Bos and Striegnitz.

A predicate takes as input a sentence (represented as a list of words) and outputs a parsed structure like

Parse = s(np(det(the), n(cat)), vp(adv(silently), v(sleeps)))

then this thing is processed and output to a .gv file which has the following look:

strict graph  {
    node [shape=plaintext]
    s -- {np vp}
    np -- {det n}
    det -- the
    n -- cat
    vp -- {adv v}
    adv -- silently
    v -- sleeps
}

This in turn is translated into a graph by writing at the terminal window
“dot -Tsvg file.gv > file.svg”

Thanx for the suggestions :+1:

Not sure if you tried to upload the *.gv and *.svg files here to show others but you should be able. :slightly_smiling_face:
If not let me know, I have admin rights on this site.

For an example of such uploaded files see this reply.

I am curious see them.

No, I didn’t. But I will upload the two *.svg files here

first
second

1 Like

the two *.gv files:

first.gv (129 Byte)
second.gv (105 Byte)

1 Like