* Interface buttons
Interface buttons
I've been using the Interface buttons snippet and can adapt it a bit to suit so that buttons show either vertically or horizontally. But how do I get a block of buttons e.g. 3 across and 3 down?
Martin
ID:6474
Martin
ID:6474
- Jane
- Site Admin
- Posts: 8440
- Joined: 01 Nov 2002 15:00
- Family Historian: V7
- Location: Somerset, England
- Contact:
Interface buttons
You'll need to look at the IUP documentation.
http://www.tecgraf.puc-rio.br/iup/
As you'll need to add three v groups each with 3 buttons within an h group.
http://www.tecgraf.puc-rio.br/iup/
As you'll need to add three v groups each with 3 buttons within an h group.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
Interface buttons
Thanks, Jane. I'll explore that. I'm just trying to make quite a lot of buttons more manageable.
Martin
Martin
Interface buttons
I think I've got the principle of embedding boxes, but I'm working from your Interface Button snippet.
I don't understand where intArgNum comes from. So I can't work out how to split the button arguments into groups. i.e. with six button names sent to iupButtons I want to split them into two (or three) groups in separate vertical boxes. Does that make sense?
Martin
I don't understand where intArgNum comes from. So I can't work out how to split the button arguments into groups. i.e. with six button names sent to iupButtons I want to split them into two (or three) groups in separate vertical boxes. Does that make sense?
Martin
- tatewise
- Megastar
- Posts: 27075
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Interface buttons
intArgNum is a counter for the button name arguments, running from 1 consecutively upwards.
An alternative to passing in arguments is to provide the button names explicitly in the function and use two horizontal boxes.
Or you can test the intArgNum value:
An alternative to passing in arguments is to provide the button names explicitly in the function and use two horizontal boxes.
Code: Select all
local intArgNum = 0
local iupBox1 = iup.hbox{homogeneous='YES'}
for intNum, strButton in ipairs({'Btn1','Btn2','Btn3'}) do
intArgNum = intArgNum + 1
local btnName = iup.button{title=strButton,expand='YES',padding='4',action=function() intButton=intArgNum return iup.CLOSE end}
iup.Append(iupBox1,btnName)
end
local iupBox2 = iup.hbox{homogeneous='YES'}
for intNum, strButton in ipairs({'Btn4','Btn5','Btn6'}) do
intArgNum = intArgNum + 1
local btnName = iup.button{title=strButton,expand='YES',padding='4',action=function() intButton=intArgNum return iup.CLOSE end}
iup.Append(iupBox2,btnName)
end
-- Create dialogue and turn off resize, maximize, minimize, and menubox except Close button
local dialogue = iup.dialog{title=strTitle,iup.vbox{lblMessage,lblLineSep,iupBox1,iupBox2},dialogframe='YES',background='250 250 250',gap='8',margin='8x8'}
Code: Select all
local iupBox1 = iup.hbox{homogeneous='YES'}
local iupBox2 = iup.hbox{homogeneous='YES'}
for intArgNum, strButton in ipairs(arg) do
local btnName = iup.button{title=strButton,expand='YES',padding='4',action=function() intButton=intArgNum return iup.CLOSE end}
if intArgNum < 4 then
iup.Append(iupBox1,btnName)
else
iup.Append(iupBox2,btnName)
end
end
-- Create dialogue and turn off resize, maximize, minimize, and menubox except Close button
local dialogue = iup.dialog{title=strTitle,iup.vbox{lblMessage,lblLineSep,iupBox1,iupBox2},dialogframe='YES',background='250 250 250',gap='8',margin='8x8'}
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Interface buttons
Great, Mike, thanks. Your second version does just what I want.
Is there a variable generated for the actual number of buttons, so that I could use ,say, that variable over 2 rather than specifying the number 4? Not crucial but it would be nice.
Is there a variable generated for the actual number of buttons, so that I could use ,say, that variable over 2 rather than specifying the number 4? Not crucial but it would be nice.
- tatewise
- Megastar
- Posts: 27075
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Interface buttons
Yes, because arg is a table listing the ... arguments, then #arg is the number of button names in the table.
Thus #arg / 2 is half the number of button names.
Thus #arg / 2 is half the number of button names.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Interface buttons
Excellent. Got it. I now understand better what that bit is doing. I found the iup info rather confusing.