Javatpoint Logo
Javatpoint Logo

Screen Rotation GUI Using Python Tkinter

In this module, we will create a Python code for rotating the screen and put it into use with a GUI.

Using some of the functions from the rotatescreen module, a simple Python library for rotating the screen in a system, the display may be changed to four orientations.

Installing rotate-screen :

Walking through the code :

Step 1 :

Importing all the packages from the Python library in order to use them in our code. So, we imported Tkinter and rotatescreen.

Step 2 :

Creating a function Scr_Rotation() to be used for calling where the screen needs to be rotated. Also, we created a variable called scr to store and detect the default screen orientation.

Step 3 :

Under the Scr_Rotation() function, we will now introduce the different methods to change the orientation of the screen. To rotate the screen upwards, we will use the set_Landscape() method. To rotate the screen rightwards, we will use the set_portrait_flipped() method. To rotate the screen downwards, we will use the set_Landscape_flipped() method. To rotate the screen leftwards, we will use the set_portarait() method.

Step 4 :

Finally, we will create the buttons for each of these orientations. Clicking on these buttons, the orientation will be changed.

The rest of the general widgets are explained along the code itself in the program.

Complete Code :


The screenshot of the output of the code jotted above is given below. The orientation can be changed by clicking on these buttons, in whichever way the user wants.

Screen Rotation GUI Using Python Tkinter

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA