Jump to content

Easy-to-maintain GUI's


Recommended Posts

I am looking for advice on how to design GUI's that require as little effort as possible to add or remove any controls.

It'll simply be a bunch of buttons and labels, if that makes it easier. It will also be fairly grid-like, as I just need something simple.

This is the design that I am aiming for.

Posted Image

(the dots represent an arbitrary number of buttons may follow below)

Basically my tool deals with two "types" of functions which I reference as "set 1 features" and "Set 2 features". There can be an arbitrary number of buttons underneath, though I do not expect it to exceed 10 per column. If it does, I'll be switching to dropdown lists instead.

I am building the small tool one function at a time as I go and releasing new updates everytime I add a function.

Currently I manually specify the coordinates where the controls should be created but that is not very flexible.

What if I wanted to add a button at the very top? Or in between two buttons? What if I want to add a label and shift everything down? Not fun.

I have read the helpfile and tried out the alternative gui coord methods, but can't seem to figure out a good way to do this.

Goal: define a general "region" where the control should be placed (like for example "row 1, column 1" and then let the controls figure out how to position themselves.

Edited by Tsukihime
Link to comment
Share on other sites

sounds like how Python works in programing GUIs.

do you have any code to work with?

Link to comment
Share on other sites

Well, this is what I have so far in the GUI design portion:

;make the window, position in the top-right corner of screen
GUICreate("Easy2Use", 280, 300 , @DesktopWidth - 300, 0)

;first column
$bLoadFile = GUICtrlCreateButton("Load File", 10, 30, 120)
$bAssignTex = GUICtrlCreateButton("Assign Textures", 10, 60, 120)
$bCreateTex = GUICtrlCreateButton("Create Textures", 10, 90, 120)
$bAddTex = GUICtrlCreateButton("Add Textures", 10, 120, 120)
$bRemoveTex = GUICtrlCreateButton("Remove Textures", 10, 150, 120)
$bAddMat = GUICtrlCreateButton("Add Materials", 10, 180, 120)

;second column
$bAddFrame = GUICtrlCreateButton("Add Frames", 140, 30, 120)

;logic to follow
GUISetState()
...

And that's pretty much it. The workaround for the buttons is somehow use a loop to deal with it so I only have to specify where the first button should be placed and everything follows, but that's just a workaround...

Edited by Tsukihime
Link to comment
Share on other sites

You could use something like this to make it as flexible as possible. No calculations needed if you want to add another button just add the lines marked with (1) and (2):

#include <GUIConstantsEx.au3>

$iXCol1 = 10        ; Left position of first button in colunmn 1
$iYCol1 = 30        ; Top position of first button in colunmn 1
$iXCol2 = 140       ; Left position of first button in colunmn 2
$iYCol2 = 30        ; Top position of first button in colunmn 2
$iBtnHeight = 20    ; Button height
$iBtnWidth = 120    ; Button width
$iBtnSpace = 10     ; space between two rows of buttons

;make the window, position in the top-right corner of screen
GUICreate("Easy2Use", 280, 300, @DesktopWidth - 300, 0)

;first column
$bLoadFile = GUICtrlCreateButton("Load File", $iXCol1, $iYCol1, $iBtnWidth)
$iYCol1 = $iYCol1 + $iBtnHeight + $iBtnSpace                                        ; (1)
$bAssignTex = GUICtrlCreateButton("Assign Textures", $iXCol1, $iYCol1, $iBtnWidth)  ; (2)
$iYCol1 = $iYCol1 + $iBtnHeight + $iBtnSpace
$bCreateTex = GUICtrlCreateButton("Create Textures", $iXCol1, $iYCol1, $iBtnWidth)
$iYCol1 = $iYCol1 + $iBtnHeight + $iBtnSpace
$bAddTex = GUICtrlCreateButton("Add Textures", $iXCol1, $iYCol1, $iBtnWidth)
$iYCol1 = $iYCol1 + $iBtnHeight + $iBtnSpace
$bRemoveTex = GUICtrlCreateButton("Remove Textures", $iXCol1, $iYCol1, $iBtnWidth)
$iYCol1 = $iYCol1 + $iBtnHeight + $iBtnSpace
$bAddMat = GUICtrlCreateButton("Add Materials", $iXCol1, $iYCol1, $iBtnWidth)

;second column
$bAddFrame = GUICtrlCreateButton("Add Frames", $iXCol2, $iYCol2, $iBtnWidth)
$iYCol2 = $iYCol2 + $iBtnHeight + $iBtnSpace

;logic to follow
GUISetState()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

@water i think he was talking about dynamically creating controls while script is running.

Link to comment
Share on other sites

@water i think he was talking about dynamically creating controls while script is running.

I just re-read the original post and I think my code just does what he wants.

All variable data is stored at the beginning of the script and can easily be changed. if he wants to move a button he just has to move the statements marked as (1) and (2) in the source code.

But maybe my english isn't good enough :unsure:

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

ooooh sorry, dynamics can be done but is difficult to keep track of. :/

Link to comment
Share on other sites

@water, that is an interesting way to design the GUI.

I can most likely expand on that to specify the "regions" that I want so I could imagine having boxes that contain different controls where expanding the box would push other boxes around.

Link to comment
Share on other sites

Haven't tried it myself but maybe is what you are looking for.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Haven't tried it myself but maybe is what you are looking for.

I would probably have a hard time updating the interface if I suddenly wanted to improve it to make it more aesthetic.

Explicitly defining each button and function in a huge select statement sounds fine.

Now I just need to define boxes where the initial positions will be dependent on all previous GUI's. Then I would have a really flexible interface where I could add 5 buttons to column one and if there are additional rows underneath, they would all be pushed down.

Would take some planning but it sounds like a good plan.

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...