Skip to content

Commit

Permalink
added text2qti_tk graphical application, plus Windows build scripts u…
Browse files Browse the repository at this point in the history
…nder make_gui_exe/ (#27)
  • Loading branch information
gpoore committed Sep 29, 2020
1 parent 005c293 commit bbe79e5
Show file tree
Hide file tree
Showing 11 changed files with 611 additions and 168 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

## v0.5.0 (dev)

* Added `text2qti_tk` executable, which provides a basic graphical user
interface (GUI) via `tkinter`. Added build scripts in `make_gui_exe/` for
creating a standalone GUI executable under Windows with PyInstaller (#27).
* In executable code blocks, `.python` now invokes `python3` on systems where
`python` is equivalent to `python2` as well as on systems that lack a
`python` executable. The README now suggests using `.python3` and
Expand Down
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,20 +214,24 @@ editor like Notepad or gedit, or a code editor like
[VS Code](https://code.visualstudio.com/). You can even use Microsoft Word,
as long as you save your file as plain text (*.txt).

text2qti is a command-line application. Open a command line in the same
folder or directory as your quiz file. Under Windows, you can hold the SHIFT
button down on the keyboard, then right click next to your file, and select
"Open PowerShell window here" or "Open command window here". You can also
launch "Command Prompt" or "PowerShell" through the Start menu, and then
navigate to your file using `cd`.
text2qti includes a graphical application and a command-line application.

Run the `text2qti` application using a command like this:
```
text2qti quiz.txt
```
Replace "quiz.txt" with the name of your file. This will create a file like
`quiz.zip` (with "quiz" replaced by the name of your file) which is the
converted quiz in QTI format.
* To use the graphical application, open a command line and run `text2qti_tk`.

* To use the command-line application, open a command line in the same folder
or directory as your quiz file. Under Windows, you can hold the SHIFT
button down on the keyboard, then right click next to your file, and select
"Open PowerShell window here" or "Open command window here". You can also
launch "Command Prompt" or "PowerShell" through the Start menu, and then
navigate to your file using `cd`.

Run the `text2qti` application using a command like this:
```
text2qti quiz.txt
```
Replace "quiz.txt" with the name of your file. This will create a file like
`quiz.zip` (with "quiz" replaced by the name of your file) which is the
converted quiz in QTI format.

Instructions for using the QTI file with Canvas:
* Go to the course in which you want to use the quiz.
Expand Down
35 changes: 35 additions & 0 deletions make_gui_exe/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Create Standalone GUI Executable for Windows

This directory contains scripts for creating a standalone GUI executable under
Windows with PyInstaller.



## Requirements

* Windows
* [conda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/)



## Directions

If you do not already have a local copy of the text2qti source, download
`make_tk_exe.bat` and `text2qti_tk.pyw`, and place them in the same directory.
Double-click on `make_tk_exe.bat` to run it. Or open a command prompt,
navigate to `make_gui_exe/` (or wherever the batch file is located), and run
the batch file. Under PowerShell, run something like
`cmd /c make_gui_exe.bat`.

The batch file performs these steps:
* Create a new conda environment for building the executable.
* Activate the conda environment.
* Install needed Python packages in the environment: bespon, markdown,
pyinstaller, and text2qti. If the batch file detects that it is part of a
local copy of the text2qti source, then this local version of text2qti will
be used. Otherwise, text2qti will be installed from PyPI via pip.
* Build executable `text2qti_tk_VERSION.exe` using PyInstaller.
* Deactivate the conda environment.
* Remove the conda environment.
* Move the executable to the working directory.
* Remove all temp files and build files.
47 changes: 47 additions & 0 deletions make_gui_exe/make_tk_exe.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
REM This is intended to be run with the .bat file directory as the working dir
if not exist make_tk_exe.bat (
echo Missing make_tk_exe.bat in working directory
pause
exit
)
if not exist text2qti_tk.pyw (
echo Missing text2qti_tk.pyw in working directory
pause
exit
)

REM Create and activate a conda env for packaging the .exe
call conda create -y --name make_text2qti_gui_exe python=3.8 --no-default-packages
call conda activate make_text2qti_gui_exe
REM List conda envs -- useful for debugging
call conda info --envs
REM Install dependencies
pip install bespon
pip install markdown
pip install pyinstaller
if exist ..\setup.py (
if exist ..\text2qti (
cd ..
pip install .
cd make_gui_exe
) else (
pip install text2qti
)
) else (
pip install text2qti
)
REM Build .exe
FOR /F "tokens=* USEBACKQ" %%g IN (`python -c "import text2qti; print(text2qti.__version__)"`) do (SET "TEXT2QTI_VERSION=%%g")
pyinstaller -F --name text2qti_tk_%TEXT2QTI_VERSION% text2qti_tk.pyw
REM Deactivate and delete conda env
call conda deactivate
call conda remove -y --name make_text2qti_gui_exe --all
REM List conda envs -- useful for debugging
call conda info --envs
REM Cleanup
move dist\text2qti_tk_%TEXT2QTI_VERSION%.exe text2qti_tk_%TEXT2QTI_VERSION%.exe
rd /s /q "__pycache__"
rd /s /q "build"
rd /s /q "dist"
del *.spec
pause
2 changes: 2 additions & 0 deletions make_gui_exe/text2qti_tk.pyw
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import text2qti.gui.tk
text2qti.gui.tk.main()
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
if sys.version_info < (3, 6):
sys.exit('text2qti requires Python 3.6+')
import pathlib
from setuptools import setup
from setuptools import setup, find_packages



Expand All @@ -30,9 +30,7 @@
setup(name='text2qti',
version=version,
py_modules=[],
packages=[
'text2qti'
],
packages=find_packages(),
package_data = {},
description='Create quizzes in QTI format from Markdown-based plain text',
long_description=long_description,
Expand Down Expand Up @@ -62,5 +60,6 @@
],
entry_points = {
'console_scripts': ['text2qti = text2qti.cmdline:main'],
'gui_scripts': ['text2qti_tk = text2qti.gui.tk:main'],
},
)
Empty file added text2qti/gui/__init__.py
Empty file.
Loading

0 comments on commit bbe79e5

Please sign in to comment.