Board Logo
« Basic Layout for GUI Programs »

Welcome Guest. Please Login or Register.
Sep 30th, 2014, 08:49am


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Please use the forums Search feature before asking.
Please post code using the code box described in Format Your Messages.
This will keep indentation, separate it better form the message and prevent gibberish.
If the code is too long for one post or additional files are needed, upload a ZIP archive to the Just BASIC Files Archive Site.

« Previous Topic | Next Topic »
Pages: 1 2  Notify Send Topic Print
 sticky  Author  Topic: Basic Layout for GUI Programs  (Read 3307 times)
Stefan Pendl
Administrator
ImageImageImageImageImage


member is offline

Avatar

Let's talk JB ...


Homepage PM

Gender: Male
Posts: 3620
xx Basic Layout for GUI Programs
« Thread started on: Mar 30th, 2007, 05:32am »

Here is a basic layout for GUI programs.

Code:
nomainwin

'initialize any variables or arrays
    dim options(20)
    TRUE  = 1
    FALSE = 0

'load defaults from external file

'open GUI window
    open "Test" for window as #main
    #main "trapclose [quit]"

'control events
[quit]
    close #main
    end

'functions and subs 
User IP Logged

Stefan - Homepage

Remember to read the forum rules board wink

Just BASIC 1.01, Windows 7 Home Premium x64 SP1, AMD Turion X2 RM-70 2GHz, 4GB R
pchri
New Member
Image


member is offline

Avatar




PM


Posts: 2
xx Re: Basic Layout for GUI Programs
« Reply #1 on: Feb 21st, 2008, 08:07am »

Hi Stefan -

I have just started in JustBasic and while I have a basic (no pun intended) understanding of GUI window creation, there is one thing that is stumping me - the tutorial has not made this clear for me - When I create a GUI window with textbox input - how do I get the text typed into the text box to 1)relate to a variable so I can manipulate it 2) just display.

ie - if the question is "What is your first name?" and the user types 'JOHN', how do I get the next window to display
"Your name is 'John'."

It seems like it should be simple and I fell dumb, but I can't figure it out.

Thanks!
User IP Logged

Welopez
Moderator
ImageImageImageImageImage


member is offline

Avatar

Never let your beliefs get in the way of learning.


PM

Gender: Male
Posts: 4396
xx Re: Basic Layout for GUI Programs
« Reply #2 on: Feb 21st, 2008, 09:19am »

Newbies experiencing GUIs for the first time, frequently have this problem, pchri. Try this tutorial, Getting User Input and see if that will answer your question.

Usually it is helpful if you post a small section of the code where you are having a problem. We can look at it and try and find your mistake (if any).

Hope you enjoy Just Basic! You'll find most subjects have been covered in the Articles and Tutorials, as well as precise syntax in the help file.

Welcome to Just Basic! Have fun!
User IP Logged

JB 1.01
Win7 64bit, 4 GB RAM, Pentium 6200@2.13 GHz (laptop)
WinXP, 1 GB RAM, Intel N270@1.6 GHz (netbook)
pchri
New Member
Image


member is offline

Avatar




PM


Posts: 2
xx Re: Basic Layout for GUI Programs
« Reply #3 on: Feb 23rd, 2008, 12:32pm »

Thanks for the reply! Here is the code I am trying to make work. It is 5 simple questions to the user, then display the answers and ask the user if the answers are correct. I can't figure out how to get the answers input in the first 5 text boxes to display in another GUI window. As you can see, the code is rather a mess because I have been trying several methods to figure out how to display the string$.

Code:
[q1]
    NOMAINWIN

    WindowWidth = 448
    WindowHeight = 75
    UpperLeftX = 200
    UpperLeftY = 150

    STATICTEXT #main.textbox1, "What is your first name?", 26, 16, 192, 20
    TEXTBOX #main.textbox1, 182, 11, 150, 25
    BUTTON #main.button3, "Okay", [buttonQ1Click], UL, 350, 11, 42, 25
    OPEN "First Name" FOR window AS #main
    PRINT #main.textbox1, "!contents? fname$"
    PRINT #main, "font ms_sans_serif 0 16"

    [main.inputLoop]   'wait here for input event
    WAIT

    [buttonQ1Click]   'Perform action for the button named 'buttonQ1'
    CLOSE #main
    GOTO [q2]


[q2]
    NOMAINWIN

    WindowWidth = 448
    WindowHeight = 75
    UpperLeftX = 200
    UpperLeftY = 150

    STATICTEXT #main2.statictext1, "What is your last name?", 26, 16, 192, 20
    TEXTBOX #main2.textbox2, 182, 11, 150, 25
    BUTTON #main2.button3, "Okay", [buttonQ2Click], UL, 350, 11, 42, 25
    OPEN "Last Name" FOR window AS #main2
    PRINT #main2, "font ms_sans_serif 0 16"


    [main2.inputLoop]   'wait here for input event
    WAIT

    [buttonQ2Click]   'Perform action for the button named 'buttonQ2'
    CLOSE #main2
    GOTO [q3]

[q3]
    NOMAINWIN

    WindowWidth = 448
    WindowHeight = 75
    UpperLeftX = 200
    UpperLeftY = 150

    STATICTEXT #main3.statictext1, "What is your age?", 26, 16, 192, 20
    TEXTBOX #main3.textbox3, 182, 11, 150, 25
    BUTTON #main3.button3, "Okay", [buttonQ3Click], UL, 350, 11, 42, 25
    OPEN "Age" FOR window AS #main3
    PRINT #main3, "font ms_sans_serif 0 16"


    [main3.inputLoop]   'wait here for input event
    WAIT

    [buttonQ3Click]   'Perform action for the button named 'buttonQ3
    CLOSE #main3
    GOTO [q4]

[q4]
    NOMAINWIN

    WindowWidth = 448
    WindowHeight = 75
    UpperLeftX = 200
    UpperLeftY = 150

    STATICTEXT #main4.statictext1, "What is your height?", 26, 16, 192, 20
    TEXTBOX #main4.textbox4, 182, 11, 150, 25
    BUTTON #main4.button3, "Okay", [buttonQ4Click], UL, 350, 11, 42, 25
    OPEN "Height" FOR window AS #main4
    PRINT #main4, "font ms_sans_serif 0 16"


    [main4.inputLoop]   'wait here for input event
    WAIT

    [buttonQ4Click]   'Perform action for the button named 'buttonQ4
    CLOSE #main4
    GOTO [q5]

[q5]
    NOMAINWIN

    WindowWidth = 360
    WindowHeight = 75
    UpperLeftX = 200
    UpperLeftY = 150

    STATICTEXT #main5.statictext1, "How many noses do you have?", 22, 16, 192, 20
    TEXTBOX #main5.textbox5, 222, 11, 30, 25
    BUTTON #main5.button3, "Okay", [buttonQ5Click], UL, 270, 11, 42, 25
    OPEN "Noses" FOR window AS #main5
    PRINT #main5, "font ms_sans_serif 0 16"


    [main5.inputLoop]   'wait here for input event
    WAIT

    [buttonQ5Click]  'Perform action for the button named 'buttonQ5
    CLOSE #main5
    GOTO [display]

[display]
    NOMAINWIN

    WindowWidth = 448
    WindowHeight = 448
    UpperLeftX = 200
    UpperLeftY = 150

    'fname$ = "#main.textbox1"
    'lname$ = "#main2.textbox2"
    'age$ = "#main3.textbox3"
    'height$ = "#main4.textbox4"
    'noses$ = "main5.textbox5"

    PRINT "Your First Name Is: "; fname$
    'STATICTEXT #maindisplay.statictext2, "Your Last Name Is; ",
    'STATICTEXT #maindisplay.statictext3, "Your Age Is: ", 26, 86, 192, 20; age$
    'STATICTEXT #maindisplay.statictext4, "Your Height Is: ", 26, 126, 192, 20; height$
    'STATICTEXT #maindisplay.statictext5, "Your Nose Is: ", 26, 166, 192, 20; noses$
    'BUTTON #maindisplay.button11, "Okay", [buttonQ11Click], UL, 200, 16, 42, 25
    'BUTTON #maindisplay.button12, "Okay", [buttonQ12Click], UL, 200, 46, 42, 25
    'BUTTON #maindisplay.button13, "Okay", [buttonQ13Click], UL, 200, 86, 42, 25
    'BUTTON #maindisplay.button14, "Okay", [buttonQ14Click], UL, 200, 126, 42, 25
    'BUTTON #maindisplay.button15, "Okay", [buttonQ15Click], UL, 200, 166, 42, 255
 
« Last Edit: Jul 7th, 2010, 03:59am by Stefan Pendl » User IP Logged

Welopez
Moderator
ImageImageImageImageImage


member is offline

Avatar

Never let your beliefs get in the way of learning.


PM

Gender: Male
Posts: 4396
xx Re: Basic Layout for GUI Programs
« Reply #4 on: Feb 23rd, 2008, 1:13pm »

There is no need to open a new window for every question, pchri. You can use one window and one statictext to ask all questions. If you have more than 10 questions, remember to DIM ques(). Try this tutorial, Final Exam.

Of course, you'll probably want to modify it for your questions and answers, but the tutorial should give you some ideas where to start.

You'll find many tutorials on how to create and modify files. If you can't find a tutorial with an answer you need, post a question, someone will answer it. wink

User IP Logged

JB 1.01
Win7 64bit, 4 GB RAM, Pentium 6200@2.13 GHz (laptop)
WinXP, 1 GB RAM, Intel N270@1.6 GHz (netbook)
redx64
Guest
xx Re: Basic Layout for GUI Programs
« Reply #5 on: Jun 13th, 2008, 11:33am »

I just wanted to know something. In GUI programs do you need the goto commands if the subs follow one another in the code. Thank You.
User IP Logged

JohnDavidson
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 4142
xx Re: Basic Layout for GUI Programs
« Reply #6 on: Jun 13th, 2008, 11:54am »

Subs and functions work like gosub, they return to the place they were called from.

They will not drop into following Subs, Functions, or code.

John
User IP Logged

John Davidson
e-me: johnshomeport@yahoo.com
My JB Page: http://john.jbusers.com/
Did ya Libby yet? http://lblibby.com/
narceleb
New Member
Image


member is offline

Avatar




PM


Posts: 1
xx Re: Basic Layout for GUI Programs
« Reply #7 on: Jun 17th, 2008, 12:52pm »

The Just BASIC Tutorial, Week 4 "Programming the Windows Graphical User Interface" has the answer.

You already have the bit of code that does it:

Code:
PRINT #main.textbox1, "!contents? fname$" 


But I think you have it in the wrong place. You need it in the [buttonQ1Click] block.
User IP Logged

Welopez
Moderator
ImageImageImageImageImage


member is offline

Avatar

Never let your beliefs get in the way of learning.


PM

Gender: Male
Posts: 4396
xx Re: Basic Layout for GUI Programs
« Reply #8 on: Jun 17th, 2008, 1:36pm »

Entirely correct, narceleb. The program must first setup the GUI and then WAIT. At that time, nothing has yet been entered in the TEXTBOX.

After an entry has been made, the user clicks the button and goes to PRINT #main.textbox1, "!contents? fname$" where the contents is read and stored in the program as fname$.

The big problem is getting the users to read the forums, helpfile, and Articles and Tutorials where the answers have been given many times.

Good catch on your part! Now, if you have a suggestion as to how we can get the users to read the answers before asking the question, it would be greatly appreciated.

User IP Logged

JB 1.01
Win7 64bit, 4 GB RAM, Pentium 6200@2.13 GHz (laptop)
WinXP, 1 GB RAM, Intel N270@1.6 GHz (netbook)
jbBoy
Member in Training
ImageImage


member is offline

Avatar




PM


Posts: 20
xx Re: Basic Layout for GUI Programs
« Reply #9 on: Mar 26th, 2009, 4:21pm »

this is helpful
User IP Logged

shyshy
New Member
Image


member is offline

Avatar




PM


Posts: 13
xx Re: Basic Layout for GUI Programs
« Reply #10 on: Jul 6th, 2010, 7:58pm »

i dont know if this is in the right place . Here it is i am wonting to make game i think all do i am rell new to programing i read half a book programming for beginner
i lorned some like nomainwin
print
prompt
input
but to use it is futrating i can look at other peeps prog and add to and undr stand 1 4th of it i wont to do today is get a open box with one sprite where i can move him bye clicking on a place in the open box and click on him and open list with one item that i can also click on that open a list so i can start to uder stand how to make it my self i lorn bye doing if i have that i will eqpand on it to get biger and lurn more thanks

kiss shyshy
User IP Logged

Atarione1984
New Member
Image


member is offline

Avatar

Hoorah! BASIC rules!!!!


PM

Gender: Male
Posts: 6
xx Re: Basic Layout for GUI Programs
« Reply #11 on: Feb 23rd, 2011, 5:46pm »

Hello, I Need A little help on creating GUI games and graphics, please reply and give me tips. And thank you in advance. grin




User IP Logged

specsdude
Guest
xx Re: Basic Layout for GUI Programs
« Reply #12 on: Feb 23rd, 2011, 6:01pm »

Ok! First thing you need to do is familiarise yourself with the GUI commands and how to use them to good effect.

I would suggest you read the section of the Just BASIC Help file starting with 'Graphical User Interface'. Just open the Help file and type 'gui' inot the search bar and hit Enter. Look at the list at the bottom and double-click on overview.

Read on from there and you should gain an understanding of how the GUI commands in JB work.

Alternatively you could also search the forums for 'gui' related programming questions. It's quite likely that whatever your problem is, it's been talked about before. If you have a specific problem that you think needs extra help, post your program code here and we'll do all we can to sort it out. smiley

I hope that helps! grin

specsdude
User IP Logged

Atarione1984
New Member
Image


member is offline

Avatar

Hoorah! BASIC rules!!!!


PM

Gender: Male
Posts: 6
xx Re: Basic Layout for GUI Programs
« Reply #13 on: Feb 23rd, 2011, 6:11pm »

Please I need help making a window for games, that is just one of my pronlems please someone send me a message telling me in advance! ;D
User IP Logged

specsdude
Guest
xx Re: Basic Layout for GUI Programs
« Reply #14 on: Feb 23rd, 2011, 6:12pm »

Just out of interest, what would your game design be? It's usually best to set down your objectives before beginning to write the code. Think about what you want to be able to do in the game, what the graphics would be like, what would you use to interact (mouse, keyboard ?), will it be a simple game like 'Guess the number' or something more like Pacman?

All of this needs to be taken into account. If it helps, take a piece of paper (or Notepad) and write down a description of game, how it works, and the features that will be included.

There is a good section about graphics programming in the help file, use the Search bar and look for 'what is a sprite' and read on from there. Remember, if you get stuck, then come back here and tell us the problem.


specsdude
User IP Logged

Pages: 1 2  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls