JonJablonowski Posted May 15 Share Posted May 15 Hey I'm working on a GUI. I initially was using the default KODA form designer but it felt a bit clunky and all elements in the GUI are hardcoded. I was hoping to make it modular, using variables. But that doesn't work in conjunction with Koda. I had a look and found this thread But after trying two of them, the same issue arises. I want to be able to plug stuff in and out and not have to re-align everything manually. I have two examples, the base hardcoded version using GUIBuilder (from the link above) #Region (=== GUI generated by GuiBuilderPlus 1.3.0 ===) Global $hGUI Global $Radio_1, $Radio_2, $Radio_3, $Group_1 ;------------------------------------------------------ ; Title...........: _guiCreate ; Description.....: Create the main GUI ;------------------------------------------------------ Func _guiCreate() $hGUI = GUICreate("MyGUI", 400, 350, 210, 0) $Radio_1 = GUICtrlCreateRadio("Radio 1", 155, 90, 96, 20) $Radio_2 = GUICtrlCreateRadio("Radio 2", 155, 120, 96, 20) $Radio_3 = GUICtrlCreateRadio("Radio 3", 155, 150, 96, 20) $Group_1 = GUICtrlCreateGroup("Group 1", 115, 55, 151, 151) GUICtrlCreateGroup("", -99, -99, 1, 1) EndFunc ;==>_guiCreate #EndRegion (=== GUI generated by GuiBuilderPlus 1.3.0 ===) And the goal I want to achieve #Region (=== GUI generated by GuiBuilderPlus 1.3.0 ===) Global $hGUI Global $Radio_1, $Radio_2, $Radio_3, $Group_1 Local $PosX Local $PosY_add = 25 Local $PosY_counter = 0 Local $PosY_Start =85 ;------------------------------------------------------ ; Title...........: _guiCreate ; Description.....: Create the main GUI ;------------------------------------------------------ Func _guiCreate() $hGUI = GUICreate("MyGUI", 400, 350, 210, 0) $Radio_1 = GUICtrlCreateRadio("Radio "& String($PosY_counter+1), 160, $PosY_Start+$PosY_add*$PosY_counter, 91, 20) $PosY_counter +=1 $Radio_2 = GUICtrlCreateRadio("Radio "& String($PosY_counter+1), 160, $PosY_Start+$PosY_add*$PosY_counter, 91, 20) $PosY_counter +=1 $Radio_3 = GUICtrlCreateRadio("Radio "& String($PosY_counter+1), 160, $PosY_Start+$PosY_add*$PosY_counter, 91, 20) $PosY_counter +=1 $Group_1 = GUICtrlCreateGroup("Group 1", 115, 55, 151, 151) GUICtrlCreateGroup("", -99, -99, 1, 1) EndFunc ;==>_guiCreate #EndRegion (=== GUI generated by GuiBuilderPlus 1.3.0 ===) If I want to remove Radio 2 in the first case, I then have to manually move up Radio 3 and rename it to Radio 2. In my case I just remove 2 lines and it does the job. I'm aware the variable name isn't changing in my example but that's fixable through some extra code. I'm new to all this so excuse my beginner questions 😕 Link to comment Share on other sites More sharing options...
argumentum Posted May 15 Share Posted May 15 expandcollapse popup#Region (=== GUI generated by argumentum 0.0.0.1 ===) Global $hGUI Global $Radio_1, $Radio_2, $Radio_3, $Group_1 Local $PosX Local $PosY_add = 25 Local $PosY_counter = 0 Local $PosY_Start = 85 ;------------------------------------------------------ ; Title...........: _guiCreate ; Description.....: Create the main GUI ;------------------------------------------------------ _guiCreate("MyGUI", 400, 350) Func _guiCreate($sTitle, $iWidth, $iHeight, $iLeft = -1, $iTop = -1) $hGUI = GUICreate($sTitle, $iWidth, $iHeight, $iLeft, $iTop) Local $idTemp For $n = 1 To 3 $idTemp = GUICtrlCreateRadio("Radio " & String($PosY_counter + 1), 160, $PosY_Start + $PosY_add * $PosY_counter, 91, 20) Assign("Radio_" & $PosY_counter + 1, $idTemp) $PosY_counter += 1 Next $Group_1 = GUICtrlCreateGroup("Group 1", 115, 55, 151, 151) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState() EndFunc ;==>_guiCreate #EndRegion (=== GUI generated by argumentum 0.0.0.1 ===) While 1 Switch GUIGetMsg() Case -3 GUIDelete() Exit Case $Radio_1 MsgBox(0, "", "$Radio_1", 1, $hGUI) Case $Radio_2 MsgBox(0, "", "$Radio_2", 1, $hGUI) Case $Radio_3 MsgBox(0, "", "$Radio_3", 1, $hGUI) EndSwitch WEnd I don't use anything other than my wish. No code generator. JonJablonowski 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
JonJablonowski Posted May 15 Author Share Posted May 15 Thanks for having a look and making a much cleaner and time saving version! Sadly it can't be used on conjunction with the GUI generators, but maybe that's just part of the limitation with the auto generated stuff and using both simply isn't an option. argumentum 1 I'm new to all this so excuse my beginner questions 😕 Link to comment Share on other sites More sharing options...
TheSaint Posted May 15 Share Posted May 15 To this day, and if not able to quickly copy the basic GUI creation code from another of my programs, I still use a version of GUIBuilder to create my initial GUI, which I will then continue to modify manually. Sometimes I will make control positions variable based, especially the bottom row, which allows me to then resize the GUI without having to reposition some of the controls. So you could in theory have some setup to always do that, but adding and especially removing controls, can add its own complications, and a need for adjustments, so the style of the GUI can be a factor of course. More often than not for me, control placement is a juggling act ... making things look uniform enough, being able to fit all I need in, not making controls too big or small, logical progression of usage from one control to another (like stepping stones with your mouse), etc. I am less concerned about how visually appealing or pretty my GUIs are, with practical being almost everything to me ... though I like things to be uniform and neat. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now