ponty / pyscreenshot

Python screenshot library, replacement for the Pillow ImageGrab module on Linux.
BSD 2-Clause "Simplified" License
502 stars 88 forks source link

can not support PySide #36

Closed Kyson closed 7 years ago

Kyson commented 7 years ago

it will be better if support PySide :+1:

ponty commented 7 years ago

Do you have some PySide code?

Kyson commented 7 years ago

sorry for late reply it works well when i change to pyqt , and the code is same as pyqt's exclude "import"

#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys

from PyQt4 import QtCore
from PyQt4.QtCore import Qt
from PyQt4.QtGui import QApplication
from PyQt4.QtGui import QLabel
from PyQt4.QtGui import QPushButton
from PyQt4.QtGui import QVBoxLayout
from PyQt4.QtGui import QWidget

class RmCmdApplication(QWidget):
    app = QApplication(sys.argv)

    def __init__(self):
        QWidget.__init__(self)
        # self.server_thread = ServerThread()
        self.status_bar = QLabel()
        self.start_btn = QPushButton(u"开始")
        self.stop_btn = QPushButton(u"停止")
        self.container = QVBoxLayout()

    def setup(self):
        self.setWindowTitle(u"远程遥控服务")
        self.setMinimumWidth(200)
        self.setMinimumHeight(200)
        self.setMaximumWidth(200)
        self.setMaximumHeight(200)
        self.container = QVBoxLayout()
        self.start_btn.setFixedHeight(40)
        self.stop_btn.setFixedHeight(40)
        self.connect(self.start_btn, QtCore.SIGNAL('clicked()'),
                     self.start_server)
        self.connect(self.stop_btn, QtCore.SIGNAL('clicked()'),
                     self.stop_server)
        self.status_bar.setAlignment(Qt.AlignLeft)
        self.status_bar.setFixedHeight(30)
        self.container.addWidget(self.start_btn)
        self.container.addWidget(self.stop_btn)
        self.container.addWidget(self.status_bar)
        self.setLayout(self.container)

    def start_server(self):
        from rm_cmd.rmcmd_server import start_msg_server
        msg_result, msg_port = start_msg_server()
        from rm_cmd.rmcmd_server import start_file_server
        file_result, file_port = start_file_server()
        status = (u"消息服务运行中... 端口: %s" % msg_port) if msg_result else u"消息服务启动失败"
        status = status + "\n" + (u"文件服务运行中... 端口: %s" % file_port) if file_result else u"文件服务启动失败"
        self.set_status(status)

    def stop_server(self):
        from rm_cmd.rmcmd_server import stop_msg_server
        stop_msg_server()
        from rm_cmd.rmcmd_server import stop_file_server
        stop_file_server()
        self.set_status(u"已停止运行")

    def set_status(self, status):
        self.status_bar.setText(status)

    def main(self):
        self.show()
        RmCmdApplication.app.exec_()
        self.stop_server()
        sys.exit(0)

rmcmd_app = RmCmdApplication()
rmcmd_app.setup()
rmcmd_app.main()
ponty commented 7 years ago

Implemented.