How to add multiple pages within an app?

It sounds simple, but really just the title. Once I’ve created the links on a page, where do I point them to such that anvil knows that it’s another page? https://bvzddzrmeoum5oc6.anvilapp.net/

1 Like

Hi Sergio,

The simplest thing to do is to create a new form for each page you want to display. Then, when you want to move to a different form, call open_form(), which replaces the whole page with a new form.

You can pass it the name of the form to open (eg open_form("Form2")), or you can import that form’s module and class, create an instance and then call open_form() on that, eg:

from Form2 import Form2

f = Form2()
open_form(f)

Does that help?


PS: The app you’ve linked to is a private app. If you want us to be able to see it, you either need to make it public (find this setting in the Share dialog), or copy and paste the long private link (also in the Share dialog).

Hi Sergio,

As a more advanced technique, you can also have one outer form that contains all your titles/menus/etc, and open other forms as panels within it. Here’s a video I posted in another thread:

Perhaps that helps :slight_smile:

3 Likes

You preempted my next question. Thank you. That is exactly what I needed.

Hi, I’m wondering, is importing a form only possible on paid subscriptions?
When I try to import and run the app I get this message: “The MyForm module is not currently installed in the server environment of this app.” and an offer for a 7-day free trial.

For reference, I was following this guide to create a popup: Anvil | Update existing articles

Forms generally run client-side (i.e., in the end-user’s browser), not server-side. There’s no one sitting at the server to see them.

I find it strange then that it’s showing that message. I might be doing something wrong, but I can’t figure out what.
Imports should be like this: from ..MyForm import MyForm

It’s probably not what you’re importing, or how you’re importing it. More likely, it’s where you’re importing it:

You might check to see whether your failing import is in a Client Code file
image
or a Server Code file
image
If it’s in the latter, I would expect it to fail.

Coming from a desktop-centric development environment, the distinction between Server and Client code was a big jump for me, the first time I had to deal with it.

It’s definitely in the client code. I have a repeating panel with a button that is supposed to open an alert that loads a form. I have nothing set up with server code/modules.