[Gambas-user] Inconsistent initialization in controls: seems a little bug

Benoît Minisini gambas at ...1...
Sat Sep 4 02:22:16 CEST 2010


> > I tested this only for control Label:
> > 
> > When a control label is created in execution time using gb.qt, then
> > 
> > control become visible just after assign a value at the Text property:
> >   PUBLIC SUB _New()
> >   
> >     DIM lbl1 AS NEW Label(ME)
> >     
> >     lbl1.Text = "Hi people"
> >   
> >   END
> > 
> > But if you write the same code in a form using gb.gtk, the control
> > Label keeps invisible until the properties X, Y, Width and Height gets
> > values.
> 
> I'm inclined to prefer the gb.gtk behaviour than the gb.qt one, aren't you?

Some explanations, because it seems that things are not clear for you:

There is no difference in what you can do with the GUI editor and what you can 
do directly by code. The Gambas compiler just transform the GUI description 
into normal Gambas code.

So when you put a Label inside a control, it generates something like that:

<Label name> = NEW Label(<Label container>) AS "<Label event name>"
WITH <Label name>
  .Text = "<Label name>"
  .MoveScaled(<X>, <Y>, <Width>, <Height>)
END WITH

*Very important!*: When a property has its default value, no code is 
generated.

As soon as a control is created, it is automatically visible. *But*, at the 
moment, gb.qt4 assign an arbitrary size to the control, whereas gb.gtk has an 
internal system that shows the control only when a size has been attributed by 
code.

When I say that I prefer the gb.gtk behaviour, I mean I thought implementing 
the same system in gb.qt4 too.

Why? Because changing a control property is generally heavier when it is 
already visible, because it must be refreshed. So it is perfectly logical that 
controls are not visible when created (which is what do *all* GUI toolkits).

As for having "AutoResize = True" by default, it is not possible anymore, as 
it will break the existing code, because of the rule about default values of 
properties described above.

Regards,

-- 
Benoît Minisini




More information about the User mailing list