Project description
Adds support for the standard Python curses
module on Windows. Based on
these wheels. Uses the
PDCurses curses implementation.
The wheels are built from this GitHub
repository.
PDCurses is compiled with wide character support, meaning get_wch()
is
available. UTF-8 is forced as the encoding.
Starting from windows-curses 2.0, in the name of pragmatism, these wheels (but
not Gohlke’s) include a hack to make resizing work for applications developed
against ncurses without Python code changes: Whenever getch()
, getkey()
, or
get_wch()
return KEY_RESIZE
, resize_term(0, 0)
is called automatically.
This gives behavior similar to the automatic SIGWINCH
handling in ncurses
(see PDCurses’ resize_term()
documentation). This
commit
implements the hack.
To add the same hack in Python code (which is harmless, and needed if you want
resizing to work with older windows-curses versions or with Gohlke’s wheels),
call curses.resize_term(0, 0)
after receiving KEY_RESIZE
, and ignore any
curses.error
exceptions. ncurses reliably fails and does nothing for
resize_term(0, 0)
, so this is safe on *nix.
Please tell me if the resize_term(0, 0)
hackery causes you any trouble.
Project details
Download files
Download the file for your platform. If you’re not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file windows_curses-2.4.1-cp313-cp313-win_amd64.whl
.
File metadata
-
Download URL:
windows_curses-2.4.1-cp313-cp313-win_amd64.whl - Upload date:
- Size: 81.6 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Hashes for windows_curses-2.4.1-cp313-cp313-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8cf653f8928af19c103ae11cfed38124f418dcdd92643c4cd17239c0cec2f9da |
|
MD5 | 9fb66ad4c775e00978f97cff667b3a62 |
|
BLAKE2b-256 | 2b4b2838a829b074a68c570d54ae0ae8539979657d3e619a4dc5a4b03eb69745 |
See more details on using hashes here.
Provenance
The following attestation bundles were made for windows_curses-2.4.1-cp313-cp313-win_amd64.whl
:
Publisher:
release.yml
on zephyrproject-rtos/windows-curses
Attestations:
Values shown here reflect the state when the release was signed and may no longer be current.
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
windows_curses-2.4.1-cp313-cp313-win_amd64.whl
- Subject digest:
8cf653f8928af19c103ae11cfed38124f418dcdd92643c4cd17239c0cec2f9da
- Sigstore transparency entry: 161520838
- Sigstore integration time:
Source repository:
- Permalink:
zephyrproject-rtos/windows-curses@2b143913c17b1e9b6651328f7e02f38723a04393
- Branch / Tag:
refs/tags/v2.4.1
- Owner: https://github.com/zephyrproject-rtos
- Access:
public
Publication detail:
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yml@2b143913c17b1e9b6651328f7e02f38723a04393
- Trigger Event:
release
- Statement type:
File details
Details for the file windows_curses-2.4.1-cp313-cp313-win32.whl
.
File metadata
-
Download URL:
windows_curses-2.4.1-cp313-cp313-win32.whl - Upload date:
- Size: 71.4 kB
- Tags: CPython 3.13, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Hashes for windows_curses-2.4.1-cp313-cp313-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05d1ca01e5199a435ccb6c8c2978df4a169cdff1ec99ab15f11ded9de8e5be26 |
|
MD5 | 342bfaaa3e73c264a38a421dc8755db5 |
|
BLAKE2b-256 | 25a0e8d074f013117633f6b502ca123ecfc377fe0bd36818fe65e8935c91ca9c |
See more details on using hashes here.
Provenance
The following attestation bundles were made for windows_curses-2.4.1-cp313-cp313-win32.whl
:
Publisher:
release.yml
on zephyrproject-rtos/windows-curses
Attestations:
Values shown here reflect the state when the release was signed and may no longer be current.
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
windows_curses-2.4.1-cp313-cp313-win32.whl
- Subject digest:
05d1ca01e5199a435ccb6c8c2978df4a169cdff1ec99ab15f11ded9de8e5be26
- Sigstore transparency entry: 161520855
- Sigstore integration time:
Source repository:
- Permalink:
zephyrproject-rtos/windows-curses@2b143913c17b1e9b6651328f7e02f38723a04393
- Branch / Tag:
refs/tags/v2.4.1
- Owner: https://github.com/zephyrproject-rtos
- Access:
public
Publication detail:
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yml@2b143913c17b1e9b6651328f7e02f38723a04393
- Trigger Event:
release
- Statement type:
File details
Details for the file windows_curses-2.4.1-cp312-cp312-win_amd64.whl
.
File metadata
-
Download URL:
windows_curses-2.4.1-cp312-cp312-win_amd64.whl - Upload date:
- Size: 81.8 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Hashes for windows_curses-2.4.1-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c9c2635faf171a229caca80e1dd760ab00db078e2a285ba2f667bbfcc31777c |
|
MD5 | e98688b426b7886df8787a269de2c004 |
|
BLAKE2b-256 | 628fd908bcab1954375b156a9300fa86ceccb110f39457cd6fd59c72777626ab |
See more details on using hashes here.
Provenance
The following attestation bundles were made for windows_curses-2.4.1-cp312-cp312-win_amd64.whl
:
Publisher:
release.yml
on zephyrproject-rtos/windows-curses
Attestations:
Values shown here reflect the state when the release was signed and may no longer be current.
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
windows_curses-2.4.1-cp312-cp312-win_amd64.whl
- Subject digest:
5c9c2635faf171a229caca80e1dd760ab00db078e2a285ba2f667bbfcc31777c
- Sigstore transparency entry: 161520850
- Sigstore integration time:
Source repository:
- Permalink:
zephyrproject-rtos/windows-curses@2b143913c17b1e9b6651328f7e02f38723a04393
- Branch / Tag:
refs/tags/v2.4.1
- Owner: https://github.com/zephyrproject-rtos
- Access:
public
Publication detail:
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yml@2b143913c17b1e9b6651328f7e02f38723a04393
- Trigger Event:
release
- Statement type:
File details
Details for the file windows_curses-2.4.1-cp312-cp312-win32.whl
.
File metadata
-
Download URL:
windows_curses-2.4.1-cp312-cp312-win32.whl - Upload date:
- Size: 71.5 kB
- Tags: CPython 3.12, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Hashes for windows_curses-2.4.1-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bdbe7d58747408aef8a9128b2654acf6fbd11c821b91224b9a046faba8c6b6ca |
|
MD5 | f9132a2f5196858f1bad10897659b1e3 |
|
BLAKE2b-256 | f49960f34e51514c82631aa5c6d21eab88ce1701562de9844608411e39462a46 |
See more details on using hashes here.
Provenance
The following attestation bundles were made for windows_curses-2.4.1-cp312-cp312-win32.whl
:
Publisher:
release.yml
on zephyrproject-rtos/windows-curses
Attestations:
Values shown here reflect the state when the release was signed and may no longer be current.
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
windows_curses-2.4.1-cp312-cp312-win32.whl
- Subject digest:
bdbe7d58747408aef8a9128b2654acf6fbd11c821b91224b9a046faba8c6b6ca
- Sigstore transparency entry: 161520858
- Sigstore integration time:
Source repository:
- Permalink:
zephyrproject-rtos/windows-curses@2b143913c17b1e9b6651328f7e02f38723a04393
- Branch / Tag:
refs/tags/v2.4.1
- Owner: https://github.com/zephyrproject-rtos
- Access:
public
Publication detail:
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yml@2b143913c17b1e9b6651328f7e02f38723a04393
- Trigger Event:
release
- Statement type:
File details
Details for the file windows_curses-2.4.1-cp311-cp311-win_amd64.whl
.
File metadata
-
Download URL:
windows_curses-2.4.1-cp311-cp311-win_amd64.whl - Upload date:
- Size: 81.4 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Hashes for windows_curses-2.4.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd7d7a9cf6c1758f46ed76b8c67f608bc5fcd5f0ca91f1580fd2d84cf41c7f4f |
|
MD5 | fd98a02b17b27c66b99c64e2eed09cc7 |
|
BLAKE2b-256 | 5029fd7c0c80177d8df55f841504a5f332b95b0002c80f82055913b6caac94e6 |
See more details on using hashes here.
Provenance
The following attestation bundles were made for windows_curses-2.4.1-cp311-cp311-win_amd64.whl
:
Publisher:
release.yml
on zephyrproject-rtos/windows-curses
Attestations:
Values shown here reflect the state when the release was signed and may no longer be current.
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
windows_curses-2.4.1-cp311-cp311-win_amd64.whl
- Subject digest:
fd7d7a9cf6c1758f46ed76b8c67f608bc5fcd5f0ca91f1580fd2d84cf41c7f4f
- Sigstore transparency entry: 161520836
- Sigstore integration time:
Source repository:
- Permalink:
zephyrproject-rtos/windows-curses@2b143913c17b1e9b6651328f7e02f38723a04393
- Branch / Tag:
refs/tags/v2.4.1
- Owner: https://github.com/zephyrproject-rtos
- Access:
public
Publication detail:
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yml@2b143913c17b1e9b6651328f7e02f38723a04393
- Trigger Event:
release
- Statement type:
File details
Details for the file windows_curses-2.4.1-cp311-cp311-win32.whl
.
File metadata
-
Download URL:
windows_curses-2.4.1-cp311-cp311-win32.whl - Upload date:
- Size: 71.1 kB
- Tags: CPython 3.11, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Hashes for windows_curses-2.4.1-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fa1a176bfcf098d0c9bb7bc03dce6e83a4257fc0c66ad721f5745ebf0c00746 |
|
MD5 | 30e338b47657629e7840bec941c0e863 |
|
BLAKE2b-256 | 74b346a2508fff83b5affb5a311797c584c494b4b0c4c8796a1afa2c1b1e03ac |
See more details on using hashes here.
Provenance
The following attestation bundles were made for windows_curses-2.4.1-cp311-cp311-win32.whl
:
Publisher:
release.yml
on zephyrproject-rtos/windows-curses
Attestations:
Values shown here reflect the state when the release was signed and may no longer be current.
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
windows_curses-2.4.1-cp311-cp311-win32.whl
- Subject digest:
4fa1a176bfcf098d0c9bb7bc03dce6e83a4257fc0c66ad721f5745ebf0c00746
- Sigstore transparency entry: 161520842
- Sigstore integration time:
Source repository:
- Permalink:
zephyrproject-rtos/windows-curses@2b143913c17b1e9b6651328f7e02f38723a04393
- Branch / Tag:
refs/tags/v2.4.1
- Owner: https://github.com/zephyrproject-rtos
- Access:
public
Publication detail:
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yml@2b143913c17b1e9b6651328f7e02f38723a04393
- Trigger Event:
release
- Statement type:
File details
Details for the file windows_curses-2.4.1-cp310-cp310-win_amd64.whl
.
File metadata
-
Download URL:
windows_curses-2.4.1-cp310-cp310-win_amd64.whl - Upload date:
- Size: 81.4 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Hashes for windows_curses-2.4.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 325439cd4f37897a1de8a9c068a5b4c432f9244bf9c855ee2fbeb3fa721a770c |
|
MD5 | 4f439a41262158f2cef8e7a10ad4b39b |
|
BLAKE2b-256 | a61d1bb512c445af24fb0a3dccf9537c8727bba5920e69539227b87f5351f608 |
See more details on using hashes here.
Provenance
The following attestation bundles were made for windows_curses-2.4.1-cp310-cp310-win_amd64.whl
:
Publisher:
release.yml
on zephyrproject-rtos/windows-curses
Attestations:
Values shown here reflect the state when the release was signed and may no longer be current.
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
windows_curses-2.4.1-cp310-cp310-win_amd64.whl
- Subject digest:
325439cd4f37897a1de8a9c068a5b4c432f9244bf9c855ee2fbeb3fa721a770c
- Sigstore transparency entry: 161520848
- Sigstore integration time:
Source repository:
- Permalink:
zephyrproject-rtos/windows-curses@2b143913c17b1e9b6651328f7e02f38723a04393
- Branch / Tag:
refs/tags/v2.4.1
- Owner: https://github.com/zephyrproject-rtos
- Access:
public
Publication detail:
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yml@2b143913c17b1e9b6651328f7e02f38723a04393
- Trigger Event:
release
- Statement type:
File details
Details for the file windows_curses-2.4.1-cp310-cp310-win32.whl
.
File metadata
-
Download URL:
windows_curses-2.4.1-cp310-cp310-win32.whl - Upload date:
- Size: 71.1 kB
- Tags: CPython 3.10, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Hashes for windows_curses-2.4.1-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53d711e07194d0d3ff7ceff29e0955b35479bc01465d46c3041de67b8141db2f |
|
MD5 | d99722ca67441a5b48c30614dd17a492 |
|
BLAKE2b-256 | 1534e70815e7ae6f157c00121180a607dbcdc82acfd949c70bba28c45d206dec |
See more details on using hashes here.
Provenance
The following attestation bundles were made for windows_curses-2.4.1-cp310-cp310-win32.whl
:
Publisher:
release.yml
on zephyrproject-rtos/windows-curses
Attestations:
Values shown here reflect the state when the release was signed and may no longer be current.
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
windows_curses-2.4.1-cp310-cp310-win32.whl
- Subject digest:
53d711e07194d0d3ff7ceff29e0955b35479bc01465d46c3041de67b8141db2f
- Sigstore transparency entry: 161520844
- Sigstore integration time:
Source repository:
- Permalink:
zephyrproject-rtos/windows-curses@2b143913c17b1e9b6651328f7e02f38723a04393
- Branch / Tag:
refs/tags/v2.4.1
- Owner: https://github.com/zephyrproject-rtos
- Access:
public
Publication detail:
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yml@2b143913c17b1e9b6651328f7e02f38723a04393
- Trigger Event:
release
- Statement type:
File details
Details for the file windows_curses-2.4.1-cp39-cp39-win_amd64.whl
.
File metadata
-
Download URL:
windows_curses-2.4.1-cp39-cp39-win_amd64.whl - Upload date:
- Size: 89.5 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Hashes for windows_curses-2.4.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4588213f7ef3b0c24c5cb9e309653d7a84c1792c707561e8b471d466ca79f2b8 |
|
MD5 | 28cabd6de9455a0f9c57a8c2f66ee838 |
|
BLAKE2b-256 | 58deb050bb1dc40ce48afb477198fb65abe51580c03a165492fce1e8fa61efd5 |
See more details on using hashes here.
Provenance
The following attestation bundles were made for windows_curses-2.4.1-cp39-cp39-win_amd64.whl
:
Publisher:
release.yml
on zephyrproject-rtos/windows-curses
Attestations:
Values shown here reflect the state when the release was signed and may no longer be current.
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
windows_curses-2.4.1-cp39-cp39-win_amd64.whl
- Subject digest:
4588213f7ef3b0c24c5cb9e309653d7a84c1792c707561e8b471d466ca79f2b8
- Sigstore transparency entry: 161520843
- Sigstore integration time:
Source repository:
- Permalink:
zephyrproject-rtos/windows-curses@2b143913c17b1e9b6651328f7e02f38723a04393
- Branch / Tag:
refs/tags/v2.4.1
- Owner: https://github.com/zephyrproject-rtos
- Access:
public
Publication detail:
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yml@2b143913c17b1e9b6651328f7e02f38723a04393
- Trigger Event:
release
- Statement type:
File details
Details for the file windows_curses-2.4.1-cp39-cp39-win32.whl
.
File metadata
-
Download URL:
windows_curses-2.4.1-cp39-cp39-win32.whl - Upload date:
- Size: 76.9 kB
- Tags: CPython 3.9, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Hashes for windows_curses-2.4.1-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 775a2e0fefeddfdb0e00b3fa6c4f21caf9982db34df30e4e62c49caaef7b5e56 |
|
MD5 | 2cb9806cd13fff1b9c091dd2e6dbac66 |
|
BLAKE2b-256 | 5a078684dabf0d8c54b2e3ffb6bbc0f0e162b0817008c0f98cca4e04f9a9e72c |
See more details on using hashes here.
Provenance
The following attestation bundles were made for windows_curses-2.4.1-cp39-cp39-win32.whl
:
Publisher:
release.yml
on zephyrproject-rtos/windows-curses
Attestations:
Values shown here reflect the state when the release was signed and may no longer be current.
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
windows_curses-2.4.1-cp39-cp39-win32.whl
- Subject digest:
775a2e0fefeddfdb0e00b3fa6c4f21caf9982db34df30e4e62c49caaef7b5e56
- Sigstore transparency entry: 161520851
- Sigstore integration time:
Source repository:
- Permalink:
zephyrproject-rtos/windows-curses@2b143913c17b1e9b6651328f7e02f38723a04393
- Branch / Tag:
refs/tags/v2.4.1
- Owner: https://github.com/zephyrproject-rtos
- Access:
public
Publication detail:
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yml@2b143913c17b1e9b6651328f7e02f38723a04393
- Trigger Event:
release
- Statement type:
File details
Details for the file windows_curses-2.4.1-cp38-cp38-win_amd64.whl
.
File metadata
-
Download URL:
windows_curses-2.4.1-cp38-cp38-win_amd64.whl - Upload date:
- Size: 89.4 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Hashes for windows_curses-2.4.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 618e31458fedba2cf8105485ff00533ece780026c544142fc1647a20dc6c7641 |
|
MD5 | bb3e77ac250c0e23d93f4e11271cb643 |
|
BLAKE2b-256 | 69670ffc78290400740898c4d0df503c1b200dae7f31bbe6172468e590404885 |
See more details on using hashes here.
Provenance
The following attestation bundles were made for windows_curses-2.4.1-cp38-cp38-win_amd64.whl
:
Publisher:
release.yml
on zephyrproject-rtos/windows-curses
Attestations:
Values shown here reflect the state when the release was signed and may no longer be current.
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
windows_curses-2.4.1-cp38-cp38-win_amd64.whl
- Subject digest:
618e31458fedba2cf8105485ff00533ece780026c544142fc1647a20dc6c7641
- Sigstore transparency entry: 161520853
- Sigstore integration time:
Source repository:
- Permalink:
zephyrproject-rtos/windows-curses@2b143913c17b1e9b6651328f7e02f38723a04393
- Branch / Tag:
refs/tags/v2.4.1
- Owner: https://github.com/zephyrproject-rtos
- Access:
public
Publication detail:
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yml@2b143913c17b1e9b6651328f7e02f38723a04393
- Trigger Event:
release
- Statement type:
File details
Details for the file windows_curses-2.4.1-cp38-cp38-win32.whl
.
File metadata
-
Download URL:
windows_curses-2.4.1-cp38-cp38-win32.whl - Upload date:
- Size: 76.5 kB
- Tags: CPython 3.8, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Hashes for windows_curses-2.4.1-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9ce84559f80de7ec770d28c3b2991e0da51748def04e25a3c08ada727cfac2d |
|
MD5 | 9f5bf3837c4c77405286400e58eee08c |
|
BLAKE2b-256 | 08580a8fd30e8952ac461949e5b5177815cb70cd8e1399b9464537bd178f28b1 |
See more details on using hashes here.
Provenance
The following attestation bundles were made for windows_curses-2.4.1-cp38-cp38-win32.whl
:
Publisher:
release.yml
on zephyrproject-rtos/windows-curses
Attestations:
Values shown here reflect the state when the release was signed and may no longer be current.
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
windows_curses-2.4.1-cp38-cp38-win32.whl
- Subject digest:
e9ce84559f80de7ec770d28c3b2991e0da51748def04e25a3c08ada727cfac2d
- Sigstore transparency entry: 161520840
- Sigstore integration time:
Source repository:
- Permalink:
zephyrproject-rtos/windows-curses@2b143913c17b1e9b6651328f7e02f38723a04393
- Branch / Tag:
refs/tags/v2.4.1
- Owner: https://github.com/zephyrproject-rtos
- Access:
public
Publication detail:
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yml@2b143913c17b1e9b6651328f7e02f38723a04393
- Trigger Event:
release
- Statement type:
File details
Details for the file windows_curses-2.4.1-cp37-cp37m-win_amd64.whl
.
File metadata
-
Download URL:
windows_curses-2.4.1-cp37-cp37m-win_amd64.whl - Upload date:
- Size: 70.8 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Hashes for windows_curses-2.4.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db776df70c10bd523c4a1ab0a7624a1d58c7d47f83ec49c6988f05bc1189e7b8 |
|
MD5 | f315671ba7cfd40f2301b53522df27b7 |
|
BLAKE2b-256 | 66c110e45e34099437256548b2d156b5841817d3b66c2c162c72b5584ea3cf18 |
See more details on using hashes here.
Provenance
The following attestation bundles were made for windows_curses-2.4.1-cp37-cp37m-win_amd64.whl
:
Publisher:
release.yml
on zephyrproject-rtos/windows-curses
Attestations:
Values shown here reflect the state when the release was signed and may no longer be current.
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
windows_curses-2.4.1-cp37-cp37m-win_amd64.whl
- Subject digest:
db776df70c10bd523c4a1ab0a7624a1d58c7d47f83ec49c6988f05bc1189e7b8
- Sigstore transparency entry: 161520860
- Sigstore integration time:
Source repository:
- Permalink:
zephyrproject-rtos/windows-curses@2b143913c17b1e9b6651328f7e02f38723a04393
- Branch / Tag:
refs/tags/v2.4.1
- Owner: https://github.com/zephyrproject-rtos
- Access:
public
Publication detail:
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yml@2b143913c17b1e9b6651328f7e02f38723a04393
- Trigger Event:
release
- Statement type:
File details
Details for the file windows_curses-2.4.1-cp37-cp37m-win32.whl
.
File metadata
-
Download URL:
windows_curses-2.4.1-cp37-cp37m-win32.whl - Upload date:
- Size: 61.7 kB
- Tags: CPython 3.7m, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Hashes for windows_curses-2.4.1-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a36b8fd4e410ddfb1a8eb65af2116c588e9f99b2ff3404412317440106755485 |
|
MD5 | 1bb465f559a92ead49313878ecd896da |
|
BLAKE2b-256 | e96c49955f6bfcdb1a387021042aadfafd736bb63a9cefffa00d5456b7b47042 |
See more details on using hashes here.
Provenance
The following attestation bundles were made for windows_curses-2.4.1-cp37-cp37m-win32.whl
:
Publisher:
release.yml
on zephyrproject-rtos/windows-curses
Attestations:
Values shown here reflect the state when the release was signed and may no longer be current.
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
windows_curses-2.4.1-cp37-cp37m-win32.whl
- Subject digest:
a36b8fd4e410ddfb1a8eb65af2116c588e9f99b2ff3404412317440106755485
- Sigstore transparency entry: 161520839
- Sigstore integration time:
Source repository:
- Permalink:
zephyrproject-rtos/windows-curses@2b143913c17b1e9b6651328f7e02f38723a04393
- Branch / Tag:
refs/tags/v2.4.1
- Owner: https://github.com/zephyrproject-rtos
- Access:
public
Publication detail:
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yml@2b143913c17b1e9b6651328f7e02f38723a04393
- Trigger Event:
release
- Statement type:
File details
Details for the file windows_curses-2.4.1-cp36-cp36m-win_amd64.whl
.
File metadata
-
Download URL:
windows_curses-2.4.1-cp36-cp36m-win_amd64.whl - Upload date:
- Size: 70.7 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Hashes for windows_curses-2.4.1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e61be805edc390ccfdeaf0e0c39736d931d3c4a007d6bf0f98d1e792ce437796 |
|
MD5 | d2bc6e5fd4c715ca5772219a48fa18c5 |
|
BLAKE2b-256 | 0eb4c2a1dd84c7152b1ede832aeaf25af5ce1a8429b78a1644d1d886c80a996c |
See more details on using hashes here.
Provenance
The following attestation bundles were made for windows_curses-2.4.1-cp36-cp36m-win_amd64.whl
:
Publisher:
release.yml
on zephyrproject-rtos/windows-curses
Attestations:
Values shown here reflect the state when the release was signed and may no longer be current.
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
windows_curses-2.4.1-cp36-cp36m-win_amd64.whl
- Subject digest:
e61be805edc390ccfdeaf0e0c39736d931d3c4a007d6bf0f98d1e792ce437796
- Sigstore transparency entry: 161520854
- Sigstore integration time:
Source repository:
- Permalink:
zephyrproject-rtos/windows-curses@2b143913c17b1e9b6651328f7e02f38723a04393
- Branch / Tag:
refs/tags/v2.4.1
- Owner: https://github.com/zephyrproject-rtos
- Access:
public
Publication detail:
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yml@2b143913c17b1e9b6651328f7e02f38723a04393
- Trigger Event:
release
- Statement type:
File details
Details for the file windows_curses-2.4.1-cp36-cp36m-win32.whl
.
File metadata
-
Download URL:
windows_curses-2.4.1-cp36-cp36m-win32.whl - Upload date:
- Size: 61.6 kB
- Tags: CPython 3.6m, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Hashes for windows_curses-2.4.1-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a5a831cabaadde41a6856fea5a0c68c74b7d11d332a816e5a5e6c84577aef3a |
|
MD5 | 172a72e9a448918a694631c844e17e64 |
|
BLAKE2b-256 | d515e8adb661437cb89f7e2cadf00b5a6aa8937a79b83e5efee843e7683db340 |
See more details on using hashes here.
Provenance
The following attestation bundles were made for windows_curses-2.4.1-cp36-cp36m-win32.whl
:
Publisher:
release.yml
on zephyrproject-rtos/windows-curses
Attestations:
Values shown here reflect the state when the release was signed and may no longer be current.
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
windows_curses-2.4.1-cp36-cp36m-win32.whl
- Subject digest:
6a5a831cabaadde41a6856fea5a0c68c74b7d11d332a816e5a5e6c84577aef3a
- Sigstore transparency entry: 161520857
- Sigstore integration time:
Source repository:
- Permalink:
zephyrproject-rtos/windows-curses@2b143913c17b1e9b6651328f7e02f38723a04393
- Branch / Tag:
refs/tags/v2.4.1
- Owner: https://github.com/zephyrproject-rtos
- Access:
public
Publication detail:
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yml@2b143913c17b1e9b6651328f7e02f38723a04393
- Trigger Event:
release
- Statement type:
Overview
- Introduction
- Install windows-curses package
- Test out curses
- Curses tutorial
- Conclusion
- Reference links
Introduction
This post only discusses how to get curses working in Windows. A full curses tutorial is also available.. For a tutorial on how to use curses, check out Curses Programming in Python.
The curses package is part of the Python standard library and is useful for creating text-based user interfaces and generally controlling the screen and keyboard input. The big problem is that it doesn’t work out-of-the-box on Windows. This show you how to get curses working in Windows. This was tested in Windows 10 with Python 3.6. This gets the screen control, keyboard input, and colors all working. It uses the windows-curses package.
The curses library goes back decades and is used to control terminal/shell output. Read more about the history on the Wikipedia curses page. This is not a full tutorial on curses programming. Refer to the official documentation, Curses Programming with Python. That will teach you how to actually use the library.
You might also be interested in the tutorial Colorize Terminal Output in Python.
In Windows 10, some color escape codes are supported without any special configuration. Read more at MSDN Console Virtual Terminal Sequences. It is not full curses support but some colors and cursor control abilities work.
Install windows-curses package
You can use pip to install the windows-curses package. That’s really all there is to it! This package will make it so you can use the Python standard curses module in Windows. From your command prompt or shell, run pip install or preferably python -m pip install like this:
python -m pip install windows-curses
Test out curses
After installing the windows-curses package using pip, you can test it out with code:
# Clear the screen and hold it for 3 seconds
import curses
import timescreen = curses.initscr()
screen.clear()time.sleep(3)
Curses tutorial
For a tutorial on how to use curses, check out Curses Programming in Python.
Conclusion
After reading this, you should know how to get curses applications running in Windows. To learn more about how to use curses in your applications, refer to Curses Programming with Python (official documentation). You might also be interested in the tutorial Colorize Terminal Output in Python.
Reference links
- MSDN Console Virtual Terminal Sequences
- windows-curses on PyPI
- Curses Programming with Python (official documentation)
- Curses (Wikipedia)
- Colorize Terminal Output in Python
Python curses wheels for Windows
This is the repository for the windows-curses wheels on
PyPI. The wheels are based on the
wheels on Christoph Gohlke’s
page.
Only build-wheels.bat
is original work.
Wheels built from this repository can be installed with this command:
pip install windows-curses
Starting with version 2.0, these wheels include a hack to make resizing work
for Python applications that haven’t been specifically adapted for PDCurses.
See this
commit.
The description on PyPI has a longer explanation.
Note that this hack is not in Gohlke’s wheels.
Maintainers Wanted
This project is not actively maintained and is looking for maintainers.
If you are interested, please let us know by either creating an issue here or messaging in the
#windows-support channel on Zephyr Discord.
Background
The curses
module is in the Python standard library, but is not available on
Windows. Trying to import curses
gives an import error for _curses
, which
is provided by Modules/_cursesmodule.c
in the CPython source code.
The wheels provided here are based on patches from
https://bugs.python.org/issue2889, which make minor modifications to
_cursesmodule.c
to make it compatible with Windows and the
PDCurses curses implementation. setup.py
defines HAVE_*
macros for features available in PDCurses and makes some minor
additional compatibility tweaks.
The patched _cursesmodule.c
is linked against PDCurses to produce a wheel
that provides the _curses
module on Windows and allows the standard curses
module to run.
Unicode support
The wheels are built with wide character support and force the encoding to
UTF-8. Remove UTF8=y
from the nmake
line in build-wheels.bat
to use the
default system encoding instead.
Build instructions
-
Clone the repository with the following command:
git clone --recurse-submodules https://github.com/zephyrproject-rtos/windows-curses.git
--recurse-submodules
pulls in the required PDCurses Git submodule. -
Install compilers compatible with the Python versions that you want to
builds wheel for by following the instructions at
https://wiki.python.org/moin/WindowsCompilers.Visual Studio 2019 will work for Python 3.6-3.9.
Visual Studio 2022 will work for Python 3.10-3.13.
-
Install Python 3.6 or later to get
the Python launcher for Windows. -
Install any other Python versions you want to build wheels for.
Only the Python X.Y versions that have
pyXY\
directories are supported. -
Install/upgrade the
wheel
andsetuptools
packages for all Python
versions. Taking Python 3.6 as an example, the following command will do
it:py -3.6 -m pip install --upgrade wheel setuptools
py
is the Python launcher, which makes it easy to run a particular Python
version. -
Open the Visual Studio
Developer Command Prompt
of the compiler required by the version of Python that you want to build
a wheel for.Use the 32-bit version (
x86 Native Tools Command Prompt for VS 2022
) to build wheels for 32-bit
Python versions, and the 64-bit version (e.g.
x64 Native Tools Command Prompt for VS 2022
) to build wheels for 64-bit Python versions. -
Run
build-wheels.bat
, passing it the Python version you’re building a
wheel for. For example, the following command will build a wheel for
Python 3.6:If you have both 32-bit and 64-bit versions of the same Python version
installed and are building a 32-bit wheel, add «-32» to the version
number, like in the following example:If you are building multiple wheels for Python versions that are all
compatible with the same compiler, you can list all of them in the same
command:build-wheels.bat
first cleans and rebuilds PDCurses, and then builds and
links the source code inpyXY\
for each of the specified Python versions,
producing wheels as output indist\
.
Rebuilding the wheels for Python 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, and 3.13
In x86 Native Tools Command Prompt for VS 2022
:
build-wheels.bat 3.6-32 3.7-32 3.8-32 3.9-32 3.10-32 3.11-32 3.12-32 3.13-32
In x64 Native Tools Command Prompt for VS 2022
:
build-wheels.bat 3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13
This gives a set of wheels in dist\
.
Compatibility note
This building scheme above should be the safest one to use. In practice, many
of the resulting wheels seem to be forwards- and backwards-compatible.
Making a new release
-
Bump the version number in
setup.py
according to the Semantic versioning. -
Create a Git tag for the release:
git tag -s -m "windows-curses 1.2.3" v1.2.3 git push upstream v1.2.3
For pre-releases, add
aNUMBER
after the release name (e.g.v1.2.3a1
,v1.2.3a2
, …). -
Create a GitHub release
from the tag.The name of the GitHub release should match the name of the release tag (e.g.
v1.2.3
) and its
body should contain a brief release note.
Once a GitHub release is created, the GitHub Actions CI will automatically build and upload the
wheels to the PyPI.
Uploading to PyPI
NOTE: The process of uploading wheels for releases is automated using the GitHub Actions and
manual uploads should not be necessary under normal circumstances.
Don’t forget to bump the version number in setup.py
before building new
wheels. Semantic versioning is intended.
Once the wheels are built, follow the instructions
here
to upload them to PyPI.
pip
/PyPI will look at the wheel metadata and automatically install the right
version of the wheel.
Adding support for a new Python version
-
Create a new directory
pyXY
for the Python version X.Y (e.g.py39
for
Python 3.9). -
Copy
Modules/_cursesmodule.c
andModules/_curses_panel.c
from the
CPython source code topyXY/_cursesmodule.c
andpyXY/_curses_panel.c
,
respectively. -
Apply the following PDCurses compatibility patches:
- https://github.com/zephyrproject-rtos/windows-curses/commit/b1cf4e10cecb9ba3e43766407c2ed2b138571f85
- https://github.com/zephyrproject-rtos/windows-curses/commit/30ca08bfbcb7a332228ddcde026181b2009ea0a7
- https://github.com/zephyrproject-rtos/windows-curses/commit/3e4fa8c6427483641300efb21a3e9af78b146c83
-
Run
Tools/clinic/clinic.py
script from the CPython source code on
pyXY/_cursesmodule.c
andpyXY/_curses_panel.c
in order to generate the
respective header files underpyXY/clinic/
. -
Add the build specifications for the new Python version in
.github/workflows/ci.yml
.
In practice, Modules\_cursesmodule.c
from newer Python 3 versions is likely
to be compatible with older Python 3 versions too. The Python 3.6 and 3.7
wheels are currently built from identical _cursesmodule.c
files (but not the
Python 3.8 or 3.9 wheels).
This tutorial provides a step-by-step guide on how to install the Curses module in Python. As a Python developer, it’s quite essential to master the art of handling various Python modules.
The Curses library in Python is a very handy module used for creating text-based User Interfaces. Therefore, knowing how to install and utilize this module can take your Python programming skills to another level.
Step 1: Check Your Python Version
Before the installation process, it’s important to check the version of Python in use. This can be done by opening the Terminal and typing the command:
Step 2: Install the ‘ncurses’ Library
For the Curses module to work properly, it’s crucial to check if you have ncurses installed in your system. Ncurses is a library that facilitates the creation of text-based user interfaces. To install it, in your terminal, use the command:
sudo apt—get install libncurses5—dev libncursesw5—dev |
Step 3: Install the ‘Curses’ Module
After you’ve installed the ncurses library, you can now easily install the Curses module. This can be done by using the following command on the Terminal or command prompt:
pip install windows—curses |
For Python3 specifically, use the following:
pip3 install windows—curses |
Step 4: Verify the Installation
To ensure that the installation process is successful, you can write a simple Python program that uses the Curses module.
import curses stdscr = curses.initscr() curses.noecho() curses.cbreak() stdscr.keypad(True) try: stdscr.addstr(«Hello, world!») stdscr.refresh() stdscr.getch() finally: curses.endwin() |
Save this code in a file and run it. If you see the string “Hello, world!” displayed without any errors, it indicates the Curses module has been installed successfully.
Conclusion
In this tutorial, we have learned how to install the Curses module in Python. It’s quite crucial to ensure that the installation process happens correctly to enjoy the wide range of functionalities offered by the Curses module.
Ever wanted to make cool text-based games or apps right in your terminal?
Have you ever wondered how some programs manage to create interactive interfaces right in your terminal? It’s not just plain text scrolling by; it’s something more dynamic, something… magical. A big part of that magic often comes from a library called curses. But here’s the thing: getting curses set up with Python, especially on Windows, can sometimes feel like trying to solve a puzzle with missing pieces. People often think it’s super complicated, but it doesn’t have to be! Knowing how to install curses for Python is actually pretty straightforward once you understand the basics. I mean, sure, there can be a few bumps along the road, but nothing you can’t handle. So, let’s clear up the confusion and get you started on your terminal-based adventure.
Curses is basically a library that lets you control the layout and content of your terminal screen. Think of it as a way to draw shapes, display text at specific locations, and handle keyboard input, all within the command line. It’s like having a mini graphical user interface (GUI) but without the actual graphics. This is incredibly useful for creating things like text-based games, system monitoring tools, or even just more interactive command-line applications.
In this guide, I’m gonna walk you through how to get curses installed and working with Python, no matter what operating system you’re using. We’ll cover the common pitfalls and how to avoid them, so you can start building your own awesome terminal-based creations. And trust me, once you get the hang of it, you’ll be amazed at what you can do. It’s a little bit like unlocking a secret level in your terminal.
By the end of this article, you’ll not only know how to install curses, but you’ll also have a basic understanding of how it works and some ideas for what you can build with it. I mean, who knows? Maybe you’ll be the next big thing in terminal-based software! Let’s get started, shall we?
So, let’s see what is Curses and why it’s so cool, then jump into how to get it installed on different operating systems, and I’ll even throw in some simple examples to get you started, and you’ll be creating your own terminal masterpieces in no time, I promise.
This is what we’re going to cover:
- What is Curses?
- Why use Curses?
- Installing Curses on Windows
- Installing Curses on macOS
- Installing Curses on Linux
- Basic Curses example
What is curses and why should I care?
Okay, so what is curses, anyway? Well, in simple terms, curses is a library that lets you create text-based user interfaces (TUI) in your terminal. Think of it as a way to draw on the screen, move text around, and respond to user input, all without needing a graphical window. It’s like having a canvas inside your command line.
Originally, curses was developed for Unix-like systems, but it’s been adapted to work on other platforms, including Windows. It provides a set of functions that allow you to manipulate the terminal display, create windows, display text in different colors and styles, and handle keyboard input. It’s kinda like the OG way to make interactive terminal applications.
Why should you care? Well, if you’re into making command-line tools or text-based games, curses can be a game-changer. It lets you create interfaces that are much more user-friendly than just printing lines of text. Plus, it’s a fun way to learn about terminal programming and how to interact with the system at a low level.
Why use Curses?
So, why bother with curses when we have fancy graphical interfaces and web apps? Well, there are a few good reasons:
- Simplicity: Curses is relatively simple to learn and use, especially compared to GUI frameworks. It’s a great way to get started with UI programming without getting bogged down in complex concepts.
- Portability: Curses is available on most Unix-like systems and even on Windows, so your programs can run on a wide range of platforms without modification.
- Efficiency: Curses applications are typically very lightweight and efficient, as they don’t require a graphical environment. This makes them ideal for systems with limited resources or for tasks where performance is critical.
- Accessibility: Text-based interfaces can be more accessible to users with disabilities, as they can be used with screen readers and other assistive technologies.
Plus, there’s a certain retro charm to curses-based applications. They remind us of the good old days of computing, when everything was done in the terminal. It’s kind of a cool way to pay homage to the past while still creating something useful today.
Installing Curses on Windows
Okay, let’s get down to business. Installing curses on Windows can be a bit tricky, because the standard Python distribution doesn’t include it. But don’t worry, there’s a solution: windows-curses. This is a package that provides curses functionality for Windows, and it’s pretty easy to install using pip.
First, make sure you have Python installed. I’m assuming you do, but if not, go download it from the official Python website. You’ll also need pip, which usually comes with Python these days. If you’re not sure, open a command prompt and type pip --version
. If it shows you the version number, you’re good to go. If not, you might need to install it separately.
Now, open a command prompt (or PowerShell, if you prefer) and type the following command:
python -m pip install windows-curses
This will download and install the windows-curses
package from PyPI (PyPI). Pip is pretty smart about figuring out which version of the package you need, so you usually don’t have to worry about specifying the version number.
If you get an error message, it could be due to a few things. Make sure you have the latest version of pip by running:
python -m pip install --upgrade pip
Also, make sure your Python installation is in your system’s PATH environment variable. This allows you to run Python and pip commands from anywhere in the command prompt. You can usually set this up during the Python installation process, but if you skipped it, you might need to add it manually.
Once the installation is complete, you can test it out by importing the curses
module in a Python script. If it works without any errors, you’re all set! If not, double-check your installation and make sure everything is configured correctly.
A little quirk to watch out for
Now, here’s a little quirk that you might encounter when using windows-curses
. According to PyPI, resizing the terminal window might not work correctly out of the box. To fix this, you need to call curses.resize_term(0, 0)
after receiving the KEY_RESIZE
event. This is a bit of a hack, but it seems to do the trick.
Here’s how you can do it in your code:
import curses
def main(stdscr):
stdscr.clear()
stdscr.refresh()
while True:
key = stdscr.getch()
if key == curses.KEY_RESIZE:
try:
curses.resize_term(0, 0)
stdscr.clear()
stdscr.refresh()
except curses.error:
pass
elif key == ord('q'):
break
curses.wrapper(main)
This code snippet shows how to catch the KEY_RESIZE
event and call curses.resize_term(0, 0)
to handle the resize. The try...except
block is there to catch any curses.error
exceptions that might occur. It’s not the prettiest solution, but it works, and that’s what matters.
I remember one time I spent hours trying to figure out why my terminal application wasn’t resizing properly on Windows. It turned out I had forgotten to add this little hack. Once I added it, everything worked like a charm. So, don’t forget this tip!
Installing Curses on macOS
Installing curses on macOS is usually much simpler than on Windows. That’s because curses is included in the base system, so you don’t need to install any extra packages. However, you might need to make sure that the Python version you’re using is configured to use the system’s curses library.
First, open a terminal and check which Python version you’re using by typing python --version
or python3 --version
. Make sure it’s the version you want to use with curses.
If you’re using the system’s default Python version, you should be able to import the curses
module without any issues. Just open a Python interpreter and type import curses
. If it works, you’re good to go.
If you’re using a different Python version (e.g., installed via Homebrew or Anaconda), you might need to install the ncurses
package. This package provides the necessary headers and libraries for curses to work correctly. You can install it using Homebrew:
brew install ncurses
After installing ncurses
, you might need to recompile your Python version to link against the new library. This is usually done automatically when you install Python via Homebrew, but if you’re using a different installation method, you might need to do it manually. I’m not gonna get into the details of recompiling Python here, as it’s a bit beyond the scope of this article. But if you’re having trouble, you can find plenty of resources online.
Once you’ve installed ncurses
and recompiled Python (if necessary), you should be able to import the curses
module without any problems. If you’re still having trouble, make sure your environment variables are set up correctly and that your Python version is configured to use the correct libraries.
Dealing with Terminal.app issues
One thing to watch out for on macOS is that the default Terminal.app might have some issues with curses. Some users have reported that certain curses features don’t work correctly in Terminal.app. If you encounter any problems, you might want to try using a different terminal emulator, such as iTerm2. I’ve heard good things about it, and it seems to play nicer with curses.
I remember switching to iTerm2 a while back, and it made a huge difference in my terminal experience. Everything just seemed to work better, including curses. So, if you’re having trouble with Terminal.app, give iTerm2 a try. It might just solve your problems.
Installing Curses on Linux
Installing curses on Linux is usually the easiest of all, because curses is almost always included in the base system. You typically don’t need to install any extra packages or configure anything. Just open a terminal and start coding!
Most Linux distributions come with curses pre-installed, so you should be able to import the curses
module without any issues. Just open a Python interpreter and type import curses
. If it works, you’re good to go.
If, for some reason, curses is not installed on your system, you can usually install it using your distribution’s package manager. For example, on Debian-based systems (like Ubuntu), you can use apt:
sudo apt-get install libncurses5-dev
On Red Hat-based systems (like Fedora), you can use yum:
sudo yum install ncurses-devel
These commands will install the necessary headers and libraries for curses to work correctly. After installing the package, you should be able to import the curses
module without any problems.
If you’re using a different distribution, consult its documentation to find the appropriate package name and installation command. But in most cases, you won’t need to do anything at all. Curses is just there, ready to go.
A word about different distributions
One thing to keep in mind is that different Linux distributions might have slightly different versions of curses or different ways of configuring it. If you encounter any issues, it’s always a good idea to consult your distribution’s documentation or online forums. There’s usually someone who has encountered the same problem and found a solution.
I’ve used curses on several different Linux distributions over the years, and I’ve rarely had any problems. But I did encounter one issue on a very old version of Debian once. It turned out that the curses library was installed in a non-standard location, so I had to set some environment variables to tell Python where to find it. It was a bit of a pain, but I eventually got it working. So, don’t be afraid to dig around and experiment if you encounter any issues.
Basic Curses example
Alright, now that you’ve got curses installed, let’s try a simple example to see how it works. This example will create a window, display some text, and wait for a key press.
Here’s the code:
import curses
def main(stdscr):
# Clear the screen
stdscr.clear()
# Add some text
stdscr.addstr(0, 0, "Hello, curses!")
# Refresh the screen
stdscr.refresh()
# Wait for a key press
stdscr.getkey()
curses.wrapper(main)
Let’s break down this code:
import curses
: This imports the curses module, so you can use its functions.def main(stdscr):
: This defines the main function that will be executed by curses. Thestdscr
argument represents the standard screen object, which is the main window of your application.stdscr.clear()
: This clears the screen, so you start with a clean slate.stdscr.addstr(0, 0, "Hello, curses!")
: This adds the text «Hello, curses!» to the screen at position (0, 0), which is the top-left corner.stdscr.refresh()
: This refreshes the screen, so the text becomes visible.stdscr.getkey()
: This waits for a key press and returns the key that was pressed.curses.wrapper(main)
: This is a helper function that initializes curses, calls your main function, and then deinitializes curses when your function is finished. It ensures that the terminal is properly restored when your program exits.
To run this code, save it to a file (e.g., hello.py
) and then run it from the command line:
python hello.py
You should see a window with the text «Hello, curses!» in the top-left corner. Press any key to exit the program.
This is just a simple example, but it shows the basic structure of a curses program. You can use these functions to create more complex interfaces, add colors, handle keyboard input, and much more.
More advanced example
Now, let’s try a more advanced example that shows how to create windows, add colors, and handle keyboard input. This example will create a window with a border, display some text in different colors, and allow the user to move the text around using the arrow keys.
Here’s the code:
import curses
def main(stdscr):
# Initialize colors
curses.start_color()
curses.use_default_colors()
curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK)
curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK)
curses.init_pair(3, curses.COLOR_YELLOW, curses.COLOR_BLACK)
# Create a window
window = curses.newwin(10, 30, 5, 5)
window.border()
# Add some text
text = "Hello, curses!"
x = 1
y = 1
window.addstr(y, x, text, curses.color_pair(1))
# Refresh the window
window.refresh()
# Handle keyboard input
while True:
key = window.getch()
if key == curses.KEY_LEFT:
x -= 1
elif key == curses.KEY_RIGHT:
x += 1
elif key == curses.KEY_UP:
y -= 1
elif key == curses.KEY_DOWN:
y += 1
elif key == ord('q'):
break
# Clear the window
window.clear()
window.border()
# Add the text at the new position
window.addstr(y, x, text, curses.color_pair(1))
# Refresh the window
window.refresh()
curses.wrapper(main)
This code is a bit more complex, but it shows some of the more advanced features of curses. Let’s break it down:
curses.start_color()
: This initializes the color system.curses.use_default_colors()
: This tells curses to use the terminal’s default colors.curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK)
: This defines a color pair with ID 1, which consists of red text on a black background.window = curses.newwin(10, 30, 5, 5)
: This creates a new window with a height of 10, a width of 30, and a position of (5, 5) on the screen.window.border()
: This adds a border around the window.window.addstr(y, x, text, curses.color_pair(1))
: This adds the text to the window at position (y, x) with the color pair 1 (red text on a black background).- The
while
loop handles keyboard input. If the user presses the arrow keys, the text is moved around the window. If the user presses ‘q’, the program exits.
This example shows how to create windows, add colors, and handle keyboard input. You can use these techniques to create much more complex and interactive terminal applications. The possibilities are endless!
Wrapping things up
So, that’s it! You’ve learned how to install curses for Python on Windows, macOS, and Linux. You’ve also seen some basic examples of how to use curses to create text-based user interfaces. I hope this guide has been helpful and that you’re now ready to start building your own awesome terminal-based creations. It’s a fun and rewarding way to explore the world of programming, and you might be surprised at what you can achieve with just a little bit of code.
Remember, curses is a powerful tool that can be used to create a wide range of applications, from simple text-based games to complex system monitoring tools. Don’t be afraid to experiment and try new things. The more you play around with it, the better you’ll get. And who knows? Maybe you’ll be the next big thing in terminal-based software!
FAQ
- Is curses difficult to learn?
- Not really! Curses has a bunch of functions, but the basic idea is simple: you’re just moving text around on a screen and reacting to what the user types. Start with small projects, and you’ll get the hang of it pretty quickly. Plus, there are tons of resources online if you get stuck.
- Can I use curses to create graphical interfaces?
- Well, not exactly. Curses is for text-based interfaces, so you won’t be drawing any fancy graphics. But you can use characters to create simple shapes and visual effects. It’s all about being creative with text. Think of it as ASCII art on steroids.
- Why doesn’t curses come pre-installed on Windows?
- That’s a good question! The original curses library was designed for Unix-like systems, and Windows has a different way of handling terminal input and output. So, someone had to create a separate version of curses for Windows, which is why we have the
windows-curses
package. It’s kind of a workaround, but it works pretty well. - Are there any alternatives to curses?
- Yep, there are a few alternatives to curses, but they each have their own pros and cons. One popular option is urwid, which is a more high-level library that provides a widget-based approach to creating terminal interfaces. It’s more powerful than curses, but it’s also more complex to learn. Another option is blessed, which is a simpler library that focuses on providing a clean and easy-to-use API for terminal manipulation. It’s a good choice if you want something lightweight and straightforward. Ultimately, the best choice depends on your specific needs and preferences.
- Can I use curses with other programming languages besides Python?
- Absolutely! Curses is a C library, so it can be used with many different programming languages, including C, C++, Python, Perl, and more. Each language has its own bindings for curses, which provide a way to access the curses functions from that language. So, if you’re not a Python fan, you can still use curses with your favorite language.
- Is curses still relevant in today’s world of graphical interfaces?
- Believe it or not, curses is still used in a lot of places! Many system administrators and developers prefer terminal-based tools for their efficiency and simplicity. Plus, curses is great for creating command-line utilities, text-based games, and other applications where a graphical interface isn’t necessary or desirable. So, while it might not be as flashy as a modern GUI, curses still has its place in the world.
References
PyPI (https://pypi.org/).