本文整理匯總了Python中View.View.signal_changed方法的典型用法代碼示例。如果您正苦於以下問題:Python View.signal_changed方法的具體用法?Python View.signal_changed怎麽用?Python View.signal_changed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類View.View
的用法示例。
在下文中一共展示了View.signal_changed方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: View
# 需要導入模塊: from View import View [as 別名]
# 或者: from View.View import signal_changed [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)