hoffstadt / DearPyGui

Dear PyGui: A fast and powerful Graphical User Interface Toolkit for Python with minimal dependencies
https://dearpygui.readthedocs.io/en/latest/
MIT License
12.94k stars 676 forks source link

How to report the logfile to Windows when using DearPyGui? #2241

Open joybio opened 8 months ago

joybio commented 8 months ago

I encountered a problem when trying to package a Python script written with DearPyGui. The script includes an executable file (muscle5.1.win64.exe) that I use within the Python code. When I run the script in PyCharm, it works fine. However, when I package it into an executable file, it crashes (flashes back)

Thank you!


My Improvement

Is there a way to report the logfile, so I can find where the issue is occurring?

joybio commented 8 months ago

Here is my script:

def muscle_main(): muscle_input = dpg.get_value("DPrime_input_fasta") muscle_output = dpg.get_value("DPrime_msa_output") os.system("{}/muscle5.1.win64.exe -align {} -output {}".format(os.path.abspath(os.path.join(os.path.dirname(file),"Scripts")), muscle_input, muscle_output))

v-ein commented 8 months ago

Please enclose your script with a code block: image

Pasting it in plain text (without the code block) removes indentation and renders Python code unreadable.

v-ein commented 8 months ago

Also, pathlib makes it much easier (and more readable) to manage paths. F-strings do the same to string formatting.

from pathlib import Path

exe_path = Path(__file__).parent / "Scripts/muscle5.1.win64.exe"
os.system(f"{exe_path.resolve()} -align {muscle_input} -output {muscle_output}")
v-ein commented 8 months ago

Can you post a screenshot of the error message that you get when it crashes? Or a copy of its text.

v-ein commented 8 months ago

If you comment out the os.system line, does your packaged version still crash? If not, then it's clearly related to muscle5.1.win64.exe and has nothing to do with DearPyGui. In that case, I'd recommend asking on StackOverflow because it's not a DearPyGui issue. Let's try to comment out that line and see what happens.

joybio commented 8 months ago

Oh! Thanks for your reply. Sorry about the delayed response. Here is an overview of my DearpyGUI application. When I click the run button, nothing happens and there is no functionality executed. It seems that the main window cant find the exe file in next fig: 1703246369819 Here is the exe file that I used for my DearpyGUI application: 1703246434107 Here is the main window that I designed in DearpyGUI: 1703246533841 Here is the PyInstaller command to build the main window into a single file: 1703246568472

The problem is that when I run the dearpyGUI in PyCharm, it works well. However, when I build the main function into an executable file, it doesn't run successfully.

joybio commented 8 months ago

Additionally, sometimes Python scripts can't run successfully and throw a bug report, but the main window won't show any response. If there is a log file in this Windows that I could follow up on, maybe I can find what caused the problem. That's why I asked this question.

joybio commented 8 months ago

Well, my problem has been resolved, but I'm still wondering if the dearpygui window can provide a log or bug report for developers. Maybe there is a similar function that I don't know about. If you have any ideas, I would be greatly thankful for your kindness. In the end, I really like dearpygui. Thanks for your effort. 1703249648949

v-ein commented 8 months ago

Well, os.system is not a DearPyGui function and looks like it's what was failing in your case. So DearPyGui can't really provide any diagnostics (log or whatever else) on a function that is not even its own.

You could try to run your EXE from within cmd.exe and see if there's any output there. Or, if you suspect that os.system fails (or any other function, for that matter), you can always wrap it with a try-except block and catch the exception, then do something like dpg.add_text(str(e)). Read up on Python exceptions, that's an integral part of Python so you'd better learn it.

joybio commented 8 months ago

@Pcothren, I appreciate your assistance. Can DearPyGUI provide a real-time interactive interface?

v-ein commented 8 months ago

Pcothren is probably too busy to answer, but anyway... it would help if you explained in a bit more detail what you mean by saying "provide a real-time interactive interface".