Are there any GUI APIs out there for GLBasic? Maybe a port of wxWindows or such?
What about next year? :)
Why not use DDGui? Its cross-platform, Take a look at Nokia/Digia-Qt its going to migrate all their gui stuff to QML (JavaScript) for cross-platform compatibility.
I searched the forum and I don't see any info on TK. Is there any documentation on out?
theres a project in samples/_Projects_/tlctk
Thanks,
I'm checking out the Tk sample to see how it all works.
I noticed a couple of errors in the sample and thought I'd post here so that maybe they can get corrected.
Line 66 :
DRAWRECT 0,0,60*ABS(SIN(GETTIMERALL()/10)),60, cols[icolor]
should be
DRAWRECT 0,0,60*ABS(SIN(GETTIMERALL()/10)),60, cols[icolor%] // icolor% instead of icolor
Line 70:
IF tk_GetVal$(but%) THEN icolor = MOD(icolor + 1, LEN(cols[]))
should be
IF tk_GetVal$(but%) = 1 THEN icolor = MOD(icolor + 1, LEN(cols[]))
I was wondering about this? If doesn't appear that GLBasic is doing a simple True/False check against 0 vs 1?
Line 88:
IF tk_GetVal$(ok%)
should be
IF tk_GetVal$(ok%)=1
Also wondering; is there somewhere else I should post bug type issues like this rather than as a post here in the forum?
A couple other things I noticed/have questions about.
tk_ComboBox states in the comments that it takes a list that is pipe separated, but it really requires a space separated list. Using a space separated list is a little painful when trying to use it to show a directory listing for example as Windows often times includes spaces in directories... I can do some string replacement to replace strings with something else, but this will look a bit ugly to end users. Maybe there is a better way to do directory listings rather than with a ComboBox in this Tk implementation? As far as I can see though there is no support for top level windows such as tk_chooseDirectory; or am I missing something there?
Another issue I've run into is that the entire GUI will become unresponsive if you change the current directory. I am managing this by keeping track of the directory the user is browsing too in one var and the default app directory in another. I then change directories to populate an array with the directory listing then immediately swap back to the default directory.
cur$ = GETCURRENTDIR$()
SETCURRENTDIR("C:\\")
GETFILELIST("*.*", files$[])
SETCURRENTDIR(cur$)
Also; if anyone is interested... I can try to put together a noob Tk tutorial once I get through this. Not sure what level of interest there is; maybe everyone else gets this already and I'm the odd man out...
To your previous post: none if this is a bug, its just a bit of lazy programming:
Quote from: bigtunacan on 2011-Sep-18Line 66 :
DRAWRECT 0,0,60*ABS(SIN(GETTIMERALL()/10)),60, cols[icolor]
should be
DRAWRECT 0,0,60*ABS(SIN(GETTIMERALL()/10)),60, cols[icolor%] // icolor% instead of icolor
Line 58 defines it LOCAL icolor%, so when you use it later (at line 66) you dont need to call it icolor% again, the computer already knows, that its an integer, so icolor works too. This works for integer (x%) and float (#) but not for strings ($)!
Quote from: bigtunacan on 2011-Sep-18Line 70:
IF tk_GetVal$(but%) THEN icolor = MOD(icolor + 1, LEN(cols[]))
should be
IF tk_GetVal$(but%) = 1 THEN icolor = MOD(icolor + 1, LEN(cols[]))
I was wondering about this? If doesn't appear that GLBasic is doing a simple True/False check against 0 vs 1?
Line 88:
IF tk_GetVal$(ok%)
should be
IF tk_GetVal$(ok%)=1
Both is correct, if you make an "IF a THEN ..." it is FALSE for a=0 and TRUE for a!=0. So it does the same like "IF a=1 THEN".
So you didnt find bugs, you just made the code a bit clearer.
btw: i think a small Tk-tutorial could help some of us, i never tried Tk, but with a good tutorial maybe i would.
That's interesting, the original code does not work properly on my setup. Is there a setting in the IDE to control this?
Those are just styling problems - it works okay as it is.
MrTAToad,
See my previous post; it does not work properly on my setup. For example
IF tk_GetVal$(but%) THEN icolor = MOD(icolor + 1, LEN(cols[]))
updates every time through the loop, rather than just when the button is pushed. The effect is that the rect is constantly flickering as it continually switches colors.
When I subbed it in with
IF tk_GetVal$(but%)=1 THEN icolor = MOD(icolor + 1, LEN(cols[]))
it is working correctly. So is there an IDE setting that is controlling the leniency for some of this?
then tk_GetVal$() returns non-zero for non pressed button. DEBUG what it prints.
That's what is really interesting. If I DEBUG tk_GetVal$(but%) the output is 0.
Also, if I setup an intermediate variable and sub it in like so.
val = tk_GetVal$(but%)
IF val THEN icolor = MOD(icolor + 1, LEN(cols[]))
This will also work correctly.
But the existing code
IF tk_GetVal$(but%) THEN icolor = MOD(icolor + 1, LEN(cols[]))
does not evaluate correctly and cause the color to continually change. This is very bizarre.
maybe it returns a space character? Print len() of the result
len(tk_GetVal$(but%)) is 1
aw, bad. So there is a character in the return. Might be a space. I'll have to check.