-
Notifications
You must be signed in to change notification settings - Fork 0
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
GUI #74
Conversation
I'm getting the following error, whether I run
|
That's the error I got too. |
Just pushed some changes to fix the issue, inspired by this thread. But now it looks like the menu needs troubleshooting. |
Yeah, now I'm getting that error when I open the file picker. |
I found this thread that may work, but I'm nervous to do any |
I was able to get the menu working by downgrading streamlit to version 1.32. Looks like this is a known issue with streamlit_option_menu: see victoryhb/streamlit-option-menu#70. Now I've reproduced the file picker bug. Looking into it... |
@standage whenever you get a chance, please test the file/folder pickers to see if they are now working for you. |
Just tested on some example data. Both the file picker and the entire workflow functioned as expected! |
I think this may be a good spot for merging. I plan to do some more work on the GUI, but I think it's a little bit more involved and wanted to get the basic version pushed to the master branch. The only issue I'm currently running into is the failing CI (which seems to be another tk issue??). Not too sure how to circumvent those errors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, works well on my end. As we discussed, we'll want to clean up the code as well as update the visual aesthetics of the app. But happy to merge for now.
def file_picker_dialog(): | ||
script_path = importlib.resources.files("lusSTR") / "scripts" / "file_selector.py" | ||
result = subprocess.run(["python", script_path], capture_output=True, text=True) | ||
if result.returncode == 0: | ||
file_data = json.loads(result.stdout) | ||
file_path = file_data.get("file_path") | ||
if file_path: | ||
return file_path | ||
else: | ||
st.error("No folder selected") | ||
else: | ||
st.error("Error selecting folder") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clever trick!
lusSTR/cli/gui.py
Outdated
import tkinter as tk | ||
from tkinter import filedialog | ||
|
||
|
||
|
||
# Create a global Tkinter root window | ||
try: | ||
root = tk.Tk() | ||
root.withdraw() # Hide the root window | ||
except: | ||
print("No GUI available!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can drop this code now, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what is allowing the GitHub CI to pass. Without it, it fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's really surprising to me. The file_selector and folder_selector scripts that actually use tk don't touch this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seemed to be hung up on the from lusSTR.cli import gui
line from the cli/__init.py__
script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that having root = tk.Tk()
in there without a try/except block will cause issues on CI. What I'm suggesting is that we shouldn't need tk anywhere in gui.py now, since that's all been moved to accessory scripts where tk can be run in the main thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooooooooh. Yes you are right!
I think this is ready now. |
Creating a GUI using streamlit. Code written by Shaheer Syed.