AutoHotkey Community

It is currently May 26th, 2012, 3:16 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: March 6th, 2009, 10:25 pm 
Offline

Joined: December 24th, 2008, 3:25 am
Posts: 1401
Location: :noitacoL
I am trying to find some terms or a starting point for a new idea I am working on. I've looked around under using a number of terms/words without luck. What is this called, where should I start looking?


Idea:

I want to make my GUI display a grid of check boxes- after a user has made a number of pre-set choises. The width and hight of the grid are variables, depending on if/else statments and math rules. So in one instance the GUI could have 4 columns and 2 rows, then next 7 columns and 5 rows, Depending on other variables and user input.

Code:
something like:


NewGUI.ahk
____________________________________
________|__1__|__2__|__3__|__4__|__5__|
Item-1  | [X] | [_]  | [_] | [_] | [_] |
Item-2  | [X] | [X]  | [_] | [_] | [_] |
Item-3  | [_] | [X]  | [X] | [X] | [_] |
--------------------------------------------------



The User would basically select how many columns and rows they would 'need' by answering the correct lines of questions, and the checks should populate based off of user_input where needed. If they only need 2 rows, 5 columns, then that is all that should appear.


I had to change the var names and stuff for security reasons, the real GUI does not deal with cars. All of the choices and math code are not in yet, but I wanted to see if it is even possible to have a check box grid populate on a new GUI page, before wasting too muc more time. I would like to output with some boxes checked and others unchecked depending on all of the above information.

I am working with this kind of code as an example:
Code:

#SingleInstance FORCE
#UseHook
Hotkey, Pause, EarlyTerm

Gui, Show, w330 h65
Gui, Add, Button, x15 y15 w90 h30 gNewCar, New Car
Gui, Add, Button, x120 y15 w90 h30 gUsedCar, Used Car
Gui, Add, Button, x220 y15 w90 h30 gRental, Rental
return


NewCar:
Gui, Submit
Gui, 2:+resize
Gui, 2:Show, w250 h150
Gui, 2:Add, Text, x10 y10, Please select which the customer wants:
Gui, 2:Add, GroupBox, r3 x15 y35 w200, A, B or C:
Gui, 2:Add, Checkbox, xp+10 yp+15 v1, Customer wants a 4 door
Gui, 2:Add, Checkbox, v2, Customer wants a 2 door
Gui, 2:Add, Checkbox, v3, Customer wants a truck/van
Gui, 2:Add, Button, x15 y120 w40 h25 gNext, Next
return


UsedCar:
Gui, Submit
Gui, 3:Show, w330 h200
Gui, 3:Add, Text, x10 y10, TEST TEST TEST
return


Rental:
Gui, Submit
Gui, 4:show, w330 h250
Gui, 4:Add, Text, x10 y10, TSET TEST TSET
return


Next:
Gui, 5:+resize
Gui, Submit, NoHide

   GuiControl, , 1, %1%
   GuiControl, , 2, %2%
   GuiControl, , 3, %3%


If(1=1 && 2=0 && 3=0)
{
   
   Gui, Submit
   Gui, 6:Show, w250 h150
   Gui, 6:Add, Text, x10 y10, Select a Make or Model:
   Gui, 6:Add, DropDownList, w150 vMake Choose1, Select Make Model:|Ford|Honda|Chevy|BMW|Other
   Gui, 6:Add, Text, x10 y60, How Many Extra Tires does the cust need?`nNot Including outlet the 4 on the car:
   Gui, 6:Add, Edit, VTires yp+35 w60 Limit2
   
}
else if(1=0 && 2=1 && 3=0)
{
   
      Gui, Submit
   Gui, 6:Show, w250 h150
   Gui, 6:Add, Text, x10 y10, Select a Make or Model:
   Gui, 6:Add, DropDownList, w150 vMake Choose1, Select Make Model:|Ford|Honda|Chevy|BMW|Other
   Gui, 6:Add, Text, x10 y60, How Many Extra Tires does the cust need?`nNot Including outlet the 4 on the car:
   Gui, 6:Add, Edit, VTires yp+35 w60 Limit2
   
}

else if(1=0 && 2=0 && 3=1)
{
   MsgBox, else
}
else if(1=1 && 2=1 && 3=0)
{
   MsgBox, else
}
else if(1=0 && 2=1 && 3=1)
{
   MsgBox, else
}
else if(1=1 && 2=0 && 3=1)
{
   MsgBox, else
}
else if(1=1 && 2=1 && 3=1)
{
   MsgBox, else

   }
else
{
   MsgBox, Please select a check box
}
return

return


EarlyTerm:
ExitApp


return            ;Main return






As always, i'm not asking anyone to do this for me, but I cant think of any other terms to search under that would suit this need.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 6th, 2009, 11:16 pm 
Offline

Joined: May 10th, 2007, 2:52 am
Posts: 194
Location: China/ Canada
Code:
Random,, A_TickCount
Loop, 3
{
 Random, c, 0, 1
 Gui, Add, Checkbox, Checked%c%
}
Gui, Show
return

_________________
Sakurako ^_^


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 6th, 2009, 11:28 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
I'm not sure you'll find anything like this pre-made. You'll need to thoroughly read the GUI section of the Help file to understand how to script it. Here's an example to get you started.
Code:
#SingleInstance force
#NoEnv

Gui, Add, Text,,Rows:
Gui, Add, Edit
Gui, Add, UpDown, Range1-7 vR
Gui, Add, Text, ym, Columns:
Gui, Add, Edit
Gui, Add, UpDown, Range1-7 vC
Gui, Add, Button, xm w75 Default, OK

Gui, Show,,Checkbox Grid
return
GuiClose:
ExitApp

ButtonOK:
Gui, Submit
Loop,% R*C
{
 Random, A_Check, 0, 1
 Gui, 2:Add, Checkbox, %A_Margin% Checked%A_Check% vBox%A_Index% gCB
 A_Margin := Mod(A_Index,R) ? "":"ym"
}
Gui, 2:Show
return

2GuiClose:
Gui, 2:Destroy
Gui, 1:Show
return

CB:
MsgBox, You just clicked %A_GuiControl%.
return


Last edited by jaco0646 on March 6th, 2009, 11:29 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 6th, 2009, 11:29 pm 
Offline

Joined: December 24th, 2008, 3:25 am
Posts: 1401
Location: :noitacoL
Thank you for the reply, but I am not sure I understand the example.

In the "Loop, 3", is the '3' able to be a user defined variable, through the GUI?
Also, why is tickcount being used if all of the data regarding the check-box-grid, is user defined also?


The GUI first asks 'How many rooms', this will determine how many columns aprear. User enters 1 for one room, and only 1 column apprears, or the user can enter 7 for 7 rooms.

The rows are the items installed in the rooms themselves, also selected through questions. No need to install an item in a room when it is not needed. Does the customer want Lightbulbs, sockets, outlets, carpet, other items. So as you select WHAT items the want, and you know how many rooms to put them in...

As in:

Code:
Install the following in the following rooms:
____________|Room1|Room2|Room3|
Light switch|-yes-|-yes-|--no--|
Outlet Cover|--no-|-yes-|-yes-|
Light bulbs |-no--|-no--|-no--|
Something   |-yes-|-yes-|-yes-|
Another     |-no--|-no--|-no--|

Basically, I want to print out a work order.  What goes into what room.  I do not need/want this to be printed out, the GUI can just display the grid



Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2009, 12:06 pm 
Offline

Joined: May 10th, 2007, 2:52 am
Posts: 194
Location: China/ Canada
Code:
Gui, Add, Edit, vENum gECheck Limit1 Number
Gui, Show
return

ECheck:
GuiControlGet, ENum
Gui, Destroy
Loop %ENum%
{
 c := A_Index
 Gui, Add, Checkbox, % "v" c "_1" (A_Index = 1 ? "" : " ys") " section", %c%_1
 Loop, 3
 {
  ANum := A_Index + 1
  Gui, Add, Checkbox, v%c%_%ANum% xs, %c%_%ANum%
 }
}
Gui, Show
return

_________________
Sakurako ^_^


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2009, 3:35 pm 
Offline

Joined: December 24th, 2008, 3:25 am
Posts: 1401
Location: :noitacoL
Very nice, Thank you jaco0646 and Sakurako, I will play around with these and show you what I have when its up.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2010, 2:23 am 
Offline

Joined: April 24th, 2009, 7:06 pm
Posts: 87
Hi Sakurako,
First of all, thanks for your code.
I am also new at dynamic GUIs similar to those you've made here.
i would like to understand what you just did. So can you please explain how
the code works and what each Gui Add CHeckbox-line does?

i would really appreciate that,
Thank You
Deep-Silence

BTW, (My Try)

Code:
Gui, Add, Edit, vENum gECheck Limit1 Number ;Adds the edit to get the userinput
Gui, Show ; shows the gui
return

ECheck: ;action for gECheck
GuiControlGet, ENum ;gets the Userinput
Gui, Destroy ;destroys the gui

Loop %ENum% ;repeats the action within this brakes %ENum%
{
 c := A_Index ;defines Variable c to get the value of %A_Index%
 Gui, Add, Checkbox, % "v" c "_1" (A_Index = 1 ? "" : " ys") " section", %c%_1 ; Adds the First Line of x lines
 Loop, 3 ;does the same for the following 3 lines
 {
  ANum := A_Index + 1 ;Defines ANum for each horizontal line
  Gui, Add, Checkbox, v%c%_%ANum% xs, %c%_%ANum% ;and adds its Checkboxes
 }
}
Gui, Show ;Shows the final GUI
return


Would be nice if you can explain the GUI, Add, Checkbox, lines...
:)



Sakurako wrote:
Code:
Gui, Add, Edit, vENum gECheck Limit1 Number
Gui, Show
return

ECheck:
GuiControlGet, ENum
Gui, Destroy
Loop %ENum%
{
 c := A_Index
 Gui, Add, Checkbox, % "v" c "_1" (A_Index = 1 ? "" : " ys") " section", %c%_1
 Loop, 3
 {
  ANum := A_Index + 1
  Gui, Add, Checkbox, v%c%_%ANum% xs, %c%_%ANum%
 }
}
Gui, Show
return


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Google Feedfetcher, nyoe, patgenn123 and 17 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group