Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't call Guy from a module when is stored in a module #32

Open
latot opened this issue Apr 5, 2021 · 0 comments
Open

Can't call Guy from a module when is stored in a module #32

latot opened this issue Apr 5, 2021 · 0 comments

Comments

@latot
Copy link

latot commented Apr 5, 2021

Hi hi, I have this very weird thing..., actually I'm trying to store guy in other module to execute actions, but sadly didn't works:

#!/usr/bin/env python
from guy import Guy

class mod:
    def __init__(self, gguy):
        self.gguy = gguy
    async def run(self):
        await self.gguy.js.setEl("hahahah", "hihi")
        await self.gguy.js.prompt()

class App(Guy):
  def __init__(self):
    Guy.__init__(self)
    self.mod = mod(self)
  async def mm(self):
    await self.mod.run()
  
if __name__ == "__main__": 
    App().serve(open=False, autoreload=False)
<script src="guy.js"></script>
<body style="display:'none'">
<button onclick="self.mm()">Test</button>
<span id="hahahah"></span>
<script>
async function setEl(id, inner){
document.getElementById(id).innerHTML = inner
}
async function start(){
document.body.style.display = ""
}
window.setEl = setEl
guy.init(start)
</script>
</body>

Maybe there is a special thing to do or how to call guy?

What is weird, If i execute the same of the module in the main module it works, but why we can't execute guy in this way?

Thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant