Forum Archive

[Share Code] `ui.View`: without x-Button

lukaskollmer

I struggled with that recently and just wanted to share my solution:

If you don't want the default x-Button at the left side of the title bar, just create a ui.NavigationView and present that instead

import ui

view = ui.View()
navigationView = ui.NavigationView(view)

# Add a close button
view.left_button_items = [ui.ButtonItem(title="Close", action=lambda x: navigationView.close())] 

# Won't show the x-button
navigationView.present("sheet", hide_title_bar=True)
henryaukc

Thanks a lot!

I have used this to make my script acting a real app by using the “Add to Home Screen” to put my script on the home screen. Without x-button, it looks more like the normal app. However, I have encountered two problems:

  1. When my home screen shortcut was run again, the pythonista ran again my app but not return to the last screen
  2. When I run another Pythonista script on the home screen, it will run on my original script

Can I detect if my script is now running already and don’t run multiple times to fix problem 1?

Can I detect that there is another script running and stop Pythonista to load a new one? Or close the old one before loading the new one?