Jump to content

How can i separate koda and custom gui on my script...


Recommended Posts

I added tons of items in groupctrls and they are all part of arrays, if i import this gui in koda it will simply mess up everything and change those items into non-array items which will then completely mess up my code algorythm.

So what i want to achieve is simply have ability to update everything in my gui trough koda except those specific controls which need special array algo to work.

Usually i solved this problem before with more simple things like statusbargui that i would add outside of koda region, its pretty simple. But this cant work like that because it needs to be part of region because its all in a tab that must be nested in a part of koda gui

Edited by Aktonius
Link to comment
Share on other sites

Learn to do it without Koda would be the best advice I could give you for this problem. While it's a great tool when you're learning to create GUI's it has limitations as you're finding out. Once you learn the basics of GUI's and item placement, you'll probably find you're using Koda a lot less. I haven't used Koda since about the 3 month mark once I dove in and tried to see what it was making for me.

It's a lot easier to move controls around in the Koda GUI than trying to figure it out for yourself, but the effort will pay off in the long run when you do it for yourself.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Learn to do it without Koda would be the best advice I could give you for this problem. While it's a great tool when you're learning to create GUI's it has limitations as you're finding out. Once you learn the basics of GUI's and item placement, you'll probably find you're using Koda a lot less. I haven't used Koda since about the 3 month mark once I dove in and tried to see what it was making for me.

It's a lot easier to move controls around in the Koda GUI than trying to figure it out for yourself, but the effort will pay off in the long run when you do it for yourself.

I don't take the same view. I have been using Koda for some time (years?) although not regularly. My experience is that it is better to find ways round problems in Koda so that you can still use it because it makes gui design and development so much easier. I would expect that given any design for a gui that needs a reasonably complex design I could produce a result in less than half th etime BrewMan can without it, and in a years time when I want to change it I could do it in one tenth the time.

If you have a group of controls that need to be arrays then I know this is a limitation with Koda but there are ways round it but it may be what I think is a reasonable approach someone else might not.

This is one way I deal with arrays of controls. Suppose you have an array of buttons.

In koda set the buttons in position. It's much easier to do this in Koda than otherwise. Give the buttons names like BtnArrayA1, BtnArrayA2 and so on.

Produce the AutoIt code or update your script.

In you code outside of the gui creation but after it, do something like

#endregion ### END Koda GUI section ###

$aBtns = _AssignToArray("BtArrayA"); just one line (ignoring the func)
;now you have your array of buttons, Koda can update and no problems

$aLabels = _AssignToArray("LabSet"); make the array of labels

And an example which I've tested

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 400, 300)
$Button1 = GUICtrlCreateButton("Button1", 38, 47, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 172, 56, 75, 25)
$Button3 = GUICtrlCreateButton("Button3", 84, 119, 75, 25)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

;create button array
Global $bt = _AssignToArray("Button")

GUICtrlSetData($bt[0], "Rearrange")

Global $DoneMove = False

While 1
    $Msg = GUIGetMsg()

    Switch $Msg
        Case -3
            Exit
        Case $bt[0]
            MsgBox(0, "CLICKED", "Button1", 0, $Form2)
            If Not $DoneMove Then
                _MoveAround()
                GUICtrlSetData($bt[0], "Button1")
            EndIf
            $DoneMove = True
        Case $bt[1]
            MsgBox(0, "CLICKED", "Button2", 0, $Form2)
        Case $bt[2]
            MsgBox(0, "CLICKED", "Button3", 0, $Form2)
    EndSwitch



WEnd

Func _MoveAround()
    ;rearrange the buttons
    $startxy = ControlGetPos($Form2, "", $bt[0])
    For $n = 1 To UBound($bt) - 1
        ControlMove($Form2, "", $bt[$n], $startxy[0], $startxy[1] + $n * 30)
    Next
EndFunc   ;==>_MoveAround


Func _AssignToArray($Group); made up as I write so not tested, just to give the idea
    Local $n, $ss
    Dim $Result[100]
    $n = 1
    ConsoleWrite(Eval("Button1") & @CRLF)
    While 1
        $ss = Eval($Group & $n)
        ConsoleWrite($ss & @CRLF)
        If Not $ss Then ExitLoop
        If UBound($Result) < $n - 1 Then ReDim $Result[$n + 10]

        $Result[$n - 1] = $ss
        $n += 1
    WEnd

    If $n = 0 Then Return SetError(-1, 0, 0)

    ReDim $Result[$n - 1]
    Return $Result

EndFunc   ;==>_AssignToArray

EDIT: Improved with tested example.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Martin i solved it somehow simmiliar to you but there is still a small issue, in your example you dont need to nest your array controls while in my example i MUST nest those arrayctrls in a tab that must be part of Koda update region.

I simply placed end of region before i started to create arrays, that means you still need to add gui_show after those arrays and when you update koda gui it creates another gui show on the end of region which on the end creates x2 gui shows for me.

Everytime i update i need to delete Koda's generated gui show but its ok, doesnt really bother me.

Link to comment
Share on other sites

Martin i solved it somehow simmiliar to you but there is still a small issue, in your example you dont need to nest your array controls while in my example i MUST nest those arrayctrls in a tab that must be part of Koda update region.

I simply placed end of region before i started to create arrays, that means you still need to add gui_show after those arrays and when you update koda gui it creates another gui show on the end of region which on the end creates x2 gui shows for me.

Everytime i update i need to delete Koda's generated gui show but its ok, doesnt really bother me.

I'm glad you found a solution.

I don't understand what you mean by nesting and I don't see why where you have the controls in the Koda design would make any difference to the approach I showed. Can you give a small example?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • Moderators

I don't take the same view. I have been using Koda for some time (years?) although not regularly. My experience is that it is better to find ways round problems in Koda so that you can still use it because it makes gui design and development so much easier. I would expect that given any design for a gui that needs a reasonably complex design I could produce a result in less than half th etime BrewMan can without it, and in a years time when I want to change it I could do it in one tenth the time.

I'll agree that it's a tool that has its place.

But that's where it stops. IMO ( yes, in my opinion ), when working on any type of "real" project, Koda code management is ridiculous.

The time it takes me to work through var name, height, width, styles, etc in Koda. I've already created 2 controls manually, more than that, I've created them in a controlled management scheme.

Edit:

I will say when I am mapping out a GUI, I often throw controls around in Koda just to see how it'd look. But ultimately, I always code it manually.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • 1 year later...

This is a problem I have seen with just about every GUI builder I have used. Even commercial ones costing big $$$.

Here's the cycle:

1) Build a graphic layout using the GUI editor

2) Autogenerate the code for the graphics

3) Add (manually) the custom code required to make the GUI work

4) Recognize the need to update the graphic layout

5) Revise the graphics layout using the GUI editor

6) Autogenerate the code for the revised graphics

7) Get frustrated because the autogeneration messed up the existing code and you have to manually add in the previous custom code in addition to the new custom code.

Isn't there some way to design a GUI builder to make revisions of autogenerated code easier?

Maybe some comment keywords that tell the GUI builder "don't touch this section of code"

And some keyword(s) that mean "don't change this control id / variable name / function name / etc"

For small projects its not a big deal to fix things up manually when revisions are made, but for a large system with 52 different screens and thousands of lines of callback code it's a real killer.

I'm just saying...

-- guiguy --

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...