forked from Wobbl/Bread_Editor
Fixed a wrong default type and a crash.
The create_file() function was crashing when the user was not selecting any file because and empty path cant be opened.
This commit is contained in:
parent
c838b99946
commit
f80fbc8348
1 changed files with 4 additions and 1 deletions
5
file.py
5
file.py
|
@ -28,13 +28,16 @@ class FileActions:
|
||||||
|
|
||||||
self.app.open_files[file_path] = File(self.app, file_path, file_path.split("/")[-1])
|
self.app.open_files[file_path] = File(self.app, file_path, file_path.split("/")[-1])
|
||||||
|
|
||||||
def create_file(self, content: str=""):
|
def create_file(self, content: bin=b""):
|
||||||
file_path, extension = QFileDialog.getSaveFileName(
|
file_path, extension = QFileDialog.getSaveFileName(
|
||||||
caption="New File",
|
caption="New File",
|
||||||
directory=self.app.utils.home_path,
|
directory=self.app.utils.home_path,
|
||||||
filter="Binary (*.bin);;Any (*)",
|
filter="Binary (*.bin);;Any (*)",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if file_path == "":
|
||||||
|
return
|
||||||
|
|
||||||
if "Binary" in extension:
|
if "Binary" in extension:
|
||||||
file_path = file_path.split(".")[0] + ".bin" # make sure it has the right extension
|
file_path = file_path.split(".")[0] + ".bin" # make sure it has the right extension
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue