本文整理汇总了Python中Model.Model.parse_file方法的典型用法代码示例。如果您正苦于以下问题:Python Model.parse_file方法的具体用法?Python Model.parse_file怎么用?Python Model.parse_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.Model
的用法示例。
在下文中一共展示了Model.parse_file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: View
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import parse_file [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)