Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions GSASII/GSASIIseqGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,7 @@ def show_project_dialog():
dialogDir.CenterOnParent()
if dialogDir.ShowModal() == wx.ID_OK:
selected_dir = dialogDir.GetPath()
dialogDir.Destroy()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not realize that with causes .Destroy() to be called. Your change is correct.

else:
dialogDir.Destroy()
print('Cancelling Cinema export')
return
if not (os.path.exists(selected_dir) and
Expand Down Expand Up @@ -394,6 +392,7 @@ def show_project_dialog():
# Project name field
name_label = wx.StaticText(panel, label="Project Name:")
name_ctrl = wx.TextCtrl(panel, value="GSAS-II Cinema Export")
name_ctrl.SetMinSize((200, -1))
grid_sizer.Add(name_label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT)
grid_sizer.Add(name_ctrl, 1, wx.EXPAND|wx.ALIGN_LEFT)

Expand Down Expand Up @@ -437,31 +436,32 @@ def show_project_dialog():
print(f"Directory creation failed: {e}")
wx.MessageBox(f"Failed to create directory: {e}", "Error", wx.OK|wx.ICON_ERROR)
return # Terminate execution if directory creation failed

try:
print('Open and reuse json')
with open(json_path, 'r', encoding='utf-8') as fil:
data = json.load(fil)
new_entry = {
"name": project_name,
"directory": db_directory,
"smoothLines": True,
"lineOpacity": 1.0
}
data.append(new_entry)
# rewrite data to json file
with open(json_path, 'w', encoding='utf-8') as file:
json.dump(data, file, indent=8, ensure_ascii=False)
except FileNotFoundError:
print(f"File {json_path} not found")
except json.JSONDecodeError:
print(f"Error reading JSON file {json_path}")
except Exception as e:
print(f"An error occurred: {e}")
else:
dlg.Destroy()
print('Cancelling Cinema export')
return

try:
with open(json_path, 'r', encoding='utf-8') as fil:
data = json.load(fil)
new_entry = {
"name": project_name,
"directory": db_directory,
"smoothLines": True,
"lineOpacity": 1.0
}
data.append(new_entry)
# rewrite data to json file
with open(json_path, 'w', encoding='utf-8') as file:
json.dump(data, file, indent=8, ensure_ascii=False)
except FileNotFoundError:
print(f"File {json_path} not found")
except json.JSONDecodeError:
print(f"Error reading JSON file {json_path}")
except Exception as e:
print(f"An error occurred: {e}")

file_path = os.path.join(selected_dir, db_directory, DATA_CSV_FILENAME)

with open(file_path, 'w', encoding='utf-8') as fil:
Expand Down