Skip to content

Commit

Permalink
Start GUI file dialogues in Downloads folder
Browse files Browse the repository at this point in the history
For #3
  • Loading branch information
peterstory committed Apr 10, 2024
1 parent d8930e2 commit 5a08a2b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/pydiode/gui/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import configparser
import os
import pathlib
from pathlib import Path
import sys
from tkinter import BooleanVar, IntVar, Listbox, StringVar, Tk, ttk

Expand All @@ -16,7 +15,7 @@
import pydiode.tar

# Save the configuration file in the user's home folder
CONFIG = pathlib.Path().home() / ".pydiode.ini"
CONFIG = Path("~/.pydiode.ini").expanduser()


def gui_main():
Expand Down Expand Up @@ -118,7 +117,9 @@ def gui_main():
ttk.Entry(rx_inner, textvariable=target).grid(column=0, row=1, sticky="EW")
rx_inner.columnconfigure(0, weight=1)
rx_inner.rowconfigure(1, weight=1)
target.set(config["pydiode"].get("target", os.getcwd()))
target.set(
config["pydiode"].get("target", Path("~/Downloads").expanduser())
)
ttk.Button(
rx_inner,
text="Browse...",
Expand Down
5 changes: 3 additions & 2 deletions src/pydiode/gui/send.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from pathlib import Path
import subprocess
import sys
from tkinter.filedialog import askopenfilenames
Expand Down Expand Up @@ -26,8 +27,8 @@ def add_source_files(sources_var, sources_list):
:param sources_list: A list of the source files currently in the Listbox
"""
# If files have been added, the dialogue will remember the directory.
# If no files have been added, start at the current working directory.
initialdir = None if sources_list else os.getcwd()
# If no files have been added, start in the Downloads folder.
initialdir = None if sources_list else Path("~/Downloads").expanduser()
selected_sources = askopenfilenames(initialdir=initialdir)
new_sources = set(selected_sources) - set(sources_list)
if new_sources:
Expand Down

0 comments on commit 5a08a2b

Please sign in to comment.