@jgoalby solved by sub_viewing c.view instead of c.container_view
import ui
import dialogs
from objc_util import *
def myform_dialog(title='', fields=None,sections=None, done_button_title='ok'):
global c
if not sections:
sections = [('',fields)]
headers_footers = []
i_s = 0
for section in sections:
if section[0] != '':
headers_footers.append((section[0],section[2]))
# comment next line if you want to see where the standard text falls
sections[i_s] = (' ',section[1],' ')
i_s = i_s + 1
c = dialogs._FormDialogController(title, sections, done_button_title=done_button_title)
w,h = 500,600
c.container_view.frame = (0, 0, w, h)
tblo = ObjCInstance(c.view)
#print(dir(tblo))
h_header = 100
h_footer = 40
tblo.sectionHeaderHeight = h_header
tblo.sectionFooterHeight = h_footer
dx = 15
y = 0
i_s = 0
for headert,footert in headers_footers:
if headert != '':
header = ui.Label()
header.text = headert
header.frame = (dx,y,w-dx,h_header)
header.font = ('<System-Bold>',80)
header.text_color = 'blue'
# uncomment next line of you want to see room of label
#header.border_width = 1 # only for tests
c.view.add_subview(header)
y = y + h_header + 1
for cell in c.cells[i_s]:
y = y + cell.height
if footert != '':
footer = ui.Label()
footer.text = footert
footer.frame = (dx,y,w-dx,h_footer)
footer.font = ('<System-Bold>',32)
footer.text_color = 'red'
# uncomment next line of you want to see room of label
#footer.border_width = 1 # only for tests
c.view.add_subview(footer)
y = y + h_footer
i_s = i_s + 1
c.container_view.present('sheet')
c.container_view.wait_modal()
# Get rid of the view to avoid a retain cycle:
c.container_view = None
if c.was_canceled:
return None
return c.values
sections = []
fields = []
field = {'title':'field1','type':'text','value':''}
fields.append(field)
field = {'title':'field2','type':'text','value':''}
fields.append(field)
section = ('header1',fields,'footer1')
sections.append(section)
fields = []
field = {'title':'field1','type':'text','value':''}
fields.append(field)
field = {'title':'field2','type':'text','value':''}
fields.append(field)
section = ('header2',fields,'footer2')
sections.append(section)
fields = []
field = {'title':'field1','type':'text','value':''}
fields.append(field)
field = {'title':'field2','type':'text','value':''}
fields.append(field)
section = ('header3',fields,'footer3')
sections.append(section)
f = myform_dialog(title='dialog title', done_button_title='ok', sections=sections)
#f = myform_dialog(title='dialog title', done_button_title='ok', fields=fields)