To Display Images in Full-Screen by PySide


Recently, I started Python programming to make applications on multi-platform. I selected “PySide” as a GUI library, and have been having trial and error in various ways. From those, I would like to post articles as a result of playing my particular interest. This time, I will describe how to display image in the full screen.

In addition, although 2.x mainstream is still Python, because movement to migrate to 3.x is likely to be activated in the future and 3.x is suitable to support Japanese language, I am programming in Python3.3. Therefore, please note the following code does not take into account any operation in 2.x.

Display an Image

First, I’ll try to make a code to display an image in PySide. You will see the JPEG file called “hoge.jpg”.

Read the image by the “QPixmap” object, set it to “QLabel” object by “setPixmap()” and display it by “show()” method. Although you would think that “label” is for displaying “text”, “QLabel” will function as a screen for image and text.

Window appears on the desktop as follows.

Display Image in Full Screen

By changing “show()” to “showFullScreen()” in line 8, you can achieve the full-screen display.

It is displayed in full screen as follows. There is no frame of the window.

However, “close button” does not appear in full screen state. You will need to be able to release the full screen by handling the key event. (If you happen to display in full screen without any measures, switch to another task by ALT + TAB, and then you can close the application from the taskbar.)

Get the Key Events of QLabel

“QLabel”, as one of the parts of GUI, is inherit “QWidget”. It has the method “keyPressEvent” to handle the key events.

Define a class called “Screen” that inherits from “QLabel”, then you are going to be able to handle the ESC key to override the “keyPressEvent”.

If you press the ESC key, display is switched in maximum display / full screen. Please note that in order to return to the normal display, you’re calling the “showNormal()”.

By using this “Screen” class instead of QLabel, you will respond to the ESC key.

If you press the ESC key in the state of being full screen display, display change to maximum as shown below. If in this state, you will be able to terminate the program in close button.

The way of the adjustment of display position, please refer to the reference of “QLabel”.

In addition, since I have prepared here the complete code. Prepare a “hoge.jpg” and try it.

[Rlated Sites]
junf/PySideSamples · GitHub

[Rlated Articles]

  1. Display Images in Full-Screen by Qt, Multi-Platform GUI Lib | DeVlog – Fly With Your Devil’s Wings –
  2. Behavior of “geometry” Property and “show” Method in PySide | DeVlog – Fly With Your Devil’s Wings –
  3. Display Image While Sliding by PySide | DeVlog – Fly With Your Devil’s Wings –
  4. Fade in / Fade-out Images by PySide | DeVlog – Fly With Your Devil’s Wings –
  5. Realize Zoom-in and Zoom-out the Image in PySide | DeVlog – Fly With Your Devil’s Wings –

JDK and Android SDK Installation on Ubuntu

I’ve been developing Android application on Windows. But recently, I tried to create an environment in Linux (Ubuntu/Xubuntu). In this article, I will describe the installation of JDK and Android SDK that is required before installing IDE. (It is assumed that without the use of ADT Bundle, we install separately JDK/SDK and IDE.)

Installation of JDK

JDK is updated frequently. So I looked for package management. Then I found that Oracle Java (JDK) 6 / 7 / 8 Installer PPA : “WebUpd8” team provides PPA. This PPA downloads and run the Oracle installer.

Install as follows. Along the way, you are prompted to agree to Oracle license. Then agree.

In the last line, you are sure the installation was successful.
At the result, in my environment, the JDK is installed in /usr/lib/jvm/java-7-oracle.

Installation of Android SDK

Following Android SDK | Android Developers, I have installed the Android SDK.

  1. First, there is the following entry in SYSTEM REQUIREMENTS – Linux.

    64-bit distributions must be capable of running 32-bit applications.

    My Environment is 64bit-Xubuntu. So I installed ia32-libs. (It is not necessary for 32bit OS.)

  2. Next, from DOWNLOAD FOR OTHER PLATFORMS, download Linux 32 & 64-bit package. (Suppose /home/hoge/Downloads/android-sdk_r21.1-linux.tgz)
    * Currently, there is a package called ADT Bundle environment, including Eclipse. However, in this article, it is assumed that you install IDE separately.
  3. In the home directory, make appropriate directory (here, suppose “Development”), and extract files there.

  4. It is useful to make a path to “tools” directory. So add the following line in ~/.bashrc.

    In order to apply the path, do the following.

  5. Update the SDK. (Because SDK for all platform will be downloaded, it will take a lot of time.)

  6. Start the SDK Manager to check the results. (In my environment, the sources has not been downloaded. So I downloaded them.)

  7. For other commands for android, check with –help option.

After this, you can set up favorite IDE, such as IntelliJ or Eclipse, and start development.

[Reference Sites]

[Relative articles]

Migrating Android Dev’s IDE from Eclipse to IntelliJ(2)

In the previous article, I described the installation and basic configuration of IntelliJ IDEA. Android development is ready now. Then I will describe how to use it actually.

Creating a New Project

When you click “Create New Project” in Welcome screen, “New Project” window opens. Select “Application Module” in “Android” section, and specify “Project name” and “Project Location”, then press “Next”.


Enter “Application name”, “Package name” and other requried matters. Then press “Finish”.
Wait for a while, after the Tip of the Day, the project will start.

Importing an Existing Project

If you want to import an existing project, by “Import Project”, specify the folder that contains the source project and ther matters required settings. (If Eclipse project and there is “.project” file, by “Open Project”, you can import it by sepecifying the “.project” file. However, “Import Project” is more useful because you can specify the matters in detail. )

Setting “.gitignore”

If you want to manage the project in Git, you need to place “.gitignore” appropriate for your development environment. You can use gitignore/Android.gitignore at master · github/gitignore · GitHub. You can also refer to Log folder of Proguard and .gitignore on IntelliJ | DeVlog.

Open Project Folder

You can click the “Project” in the upper left to open the project folder.
From here you will be able to open the source files, such as.folder_compressed

Use SDK/AVD Manager

From the “Tools” menu, you can call “Android SDK Manager” or “AVD Manager”.

Run Application

From the “Run” menu, you can run the application.

Export Signed APK

To exprot signed APK, from the “Build” menu, click “Generate Signed APK …”.

Specify or create the path of keystore, password, and key alias.

I think you got a clue if you know above. At first, there may be a confusion. Please developing with reference also Getting Help .

[Reference Articles]