How to instantiate arbitrary number of widgets of different types dynamically?

60 views
Skip to first unread message

Félix Le Blanc

unread,
Mar 20, 2022, 1:13:08 PM3/20/22
to fltk.general
I am working on a GUI Interface for a terminal application.  

I need to instantatiate random number of random FLTK widget types. 

Ex.: dial, button, valuator,  switch etc  

What is the best way to acheive this? 

Thank's for your help.

Albrecht Schlosser

unread,
Mar 20, 2022, 1:24:23 PM3/20/22
to fltkg...@googlegroups.com
On 3/20/22 18:06 Félix Le Blanc wrote:
> I am working on a GUI Interface for a terminal application.
>
> I need to instantatiate random number of random FLTK widget types.
>
> Ex.: dial, button, valuator,  switch etc

"Random" is a big word for describing which widgets you want to use. I
don't think your GUI consists of really "random" widgets, does it?

> What is the best way to acheive this?

There's no "best way". It depends on what you want to achieve, how you
want to create the GUI layout, how flexible your GUI needs to be, etc.

The "simple" way is to write C++ code that creates the widgets. Please
read the docs to see how this works, for instance
https://fltk.gitlab.io/fltk/basics.html#basics_writing
There are lots of examples in the examples/ and test/ folders of the
FLTK distribution, for instance the simple test/hello.cxx.

The more comfortable layout tool is fluid, but this is maybe hard to use
for the first time. There's also a documentation section about this:
https://fltk.gitlab.io/fltk/fluid.html

FLTK 1.4.0 will provide a grid layout widget (Fl_Grid) but this is not
yet available (it's in current development). It can help to create a
dynamic layout with multiple widgets, similar to a HTML "table".

Basile Starynkevitch

unread,
Mar 20, 2022, 5:06:46 PM3/20/22
to fltkg...@googlegroups.com, Félix Le Blanc

A possible way is to have some interpreter (which interprets some  scripting language of your design) driving FLTK.


You could look for example into the RefPerSys project (on http://refpersys.org/ and source code on https://github.com/RefPerSys/RefPerSys ...) or extend GNU guile or minilisp or look at French talks  in honor of Jacques Pitrat  or read Pitrat's books and papers.

Standarde blurb on RefPerSys: follows.

I am living near Paris in France and got my PhD in 1990 at Paris LIP6, on symbolic artificial intelligence.

On github I am https://github.com/bstarynk

On SoftwareEngineering I am  https://softwareengineering.stackexchange.com/users/40065/basile-starynkevitch

You (or colleagues in computer science) could be interested by the RefPerSys -a reflexive& persistent system- open source symbolic artificial intelligence system (GPLv3+ licensed, for Linux) - work in progress

See http://refpersys.org/ for details. (It is in july 2021 - March. 2022 an unfunded project)

It is related to the work of the late Jacques Pitrat (1934 - oct. 2019) who was the director of my PhD jury, defended in Paris in 1990.

You probably would enjoy reading both Pitrat's blog, still on http://bootstrappingartificialintelligence.fr/WordPress3/ and his last book:

Artificial Beings: the Conscience of a Conscious Machine

ISBN-13: 978-1848211018

(that book also contains something relevant to machine learning with metarules)


My professional work at CEA LIST in France is on cybersecurity on Bismon, a static source code analyzer above GCC for C and C++ code : code is on https://github.com/bstarynk/bismon and funding happens thru the DECODER projects. They could end quickly. My professional email is basile.sta...@cea.fr.
RefPerSys is currently (2020 to early 2022) a pet or hobby project (coded with others in C++, and we are rewriting it in C for non-technical reasons), but I am trying to find some contributors (some of them are in India), maybe funds and applications for it (and dream of being able to work on, it part time in a few months). It is (as a Linux application) orthogonally persistent and generates C++ (and hopefully soon C) code. The insight is to generate a lot more and more C or C++ code from a more declarative description, as advocated by the late Jacques Pitrat.
Perhaps you could be interested in contributing to RefPerSys?

Perhaps you have students or colleagues interested in actively contributing to RefPerSys?

Perhaps RefPerSys could be useful to some students or become a starting point for some future HorizonEurope submission, or ITEA proposal....? Or any kind of project which could partly fund  or contribute code to RefPerSys? In such case email me also at work: basile.sta...@cea.fr


Difference between RefPerSys and Ocaml: RefPerSys has introspection, is dynamically typed, and multi-threaded. It is alpha quality.


My constraints are: RefPerSys is for Linux only, and I am only capable of producing PDF documents with LaTeX (but not with Microsoft software) I never used in my life any Microsoft Windows operating system (only Linux), and at the age of 62 I don't have the time -or the motivation- to learn how to use a Microsoft Windows operating system. But I am using Linux both at home and at work since 1993.

A mailing list for RefPerSys also exists, archived on https://framalistes.org/sympa/arc/refpersys-forum

NB. In French: voyez le logiciel libre d'intelligence artificielle symbolique RefPerSys

PS. If you have money to spend, please support Ukraine against Russian invasion


-- 
Basile Starynkevitch                  <bas...@starynkevitch.net>
(only mine opinions / les opinions sont miennes uniquement)
92340 Bourg-la-Reine, France
web page: starynkevitch.net/Basile/

Matthias Melcher

unread,
Mar 20, 2022, 8:16:58 PM3/20/22
to fltk.general
Call `begin()` on any Fl_Group widget, then just generate your widgets calling `new` like on any other c++ class. The new widget will be instantiated and added to the current group thanks to teh begin call. If your group is Fl_Pack, your new widgets will be arranged for you. If not, you must give them coordinates.

myGroup->begin(); Fl_Dial *myDial = new Fl_Dial(10, 10, 100, 100, "Dial"); myGroup->end();

Ian MacArthur

unread,
Mar 21, 2022, 5:41:15 AM3/21/22
to fltk.general
On Monday, 21 March 2022 at 00:16:58 UTC Matthias Melcher wrote:
Call `begin()` on any Fl_Group widget, then just generate your widgets calling `new` like on any other c++ class. The new widget will be instantiated and added to the current group thanks to teh begin call. If your group is Fl_Pack, your new widgets will be arranged for you. If not, you must give them coordinates.

myGroup->begin(); Fl_Dial *myDial = new Fl_Dial(10, 10, 100, 100, "Dial"); myGroup->end();

flbs... schrieb am Sonntag, 20. März 2022 um 18:13:08 UTC+1:
I am working on a GUI Interface for a terminal application.  

I need to instantatiate random number of random FLTK widget types. 

Ex.: dial, button, valuator,  switch etc  

What is the best way to acheive this? 

Thank's for your help.


Quite a few of Erco's examples build the UI programmatically, or add widgets dynamically, so you can refer to those to see some ways this can be done. It's not hard.



ps: TBH - this looks quite a lot like someone's homework question: I'd just caution the OP that, if it is, they will learn nothing by getting others to do their work for them.


Félix Le Blanc

unread,
Jul 11, 2022, 5:16:50 PM7/11/22
to fltk.general
 Vous êtes le seul à avoir bien compris ma question. Merci pour votre réponse.  Je vais intégrer python. (reference counting)
Reply all
Reply to author
Forward
0 new messages