Help, GTK and Win32: load .UI, change Label, and more....

New to FreeBASIC? Post your questions here.
Post Reply
CFreBasic
Posts: 14
Joined: Feb 01, 2015 21:17

Help, GTK and Win32: load .UI, change Label, and more....

Post by CFreBasic »

Hi. (sorry my english)
Starting with freebasic. (came from Qbasic, QuickBasic, Visual Basic....)
Some questions: (not only an answer, but with a code example, please)

1)-
I have my "file.ui" done.
I know how to load a ".glade", but: how to load a ".ui" with Gtk?

2)-
If in my ".ui" i have a "Label" named "Label1A":
(and keeping in mind that is loaded in my program)
In VB, is: Label1A.Caption = "Some text"

In code (GTK): how can i change the "Caption" value?
And in Win32 ("Windows.bi")?

3)-
Can i mix in one ".bas" code of GTK and Win32?

4)-
With the ".ui" loaded:
How can disable "Maximize Button" of the Window?
- Or in "Glade": where is the option?

5)-
If i have three or more ".ui" files:
In code, i want to see only one window and in two buttons:
- how call to show window?
- Even if i see the window: how show window and close the window from who was called?
(so the First window is no more)

I have other questions, but for now this.
(i searched, but many of this questions are in big examples that i dont understand)
Thanks
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Help, GTK and Win32: load .UI, change Label, and more...

Post by TJF »

Hello CFreBasic, welcome at the forum!

I recommend that you check out the examples at freebasic/examples/GUI/GTK+ first. Especially in the example code GtkBuilder.bas you shoud find a lot of answers.

If you've still questions left (or new onces), then ask again.

BR
CFreBasic
Posts: 14
Joined: Feb 01, 2015 21:17

Re: Help, GTK and Win32: load .UI, change Label, and more...

Post by CFreBasic »

Thanks TJF, i was testing the GtkBuilder.bas, the problem.... the "window" (.UI file), load and all, but GTK don´t show anything. Just the CMD window (the black window, the "console") and shut down.
I tested using "sleep" in diferents parts of the code: the CMD just show nothing, no key answer, and i must close the CMD, the only way to terminate.
Very strange. Clean install. (last freebasic, and last GTK 3) (it was necessary to use #LIBPATH in the code)
If i use code inside the .bas to CREATE the window, labels, etc...: they work perfect. See the window and all, but if i use the code of loading the .UI: don´t show nothing.
- Is frustrating, because using code in the .bas to make complex windows, is imposible.
Much easy to buil with Glade and load it whit GTK.... but.... don´t work.
And looking in internet, i found nothing about the problem.

With this, i can´t continue learning. If in this days (maybe one week more) i can´t see results:
Freebasic (a great languaje) will not be usefull to my, because the "lack" of a "nice interface to the final user".
(today, making programs, the interface, is NECESARY por the most people).
(For my: no problem. I from the good old times of Atari and commodores :-)
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Help, GTK and Win32: load .UI, change Label, and more...

Post by TJF »

CFreBasic wrote:Thanks TJF, i was testing the GtkBuilder.bas, the problem.... the "window" (.UI file), load and all, but GTK don´t show anything. Just the CMD window (the black window, the "console") and shut down.
Sounds like a problem in the libraries install. (Most likely a mismatch between GLib and GTK+ versions. On non-LINUX systems you get rare and bad error messages.)
CFreBasic wrote:Very strange. Clean install. (last freebasic, and last GTK 3) (it was necessary to use #LIBPATH in the code)
Yes, either #LIBPATH or option -p in the command line is necessary.

What does last mean? Version No? Where did you get GTK+ from (32 or 64 bit)? Some days ago, I tried those binaries (GTK+3.6.4, 32 bit), working fine here.
CFreBasic
Posts: 14
Joined: Feb 01, 2015 21:17

Re: Help, GTK and Win32: load .UI, change Label, and more...

Post by CFreBasic »

GTK+-bundle v3_8_2-20130704_win32-RC1
Still searching for a solution....
TJF wrote:Sounds like a problem in the libraries install. (Most likely a mismatch between GLib and GTK+ versions. On non-LINUX systems you get rare and bad error messages.)
In QB64, they make a "Temp" directory with some ".BAT" to rebuild and see in .TXT files the problem....

Can Freebasic make a log of the compiled o running program?. Maybe with that, i can see what is going on....
(and post the log).
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Help, GTK and Win32: load .UI, change Label, and more...

Post by TJF »

CFreBasic wrote:GTK+-bundle v3_8_2-20130704_win32-RC1
google wrote:Es wurden keine mit Ihrer Suchanfrage - "GTK+-bundle v3_8_2-20130704_win32-RC1" - übereinstimmenden Dokumente gefunden.
TJF wrote:Where did you get GTK+ from ...?
I cannot help if you don't answer my questions ...
CFreBasic
Posts: 14
Joined: Feb 01, 2015 21:17

Re: Help, GTK and Win32: load .UI, change Label, and more...

Post by CFreBasic »

Sorry, i was busy in some family problem....
The "GTK+-bundle v3_8_2-20130704_win32-RC" was from a page of GTK (i dont remember right now) where lot of people are using it with no problem. (29mb, run-time and developer packages).

As i see in http://win32builder.gnome.org/, there is other version: gtk+-bundle_3.8.2-20131001_win32.zip
And other: gtk+-bundle_3.10.4-20131202_win32.zip

My freebasic dir, now, is a mess... After several attempts ...
Maybe is time to decompress (again, after TEN times) in other folder and try once more another GTK.
(My patience is getting involved ...) :-)
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Help, GTK and Win32: load .UI, change Label, and more...

Post by TJF »

I do not mix FB and GTK binaries. Instead, I install FB in the usual way (calling the installer) and then I create a folder C:\opt. In that folder I copy the GTK+binaries, so that I have subfolders like
  • C:\opt\bin
  • C:\opt\lib
  • C:\opt\usr
  • ...
I add the first to my PATH environment varaible. And I prepend the source code by #LIBPATH "C:/opt/lib" (or use option -p C:\opt\lib when compiling). That way I can install various GTK+ versions and compile and test against them, by just renaming the C:\opt folder.
CFreBasic
Posts: 14
Joined: Feb 01, 2015 21:17

Re: Help, GTK and Win32: load .UI, change Label, and more...

Post by CFreBasic »

Thanks for the info.
I was trying with a fresh install of FB and GTK 3.10.4.
Same result. Black screen, but (again) if i use code to create the window (butons, label, etc..): no problem.
No errors, no log, nothing.... the load of the ".ui" (or .glade) file: fine. but, don´t show anything.

In the next days, i will move in differents PCs (FB and GTK), and see what happend.
So, i think, next week, i will post the results.
(...fingers crossed...)
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Help, GTK and Win32: load .UI, change Label, and more...

Post by TJF »

CFreBasic wrote: if i use code to create the window (butons, label, etc..): no problem.
No errors, no log, nothing.... the load of the ".ui" (or .glade) file: fine. but, don´t show anything.
Did you make the main window in the ui file "visible"? Or use gtk_widget_show_all() on it?
CFreBasic
Posts: 14
Joined: Feb 01, 2015 21:17

Re: Help, GTK and Win32: load .UI, change Label, and more...

Post by CFreBasic »

Sorry the big absence. Lot of work. Even in my spare time, I tested in differents PC the "problem" with GTK.
TJF wrote:Did you make the main window in the ui file "visible"? Or use gtk_widget_show_all() on it?
All the properties in the ".ui" are "True". Even the "Visible".
gtk_widget_show_all() works well if i do not use the ".ui", if i write code to draw buttons and so....
(again: in pure code, all good. But in a new code, loading ".ui": black screen (the "cmd") and none window showing.

After all this time, tested in 26 PC (yes, 26!). XP SP2, XP SP3, and W7 SP1.
Only in two, the window showed. And I could not find, HOW or WHY window appear.
Very, very strange.... (or the process to load the ".ui" is deprecated, or someting inside the code can´t handle..., or is giving an "hidden" error I can not see beacause, as i say weeks ago, i don´t have a ".log" or similar).

For now, i will still search the problem and (without and option) i will code at the "classic style" of Clipper or old D.O.S.
Thanks TJF, and I keep hearing suggestions
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Help, GTK and Win32: load .UI, change Label, and more...

Post by TJF »

What about posting a minimal example code here (ui file and FB source code)?

What happens when you compile and run the example
  • freebasic/examples/GUI/GTK+/GtkBuilder.bas
Post Reply