Hi,
I am learning how to use Pythonista and am looking for advice on the best method to implement a simple idea for a script I have. I have a GUI created with the designer to set up up a crossword grid. A cell is tapped to turn it either black or white (these are buttons). However, I want another option available when tapped to produce another GUI in the form of a Tableview with a list of numbers to select (up to 26).
My problem is that I do not understand how to load the tableview I created with the designer, into view. Is it a new view requiring a frame or should it be loaded as a subview into my existing frame? All the examples I have found seem to be adding buttons to existing frames. Whereas I think I am trying to add a view which seems different. It wont load using subview with error ‘expecting’ view.
Basically I’m trying to add another GUI called NumberSelector.pyui into the process when a cell is tapped.
Is this the right way to implement my idea or should it be a different approach. If not, what am I doing wrong please?
Thanks.
## AlphaPuzzle Solver by G A ##
import ui
b = ui.Button()
def button_tapped(sender):
'@type sender: ui.Button'
# Get the button's title for the following logic:
t= sender.name
b = sender
#print(t)
#b.background_color = 'black'
if (str(b.background_color)) != '(1.0, 1.0, 1.0, 1.0)':
b.background_color = 'white'
else:
b.background_color = 'black'
#print(b.background_color)
v = ui.load_view('AlphaGrid')
if min(ui.get_screen_size()) >= 768:
# iPad
v.frame = (0, 0, 360, 400)
v.present('sheet')
else:
# iPhone
v.present(orientations=['portrait'])