[Gambas-devel] Creating a Control

Tobias Boege taboege at ...176...
Mon Sep 8 16:47:50 CEST 2014


On Mon, 08 Sep 2014, John Leake wrote:
> Hi Tobi,
> 
> Thank you for the response. Please do not forget I am a complete newbie
> to Gambas and just trying to get bye following the docs without
> bothering anyone.
> 

Yes, I lose focus of such information while writing. Sorry.

> >> Start
> >> -----
> >> 1) create a new project and set its project type to 'Graphical
> >> application' and check the option 'Component programming'.
> >>
> > 
> > No, you are not programming a component here. A component is a shared
> > library which you can plug into the interpreter to add functionality.
> > You don't do that here (yet?), you're just experimenting in an ordinary
> > project, not a component project.
> 
> The docs say create a new project and mark its type as component. They
> also say that component controls are just ordinary projects.
> 

Yes, the link is actually about writing an own component (shared library)
but it's also cited frequently as a resource of how to implement your own
(graphical) control. Both topics are technically independent of one another,
i.e. you don't need to create a component to add new controls to your
project and new components don't always contain controls. But typically (?)
they're used together.

> What should I do instead of 1) ?
> 

If you just want to experiment/exercise, then don't check the "Component
programming" box. It's not a big deal if you do. The IDE will just behave a
little differently and the project contains some more bits of meta data.

You only need to check this box if you are
  a) exploring how to integrate your own component into other projects or
  b) seriously writing a useful component.

> > It's very natural that it is not there: your MyToggleButton is a class in
> > your first project.
> 
> Again from a newbies perspective I have made a new component.  Perhaps
> it should be found by Gambas (at least as a locally created new
> component)
>

Look at it from a developer's point of view: what would it take to collect
all custom controls from projects the user might have? It would need to scan
at least the entire home directory of the user (not all projects containing
custom controls might have ever been opened by that IDE; you could have just
downloaded them, e.g.). No sane program would do that on each startup.

The Gambas IDE requires *you* to put your stuff into one of the (very) finite
number of standard locations so that it can be found. One of those standard
locations is the project's source code directory and /usr/lib/gambas3 for
components.

[ But note (again?): I don't really work with custom (not in the official
  source tree) components and libraries. I just don't create them because my
  projects are simple and heterogenous enough to be self-contained. Almost
  all my experience here is from reading the docs and occasional mails about
  it. I just answer because I'm afraid Benoit is too busy and so nobody else
  will respond.

  Maybe I should stop doing that so that others don't think you are already
  "being treated"? Or maybe you should write to gambas-user where the chances
  are higher that people with custom components/libraries listen. Ceterum
  censeo Carthaginem esse delendam ;-) ]

> where my new projects can make use of it and also where it
> can be combined with additional new local controls to create more
> aggregated controls.
> 
> One way of achieving this would be to have a publish function that
> copies or moves the new code into the correct place for it to be picked
> up along with all the existing/native controls.
> 

Yes, this "publish" function is the "cp" program :-) Except there is no
great global "pool" of classes when using "cp".

If you miss an integrated function for this way of organisation, you are
very welcome to implement it once you can imagine how to do it.

> > cannot be found. Your custom controls are local to your project, so to say.
> 
> How can I use my new local control an new projects ?
> 
> > If you want to use it in other projects, you can
> >  - create a component, install it and plug it in (Project -> Properties ->
> >    Components),
> 
> Sorry I cannot find instruction for this.
> 

I think your next mail addresses this...

> w.r.t. 5) From the docs "Each control must have an icon that will be
> displayed
> in the IDE control tool box.".
> 
> Shouldn't the default be images from the original control ?
> 

So you suppose that if there is no picture to symbolise a control, the
parent class should be drawn. I would agree. But maybe this logic is just
not integrated yet (I think it would require to extract files from other
components). Let's (implicitely) ask Benoit.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the Devel mailing list