如何在手机版 Ubuntu 上运行 PyQt 程序?

如何在手机版 Ubuntu 上运行 PyQt 程序?

我有一个小的 PyQt 程序,我想将其安装在 Ubuntu 手机上。它是一个简单的切换按钮 GUI,用于将手机设置为分阶段或窗口模式。如何做到这一点?

#!/usr/bin/python3
# -*- coding: utf-8 -*-

from PyQt5.QtWidgets import (
    QWidget,
    QToolTip, 
    QPushButton,
    QApplication,
    QVBoxLayout
)
from PyQt5.QtGui import QFont
import subprocess
import sys

def main():

    application = QApplication(sys.argv)
    window = Window()
    sys.exit(application.exec_())

class Window(QWidget):

    def __init__(self):
        super().__init__()

        self.initUI()

    def __init__(self):
        super(Window, self).__init__()
        self.button = QPushButton("toggle windowed/staged", self)
        self.button.clicked.connect(self.button_action)
        layout = QVBoxLayout(self)
        layout.addWidget(self.button)
        self.show()

    def button_action(self):
        toggle_status = engage_command(
            command = "gsettings get com.canonical.Unity8 usage-mode"
        ).strip("'")
        if toggle_status == "staged":
            engage_command("gsettings set com.canonical.Unity8 usage-mode Windowed")
        elif toggle_status == "windowed":
            engage_command("gsettings set com.canonical.Unity8 usage-mode Staged")

def engage_command(
    command = None
    ):
    process = subprocess.Popen(
        [command],
        shell      = True,
        executable = "/bin/bash")
    process.wait()
    output, errors = process.communicate()
    return output

if __name__ == "__main__":
    main()

相关内容