Skip to content

Commit

Permalink
Allow running the program with a GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
nygrenh committed Oct 6, 2023
1 parent d27e8c7 commit 1498638
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 11 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install system dependencies
run: sudo apt-get install libgtk-3-dev
if: ${{ matrix.os == 'ubuntu-latest' }}
- name: Run image
uses: abatilo/actions-poetry@v2
with:
Expand All @@ -29,11 +32,8 @@ jobs:

- name: Install dependencies
run: poetry install

- name: install pyinstaller
run: poetry run pip install -U pyinstaller
- name: Build execution file
run: poetry run pyinstaller main.py --onefile
run: poetry run pyinstaller main.py --onefile --windowed

- name: Sign the macos-version build
if: ${{ matrix.os == 'macos-latest' }}
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Feedback data converter

Converts feedback data that has been collected from courses.mooc.fi exercises to an Excel file.

## Usage

1. Download the program from the releases on the right side of this page.
2. Create a new empty folder where you'll place the program. The program, the input files and the output files will be placed in this folder.
3. Run the program once to create the configuration file on the same folder.
- If you're running Linux, you'll need to allow executing the file as a program. (Right click the file, select Properties, go to Permissions tab and check the "Allow executing file as program" checkbox.)
4. Export exercise tasks and submissions from courses.mooc.fi and place them to a folder called `data`.
5. Run the program. The output file will be placed in a folder called `output`.

30 changes: 26 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import numpy as np
import pdb
import sys
from argparse import ArgumentParser

current_file_path = sys.executable
basename = os.path.basename(current_file_path)
Expand All @@ -18,8 +19,12 @@


def main():
# Change pwd to the directory of this file
# To make Gooey work, we need to use argparse
parser = ArgumentParser(add_help=True)
args = parser.parse_args()
print("🚀 Starting the program")

# Change pwd to the directory of this file
abspath = os.path.abspath(current_file_path)
dname = os.path.dirname(abspath)
print(f"Using working directory {dname}")
Expand Down Expand Up @@ -202,9 +207,8 @@ def sort_key(x):
print()

current_timestamp_in_iso_format = date.today().isoformat()
workbook = xlsxwriter.Workbook(
f"./output/feedback_{current_timestamp_in_iso_format}.xlsx"
)
excel_output_path = f"./output/feedback_{current_timestamp_in_iso_format}.xlsx"
workbook = xlsxwriter.Workbook(excel_output_path)

# create output folder if it does not exist
if not os.path.exists("./output"):
Expand Down Expand Up @@ -265,7 +269,25 @@ def sort_key(x):
)

workbook.close()
print()
print(f"✅ Processing complete. Results written to {excel_output_path}")


if __name__ == "__main__":
if "--help" in sys.argv or "-h" in sys.argv:
print("Note: To run this program with a graphical user interface, use --gui")
# If we are not running from the terminal, run with GUI
run_with_gui = not sys.stdin.isatty()
if "--gui" in sys.argv:
run_with_gui = True
if run_with_gui:
from gooey import Gooey

main = Gooey(
auto_start=True,
program_name="Feedback data converter",
# make the window a little bigger
default_size=(800, 900),
terminal_font_family="monospace",
)(main)
main()
135 changes: 132 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ polars = "^0.19.3"
PyYAML = "^6.0.1"
XlsxWriter = "^3.1.4"
numpy = "^1.26.0"
Gooey = "^1.0.8"

[tool.poetry.dev-dependencies]
ipykernel = "^6.25.2"
pyinstaller = "^6.0.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down

0 comments on commit 1498638

Please sign in to comment.