manatlan / guy

Graphics User Ynterface : a simple module for making GUI applications (with html/js) for py3 ... to target windows, linux, mac & android
Apache License 2.0
202 stars 23 forks source link

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

Open latot opened 3 years ago

latot commented 3 years ago

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.