Skip to content

Commit

Permalink
Merge pull request #38 from FrameworkComputer/python-docs
Browse files Browse the repository at this point in the history
python: Add development instructions and fix running locally
  • Loading branch information
JohnAZoidberg authored Nov 23, 2024
2 parents bd97e6c + 1639a2c commit c097bb3
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
31 changes: 31 additions & 0 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,34 @@ python3 -m pip install qmk_hid

On Linux install Python requirements via `python3 -m pip install -r requirements.txt` and run `python3 qmk_hid/gui.py`.
On Windows download the `qmk_gui.exe` and run it.

## Developing

One time setup

```
# Install dependencies on Ubuntu
sudo apt install python3 python3-tk python3-devel libhidapi-dev
# Install dependencies on Fedora
sudo dnf install python3 python3-tkinter hidapi-devel
# Create local venv and enter it
python3 -m venv venv
source venv/bin/activate
# Install package into local env
python3 -m pip install -e .
```

Developing

```
# In every new shell, source the virtual environment
source venv/bin/activate
# Launch GUI or commandline
qmk_gui
# Launch Python REPL and import the library
# As example, launch the GUI
> python3
>>> from qmk_hid import gui
>>> gui.main()
```
8 changes: 4 additions & 4 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ classifiers = [
Issues = "https://github.com/FrameworkComputer/qmk_hid/issues"
Source = "https://github.com/FrameworkComputer/qmk_hid"

# TODO: Figure out how to add a runnable-script
#[project.scripts]
#qmk_hid = "qmk_hid.gui:main_cli"
# TODO: There's no CLI yet
# [project.scripts]
# qmk_hid = "qmk_hid.gui:main_cli"

[project.gui-scripts]
qmk_gui = "qmk_hid.gui:main"
Expand Down Expand Up @@ -66,4 +66,4 @@ exclude = [
# pretty = true
# show_column_numbers = true
# warn_no_return = false
# warn_unused_ignores = true
# warn_unused_ignores = true
2 changes: 1 addition & 1 deletion python/qmk_hid/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from win32con import VK_NUMLOCK, VK_CAPITAL
import winreg

import uf2conv
import qmk_hid.uf2conv

# TODO:
# - Get current values
Expand Down
2 changes: 1 addition & 1 deletion python/qmk_hid/uf2conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def get_drives():
"get", "DeviceID,",
"FileSystem,", "DriveType"])
for line in to_str(r).split('\n'):
words = re.split('\s+', line)
words = re.split(r'\s+', line)
if len(words) >= 3 and words[1] == "2" and words[2] == "FAT":
drives.append(words[0])
else:
Expand Down

0 comments on commit c097bb3

Please sign in to comment.