* IUP again
Re: IUP again
am I to understand that the frame goes inside the hbox or vbox and not the other way around?
FH V.6.2.7 Win 10 64 bit
- Jane
- Site Admin
- Posts: 8514
- Joined: 01 Nov 2002 15:00
- Family Historian: V7
- Location: Somerset, England
- Contact:
Re: IUP again
Both if you want, in general if you have more than one element they need to be wrapped with a v or h box as shown in most examples.
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."
Re: IUP again
I believe the code I posted did that. I have some other error, and it must be trivial.
this is the current code in standalone fashion, I have removed frames, since they did nothing.
sfl is a vbox of a scrollbar of a gbox
fn_keys is an hbox of two buttons
this is the current code in standalone fashion, I have removed frames, since they did nothing.
sfl is a vbox of a scrollbar of a gbox
fn_keys is an hbox of two buttons
Code: Select all
fhSetStringEncoding('UTF-8')
iup.SetGlobal('UTF8MODE','YES')
WS_Abort = 'Abort'
WS_CANCEL = false
WS_Cancel = 'Cancel'
WS_ENTER = true
WS_Ignore = 'Ignore'
WS_OK = 'OK'
WS_Retry = 'Retry'
WS_ERR = 2
WS_YES = 'Yes'
WS_NO = 'No'
local rtx = {}
function MakeText(options)
-- there are no mandatory options
local txt = iup.text
{
visiblelines = options.visiblelines or '1',
multiline = options.multiline or 'NO',
readonly = options.readonly or 'NO'
}
if options.name then
iup.SetHandle(options.name, txt)
end
if options.value then
txt.value = options.value
else
txt.value = ''
end
if options.filter then
txt.filter = options.filter
end
if options.mask ~= nil then
txt.mask = options.mask
end
return txt
end
function MakeLabel(options)
local lbl = iup.label
{
title = options.name or '',
visiblelines = options.visiblelines or '1',
multiline = options.multiline or 'NO',
readonly = options.readonly or 'NO'
}
return lbl
end
function crtgbox()
-- sysval:
-- lbl KEY
-- usr (changeable) true or false
-- typ (num) or (char)
-- val value
-- returns a container
-- iup.gridbox{child, ...: ihandle} -> (ih: ihandle) [in Lua]
-- make a gridbox, 4 columns wide
local gbox = iup.gridbox{}
gbox.alignmentlin = 'ACENTER'
gbox.expandchildren = 'HORIZONTAL'
gbox.gaplin = '10'
gbox.gapcol = '10'
gbox.normalizesize = 'YES'
gbox.numdiv = '4'
gbox.orientation = 'HORIZONTAL'
for k, v in pairs(siz) do
local sysval = MakeLabel
{
name = k,
readonly = 'YES'
}
gbox:append(sysval)
local m = MakeText
{
name = 'm',
value = v[1],
filter = 'NUMBER',
mask = IUP_MASK_INT
}
gbox:append(m)
local x = MakeText
{
name = 'x',
value = v[2],
filter = 'NUMBER',
mask = IUP_MASK_INT
}
gbox:append(x)
local b = MakeText
{
name = 'b',
value = v[3],
filter = 'NUMBER',
mask = IUP_MASK_INT
}
gbox:append(b)
end
return gbox
end
local function GetSingleValue(list)
local function choose(cond, value)
return cond and value
end
return choose(list.value ~=0, list[tostring(list.value)])
end -- fn GetSingleValue
local function matDLG(sysval)
-- Creates frame with dropdown list and sets its title
local sfl = iup.vbox{iup.scrollbox{sysval}}
local btn_ok = iup.button
{
name = 'ENTER',
title = 'ENTER',
action = function(self)
rtx.rc = WS_ENTER
rtx.TAG = TAG
return iup.CLOSE
end
}
local btn_cancel = iup.button
{
name = 'CANCEL',
title = 'CANCEL',
action = function(self)
rtx.rc = WS_CANCEL
rtx.TAG = ''
return iup.CLOSE
end
}
local fn_keys = iup.hbox{btn_ok, btn_cancel}
-- Creates a dialog with the frame and sets its title
local dlg = iup.dialog
{
sfl,
fn_keys,
title = 'System Values',
size = '164xHALF',
margin = '5x5'
}
return dlg
end -- fn matDLG
siz =
{
adr={0,4,1},
age={0,6,0},
ahn={0,6,0},
ara={0,4,0},
arm={0,4,0},
bin={0,4,4},
cem={0,4,4},
dir={0,4,2},
dob={0,4,0},
dod={0,4,0},
dst={0,4,4},
dup={0,4,0},
era={0,1,0},
err={0,4,0},
erx={0,1,0},
fct={0,8,0},
fid={0,6,0},
gen={0,6,0},
gli={0,4,0},
gps={0,1,4},
iid={0,6,0},
loc={0,4,4},
mdt={0,4,0},
mml={0,4,0},
nam={0,4,1},
nct={0,8,0},
ord={0,4,0},
oth={0,4,0},
plc={0,4,0},
ptg={0,4,0},
ptr={0,1,0},
rgn={0,4,4},
rlt={0,4,4},
rmn={0,6,0},
rnk={0,4,0},
rte={0,4,2},
sdf={0,4,0},
sep={0,4,0},
set={0,6,0},
sex={0,1,0},
src={0,4,0},
svc={0,4,2},
tim={0,3,0},
war={0,4,0},
web={0,4,4},
yr ={0,1,0}
}
return
-- EXEC()
if not sysval then
-- global local
sysval = crtgbox()
-- dlg must be global
dlg = matDLG(sysval)
end
dlg:show(iup.CENTER, iup.CENTER)
iup.MainLoop()
dlg:destroy()
return
FH V.6.2.7 Win 10 64 bit
- Jane
- Site Admin
- Posts: 8514
- Joined: 01 Nov 2002 15:00
- Family Historian: V7
- Location: Somerset, England
- Contact:
Re: IUP again
There is no point in posting examples if they do not run.
and you have still not wrapped your elements in a v or h box at line 154
An error has occurred - plugin failed to complete
[string "C:\Users\JANE\AppData\Local\Temp\~fh6F1.tmp"]:222: unexpected symbol near 'if'
No changes have been made to data records.
and you have still not wrapped your elements in a v or h box at line 154
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."
Re: IUP again
229: sysval = crtgbox()
128: local sfl = iup.vbox{iup.scrollbox{sysval}}
151: local fn_keys = iup.hbox{btn_ok, btn_cancel}
each respectively, sfl and fn_keys, is wrapped in another vbox and hbox inside the dialog. no change in operation.
if I have sfl only in the dialog it shows and runs
if I have fn_keys only in the dialog it shows and runs
if I have both in the dialog it shows sfl only.
this leads me to believe that I have some issue with the sfl
128: local sfl = iup.vbox{iup.scrollbox{sysval}}
151: local fn_keys = iup.hbox{btn_ok, btn_cancel}
each respectively, sfl and fn_keys, is wrapped in another vbox and hbox inside the dialog. no change in operation.
if I have sfl only in the dialog it shows and runs
if I have fn_keys only in the dialog it shows and runs
if I have both in the dialog it shows sfl only.
this leads me to believe that I have some issue with the sfl
Code: Select all
fhSetStringEncoding('UTF-8')
iup.SetGlobal('UTF8MODE','YES')
WS_Abort = 'Abort'
WS_CANCEL = false
WS_Cancel = 'Cancel'
WS_ENTER = true
WS_Ignore = 'Ignore'
WS_OK = 'OK'
WS_Retry = 'Retry'
WS_ERR = 2
WS_YES = 'Yes'
WS_NO = 'No'
local rtx = {}
function MakeText(options)
-- there are no mandatory options
local txt = iup.text
{
visiblelines = options.visiblelines or '1',
multiline = options.multiline or 'NO',
readonly = options.readonly or 'NO'
}
if options.name then
iup.SetHandle(options.name, txt)
end
if options.value then
txt.value = options.value
else
txt.value = ''
end
if options.filter then
txt.filter = options.filter
end
if options.mask ~= nil then
txt.mask = options.mask
end
return txt
end
function MakeLabel(options)
local lbl = iup.label
{
title = options.name or '',
visiblelines = options.visiblelines or '1',
multiline = options.multiline or 'NO',
readonly = options.readonly or 'NO'
}
return lbl
end
function crtgbox()
-- sysval:
-- lbl KEY
-- usr (changeable) true or false
-- typ (num) or (char)
-- val value
-- returns a container
-- iup.gridbox{child, ...: ihandle} -> (ih: ihandle) [in Lua]
-- make a gridbox, 4 columns wide
local gbox = iup.gridbox{}
gbox.alignmentlin = 'ACENTER'
gbox.expandchildren = 'HORIZONTAL'
gbox.gaplin = '10'
gbox.gapcol = '10'
gbox.normalizesize = 'YES'
gbox.numdiv = '4'
gbox.orientation = 'HORIZONTAL'
for k, v in pairs(siz) do
local sysval = MakeLabel
{
name = k,
readonly = 'YES'
}
gbox:append(sysval)
local m = MakeText
{
name = 'm',
value = v[1],
filter = 'NUMBER',
mask = IUP_MASK_INT
}
gbox:append(m)
local x = MakeText
{
name = 'x',
value = v[2],
filter = 'NUMBER',
mask = IUP_MASK_INT
}
gbox:append(x)
local b = MakeText
{
name = 'b',
value = v[3],
filter = 'NUMBER',
mask = IUP_MASK_INT
}
gbox:append(b)
end
return gbox
end
local function GetSingleValue(list)
local function choose(cond, value)
return cond and value
end
return choose(list.value ~=0, list[tostring(list.value)])
end -- fn GetSingleValue
local function matDLG(sysval)
-- Creates frame with dropdown list and sets its title
local sfl = iup.vbox{iup.scrollbox{sysval}}
local btn_ok = iup.button
{
name = 'ENTER',
title = 'ENTER',
action = function(self)
rtx.rc = WS_ENTER
rtx.TAG = TAG
return iup.CLOSE
end
}
local btn_cancel = iup.button
{
name = 'CANCEL',
title = 'CANCEL',
action = function(self)
rtx.rc = WS_CANCEL
rtx.TAG = ''
return iup.CLOSE
end
}
local fn_keys = iup.hbox{btn_ok, btn_cancel}
-- Creates a dialog with the frame and sets its title
local dlg = iup.dialog
{
iup.vbox{sfl},
iup.hbox{fn_keys},
title = 'System Values',
size = '164xHALF',
margin = '5x5'
}
return dlg
end -- fn matDLG
siz =
{
adr={0,4,1},
age={0,6,0},
ahn={0,6,0},
ara={0,4,0},
arm={0,4,0},
bin={0,4,4},
cem={0,4,4},
dir={0,4,2},
dob={0,4,0},
dod={0,4,0},
dst={0,4,4},
dup={0,4,0},
era={0,1,0},
err={0,4,0},
erx={0,1,0},
fct={0,8,0},
fid={0,6,0},
gen={0,6,0},
gli={0,4,0},
gps={0,1,4},
iid={0,6,0},
loc={0,4,4},
mdt={0,4,0},
mml={0,4,0},
nam={0,4,1},
nct={0,8,0},
ord={0,4,0},
oth={0,4,0},
plc={0,4,0},
ptg={0,4,0},
ptr={0,1,0},
rgn={0,4,4},
rlt={0,4,4},
rmn={0,6,0},
rnk={0,4,0},
rte={0,4,2},
sdf={0,4,0},
sep={0,4,0},
set={0,6,0},
sex={0,1,0},
src={0,4,0},
svc={0,4,2},
tim={0,3,0},
war={0,4,0},
web={0,4,4},
yr ={0,1,0}
}
-- EXEC()
if not sysval then
-- global local
sysval = crtgbox()
-- dlg must be global
dlg = matDLG(sysval)
end
dlg:show(iup.CENTER, iup.CENTER)
iup.MainLoop()
dlg:destroy()
return
FH V.6.2.7 Win 10 64 bit
- tatewise
- Megastar
- Posts: 28410
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: IUP again
Try iup.vbox{ sfl; iup.hbox{fn_keys} },
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Re: IUP again
that is no change.
fn_keys in the dialog alone runs fine.
sfl in the dialog alone or with fn_keys runs fine, but no fn_keys shown.
if I put fn_keys before sfl, I am presented with an altogether blank dialog just title and box to size.
fn_keys in the dialog alone runs fine.
sfl in the dialog alone or with fn_keys runs fine, but no fn_keys shown.
if I put fn_keys before sfl, I am presented with an altogether blank dialog just title and box to size.
FH V.6.2.7 Win 10 64 bit
- tatewise
- Megastar
- Posts: 28410
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: IUP again
This worked perfectly for me! What did you do?
Code: Select all
local dlg = iup.dialog
{
iup.vbox{ sfl; iup.hbox{fn_keys} },
title = 'System Values',
size = '164xHALF',
margin = '5x5'
}
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Re: IUP again
I work in ZeroBrane.
forgetting to save before running....I feel so cheap.
I see the difference from splitting them, wonder why the double v and h box.
forgetting to save before running....I feel so cheap.
I see the difference from splitting them, wonder why the double v and h box.
FH V.6.2.7 Win 10 64 bit
- tatewise
- Megastar
- Posts: 28410
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: IUP again
"wonder why the double v and h box."
The documentation clearly says that only one child interface element is allowed.
All other interface elements must be encapsulated within that one child element.
Remember an interface element is different from the attributes such as title and size.
So in your original code, only the iup.vbox{sfl} element was handled, and before you ask, no, iup doesn't raise errors for that.
The documentation clearly says that only one child interface element is allowed.
All other interface elements must be encapsulated within that one child element.
Remember an interface element is different from the attributes such as title and size.
So in your original code, only the iup.vbox{sfl} element was handled, and before you ask, no, iup doesn't raise errors for that.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry