First Program Test

New to Gambas? Post your questions here. No question is too silly or too simple.
Post Reply
PeteMarsh
Posts: 13
Joined: Thursday 22nd February 2024 8:01pm

First Program Test

Post by PeteMarsh »

Hi - I'm Experienced on VB6 but brand New to Gambas.

Once installed i built an on screen app to simply put text in a box when a button was pressed as an initial test.

For every Item on the screen (eg button, text box etc) i get a line in what was the "Immediate" window in VB6 like :

(First_Test:1173): Gtk-CRITICAL **: 19:52:44.824 IA_gtk_container~_add assertion "GTK_ID_WIDGET (Widget)' failed

Ive removed Gambas and then reinstalled but to no avail. I tried downloading someone elses text only app and it just worked with no comments in the immediate window.

Any Ideas - I'd love to get programming - Thanks
User avatar
BruceSteers
Posts: 1578
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: First Program Test

Post by BruceSteers »

Welcome to the wonderful world of gambas 😎

It's just a gtk toolkit warning.

It usually means something it too small. A panel or something has zero or negative size.

You get it if labels or check boxes are too small too.

What version of gambas are you using?
If at first you don't succeed , try doing something differently.
BruceS
PeteMarsh
Posts: 13
Joined: Thursday 22nd February 2024 8:01pm

Re: First Program Test

Post by PeteMarsh »

Thanks Bruce. Fell at the first fence there ! I'll start again. Do buttons etc have to be in a container or can i just put them on a form like VB ? Version - Gambas3 - everything newly downloaded and updated including Debian. Can't beleive im only finding Gambas now - have tried using VB6 exe's on windows Iot but cant get at the IO pins easily and coulndt get serial data out Gave up in the end and shelved the project.
Last edited by PeteMarsh on Friday 23rd February 2024 11:46am, edited 1 time in total.
User avatar
BruceSteers
Posts: 1578
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: First Program Test

Post by BruceSteers »

Yes there are a variety of "Containers" and the main form is one of them.

You will get used to it all don't worry.
I'd hardly call it falling down. just a mere stumbling block :)

It''s just one of those things to learn along the way.
Gambas is far easier than VB at the end of the day and the IDE is awesome , and written in gambas too :)

I used to get layout warning messages like that once upon a time but not so much these days as i just got better at making the GUIs and learned all the the tricks to avoid them,
like, for example, setting the AutoResize property on things like CheckBox's and Labels if they are giving warnings (usually because they are too small to fit their text)

Things to watch out for in GUI building...
Some things like a slider for example will not render in your GUI if they are too thin. I think this is to stop all those warning messages, it simply does not render if it does not have the space.

Experiment using Panels/HBox's/etc and use the Panel.Arrangement and the Expand properties to auto-layout your controls.

Also if you are using gb.gui then you can easily switch your program from GTK3 to QT5 by using the debugger option.
GTK+ and QT toolkits behave slightly differently to each other and checking out both toolkits can help make sure you have laid it all out best.

also ANY application using gb.gui (including the gambas IDE) can be run using either toolkit using the env variable GB_GUI in the command.
Run in a terminal like this...

env GB_GUI=gb.qt5 gambas3

that will force the IDE (and any gb.gui program) to use qt instead of gtk3
env GB_GUI=gb.qt5 $HOME/MyApp/MyApp.gambas
If at first you don't succeed , try doing something differently.
BruceS
Online
User avatar
cogier
Site Admin
Posts: 1127
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: First Program Test

Post by cogier »

Welcome to the forum.

There is quite a difference between VB and Gambas regarding placing items on the form. You can just drag a tool on to the form and your program will run. If you want the form to be resizeable and the contents to rearrange nicely, then there is a bit of a learning curve. I have written a program to get users started with the concepts. It's called ExpandingForms and you can download it from the Gambas Farm. (Tools>Software Farm).
User avatar
thatbruce
Posts: 168
Joined: Saturday 4th September 2021 11:29pm

Re: First Program Test

Post by thatbruce »

and a tip from me (that some may have heard before :D )
Read the help pages until your eyes bleed. Read every word. It is succinct and can easily be misunderstood if your mind skips words or think they mean something from some other language.
For example look at one of the Balloon functions, say Balloon.Question(). It is easy to miss that the X and Y parameters are relative to the control.
Have you ever noticed that software is never advertised using the adjective "spreadable".
PeteMarsh
Posts: 13
Joined: Thursday 22nd February 2024 8:01pm

Re: First Program Test

Post by PeteMarsh »

Thanks again Bruce and everyone else. All working now and crashing on in to my first application ( A HIIT Timer running external LED displays over a serial port).

I stumbled again trying to define variables - they seemed to object to being at the top of the page until I copied the header from another program - I think it had something to do with ' Gambas Class file then ' Gambas module file headings, but these are just inert labels so im not sure what was going on.

I think I have the graphics sorted out now, but am struggling to use the gb.net serial port - I'm sure there must be an equivalent to setting the port name to "Com1" as in VB, but not sure what its called on the GPIO pins.

I'll keep googling ! - Thanks again all.

Pete
User avatar
BruceSteers
Posts: 1578
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: First Program Test

Post by BruceSteers »

well without seeing example code it's hard to tell.

Dim cannot be used outside of methods.


' the following are global variables seen to all methods of the class and Public ones can be accessed from other classes
Public MyPublicVar as Integer
Private MyPrivateVar As Integer

Static Public MyStaticVar

Public Sub MyMethod()

 ' the following is local only to the MyMethod() function and cannot be seen/used outside unless passed as an argument
 Dim MyLovalVar as Integer

End




Hope that all makes sense.
the ' gambas class comment line that EVERY gambas class file has is probably NOT the cause of the error , if you remove/move it the IDE just pops it back in again :)

Don't be afraid to post code snippets so we might be able to help better :)
If at first you don't succeed , try doing something differently.
BruceS
Post Reply