Computer Science Canada Buttons for Dummies! |
Author: | recneps [ Mon Feb 09, 2004 4:13 pm ] | ||||||||||||||
Post subject: | Buttons for Dummies! | ||||||||||||||
I saw someone make a post in AsianSensation's "Suggest a Tutorial" post and thought i'd clarify it for the people. First off, lets see what the Turing Reference Says about buttons. : Quote: Syntax GUI.CreateButton (x, y, width : int, text : string,
actionProc : procedure x ()) : int GUI.CreateButtonFull (x, y, width : int, text : string, actionProc : procedure x (), height : int, shortcut : char, default : boolean) : int Description Creates a button and returns the button's widget ID. The button widget is used to implement a textual button. When you click on a button, the button's action procedure is called. If a button is given a short cut, then entering the keystroke will cause the action procedure to be called. It will not visibly cause the button to depress. Two Buttons The x and y parameters specify the lower-left corner of the button. The width parameter specifies the width of the button. If width is less than the size necessary to display the button, the button is automatically enlarged to fit the text. The text parameter specifies the text to appear in the button. The actionProc parameter is the name of a procedure that is called when the button is pressed. For GUI.CreateButtonFull, the height parameter specifies the height of the button. If height is less than the size necessary to display the button, the button is automatically enlarged to fit the text. The shortcut parameter is the keystroke to be used as the button's shortcut. The default parameter is a boolean indicating whether the button should be the default button. If there is already a default button, and default is set to true, then this button becomes the new default button. Since this is "Buttons for Dummies", forget the CreateButtonFull. Got that? Bye! So now, we have The syntax, the description, and the explanation of the syntax. So let me clarify. this is how you use the GUI.CreateButton command. First, tell Turing you're gonna be using GUI, place this line at the top of your program.
Next, create procedures containing all the work you want that button to do, like....
Next, declare the button names as variables.
and Turn those variables into buttons!
And finally, fill in the parameters for them.
Where x and y are the bottom left corner of the button, and "0 is the width of the button( note: The width will be incresed if the button text is larger than the width of the button specified) "ButtonText" is the text on the button's face, and procedure is the procedure you named above that you want the button to call when being pressed. Finally, you need to have a little thing in there to keep the program going until a button is pressed, otherwise it would just draw the button, and then finish the program. so we add:
And thats it! So now we put it all together......
|
Author: | Paul [ Mon Feb 09, 2004 4:18 pm ] |
Post subject: | |
Hey! Are you implying Im a dummy? (j/k), thanks for the tutorial +bits. Oh yea, the import is lowercase, and the text writes over the buttons. What does GUI.ProcessEvent do exactly? Does it call anything with GUI in it? Thats why I don't know how to clear it. |
Author: | recneps [ Mon Feb 09, 2004 4:22 pm ] |
Post subject: | |
oops! forgot to make those changes! Its fixed now. And GUI . Process Event... if you break it down, it literally starts an infinite loop, UNTIL that GUI processes something (the button click) Get it? |
Author: | Paul [ Mon Feb 09, 2004 4:27 pm ] | ||
Post subject: | |||
Oh, so when you do this:
The buttons are automatically drawn? |
Author: | Delta [ Mon Feb 09, 2004 6:27 pm ] |
Post subject: | |
Heck no! Writing the : var button1:int:=GUI.CreateButton var button2:int:=GUI.CreateButton does absolutely nothing, besides giving you an error of course... I'm not sure why he would put that in there sure its for dummies but still it gets ppl confused And ya without the GUI.ProcessEvent your GUI commands won't work... GUI.ProcessEvent processes and event such as keyboard or mouse events (clicks, key strokes) if one of these events call a widget(your button/textfield/gui stuff) then it works... |
Author: | AsianSensation [ Mon Feb 09, 2004 9:13 pm ] |
Post subject: | |
good attempts at tutorials now if everyone begins to write a tutorial, we'll soon have enough to get all kinds of people at all different levels started. here, have some bits. +35 bits |
Author: | shorthair [ Mon Feb 09, 2004 10:04 pm ] |
Post subject: | |
i think there is a thread about how to reset , the gui event , so that you can have multiple buttons in differnt parts of the program , but in hte turing 5 documentation there is a F9 about a command that resets it automatically , its a good update , if i had turing handy id give it to you, but im sure someonne here knows what it is |
Author: | recneps [ Tue Feb 10, 2004 3:56 pm ] | ||||
Post subject: | |||||
Well, i wrote it in pieces, set by step of what you have to do, so that was the first part
and then i went on to tell you you needed to add things to it, like:
Understand now? the button will be drawn after you add in the parameters, x and y positions of the bottom left corner, height(automatically expands to fit the text if needed), the text on the button face, and the procedure the button calls when clicked. P.S. Thanks for bits! I'm thinking of more tutorials that people really need |
Author: | the_short1 [ Tue Feb 10, 2004 7:26 pm ] |
Post subject: | |
VERY COOL!!!! i was just thinking on asking Templest for help on this ssince hes the Aclaimed master GUI! i want to fix my unit converter with each button and have a pop up area show the buttons FULL NAME!!!! Id give you bits... but i saving up for a email now...only 1900 to go... (i have lots in my title) |
Author: | the_short1 [ Tue Feb 10, 2004 8:26 pm ] |
Post subject: | |
btw is there a specific command for making a rounded button (oval) for my unit converter words.... the normal ones are too big....even with just letter a in button and width of 0 or should i just make a Menu for the Base and new unit of measure? Thanks,.....(I AM GUI NOOB) |
Author: | recneps [ Tue Feb 10, 2004 8:41 pm ] | ||
Post subject: | |||
I dont believe there is a command for round buttons, if there is, then I dont know but you could make your own buttons , they just wouldnt look as nice like
|
Author: | Andy [ Tue Feb 10, 2004 9:54 pm ] | ||
Post subject: | |||
circle button |
Author: | Paul [ Tue Feb 10, 2004 9:57 pm ] |
Post subject: | |
Thanx dodge, I've always wondered how to do a circle button, but there isn't a command for a GUI round or circle button is there? |
Author: | Andy [ Tue Feb 10, 2004 10:17 pm ] |
Post subject: | |
not that i noe of... |
Author: | SuperGenius [ Tue Mar 16, 2004 9:46 pm ] |
Post subject: | |
Thank you for this tutorial, because at the rate my comp sci class moves, we might get to processes and procedures by June. I ran the code from the first post( You pressed button 1 / You pressed button 2) and when I closed the window another window opened called Quote: WidgetModule.tu What is this window for? |
Author: | AsianSensation [ Tue Mar 16, 2004 11:37 pm ] |
Post subject: | |
the WidgetModule is the file turing includes which gives you the access to the GUI modules/functions, etc. That's why you have to do import GUI at the beginning. It's kinda like a header file. So basicly, that means you can customize things to suit your taste and use a customized WidgetModule so things worklout nicer, or simply just look nicer. I know someone who personally drew out her own GUI buttons, and if she included that in the widget module and gave it to other people, others will be able to use the buttons she drew. |
Author: | the_short1 [ Tue Mar 16, 2004 11:54 pm ] |
Post subject: | |
GUI. CreateRadioButton <<<makes a round button for forms... and here is 10 BITs spencer |
Author: | recneps [ Thu Mar 18, 2004 9:05 pm ] |
Post subject: | |
Thats cool. I didnt know that. and thanks ;D (By the way, where did you get so many bits??lol) |
Author: | Paul [ Thu Mar 18, 2004 9:38 pm ] |
Post subject: | |
He was storing them in the items. |
Author: | Thuged_Out_G [ Fri Mar 19, 2004 2:19 am ] |
Post subject: | |
although its called CreateRadioButton,its not really a button. more a rounded check box. except, with a radiobutton, once you click it, the only way i know of to unclick it, is to click another one(going by radiobuttons on webpages)...it would still work well as a button, but its not quite a button...just to clarify |
Author: | recneps [ Fri Mar 19, 2004 11:27 am ] |
Post subject: | |
Interesting. So theres no need to edit my tutorial to explain round buttons? |
Author: | the_short1 [ Fri Mar 26, 2004 7:19 pm ] |
Post subject: | |
yes i was storing.... but meh... i like seing that LARGE number... also .i bough 'black' title effect so nonon would realy see the large numnber.... i saving up for 1500 so i can buy something.... second note... instead of: loop exit when GUI.ProcessEvent end loop which sucks cuz it that happens and u havn;t pressed a button yet it will freeze ur program i find this works TEN times better... in your active game loop add this: if GUI.ProcessEvent then end if and that works the same as the loop but, does not hang the program if you havn;t clicked on a button yet... second alternative... process guibuttonevent loop if GUI.ProcessEvent then end if end loop end guibuttoneven fork guibuttonevent now it will always try to find a GUI button event and will happen more acurately... (you click on it and it will work in nano second isntead of maybe being delayed) either way... MUCH better in my opinion.... is this method better in others eyes too??? or is it just me..... stupid turing references sometimes... very good for the older basic stuff..... but i think Holtsoft is not putting as much effort into the turing reference as the versions increase (with more functions)... like look at the newer functions... theres a whole lot less documentation and a lot more flaky....but i love the new version how they have more examples tho (and have buttons in help to auto run those) |
Author: | Hotaru [ Thu May 20, 2004 7:29 pm ] |
Post subject: | |
~this tutorial is crap~even the one found on the newer version of turing is way more helpful than this~ ~but thanks for this helpful tutorial though~ |
Author: | AsianSensation [ Thu May 20, 2004 9:52 pm ] |
Post subject: | |
Hotaru wrote: ~this tutorial is crap~even the one found on the newer version of turing is way more helpful than this~
~but thanks for this helpful tutorial though~ are you stupid? Did God give you 6 as your Intelligence score when he was rolling for your abilities? Did you just wanted bits? If it's like that, here is some bits. + negtive 100 bits there, you'll be owning some bits. |
Author: | the_short1 [ Thu May 20, 2004 9:59 pm ] |
Post subject: | |
i was just goign to post a negative response to that... but i dont have the mod powers to enforce... |
Author: | DaVe g [ Sun Sep 19, 2004 11:08 am ] |
Post subject: | |
Thanks for the tutorial, I tried to make a ball chooser using buttons for my game, and then it chose colour, and just sat there and never went to the game =( |
Author: | Malazan [ Tue May 10, 2005 9:49 pm ] |
Post subject: | |
Thanks so much for the tutorial. It's been a super help for me and my project |
Author: | adams [ Tue May 24, 2005 11:17 am ] | ||
Post subject: | disposing buttons | ||
I know you guys are creating buttons but how do you dispose them. I'm making a program with lots of buttons and 'forward proc' and "body proc' stuff like that etc... heres my program can you help with putting in GUi.Dispose or GUI.Disable or GUI.Hide.
|
Author: | TokenHerbz [ Thu Aug 25, 2005 8:11 pm ] |
Post subject: | |
ok well, i didn't understand anything besodes the 1st post... And that dosn't explain the fillbutton. Anyways... i just wanted to say that your custom circle button dosn't work when u click the right side of it, only the left, or it appears that way on my comp anyways. I will practice with GUI, but is it possible to Change the TEXT of the buton, when it is clicked? |
Author: | jrblast [ Thu Dec 08, 2005 6:37 pm ] |
Post subject: | |
TokenHerbz wrote: ok well, i didn't understand anything besodes the 1st post...
And that dosn't explain the fillbutton. Anyways... i just wanted to say that your custom circle button dosn't work when u click the right side of it, only the left, or it appears that way on my comp anyways. I will practice with GUI, but is it possible to Change the TEXT of the buton, when it is clicked? perhaps just create a new button over it? and stop making that one? what if i want to execute other functions after the buttons? in my proggy the proc executes, but it doesnt continue after the loop :S |
Author: | iker [ Thu Dec 08, 2005 10:49 pm ] |
Post subject: | |
is it just me, or is this topic considered old? |
Author: | theguru [ Sun Jan 15, 2006 5:32 pm ] |
Post subject: | |
ok, this tutorial was extremely helpful but it left me with a lot of questions. I've tried the different methods of processing the 'buttons' (sorry for my horrible terminology) using a loop, if statement and a process but none of them seem to help me with my problem is that I want to exit the loop after the button has been pressed (so I can continue with my program). For example I want to use a button as 'next' so when clicked it will continue on with the program. I know I can use getch or get or something like that but just to make it fancy I'd like to add some buttons. Their squary and so cool . // I hope my questions actually makes sense to you guys |
Author: | Cervantes [ Sun Jan 15, 2006 5:35 pm ] |
Post subject: | |
You could use a Quit button, that calls GUI.Quit, then have the code for the rest of the program waiting after your exit when GUI.ProcessEvent loop Alternatively, you could have your button call the code that runs the next part of your program. Alternatively alternatively, you could make your own buttons, and not be so restricted in how you code. |
Author: | Clayton [ Wed Jan 25, 2006 2:39 pm ] | ||||
Post subject: | |||||
i would like to add a bit to this if you want your buttons to be disabled you would do this
this stops the button from working, also if you are drawing boxes and such on the screen and you dont want your buttons to disappear then use the GUI.Refresh command as such
this basically redraws your buttons on top of the screen again in the middle of your program without actually creating it hope this helps |
Author: | flippy [ Wed Apr 26, 2006 12:52 pm ] |
Post subject: | Didn't notice a reply to this, soooo... |
shorthair wrote: i think there is a thread about how to reset , the gui event , so that you can have multiple buttons in differnt parts of the program , but in hte turing 5 documentation there is a F9 about a command that resets it automatically , its a good update , if i had turing handy id give it to you, but im sure someonne here knows what it is
The only command I could find in the tutorial to reset the GUI event was GUI.ResetQuit... but I think that's the only one you need... |
Author: | flippy [ Wed Apr 26, 2006 1:12 pm ] |
Post subject: | Oh yeah... one more thing |
BTW... I was wondering if there was a way to exit a double layer fo loops (if that doesn'y make sense: call a button, press button, button calls a procedure that containes more buttons, press a second button, second procedure does it's stuff, exit to main program and keep going) I would show you the code, but it is kinda long... |
Author: | MysticVegeta [ Wed Apr 26, 2006 1:40 pm ] |
Post subject: | |
well to exit nested loops you need a boolean |
Author: | Foundation [ Sat Sep 16, 2006 11:37 am ] |
Post subject: | |
Good tutorial, btw, I was just thinking, is there any way to change the appearances of the Turing buttons, they look too grey. Anyone post a tutorial on that? |
Author: | Cervantes [ Sat Sep 16, 2006 2:01 pm ] |
Post subject: | |
The widgets are open-source. The code for them is written in Turing. You can find it in C:\Program Files\Turing\support\lib\guiclass, assuming your Turing directory is at C:\Program Files\Turing. Alternatively, you could check out S-engine. |
Author: | War_Caymore [ Fri Sep 22, 2006 7:50 am ] |
Post subject: | |
Before reading this, i was completely unaware on how to use Turing's GRI system. i'd like to thank the maker of this thread for teaching me how to use GUI, mostly becasue he pretty much made this for me (yes, i am a dummy...). I look foward for moer tutorials taht are for people jsut like me |
Author: | kompsai [ Tue Nov 07, 2006 3:41 pm ] |
Post subject: | |
props, great explanation...really clarifies how to make some basic buttons. though the step-by-step thing was a good idea, i think it should probably be changed because it is a bit confusing...believe it or not, it's most understandable starting from the bottom and working your way up to the top. |
Author: | Macbuchu [ Thu Dec 21, 2006 7:17 pm ] |
Post subject: | Need to continue on program after procedure |
is it possible to put a process instead of a procedure at the end of the button somehow??? cuz i need to continue on my program after my procedure. |
Author: | Macbuchu [ Thu Dec 21, 2006 7:19 pm ] |
Post subject: | Need to continue on program after procedure |
is it possible to put a process instead of a procedure at the end of the button somehow??? cuz i need to continue on my program after my procedure. look at code ..... ===> |
Author: | CodeMonkey2000 [ Thu Dec 21, 2006 8:26 pm ] |
Post subject: | |
dude do u go to cameron?and for something like this dont use process except for music. |
Author: | Macbuchu [ Mon Jan 01, 2007 8:21 pm ] |
Post subject: | |
yah i do and i finally got past my prblem |
Author: | elmocookies [ Tue Jan 02, 2007 8:50 pm ] |
Post subject: | |
Does anyone know if there is tutorial on GUI.CreateRadioButtons or is this the only tutorial for anything involving GUI? |
Author: | beginnerprogrammer [ Sat May 26, 2007 3:19 pm ] |
Post subject: | RE:Buttons for Dummies! |
i just started programmering and turing i don't know what this error means it is. The error is it is unable to pen file GUI. Why isn't it working i followed all the instructions |
Author: | Agner [ Tue Feb 24, 2009 9:24 pm ] | ||||
Post subject: | |||||
Clayton @ Wed Jan 25, 2006 11:39 am wrote: i would like to add a bit to this if you want your buttons to be disabled you would do this
this stops the button from working, also if you are drawing boxes and such on the screen and you dont want your buttons to disappear then use the GUI.Refresh command as such
this basically redraws your buttons on top of the screen again in the middle of your program without actually creating it hope this helps So if I want to have multiple buttons throughout my program (and not have them reappearing in sections I don't want them in), I would just use these commands or is there more? Btw nice tutorial on GUI, helped me a lot with making buttons, I just need to figure out how to remove them when I don't need em |
Author: | flyforfame [ Sat Mar 28, 2009 8:50 pm ] |
Post subject: | Re: Buttons for Dummies! |
hi can u tell me how to make the program go to a next question? for example i put What is Ice cream made out of and there is 2 buttons i can click how can i make it so that if i click any of the 2 buttons i go the to the next question for example the next question is What is Fries made out of so like this What is ice cream made out of? button 1 button 2 so if someone clicks one of the buttons it clears the page and goes to What is Fries Made out of? button 1 button 2 etc etc and please reply as soon as possible i need to use this for my project |
Author: | qmanjr5 [ Mon Jan 11, 2010 11:19 am ] |
Post subject: | RE:Buttons for Dummies! |
Can the loop go ANYWHERE in the code? |
Author: | qmanjr5 [ Mon Jan 11, 2010 11:24 am ] | ||
Post subject: | RE:Buttons for Dummies! | ||
Also, how would I make it so it displays the button at a certain point in the code?
Doesn't work, even if I put "var button1..." after "procedure test1...." How would i make this work? |
Author: | xBalmungx [ Wed Jan 13, 2010 6:05 pm ] |
Post subject: | Re: Buttons for Dummies! |
Omg, this helped alot, thank you sooo much |
Author: | blizzard4800 [ Fri Jan 15, 2010 6:46 pm ] |
Post subject: | RE:Buttons for Dummies! |
Thank you soooooooo much |
Author: | blizzard4800 [ Fri Jan 15, 2010 7:45 pm ] |
Post subject: | RE:Buttons for Dummies! |
but it doesnt work when you change the colour of the boutton |
Author: | qmanjr5 [ Mon Jan 18, 2010 9:11 am ] |
Post subject: | RE:Buttons for Dummies! |
how WOULD you change the color of the button? |
Author: | TheGuardian001 [ Mon Jan 18, 2010 9:33 am ] |
Post subject: | Re: RE:Buttons for Dummies! |
qmanjr5 @ Mon Jan 18, 2010 9:11 am wrote: how WOULD you change the color of the button?
with the gui_setcolor command, which appears to work fine for me. |
Author: | A2theBEAST [ Wed May 19, 2010 7:27 pm ] |
Post subject: | RE:Buttons for Dummies! |
Great tuti, I understand the button GUI commands pretty well now, Is there a way besides GUI.setsize to change the height of the button? |
Author: | jacobjacobb [ Thu Jun 10, 2010 7:53 pm ] |
Post subject: | Re: Buttons for Dummies! |
can someone check my code and tell me whats wrong. Its suppose to be a rock, paper, scissors game. import GUI setscreen("graphics:400;450") var choice : char var bet : int var winning : int var money : int var answer : char put "What difficulty do you want to play? Hard(H), Medium(M), or Easy(E)? " .. procedure easy locate(5,1) put "You chose Easy!" answer := "e" end easy procedure medium locate(5,1) put "You chose Medium!" answer := "m" end medium procedure hard locate(5,1) put "You chose Hard!" answer := "h" end hard var button1:int:=GUI.CreateButton(50,50,0,"Easy",easy) var button2:int:=GUI.CreateButton(150,50,0,"Medium",medium) var button3:int:=GUI.CreateButton(250,50,0,"Hard",hard) loop exit when GUI.ProcessEvent end loop if answer = "E" or answer = "e" or answer = "easy" or answer = "Easy" or answer = "EASY" then money := 1000 elsif answer = "M" or answer = "m" or answer = "medium" or answer = "Medium" or answer = "MEDIUM" then money := 750 elsif answer = "H" or answer = "h" or answer = "hard" or answer = "Hard" or answer = "HARD" then money := 500 end if loop var random := Rand. Int (1, 3) put "You have " .. put money .. put " dollars left to bet." put "How much money do you want to bet? " .. get bet if bet > money then put "You have been caught trying to cheat!" put "Remember kids the T-rex ate the Unicorn." put "Listen carefully." for count : 1..3 sound (440, 500) sound (400, 500) sound (500, 500) sound (360, 500) end for sound (440, 600) quit end if put " " put "Rock(r), Paper(p) or Scissors(s)?(Push e to exit the game) " .. get choice if choice = "r" and random = 1 then put "Computer chose Rock. " put "You chose Rock." put "Its a tie." elsif choice = "p" and random = 2 then put "Computer chose Paper. " put "You chose Paper." put "Its a tie." elsif choice = "s" and random = 3 then put "Computer chose Scissors. " put "You chose Scissors." put "Its a tie." elsif choice = "r" and random = 3 then put "Computer chose Scissors. " put "You chose Rock." put "You won." money := bet + money elsif choice = "p" and random = 1 then put "Computer chose Rock. " put "You chose Paper." put "You won." money := bet + money elsif choice = "s" and random = 2 then put "Computer chose Paper. " put "You chose Scissors." put "You won." money := bet + money elsif choice = "s" and random = 1 then put "Computer chose Rock. " put "You chose Scissors." put "You lose." money := money - bet elsif choice = "p" and random = 3 then put "Computer chose Scissors. " put "You chose Paper." put "You lose." money := money - bet elsif choice = "r" and random = 2 then put "Computer chose Paper. " put "You chose Rock." put "You lose." money := money - bet end if put " " if money < 1 then put "You lose." put "Remember kids the T-rex ate the Unicorn." put "Listen carefully." for count : 1..3 sound (440, 500) sound (400, 500) sound (500, 500) sound (360, 500) end for sound (440, 600) quit end if if money > 4999 then put "You win!" put "Remember kids the T-rex ate the Unicorn." put "Listen carefully." for count : 1..3 sound (440, 500) sound (400, 500) sound (500, 500) sound (360, 500) end for sound (440, 600) quit end if if choice = "e" or choice = "E" or choice = "exit" or choice = "Exit" or choice = "EXIT" or choice = "quit" or choice = "Quit" or choice = "QUIT" then put "You have quit." put "Remember kids the T-rex ate the Unicorn." put "Listen carefully." for count : 1..3 sound (440, 500) sound (400, 500) sound (500, 500) sound (360, 500) end for sound (440, 600) quit end if end loop |
Author: | USEC_OFFICER [ Thu Jun 10, 2010 8:26 pm ] |
Post subject: | RE:Buttons for Dummies! |
Um, why isn't this in a seperate topic? |
Author: | Cezna [ Fri Jun 11, 2010 5:15 am ] |
Post subject: | RE:Buttons for Dummies! |
@ jacobjacobb you will get much more attention for your program if you post it in a separate topic, which from the start of your post, should probably be in the Help section |
Author: | hahd [ Mon Nov 08, 2010 10:33 pm ] |
Post subject: | RE:Buttons for Dummies! |
who u calling a dummy jkin thnkx for the help |
Author: | Space!!! [ Sun Jan 02, 2011 4:23 pm ] |
Post subject: | RE:Buttons for Dummies! |
Wondering how to move or drag a button? |
Author: | Birdo [ Tue Jun 28, 2011 11:28 pm ] |
Post subject: | RE:Buttons for Dummies! |
wow so helpful |
Author: | Gaddy [ Tue Dec 25, 2012 11:20 am ] |
Post subject: | RE:Buttons for Dummies! |
My teacher makes us use procedures how would i make a GUI button to work for that procedure and lead to another one |
Author: | Shootforwhat [ Thu Mar 21, 2019 7:20 pm ] |
Post subject: | Re: Buttons for Dummies! |
what if I want to exit the loop with one of the two buttons but let the other button continue on with the loop. |