Closed etherealxx closed 11 months ago
I have never seen that problem, which means I have no way of replicating it on my system. Can you fix the problem yourself, and submit some code that contains the fix?
This is the shortest recreation of my code. i was able to replicate it. My device is windows (10 AND 11), python 3.10.6.
import tkinter as tk
from tkinter import filedialog
import os
from showinfm import show_in_file_manager
global_imagepath = ""
def open_file_dialog():
global global_imagepath
path = filedialog.askopenfilename(filetypes=[("Image Files", "*.png")])
if path:
if os.path.isfile(path):
global_imagepath = path
def open_explorer():
if not global_imagepath:
open_file_dialog()
print("current global_imagepath: " + global_imagepath)
openthisimagebutton.config(text="View on Explorer")
else:
if os.path.exists(global_imagepath):
show_in_file_manager(global_imagepath)
window = tk.Tk()
openthisimagebutton = tk.Button(window, text="Select a file", command=open_explorer)
openthisimagebutton.pack(padx=20, pady=20)
window.mainloop()
found something.
from the code i sent before, if i change show_in_file_manager(global_imagepath)
to show_in_file_manager(global_imagepath.replace("/", os.sep))
or show_in_file_manager(os.path.normpath(global_imagepath))
, the module works fine.
i think the problem lies in filedialog.askopenfilename()
(from tkinter) that saves the path with slash instead of backlash in windows.
You can close this issue, or maybe implementing a feature on your module to fix this scenario, probably useful in the future.👀
Thanks for the update. I will close the issue.
Btw that file in "global_imagepath" exist so idk what's wrong in this. It works before.
Just ask anything to me if you need more context.