Sign in to follow this  
Followers 0
sliwek

How can i clean my GUI code

5 posts in this topic

#1 ·  Posted (edited)

i have lots labels and think how can i sort or rename or recount all names in gui

$Tabsheet1 = GUICtrlCreateTabItem("..")
$InfoBox = GUICtrlCreateGroup("..", 72, 48, 489, 129)
$Label74 = GUICtrlCreateLabel("..", 80, 64, 516, 17)
$Label74 = GUICtrlCreateLabel("..", 80, 80, 516, 17)
$Label74 = GUICtrlCreateLabel("..", 80, 96, 516, 17)
$Label74 = GUICtrlCreateLabel("..", 80, 112, 516, 17)
$buttonNew1 = GUICtrlCreateButton("..", 80, 140, 90, 30, $WS_GROUP)
$LabelNew2 = GUICtrlCreateLabel("..", 175, 150, 100, 100)
$Label74 = GUICtrlCreateLabel("..", 80, 128, 516, 17)
$Label74 = GUICtrlCreateLabel("..", 80, 144, 516, 17)
$InfoBox = GUICtrlCreateGroup("..", 72, 188, 489, 189)
$Label74 = GUICtrlCreateLabel("..", 80, 204, 516, 17)
$Label75 = GUICtrlCreateLabel("..", 80, 220, 516, 17)
$Label76 = GUICtrlCreateLabel("..", 80, 236, 516, 17)
$Label74 = GUICtrlCreateLabel("..", 80, 253, 516, 17)
$Label74 = GUICtrlCreateLabel("..", 80, 270, 516, 17)

and i have whole my gui like that. how can i recount my Labels, InfoBoxs? its about 500 lines code

Edited by sliwek

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

What I usually do is use an array for my gui elements, like so:

$GUIArray[0] =      GUICreate("QuickCopy", 170, 510, @DesktopWidth-190, 75)
    ;BASIC DETAILS
    $GUIArray[1] =      GUICtrlCreateRadio("Product Name", 25, 25)
    $GUIArray[16] =     GUICtrlCreateCheckbox("Automate Product Code", 25, 45)
    ;PRICE DETAILS
    $GUIArray[2] =      GUICtrlCreateRadio("Final Price", 25, 90)
    ;DESCRIPTION
    $GUIArray[3] =      GUICtrlCreateRadio("Description", 25, 135)
    ;IMAGES
    $GUIArray[4] =      GUICtrlCreateRadio("Images", 25, 180) ;Copies the image URL into an array
    $GUIArray[17] =     GUICtrlCreateButton("Add URL", 100, 175)
    ;ADVANCED DETAILS
    $GUIArray[5] =      GUICtrlCreateRadio("Wholesale Price", 25, 225)
    $GUIArray[6] =      GUICtrlCreateRadio("Brand", 25, 245)
    $GUIArray[7] =      GUICtrlCreateRadio("Notes", 25, 265)
    $GUIArray[8] =      GUICtrlCreateRadio("Product Search Tags", 25, 285)
    ;POSTAGE
    $GUIArray[9] =      GUICtrlCreateRadio("Fixed Cost", 25, 330)
    ;SEARCH ENGINE OPTIMISATION
    $GUIArray[10] =     GUICtrlCreateRadio("Title", 25, 375)
    $GUIArray[11] =     GUICtrlCreateRadio("Keywords", 25, 395)
    $GUIArray[12] =     GUICtrlCreateRadio("Description", 25, 415)
    ;BUTTONS
    $GUIArray[13] =     GUICtrlCreateButton("Clear All Values", 10, 445, 150, 25)
    $GUIArray[14] =     GUICtrlCreateButton("Paste All", 10, 475, 150, 25)
    $GUIArray[15] =     GUICtrlCreateButton("Calculate", 100, 130)
    ;GROUPS
    GUICtrlCreateGroup("Basic Details",                 10,     10,     150,    60)
    GUICtrlCreateGroup("Price Details",                 10,     75,     150,    40)
    GUICtrlCreateGroup("Description",                    10,        120,    150,    40)
    GUICtrlCreateGroup("Images",                        10,     165,    150,    40)
    GUICtrlCreateGroup("Advanced Details",              10,     210,    150,    100)
    GUICtrlCreateGroup("Postage",                       10,     315,    150,    40)
    GUICtrlCreateGroup("Search Engine Optimisation",    10,     360,    150,    80)

If you view that in notepad or the scite editor and replace each group of four spaces with a tab character, you will also notice that when creating the groups, I laid it all out neatly (but it doesnt look like it on the forums). Ofcourse, everyone does it as they like to, that is just how I do it. I do a different array for each GUI, by the way.

Edited by Mikeman27294

Share this post


Link to post
Share on other sites

You could store the ControlIds in an array. So to create and change them you could simply loop through the array.

Can you post a screenshot of the GUI you ahve so far?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

It seems you created your GUI in Koda.

You can manually assign Name property for each control in GUI directly in Koda instead of default LabelNNN.

yea at start it was in koda but i updating program for few years in SciTE script.

that my first working program in AutoIt and just wanted clean it little :)

tried back to koda but cant import gui because of labels names

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0