美文网首页
PyQt5 Event 学习

PyQt5 Event 学习

作者: _Mirage | 来源:发表于2020-04-02 13:02 被阅读0次

    Events
    GUI applications are event-driven. Events are generated mainly by the user of an application. But they can be generated by other means as well; e.g. an Internet connection, a window manager, or a timer. When we call the application's exec_() method, the application enters the main loop. The main loop fetches events and sends them to the objects.

    In the event model, there are three participants:

    event source(状态变化就产生事件的组件)
    event object(用来捕捉事件源的状态变化)
    event target(具体的被产生的事件)
    The event source is the object whose state changes. It generates events. The event object (event) encapsulates the state changes in the event source. The event target is the object that wants to be notified. Event source object delegates the task of handling an event to the event target.

    PyQt5 has a unique signal and slot(信号和槽) mechanism to deal with events. Signals and slots are used for communication between objects. A signal is emitted when a particular event occurs. A slot can be any Python callable. A slot is called when its connected signal is emitted.

    相关文章

      网友评论

          本文标题:PyQt5 Event 学习

          本文链接:https://www.haomeiwen.com/subject/xlcxphtx.html