Kalmat / PyMonCtl

Cross-Platform module which provides a set of features to get info on and control monitors/screens/displays.
BSD 3-Clause "New" or "Revised" License
5 stars 3 forks source link

ValueError: _type_ 'v' not supported #7

Closed saifeiLee closed 1 year ago

saifeiLee commented 1 year ago

Environment

python 3.8.2

Operation

Run tests with:

python tests/test_pymonctl.py 

The output

Traceback (most recent call last):
  File "tests/test_pymonctl.py", line 8, in <module>
    import pymonctl as pmc
  File "/home/seewo/.local/lib/python3.8/site-packages/pymonctl/__init__.py", line 22, in <module>
    from ._main import (getAllMonitors, getAllMonitorsDict, getMonitorsCount, getPrimary,
  File "/home/seewo/.local/lib/python3.8/site-packages/pymonctl/_main.py", line 11, in <module>
    from ._structs import DisplayMode, ScreenValue, Size, Point, Box, Rect, Position, Orientation
  File "/home/seewo/.local/lib/python3.8/site-packages/pymonctl/_structs.py", line 5, in <module>
    import ctypes.wintypes
  File "/usr/lib/python3.8/ctypes/wintypes.py", line 20, in <module>
    class VARIANT_BOOL(ctypes._SimpleCData):
ValueError: _type_ 'v' not supported
Kalmat commented 1 year ago

Hi! Thank you for your feedback!

I think the problem of wintypes crashing in other OSs apart from Windows is solved in Python 3.10 so, just updating your Python version it should work ok. I might be wrong, never the less. Ayway, it will be fixed in next PyMonCtl version.

Just curious: which OS (and Desktop Manager in case of Linux) are you using?

Thank you again!

saifeiLee commented 1 year ago

Hi! Thank you for your feedback!

I think the problem of wintypes crashing in other OSs apart from Windows is solved in Python 3.10 so, just updating your Python version it should work ok. I might be wrong, never the less. Ayway, it will be fixed in next PyMonCtl version.

Just curious: which OS (and Desktop Manager in case of Linux) are you using?

Thank you again!

Thanks for reply. My Linux OS is ubuntu 22.04. And It is indeed that python 3.10 has fix this problem. By the way, how will you fix it? I am curious.

Kalmat commented 1 year ago

Great!

To avoid crashing in previous versions, you only have to ask for the platform you are in before importing and using it, like this:

if sys.platform == "win32":
    import ctypes.wintypes

    class _POINTL(ctypes.Structure):
        _fields_ = [
            ('x', ctypes.wintypes.LONG),
            ('y', ctypes.wintypes.LONG)
        ]
saifeiLee commented 1 year ago

Cool