Sign in to follow this  
Followers 0
DiscoEd

Best method to Re-Use GUI code in multiple applications

5 posts in this topic

Greetings,

O.k. I've got this Autoit (work related) project that I've been working on for about a year. It started out small, but the scope of the project and the script(s) keep getting larger.

For this project I have written several scripts that keep a similar appearance and have similar functions in many cases. The problem that has developed is that I'm starting to have trouble managing changes to what is essentially the same GUI code across these several scripts.

I've been trying to approach this problem using includes, but while that seems to work for non GUI related functions, I'm running into problems when it comes to things such as creating a new GUI window (with controls) from a function within an include file.

To better describe the scenario...

1. I have a main GUI window with two Tabs and numerous controls on each of those tabs. These are created by the main script.

2. Then I want a third Tab with controls which is used for program config settings. The same code for this third Tab can be used across several other "main" scripts.

3. When I try to work this out by creating an include files containing the controls and logic for the third tab I start to run into problems with the controls showing up as not being declared. I was able to clear some of these up by declaring values globally either in the include or by declaring the variables before the include is called by the main script.

4. I also tried another approach of trying to have the include file create a whole new GUI window which would just have the needed configuration controls and which could simply be closed when the config was done. You would then go back to the using the main script GUI.

Bottom line is that I want to have some code that I can reuse in multiple scripts and maintain in only one place. Is there some one who could point me in the direction of some help in how to do this in a professional sort of way?

I guess what I'm looking for would be something along the lines of a "best Autoit GUI practices" or a "best practices with Autoit includes" type of guide.

Perhaps the real problem is that Autoit is just too powerful and awesome, had Autoit been wimpy and useless my project would have never grown to what it is today. Doh!

Thanks in Advance,

DiscoEd

Share this post


Link to post
Share on other sites



- Use KODA to design the GUI

- Always use the same control names

- Put the GUI code into an include file

- To add a variable to the KODA GUI, declare it first in the target script before including the GUI

$sGUI_Name = "GUI Test Name 1"

#include <_Default_GUI.au3>

while you declare the GUI name in Koda something like "" & $sGUI_Name & ""

Share this post


Link to post
Share on other sites

If you have troubles with not declared constants then make new helper include file <All_GUI_Constants.au3>

containing all GUI constants include files

and add it at top of your include _Default_GUI.au3

#include <All_GUI_Constants.au3>

--->

#include <AVIConstants.au3>

#include <ButtonConstants.au3>

#include <ComboConstants.au3>

... all other *Constants.au3 files here ...

Share this post


Link to post
Share on other sites

Sound to me like this could use some sort of used.tabs and used.controls management system.

Though I'm probably looking at it from a wrong and overly complicated point of view. :)


"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

Use the Snippet Holder in SciTE4AutoIt3

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