textual icon indicating copy to clipboard operation
textual copied to clipboard

Both parent's and child's [on_mount] method are called in runtime

Open jasonlkh-wa opened this issue 2 years ago • 3 comments

Defining an [on_mount] method in the child class would cause [on_mount] method being called from both the parent and the child class.

e.g.

# During runtime, both messages will be printed
class Parent(App):
    def on_mount(self):
        print("triggered")
        
class Child(Parent):
    def on_mount(self):
        print("triggered in child")

jasonlkh-wa avatar Feb 03 '24 16:02 jasonlkh-wa

I think this is intentional, see https://textual.textualize.io/guide/events/#default-behaviors

TomJGooding avatar Feb 03 '24 16:02 TomJGooding

Ah sorry my bad, thanks a lot!

jasonlkh-wa avatar Feb 03 '24 17:02 jasonlkh-wa

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

github-actions[bot] avatar Feb 03 '24 17:02 github-actions[bot]