Notification with custom content possible?

What I’m trying to do:

I show a Notification while a background task is created and executed. When the task has finished I hide the notification. So far so good.
Now I want to show an animated gif and update the text to better report on the task’s progress.

What I’ve tried and what’s not working:

  • I tried changing the notification.text or .message properties. Does not work.
  • I tried re-creating the notification on each update. Gives the funny effect of the new notification ‘running of the page’
  • I tried (as for alerts) Notification(content=MyProgressPanel(), title=‘Please wait’, timeout=None)
  • I tried using an alert. But an alert blocks the rest of the code, IOW the background task is not started.

So, in retrospect, I just want to have a floating form with my now content, which does not block the UI. I want to manipulate the custom content in response to background activity.

Ideas?

There is a blog on building a search engine in the docs which might help you. From memory it launched a background task and then updates the UI form based on the state of the background task. Have you had a look at this?

https://anvil.works/blog/how-to-build-a-search-engine

Thanks Rick, but I have the background stuff working. My problem is with the UI.
In the blog post they update the page. I want a hovering window.

1 Like

You could create a role floating

then in theme.css

.anvil-role-floating {
    position: fixed;
    bottom: 100px;
    right: 100px;
}

Add this to your main form and you have yourself a floating window.

Here’s a proof of concept
https://anvil.works/build#clone:Z77URLCLYX7MKU24=LT6UL64TSXA3VPMXQRFIPNPQ

2 Likes

@stucork Ah so simple?! Thanks.
And I learned that you can have more than 1 role!!
And I learned that you can set the RichText.data property, but that you have to change the whole dict value.

So:

  self.form3_1.rich_text_1.data = {'time': self.time, 'other': 'AA'}  # OK
  self.form3_1.rich_text_1.data = {'time': self.time}  # OK-ish but will clear 'other'
  self.form3_1.rich_text_1.data['time']='xx'   # does nothing
1 Like

I believe that it’s the assignment statement

that triggers the visual update.

I’m “used” to .item being special, but did not expect .data to be.

It serves the same purpose, so I expect the same behavior.

Why did Anvil use .data then, instead of the usual .item? Do you know?

Not a clue. :man_shrugging:

1 Like