Skip to main content

A small Python package for rotating the screen.

Project description

Rotate Screen

PyPI - Python Version PyPI - Downloads GitHub

Platforms Supported

Windows is currently the only platform supported.

Installation

Clone the repo, download as a zip file, or use the following command...

pip install rotate-screen

Documentation

The package comes with some functions to get available displays in the form of <rotatescreen Display> objects. You can then use the <rotatescreen Display> object methods to change the orientation of the display.

Here are a few of the available package functions...

Function Returns
rotatescreen.get_displays() Returns a list of <rotatescreen Display> objects for each available display.
rotatescreen.get_secondary_displays() Returns a list of <rotatescreen Display> objects for every display apart from the primary display.
rotatescreen.get_primary_display() Returns a <rotatescreen Display> object for the primary display.

Here are the available methods (no return value) for a <rotatescreen Display> object...

Procedure Arguments Result
.rotate_to(pos) pos (int): Degrees to rotate the screen to. Must be one of 0, 90, 180, 270. Rotates the screen to desired.
.set_landscape() Rotates the screen to landscape.
.set_landscape_flipped() Rotates the screen to upside down landscape.
.set_portrait() Rotates the screen to portrait.
.set_portrait_flipped() Rotates the screen to upside down portrait.

Here are the available attributes for a <rotatescreen Display> object...

Attribute Returns
.current_orientation Returns (int) the current orientation of the display, will be one of 0, 90, 180, 270.
.is_primary Returns (bool) if the display is the primary monitor.
.info Returns (dict) monitor info.
.device Returns monitor device info.
.device_description Returns (str) visable name for display device.

Example: Ctrl+Alt+Arrow Shortcut

This is a simple example that implements the 'Ctrl+Alt+Arrow' keyboard shortcut for rotating the display. This is because some graphics cards don't come with this capability by default.

This example requires the keyboard module...

pip install keyboard

Here is the code! It adds hotkeys to rotate the primary display in the desired direction upon the user entering Ctrl, Alt and an arrow key. It then waits until the script is exited.

import rotatescreen
import keyboard

screen = rotatescreen.get_primary_display()

keyboard.add_hotkey('ctrl+alt+up', screen.set_landscape, suppress=True)
keyboard.add_hotkey('ctrl+alt+right', screen.set_portrait_flipped, suppress=True)
keyboard.add_hotkey('ctrl+alt+down', screen.set_landscape_flipped, suppress=True)
keyboard.add_hotkey('ctrl+alt+left', screen.set_portrait, suppress=True)

keyboard.wait()

Example: Do A Barrel Roll

This was a little joke script to show off some more of the modules functionality, due to the way windows rotates the display this is a pretty horrific looking, but entertaining. :)

import rotatescreen
import time

screen = rotatescreen.get_primary_display()
start_pos = screen.current_orientation

for i in range(1, 5):
    pos = abs((start_pos - i*90) % 360)
    screen.rotate_to(pos)
    time.sleep(1.5)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rotate-screen-0.1.4.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rotate_screen-0.1.4-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file rotate-screen-0.1.4.tar.gz.

File metadata

  • Download URL: rotate-screen-0.1.4.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for rotate-screen-0.1.4.tar.gz
Algorithm Hash digest
SHA256 2e9ffb324ba428166c69ab77554a667c0102ee1e248a9e9239f2d0a67c7942c2
MD5 e8bdded906a46e116b53080b54320dde
BLAKE2b-256 3e93957583a55057ebc1723be2d98a4c4b17d91ae5303db27f23db59e32487a7

See more details on using hashes here.

File details

Details for the file rotate_screen-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: rotate_screen-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for rotate_screen-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e715dfe98ec55b60bfbbe1bcec6dbd43f1d0af4ba7bd8f03bad2863d43033180
MD5 95aaa9e5d1ae60b21809383f675a7afe
BLAKE2b-256 599cf7f8db5c76522fa5aa2705c35bb7adc1fa122bb74b98387785e04a8908e5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page