Sign in to follow this  
Followers 0
kyriakos

tab and buttons dynamically created

4 posts in this topic

I'm trying to make an application launcher gui for my setups.

the general idea is to have a tab for every software category and a button for every application folder.

I have manage so far. the problem is to assign actions for the buttons.

using a two dimension array ends up in endless loop.

test the code and you will see what i mean.

CODE
#Include <File.au3>

#Include <Array.au3>

#include <GuiConstants.au3>

$i=0

$k=0

$m=0

$o=0

Global $ins_btn[20][20]

Dim $auto_ins_btn[30][30]

Dim $icon[30][30]

Dim $lbl[30][30]

dim $info[30][30]

Dim $tab[30]

Dim $text[30]

$mainwindow = GUICreate("Setup CD Kyriakos", 800, 600,-1,-1,-1)

$font="Comic Sans MS"

GUISetFont (10, 400, 1, $font,$mainwindow)

$tabmain=GUICtrlCreateTab (10,10, 780,580,$TCS_MULTILINE )

$folderListbase=_FileListToArray(".\","*.",2)

If @Error=1 Then

MsgBox (0,"","No Files\Folders Found.")

Exit

EndIf

$Pos = _ArraySearch ($folderListbase, "test", 0, 0, 0, True)

_ArrayDelete($folderListbase,$Pos)

$Pos = _ArraySearch ($folderListbase, "Tweak", 0, 0, 0, True)

_ArrayDelete($folderListbase,$Pos)

$Pos = _ArraySearch ($folderListbase, "Games_small", 0, 0, 0, True)

_ArrayDelete($folderListbase,$Pos)

for $folders in $folderListbase

;MsgBox(1,$i,$folders)

if $i<>0 Then

$tab[$i]=GUICtrlCreateTabitem ($i&". "&$folders)

$text[$i]=GUICtrlCreateEdit("",450,70,300,450,$ES_MULTILINE)

$FileList=_FileListToArray(".\"&$folders,"*.",2)

If @Error=1 Then

MsgBox (0,"","No Files\Folders Found.")

Exit

EndIf

;_ArrayDisplay($FileList)

for $folders2 in $FileList

if $k<>0 Then

;$lbl[$i][$k]=GUICtrlCreateLabel ($k&". "&StringLeft($folders2,15), 40,40+$m,150,20);

$ins_btn[$i][$k]=GUICtrlCreateButton ("",250,40+$m,30,30,$BS_ICON)

;GUICtrlSetImage (-1, ".\Scripts\icons\install.ico")

;$auto_ins_btn[$i][$k]=GUICtrlCreateButton ("",300,40+$m,30,30,$BS_ICON)

;GUICtrlSetImage (-1, ".\Scripts\icons\kkk.ico")

;$icon[$i][$k]=GUICtrlCreateIcon(".\"&$folders&"\"&$folders2&"\icon.ico",-1,350,40+$m,40,40)

;$info[$i][$k]=".\"&$folders&"\"&$folders2&"\info.txt"

EndIf

$m += 35

$k += 1

Next

EndIf

$i += 1

$k=0

$m=0

Next

GUICtrlCreateTabitem (""); end tabitem definition

$temp_lbl=GUICtrlCreateLabel ("label1324", 200,570,350,20)

GUISetState( @SW_SHOW )

;MsgBox(1,$i,$folders)

Do

$msg = GUIGetMsg()

For $i = 1 to 10

For $j = 1 To 10

If $msg = $ins_btn[$i][$j] Then

$m += 1

GUICtrlSetData($temp_lbl,$m&" "&$i);"&$j) ; <========= Here is the problem

EndIf

Next

Next

Until $msg = $GUI_EVENT_CLOSE

Func info_load()

If WinActive($mainwindow) Then

$ggci = GUIGetCursorInfo($mainwindow)

For $i=1 to 15

For $k=1 to 15

If $ggci[4] = $lbl[$i][$k] Then

GUICtrlSetData($text[$i],FileRead($info[$i][$k], FileGetSize($info[$i][$k])))

Else

;; Mouse has left button_0

EndIf

Next

Next

EndIf

EndFunc

This is the first time i post a massage, usually i manage it with the help of the forum and i would appreciate any help

P.S. the example on http://www.autoitscript.com/forum/index.ph...hl=many+buttons DOES work mine DOES NOT.

Kyriakos

Share this post


Link to post
Share on other sites



I'm trying to make an application launcher gui for my setups.

the general idea is to have a tab for every software category and a button for every application folder.

I have manage so far. the problem is to assign actions for the buttons.

using a two dimension array ends up in endless loop.

test the code and you will see what i mean.

CODE
#Include <File.au3>

#Include <Array.au3>

#include <GuiConstants.au3>

$i=0

$k=0

$m=0

$o=0

Global $ins_btn[20][20]

Dim $auto_ins_btn[30][30]

Dim $icon[30][30]

Dim $lbl[30][30]

dim $info[30][30]

Dim $tab[30]

Dim $text[30]

$mainwindow = GUICreate("Setup CD Kyriakos", 800, 600,-1,-1,-1)

$font="Comic Sans MS"

GUISetFont (10, 400, 1, $font,$mainwindow)

$tabmain=GUICtrlCreateTab (10,10, 780,580,$TCS_MULTILINE )

$folderListbase=_FileListToArray(".\","*.",2)

If @Error=1 Then

MsgBox (0,"","No Files\Folders Found.")

Exit

EndIf

$Pos = _ArraySearch ($folderListbase, "test", 0, 0, 0, True)

_ArrayDelete($folderListbase,$Pos)

$Pos = _ArraySearch ($folderListbase, "Tweak", 0, 0, 0, True)

_ArrayDelete($folderListbase,$Pos)

$Pos = _ArraySearch ($folderListbase, "Games_small", 0, 0, 0, True)

_ArrayDelete($folderListbase,$Pos)

for $folders in $folderListbase

;MsgBox(1,$i,$folders)

if $i<>0 Then

$tab[$i]=GUICtrlCreateTabitem ($i&". "&$folders)

$text[$i]=GUICtrlCreateEdit("",450,70,300,450,$ES_MULTILINE)

$FileList=_FileListToArray(".\"&$folders,"*.",2)

If @Error=1 Then

MsgBox (0,"","No Files\Folders Found.")

Exit

EndIf

;_ArrayDisplay($FileList)

for $folders2 in $FileList

if $k<>0 Then

;$lbl[$i][$k]=GUICtrlCreateLabel ($k&". "&StringLeft($folders2,15), 40,40+$m,150,20);

$ins_btn[$i][$k]=GUICtrlCreateButton ("",250,40+$m,30,30,$BS_ICON)

;GUICtrlSetImage (-1, ".\Scripts\icons\install.ico")

;$auto_ins_btn[$i][$k]=GUICtrlCreateButton ("",300,40+$m,30,30,$BS_ICON)

;GUICtrlSetImage (-1, ".\Scripts\icons\kkk.ico")

;$icon[$i][$k]=GUICtrlCreateIcon(".\"&$folders&"\"&$folders2&"\icon.ico",-1,350,40+$m,40,40)

;$info[$i][$k]=".\"&$folders&"\"&$folders2&"\info.txt"

EndIf

$m += 35

$k += 1

Next

EndIf

$i += 1

$k=0

$m=0

Next

GUICtrlCreateTabitem (""); end tabitem definition

$temp_lbl=GUICtrlCreateLabel ("label1324", 200,570,350,20)

GUISetState( @SW_SHOW )

;MsgBox(1,$i,$folders)

Do

$msg = GUIGetMsg()

For $i = 1 to 10

For $j = 1 To 10

If $msg = $ins_btn[$i][$j] Then

$m += 1

GUICtrlSetData($temp_lbl,$m&" "&$i);"&$j) ; <========= Here is the problem

EndIf

Next

Next

Until $msg = $GUI_EVENT_CLOSE

Func info_load()

If WinActive($mainwindow) Then

$ggci = GUIGetCursorInfo($mainwindow)

For $i=1 to 15

For $k=1 to 15

If $ggci[4] = $lbl[$i][$k] Then

GUICtrlSetData($text[$i],FileRead($info[$i][$k], FileGetSize($info[$i][$k])))

Else

;; Mouse has left button_0

EndIf

Next

Next

EndIf

EndFunc

This is the first time i post a massage, usually i manage it with the help of the forum and i would appreciate any help

P.S. the example on http://www.autoitscript.com/forum/index.ph...hl=many+buttons DOES work mine DOES NOT.

Kyriakos

Is the problem that there are no buttons created?

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.

Share this post


Link to post
Share on other sites

Is the problem that there are no buttons created?

No the buttons are created just fine. is just that i cannot assign the to do something

here is the problem.

this works

CODE

#include <guiconstants.au3>

Global $Button[11][11]

GUICreate("" )

For $a = 1 to 10

For $b = 1 to 10

$Button[$a][$b] = GUICtrlCreateButton( "Button[" & $a & "][" & $b & "]" , $a * 45 , $b * 45 , 30 , 30)

Next

Next

GUISetState( @SW_SHOW )

Do

$msg = GUIGetMsg()

For $i = 1 to 10

For $j = 1 To 10

If $msg = $Button[$i][$j] Then

MsgBox( 0, "", "Perform some action cuz a button was clicked." )

EndIf

Next

Next

Until $msg = $GUI_EVENT_CLOSE

this does NOT work

CODE

#Include <File.au3>

#Include <Array.au3>

#include <GuiConstants.au3>

$i=0

$k=0

$m=0

$o=0

Global $ins_btn[20][20]

Dim $auto_ins_btn[30][30]

Dim $icon[30][30]

Dim $lbl[30][30]

dim $info[30][30]

Dim $tab[30]

Dim $text[30]

$mainwindow = GUICreate("Setup CD Kyriakos", 800, 600,-1,-1,-1)

$font="Comic Sans MS"

GUISetFont (10, 400, 1, $font,$mainwindow)

$tabmain=GUICtrlCreateTab (10,10, 780,580,$TCS_MULTILINE )

$folderListbase=_FileListToArray(".\","*.",2)

If @Error=1 Then

MsgBox (0,"","No Files\Folders Found.")

Exit

EndIf

;$Pos = _ArraySearch ($folderListbase, "test", 0, 0, 0, True)

;_ArrayDelete($folderListbase,$Pos)

$Pos = _ArraySearch ($folderListbase, "Tweak", 0, 0, 0, True)

_ArrayDelete($folderListbase,$Pos)

$Pos = _ArraySearch ($folderListbase, "Games_small", 0, 0, 0, True)

_ArrayDelete($folderListbase,$Pos)

create_btns()

Func create_btns()

for $folders in $folderListbase

;MsgBox(1,$i,$folders)

if $i<>0 Then

$tab[$i]=GUICtrlCreateTabitem ($i&". "&$folders)

$text[$i]=GUICtrlCreateEdit("",450,70,300,450,$ES_MULTILINE)

$FileList=_FileListToArray(".\"&$folders,"*.",2)

If @Error=4 Then

$Pos = _ArraySearch ($folderListbase, $folders, 0, 0, 0, True)

_ArrayDelete($folderListbase,$Pos)

$i=0

Return

EndIf

;_ArrayDisplay($FileList)

for $folders2 in $FileList

if $k<>0 Then

$lbl[$i][$k]=GUICtrlCreateLabel ($k&". "&StringLeft($folders2,15), 40,40+$m,150,20);

$ins_btn[$i][$k]=GUICtrlCreateButton ("",250,40+$m,30,30,$BS_ICON)

GUICtrlSetImage (-1, ".\Scripts\icons\install.ico")

$auto_ins_btn[$i][$k]=GUICtrlCreateButton ("",300,40+$m,30,30,$BS_ICON)

GUICtrlSetImage (-1, ".\Scripts\icons\kkk.ico")

$icon[$i][$k]=GUICtrlCreateIcon(".\"&$folders&"\"&$folders2&"\icon.ico",-1,350,40+$m,40,40)

$info[$i][$k]=".\"&$folders&"\"&$folders2&"\info.txt"

EndIf

$m += 35

$k += 1

Next

EndIf

$i += 1

$k=0

$m=0

Next

EndFunc

GUICtrlCreateTabitem (""); end tabitem definition

$temp_lbl=GUICtrlCreateLabel ("label1324", 200,570,350,20)

GUISetState( @SW_SHOW )

Do

$msg = GUIGetMsg()

For $i = 1 to 10

For $j = 1 To 10

If $msg = $ins_btn[$i][$j] Then; <========================================== Here is the problem

$m += 1

GUICtrlSetData($temp_lbl,$m&" "&$i);"&$j)

EndIf

Next

Next

info_load()

Until $msg = $GUI_EVENT_CLOSE

Func info_load()

If WinActive($mainwindow) Then

$ggci = GUIGetCursorInfo($mainwindow)

For $i=1 to 15

For $k=1 to 15

If $ggci[4] = $lbl[$i][$k] Then

GUICtrlSetData($text[$i],FileRead($info[$i][$k], FileGetSize($info[$i][$k])))

Else

;; Mouse has left button_0

EndIf

Next

Next

EndIf

EndFunc

Share this post


Link to post
Share on other sites

thanks for the help guys :whistle:

i found it myself.

you allways have to put the correct number of dimenions of the array ($i,$j) . if for example $j max = 5 and you put i = 1 to 6 then it loops for ever.

here is the correct code

CODE
#Include <File.au3>

#Include <Array.au3>

#include <GuiConstants.au3>

$i=0

$k=0

$m=0

$o=0

$i_max=0

Global $ins_btn[20][20]

Dim $k_max[20]

Dim $auto_ins_btn[30][30]

Dim $icon[30][30]

Dim $lbl[30][30]

dim $info[30][30]

Dim $tab[30]

Dim $text[30]

$mainwindow = GUICreate("Setup CD Kyriakos", 800, 600,-1,-1,-1)

$font="Comic Sans MS"

GUISetFont (10, 400, 1, $font,$mainwindow)

$tabmain=GUICtrlCreateTab (10,10, 780,580,$TCS_MULTILINE )

$folderListbase=_FileListToArray(".\","*.",2)

If @Error=1 Then

MsgBox (0,"","No Files\Folders Found.")

Exit

EndIf

for $folders in $folderListbase

$FileList=_FileListToArray(".\"&$folders,"*.",2)

If @Error=4 Then

$Pos = _ArraySearch ($folderListbase, $folders, 0, 0, 0, True)

_ArrayDelete($folderListbase,$Pos)

;$i=0

;Return

EndIf

Next

$Pos = _ArraySearch ($folderListbase, "lexika", 0, 0, 0, True)

_ArrayDelete($folderListbase,$Pos)

$Pos = _ArraySearch ($folderListbase, "Tweak", 0, 0, 0, True)

_ArrayDelete($folderListbase,$Pos)

$Pos = _ArraySearch ($folderListbase, "Games_small", 0, 0, 0, True)

_ArrayDelete($folderListbase,$Pos)

create_btns()

Func create_btns()

for $folders in $folderListbase

;MsgBox(1,$i,$folders)

if $i<>0 Then

$tab[$i]=GUICtrlCreateTabitem ($i&". "&$folders)

$text[$i]=GUICtrlCreateEdit("",450,70,300,450,$ES_MULTILINE)

$FileList=_FileListToArray(".\"&$folders,"*.",2)

for $folders2 in $FileList

if $k<>0 Then

$lbl[$i][$k]=GUICtrlCreateLabel ($k&". "&StringLeft($folders2,15), 40,40+$m,150,20);

$ins_btn[$i][$k]=GUICtrlCreateButton ("",250,40+$m,30,30,$BS_ICON)

GUICtrlSetImage (-1, ".\Scripts\icons\install.ico")

$auto_ins_btn[$i][$k]=GUICtrlCreateButton ("",300,40+$m,30,30,$BS_ICON)

GUICtrlSetImage (-1, ".\Scripts\icons\kkk.ico")

$icon[$i][$k]=GUICtrlCreateIcon(".\"&$folders&"\"&$folders2&"\icon.ico",-1,350,40+$m,40,40)

$info[$i][$k]=".\"&$folders&"\"&$folders2&"\info.txt"

EndIf

$m += 35

$k += 1

Next

if $k>$k_max[$i] Then $k_max[$i] = $k

EndIf

$i += 1

$k=0

$m=0

if $i>$i_max Then $i_max=$i

Next

MsgBox(1,$i,$i_max)

_ArrayDisplay($k_max)

EndFunc

GUICtrlCreateTabitem (""); end tabitem definition

$temp_lbl=GUICtrlCreateLabel ("label1324", 200,570,350,20)

GUISetState( @SW_SHOW )

Do

$msg = GUIGetMsg()

For $i = 1 to $i_max-1

For $j = 1 To $k_max[$i]-1

If $msg = $ins_btn[$i][$j] Then; <========================================== Here WAS the problem

$m += 1

GUICtrlSetData($temp_lbl,$m&" "&$i&"|"&$j);"&$j)

EndIf

Next

Next

info_load()

Until $msg = $GUI_EVENT_CLOSE

Func info_load()

If WinActive($mainwindow) Then

$ggci = GUIGetCursorInfo($mainwindow)

For $i=1 to 15

For $k=1 to 15

If $ggci[4] = $lbl[$i][$k] Then

GUICtrlSetData($text[$i],FileRead($info[$i][$k], FileGetSize($info[$i][$k])))

Else

;; Mouse has left button_0

EndIf

Next

Next

EndIf

EndFunc

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