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

Failed to execute script app #26

Closed dbsantos1981 closed 4 years ago

dbsantos1981 commented 4 years ago

Greetings,

If I generate the app's executable on windows with pyinstaller using the --noconsole option, the message 'Failed to execute script App' appears when running the generated exe application, and the app does not work.

If I generate the executable without this option, the system works normally, however, the console window appears.

I would like, as in previous versions, that compilation without the console would work. Have you seen this error in any situation? Do you have any tips to give me?

manatlan commented 4 years ago

hi

Have you seen this error in any situation?

Clearly ... but it's not tied to guy But in many cases ... it's just because you use a "lib" (or some code) which need to have a stdout output. (something which do some print statement) ... So, when freezed : it can only works in "a console". So you cant produce a freezed exe with "noconsole" mode ...

JeswinSunsi commented 4 years ago

Ah yes, there's a workaround to this which I've used.

def hideConsole():
  whnd = ctypes.windll.kernel32.GetConsoleWindow()
  if whnd != 0:
     ctypes.windll.user32.ShowWindow(whnd, 0)

You can then call hideConsole() and the console gets hidden. Also, do import ctypes.

dbsantos1981 commented 4 years ago

It works! Thank you very much.

I tested this solution in two possibilities and both worked:

First:

I put the function call at the beginning of the code as below:

if __name__ == "__main__":
     # hide the console
     SapTec.hide_console(SapTec)

Second:

I put the function call in the HTML file after loading all its content.

<script>
    self.hide_console();
</script>

Thanks again to @manatlan and @

Ah yes, there's a workaround to this which I've used.

def hideConsole():
  whnd = ctypes.windll.kernel32.GetConsoleWindow()
  if whnd != 0:
     ctypes.windll.user32.ShowWindow(whnd, 0)

You can then call hideConsole() and the console gets hidden. Also, do import ctypes.

Thank you! It Works!