I’ve been trying to scratch a recent itch involving prolog and gui applications, so I’ve been trying my hand at writing some basic applications with XPCE. While manpce
and the user guide have been useful for building the most basic of applications, I am struggling to manipulate simple elements.
I’m building a toy flight booker app ala 7GUIs. I’m currently struggling on changing the background color of an XPCE text_item
. If possible, I’d also like to make a text element immutable (or view only) like one might make an immutable textbox in HTML.
My code so far is simple:
% main.pl
% usage: swipl-win.exe main.pl
:- use_module(library(pce)).
:- initialization main.
main :-
new(D, dialog('Flight Booker')),
menu(Menu),
date_box(StartBox, '2022-01-01'),
date_box(ReturnBox, '2022-02-01'),
send(D, append, Menu),
send(D, append, StartBox),
send(D, append, ReturnBox),
send(Menu, message, message(@prolog, menu_selected, Menu)),
get(D, confirm, _).
menu_selected(Menu) :-
get(Menu, selection, Item),
% print Item
write(Item), nl.
menu(Menu):-
new(Menu, menu(flighttype, cycle)),
send(Menu, show_label, @off),
send_list(Menu, append, ['one-way flight', 'return flight']).
date_box(Box, InitDate) :-
new(Box, text_item(date, InitDate)),
send(Box, type, string),
send(Box, length, 12),
send(Box, show_label, @off).
I can change the color of the text in the text_item
box by sending a message the color
properties in date_box
, but I can’t change the color of the background (which I would like to turn red). In general, it has been difficult to determine which properties I can notify by reading the manual. The closest I’ve gotten is to look through Appendix H and glimpsing some hints from the code samples there. I have used the manpce dialog editor to build elements and view the generated source in (the built-in) emacs, but unfortunately it doesn’t look like there is anything related to the background.
I’m hoping there’s a way to modify visual properties from one of the dialog’s super classes:
It would be great too if there were ways to prevent input from temporarily being accepted to one of the dialogs. I’m just not sure how I could achieve this goal.