python3+PyQt5实现窗口切分条

<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file alias="icon.png">images/icon.png</file>
<file alias="filenew.png">images/filenew.png</file>
<file alias="fileopen.png">images/fileopen.png</file>
<file alias="filesave.png">images/filesave.png</file>
<file alias="filesaveas.png">images/filesaveas.png</file>
<file alias="fileclose.png">images/filequit.png</file>
<file alias="filequit.png">images/filequit.png</file>
<file alias="editcut.png">images/editcut.png</file>
<file alias="editcopy.png">images/editcopy.png</file>
<file alias="editpaste.png">images/editpaste.png</file>
<file alias="editadd.png">images/editadd.png</file>
<file alias="editedit.png">images/editedit.png</file>
<file alias="editdelete.png">images/editdelete.png</file>
</qresource>
</RCC>

======
sudo pyrcc5 -o qrc_resources.py resources.qrc 生成qrc_resources.py

 

import sys
from PyQt5.QtCore import (QSettings, Qt,QByteArray)
from PyQt5.QtWidgets import (QAction, QApplication, QListWidget,
        QMainWindow, QSplitter, QTextBrowser)
from PyQt5.QtGui import QIcon
import qrc_resources


__version__ = "1.0.0"


class MainWindow(QMainWindow):

    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.groupsList = QListWidget()
        self.messagesList = QListWidget()
        self.messageView = QTextBrowser()

        self.messageSplitter = QSplitter(Qt.Vertical)
        self.messageSplitter.addWidget(self.messagesList)
        self.messageSplitter.addWidget(self.messageView)
        self.mainSplitter = QSplitter(Qt.Horizontal)
        self.mainSplitter.addWidget(self.groupsList)
        self.mainSplitter.addWidget(self.messageSplitter)
        self.setCentralWidget(self.mainSplitter)

        self.mainSplitter.setStretchFactor(0, 1)
        self.mainSplitter.setStretchFactor(1, 3)
        self.messageSplitter.setStretchFactor(0, 1)
        self.messageSplitter.setStretchFactor(1, 2)

        self.createMenusAndToolbars()

        settings = QSettings()
        if settings.value("MainWindow/Geometry") or \
                      settings.value("MainWindow/State") or \
                      settings.value("MainSplitter"):
            self.restoreGeometry(
                    QByteArray(settings.value("MainWindow/Geometry")))
            self.restoreState(
                    QByteArray(settings.value("MainWindow/State")))
            self.messageSplitter.restoreState(
                    QByteArray(settings.value("MessageSplitter")))
            self.mainSplitter.restoreState(
                    QByteArray(settings.value("MainSplitter")))

        status = self.statusBar()
        status.setSizeGripEnabled(False)
        status.showMessage("Ready", 5000)
        self.setWindowTitle("News Reader")
        self.generateFakeData()


    def createMenusAndToolbars(self):
        fileMenu = self.menuBar().addMenu("&File")
        fileToolbar = self.addToolBar("File")
        fileToolbar.setObjectName("FileToolbar")
        for icon, text in (("new", "&New..."), ("open", "&Open..."),
                ("save", "&Save"), ("save", "Save &As..."),
                (None, None), ("quit", "&Quit")):
            if icon is None:
                fileMenu.addSeparator()
            else:
                action = QAction(QIcon(":/file{0}.png".format(icon)),
                                 text, self)
                if icon == "quit":
                    action.triggered.connect(self.close)
                elif text != "Save &As...":
                    fileToolbar.addAction(action)
                fileMenu.addAction(action)

        editMenu = self.menuBar().addMenu("&Edit")
        editToolbar = self.addToolBar("Edit")
        editToolbar.setObjectName("EditToolbar")
        for icon, text in (("add", "&Add..."), ("edit", "&Edit..."),
                           ("delete", "&Remove")):
            action = QAction(QIcon(":/edit{0}.png".format(icon)),
                             text, self)
            editToolbar.addAction(action)
            editMenu.addAction(action)


    def closeEvent(self, event):
        if self.okToContinue():
            settings = QSettings()
            settings.setValue("MainWindow/Geometry",
                              self.saveGeometry())
            settings.setValue("MainWindow/State",
                              self.saveState())
            settings.setValue("MessageSplitter",
                    self.messageSplitter.saveState())
            settings.setValue("MainSplitter",
                    self.mainSplitter.saveState())
        else:
            event.ignore()


    def okToContinue(self):
        return True


    def generateFakeData(self):
        for group in ("ada", "apl", "asm.*", "asm370", "awk", "basic.*",
                "beta", "c.*", "c++.*", "clarion", "clipper.*", "clos",
                "clu", "cobol", "dylan", "eiffel", "forth.*",
                "fortran.*", "functional", "haskell", "hermes", "icon",
                "idl", "idl-pvwave", "java.*", "javascript", "labview",
                "limbo", "lisp.*", "logo", "misc", "ml.*", "modula2",
                "modula3", "mumps", "oberon", "objective-c", "pascal.*",
                "perl.*", "php.*", "pl1", "pop", "postscript",
                "prograph", "prolog", "python.*", "rexx.*", "ruby",
                "sathe", "scheme.*", "sigplan", "smalltalk.*", "tcl.*",
                "verilog", "vhdl", "visual.*", "vrml"):
            self.groupsList.addItem("comp.lang.{0}".format(group))
        for topic, author in (
                ("ANN: Einf\u00FChrung in die Programmierung mit Python",
                 "Ian Ozsvald",),
                ("SQLObject 0.7.3", "Oleg Broytmann",),
                ("ANN: Pyrex 0.9.5.1", "greg",),
                ("ANN: gozerbot IRC and JABBER bot", "bthate",),
                ("Extended deadline: CfP IEEE Software Special Issue on "
                 "Rapid Application Development with Dynamically Typed "
                 "Languages", "Laurence Tratt",),
                ("ANN: New python software community website in Chinese, "
                 "PythonNet.com", "Wenshan Du",),
                ("ANN: Plex 1.1.5 (Repost)", "greg",),
                ("ANN: Pyrex 0.9.5", "greg",),
                ("ftputil 2.2.1", "Stefan Schwarzer",),
                ("FlightFeather Social Networking Platform 0.3.1",
                 "George Belotsky",),
                ("OSCON 2007 Call for Participation Ends Soon",
                 "Kevin Altis",),
                ("ANN: tl.googlepagerank", "Thomas Lotze",),
                ("Dejavu 1.5.0RC1", "Robert Brewer",),
                ("PyCon: one week left for hotel registration",
                 "A.M. Kuchling",),
                ("FlightFeather Social Networking Platform 0.3.0",
                "George Belotsky",),
                ("SQLObject 0.8.0b2", "Oleg Broytmann",),
                ("SQLObject 0.7.3b1", "Oleg Broytmann",),
                ("ANN: Updated TkTreectrl wrapper module", "klappnase",),
                ("PyPy Trillke Sprints Feb/March 2007", "holger krekel",),
                ("wxPython 2.8.1.1", "Robin Dunn",),
                ("Movable Python 2.0.0 Final Available", "Fuzzyman",),
                ("ANN: Phebe 0.1.1", "Thomas Lotze",),
                ("Exception #03. Python seminar in Kiev city (Ukraine).",
                 "Mkdir",),
                ("FlightFeather Social Networking Platform 0.2.8",
                "George Belotsky",),
                ("ANN: Python Installation", "Ian Ozsvald",),
                ("ANN: pyGame Basics", "Ian Ozsvald",),
                ("PythonTidy 1.10", "Chuck Rhode",),
                ("Shed Skin Optimizing Python-to-C++ Compiler 0.0.10",
                 "Mark Dufour",),
                ("ANN : Karrigell 2.3.3", "Pierre Quentel",),
                ("ANN: amplee 0.4.0", "Sylvain Hellegouarch")):
            self.messagesList.addItem("{0} from {1}".format(topic, author))
        self.messageView.setHtml("""<table bgcolor=yellow>
<tr><td>Groups:</td><td>comp.lang.python.announce</td></tr>
<tr><td>From:</td><td>"Fuzzyman" &lt;fuzzy...@gmail.com&gt;</td></tr>
<tr><td>Subject:</td><td><b>[ANN] Movable Python 2.0.0 Final
Available</b></td></tr>
</table>

<h3>Movable Python 2.0.0 Final</h3>
<p>
<a href="http://www.voidspace.org.uk/python/movpy/">
http://www.voidspace.org.uk/python/movpy/</a>
is now available.

<p>
The new binaries are available for download from the groups page :

<p>Movable Python Groups Page
<a href="http://voidspace.tradebit.com/groups.php">
http://voidspace.tradebit.com/groups.php</a>
<p>
Binaries are uploaded for Python 2.2.3, 2.3.5, 2.4.4, 2.5 and the
MegaPack
<a href="http://www.voidspace.org.uk/python/movpy/megapack.html">
http://www.voidspace.org.uk/python/movpy/megapack.html</a>.
<p>
There is also a fresh version of the free demo, based on Python 2.3.5:

<p>Movable Python Trial Version
<a href="http://voidspace.tradebit.com/files.php/7007">
http://voidspace.tradebit.com/files.php/7007</a>

<h3>What is Movable Python</h3>

<p>
<b><i>Movable Python</i></b> is a distribution of Python, for Windows,
that can run without being installed. It means you can carry a full
development environment round on a USB stick.

<p>
It is also useful for testing programs with a 'clean Python install',
and testing programs with multiple versions of Python.

<p>
The GUI program launcher makes it a useful programmers tool, including
features like :

<ul>
<li>Log the output of all Python scripts run
<li>Enable Psyco for all scripts
<li>Quick Launch buttons for commonly used programs
<li>Configure multiple interpreters for use from a single interface
</ul>
<p>
It comes with the Pythonwin IDE and works fine with other IDEs like
SPE
<a href="http://developer.berlios.de/projects/python/">
http://developer.berlios.de/projects/python/</a>.
<p>
Plus many other features and bundled libraries.""")


if __name__ == "__main__":
    app = QApplication(sys.argv)
    app.setOrganizationName("Qtrac Ltd.")
    app.setOrganizationDomain("qtrac.eu")
    app.setApplicationName("News Reader")
    form = MainWindow()
    form.show()
    app.exec_()

 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
### 回答1: Python3是一种编程语言,它提供了很多库和框架可以用于各种应用开发。PyQt5Python3的一个GUI(图形用户界面)库,它允许我们创建各种图形界面应用程序。PyCharm是一个Python集成开发环境(IDE),它提供了丰富的功能和工具,可以方便地进行Python编程和应用程序开发。 在Python3中,我们可以使用PyQt5库来访问和控制摄像头。通过使用PyQt5的QCamera和QCameraViewfinder类,我们可以访问计算机上已连接的摄像头设备,并在应用程序中显示摄像头视频流。这样我们就能够在应用程序中捕捉摄像头的图像,并进行进一步的处理和分析。 PyCharm是一个非常流行的Python开发工具,它提供了许多有用的功能来帮助我们编写、调试和测试Python代码。在PyCharm中,我们可以直接编写Python代码,并使用其强大的代码编辑器和自动补全功能来提高编码效率。同时,PyCharm还提供了集成的调试器,可以方便地调试和跟踪代码的执行过程。 因此,如果我们想在Python3中使用PyQt5库来访问和控制摄像头,并且希望使用一个强大的开发工具来编写和调试代码,我们可以选择使用PyCharm作为我们的开发环境。PyCharm提供了直观的界面和丰富的功能,可以让我们更轻松地编写和调试基于PyQt5的摄像头应用程序。 ### 回答2: Python3是一种高级编程语言,PyQt5是用于创建图形界面应用程序的Python库,PyCharm是一种集成开发环境(IDE)。摄像头通常是指用于捕捉图像或视频的设备。 在Python中使用摄像头,可以使用OpenCV库来实现。OpenCV是一个开源计算机视觉库,可用于处理图像和视频。 要在PyQt5中使用摄像头,可以通过使用QCamera类来获取和控制摄像头。您可以将QCamera对象与QCameraViewfinder或QGraphicsView一起使用,以便在应用程序中显示摄像头捕捉的图像。 对于IDE,PyCharm是一种流行的Python开发环境,具有代码编辑器、调试器、版本控制等功能。PyCharm提供了丰富的功能和工具,使Python开发更加高效和便捷。 要在PyCharm中使用Python3PyQt5以及摄像头,您可以首先安装Python3PyQt5库。然后,您可以设置项目,并使用PyCharm提供的编辑器编写代码。在代码中,您可以导入所需的库和模块,以及使用适当的代码来处理摄像头和图像。 总而言之,您可以使用Python3编写具有PyQt5界面的应用程序,并在PyCharm中进行开发和调试。通过使用OpenCV库,您还可以使用摄像头捕捉图像和视频。 ### 回答3: Python3是一种高级编程语言,广泛应用于各个领域的软件开发和数据分析。PyQt5是一个Python模块,用于创建交互式和可视化的桌面应用程序。PyCharm是一种以Python为主要语言的集成开发环境(IDE),它提供了许多方便的工具和功能来帮助开发者更高效地编写和调试代码。 在Python3中,我们可以使用PyQt5来编写应用程序,包括调用摄像头进行图像采集和处理。通过调用PyQt5中的相机模块,我们可以访问计算机上的摄像头设备,并获取实时的图像数据。使用这些图像数据,我们可以进行各种图像处理操作,如图像增强、图像过滤、目标跟踪等。 为了更好地开发和调试Python应用程序,我们可以使用PyCharm作为开发工具。PyCharm提供了代码编辑器、调试器、版本控制集成等功能,可以提高开发效率和代码质量。在PyCharm中,我们可以轻松设置Python解释器,并导入所需的库和模块,以便使用PyQt5进行摄像头编程。 总结来说,Python3PyQt5和PyCharm可以一起使用来实现摄像头相关的应用程序。Python3提供了强大的编程能力,PyQt5提供了访问和处理摄像头图像的功能,而PyCharm提供了开发工具和环境,使开发者可以更轻松地进行开发和调试工作。通过这些工具和技术,我们可以实现各种摄像头应用,如视频监控系统、人脸识别系统等。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值