XPCE GUI does not fit onto screen

Hello,

I am looking for help with my XPCE-GUI.

I’m using: SWI-Prolog version 8.4.3

I want the code to: Show a graphical user interface with 10 columns that fits onto my screen.

But what I’m getting is: My user interface does not fit onto the screen! The columns 9 and 10 are not shown and there is no way to access them, because the window has no horizontal scrolling option.

I tried changing the dialog size. Using the property “size(200,200)” in line 3 of the source code does not change the size of the dialog. If I change it to i.e. “size(20, 20)”, the size does not change.

I tried changing the text box sizes with “width”. The text boxes can be shortened by this, however XPCE still seems to reserve the same amount of space for each column, regardless of text item width.

  1. How can I squeeze the columns closer together?
  2. Is there a way to implement a horizontal menu bar that allows to access elements that do not fit onto the screen?

My code looks like this:

:- use_module(library(pce)).

t1:-new(D,dialog('GUI', size(200, 200))),
new(H1, dialog_group('  Caption1  ')),

	
new(HN1, text_item('cn1','')),
send(HN1, width,40),
send(HN1,show_label,false),
send(H1, append, HN1,right),

send(D, append, H1),


new(H2, dialog_group(' Caption2 ')),


column(C1,0,group,"Cpt1",'test1'),

column(C2,1,group,"Cpt2",'test2'),
column(C3,1,group,"Cpt3",'test3'),
column(C4,1,group,"Cpt4",'test4'),
column(C5,1,group,"Cpt5",'test5'),
column(C6,1,group,"Cpt6",'test6'),
column(C7,1,group,"Cpt7",'test7'),
column(C8,1,group,"Cpt8",'test8'),
column(C9,1,group,"Cpt9",'test9'),
column(C10,1,group,"Cpt10",'test10'),


row(RowAll,group,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10),
send(H2,append,RowAll),

send(D, append, H2, below),


send(D,open).

column(C,0,Type,Labeltext1,Labeltext2) :-
	new(C,dialog_group('Col1',Type)),
    
	new(Lab1,label(lab_1_0,Labeltext1)),
	send(C, append, Lab1),
	send(C, append, label(lab_1_1,Labeltext2), below),
    
	
	send(C,gap,size(1,0)),
	
    new(CN1, text_item('cn1','')),
	send(CN1, width,20),
    send(CN1,show_label,false),
    send(C, append, CN1,below),

    new(CN2, text_item('cn2','')),
	send(CN2, width,20),
    send(CN2,show_label,false),
    send(C, append, CN2,below),

    new(CN3, text_item('cn3','')),
	send(CN3, width,20),
    send(CN3,show_label,false),
    send(C, append, CN3,below),

    new(CN4, text_item('cn4','')),
	send(CN4, width,20),
    send(CN4,show_label,false),
    send(C, append, CN4,below),
	
    new(CN5, text_item('cn4','')),
	send(CN5, width,20),
    send(CN5,show_label,false),
    send(C, append, CN5,below),
	
    new(CN6, text_item('cn4','')),
	send(CN6, width,20),
    send(CN6,show_label,false),
    send(C, append, CN6,below).


column(C,1,Type,Labeltext1,Labeltext2) :-
	new(C,dialog_group('Col1',Type)),
    
	send(C,gap,size(1,0)),
	
	new(Lab1,label(lab_1_0,Labeltext1)),
	send(C, append, Lab1),

	send(C, append, label(lab_1_1,Labeltext2), below),
    
	
    new(CN1, text_item('cn1','')),
	send(CN1, width,10),
    send(CN1,show_label,false),
    send(C, append, CN1,below),

    new(CN2, text_item('cn2','')),
	send(CN2, width,10),
    send(CN2,show_label,false),
    send(C, append, CN2,below),

    new(CN3, text_item('cn3','')),
	send(CN3, width,10),
    send(CN3,show_label,false),
    send(C, append, CN3,below),

    new(CN4, text_item('cn4','')),
	send(CN4, width,10),
    send(CN4,show_label,false),
    send(C, append, CN4,below),
	
    new(CN5, text_item('cn4','')),
	send(CN5, width,10),
    send(CN5,show_label,false),
    send(C, append, CN5,below),
	
    new(CN6, text_item('cn4','')),
	send(CN6, width,10),
    send(CN6,show_label,false),
    send(C, append, CN6,below).

row(R,Type,Column1,Column2,Column3,Column4,Column5,Column6,Column7,Column8,Column9,Column10) :-
	new(R,dialog_group('ColAll',Type)),
	
	%send(R,gap,size(1,1)),
	send(R, append, Column1, right),
	send(R, append, Column2, right),
	send(R, append, Column3, right),
	send(R, append, Column4, right),
	send(R, append, Column5, right),
	send(R, append, Column6, right),
	send(R, append, Column7, right),
	send(R, append, Column8, right),
	send(R, append, Column9, right),
	send(R, append, Column10, right).

The resulting GUI does not fit to the screen, e.g. it is cut off on the right and does not display the last two columns:


I am looking forward to read advice from a prolog programmer that is more experienced than I am!

Malo

It has little to do with Prolog :slight_smile: Anyway, you can get there, but is is a bit ugly. Dialogs have their size fixed by their content, so we have to cheat a little. First, give it scrollbars (and remove the size as it is meaningless):

t1 :-
    new(D,dialog('GUI')),
    send(D, scrollbars, both),
    ...

Now, at the end, fix the size, first we must run layout by hand to avoid the lazily called layout during open from resizing the dialog and then we set the size:

    ...,
    send(D, layout),
    send(D, size, size(200,200)),
    send(D,open).

Hello Jan,

thanks a lot for your solution (it works perfectly) and the kind explanation.

You are of course correct regarding my word choice, my XPCE-problem has little to do with Prolog. May I still ask future XPCE-related questions in this forum, or is this help forum intended to be strictly about Prolog itself?

Kind regards,
Malo

You are more than welcome to ask XPCE-related question in this forum. :slightly_smiling_face:

1 Like