-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from carlosfelgarcia:Fixing-bugs-and-added-tkinter
Add GUI for file selection and update .gitignore
- Loading branch information
Showing
7 changed files
with
93 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,56 @@ | ||
#!.venv/bin/python3 | ||
import pathlib | ||
from typing import Union | ||
import sys | ||
|
||
import tkinter as tk | ||
from tkinter import filedialog | ||
from tkinter import messagebox | ||
import typer | ||
|
||
from converter import Converter | ||
|
||
|
||
def main( | ||
files_path=typer.Option( | ||
pathlib.Path.home() / "Downloads", | ||
None, | ||
help="Path to the files to convert, usually the Downloads folder.", | ||
), | ||
): | ||
if isinstance(files_path, str): | ||
files_path = pathlib.Path(files_path) | ||
|
||
if files_path is None: | ||
files_path = pathlib.Path.home() / "Downloads" | ||
convert_transactions(files_path) | ||
|
||
|
||
def convert_transactions(files_path: Union[pathlib.Path, None]) -> None: | ||
converter = Converter(files_path) | ||
def mainUI(): | ||
root = tk.Tk() | ||
root.withdraw() | ||
files_path = filedialog.askdirectory( | ||
title="Select the folder with the files to convert", initialdir=str(pathlib.Path.home() / "Downloads") | ||
) | ||
|
||
progress_window = tk.Tk() | ||
progress_window.title("Converting files") | ||
progress_window.geometry("300x200") | ||
if not files_path: | ||
messagebox.showerror("Error", "No folder selected.") | ||
sys.exit(1) | ||
|
||
info_label = tk.Label(progress_window, text="Converting files...") | ||
info_label.pack() | ||
convert_transactions(pathlib.Path(files_path), info_label=info_label) | ||
messagebox.showinfo("Success", "Files converted successfully!") | ||
progress_window.destroy() | ||
|
||
|
||
def convert_transactions(files_path: pathlib.Path | None, info_label: tk.Label | None = None) -> None: | ||
converter = Converter(files_path, info_label) | ||
converter.create_transactions_files_excel() | ||
converter.create_transaction_files_qfx() | ||
|
||
|
||
if __name__ == "__main__": | ||
typer.run(main) | ||
if hasattr(sys, "frozen") and getattr(sys, "frozen") == "macosx_app": | ||
mainUI() | ||
else: | ||
typer.run(main) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# MIT License (c) 2024. Carlos Garcia, www.carlosgarciadev.com | ||
|
||
from setuptools import setup | ||
|
||
APP = ["main.py"] | ||
DATA_FILES = [] | ||
OPTIONS = { | ||
"argv_emulation": True, | ||
"packages": ["pandas", "ofxparse"], | ||
} | ||
|
||
setup( | ||
app=APP, | ||
name="Transactify", | ||
data_files=DATA_FILES, | ||
options={"py2app": OPTIONS}, | ||
setup_requires=["py2app"], | ||
) |