当前位置: 首页>>代码示例>>Python>>正文


Python View.show_exception方法代码示例

本文整理汇总了Python中View.View.show_exception方法的典型用法代码示例。如果您正苦于以下问题:Python View.show_exception方法的具体用法?Python View.show_exception怎么用?Python View.show_exception使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在View.View的用法示例。


在下文中一共展示了View.show_exception方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: View

# 需要导入模块: from View import View [as 别名]
# 或者: from View.View import show_exception [as 别名]
class Controller:
    """ a 'middleman' between the View (visual aspects) and the Model (information) of the application.
        It ensures decoupling between both.
    """

    def __init__(self, app):
        # initialize the model and view
        # * The model handles all the data, and signal-related operations
        # * The view handles all the data visualization
        self.model = Model()
        self.view = View()

        # subscribe to messages sent by the view
        pub.subscribe(self.parse_file, "FILE PATH CHANGED")
        pub.subscribe(self.reprocess_fft, "FFT CONTROLS CHANGED")

        # subscribe to messages sent by the model
        pub.subscribe(self.signal_changed, "SIGNAL CHANGED")
        pub.subscribe(self.signal_changed, "FFT CHANGED")

        self.view.Show()

    def parse_file(self, message):
        """
        Handles "FILE PATH CHANGED" messages, send by the View. It tells the model to parse a new file.
        message.data should contain the path of the new file
        """
        try:
            self.model.parse_file(message.data)

        except Exception as exception:
            self.view.show_exception(
                "Error reading file", "The following error happened while reading the file:\n%s" % str(exception)
            )

    def reprocess_fft(self, message):
        """
        Handler "FFT CONTROLS CHANGED" messages from the View. It tells the model to re-process the fft.
        message.data should contain the array [window, slices, max_peaks]
        """
        self.model.reprocess_fft(*message.data)

    def signal_changed(self, message):
        """
        Handles "SIGNAL CHANGED" messages sent by the model. Tells the view to update itself.
        message is ignored
        """
        self.view.signal_changed(self.model)

    def fft_changed(self, message):
        """
        Handles "FFT CHANGED" messages sent by the model. Tells the view to update itself.
        message is ignored
        """
        self.view.fft_changed(self.model)
开发者ID:splendeo,项目名称:adctest,代码行数:57,代码来源:Controller.py


注:本文中的View.View.show_exception方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。