Commit 5ca3f3ba authored by eric pellegrini's avatar eric pellegrini

Modified the sendMessage call according to the wx pubusb API

parent 5428380b
...@@ -71,16 +71,17 @@ class DataTreePanel(wx.Panel): ...@@ -71,16 +71,17 @@ class DataTreePanel(wx.Panel):
PUBLISHER.unsubscribe(self.msg_delete_input_data, 'msg_delete_input_data') PUBLISHER.unsubscribe(self.msg_delete_input_data, 'msg_delete_input_data')
event.Skip() event.Skip()
def msg_load_input_data(self, data): def msg_load_input_data(self,message):
data = message.data
if data is None: if data is None:
return return
self.add_data(data) self.add_data(data)
def msg_delete_input_data(self, data): def msg_delete_input_data(self,message):
data = message.data
item = self.get_tree_item(self._root,data) item = self.get_tree_item(self._root,data)
if item is None: if item is None:
...@@ -111,7 +112,7 @@ class DataTreePanel(wx.Panel): ...@@ -111,7 +112,7 @@ class DataTreePanel(wx.Panel):
yield item yield item
item = self._tree.GetNextSibling(item) item = self._tree.GetNextSibling(item)
def add_data(self, data): def add_data(self,data):
dataItem = wx.TreeItemData(data.name) dataItem = wx.TreeItemData(data.name)
......
...@@ -149,8 +149,9 @@ class AnimationPlugin(ComponentPlugin): ...@@ -149,8 +149,9 @@ class AnimationPlugin(ComponentPlugin):
self.speedSlider.SetValue(int(self.speedEntry.GetValue())) self.speedSlider.SetValue(int(self.speedEntry.GetValue()))
self._parent.change_frame_rate() self._parent.change_frame_rate()
def msg_timer(self, plugin): def msg_timer(self, message):
plugin = message.data
if not plugin.is_parent(self): if not plugin.is_parent(self):
return return
...@@ -171,8 +172,9 @@ class AnimationPlugin(ComponentPlugin): ...@@ -171,8 +172,9 @@ class AnimationPlugin(ComponentPlugin):
self._parent.start_stop_animation() self._parent.start_stop_animation()
def msg_update_animation_icon(self, plugin): def msg_update_animation_icon(self, message):
plugin = message.data
if not plugin.is_parent(self): if not plugin.is_parent(self):
return return
...@@ -181,8 +183,9 @@ class AnimationPlugin(ComponentPlugin): ...@@ -181,8 +183,9 @@ class AnimationPlugin(ComponentPlugin):
else: else:
self.startStop.SetBitmapLabel(ICONS["play",32,32]) self.startStop.SetBitmapLabel(ICONS["play",32,32])
def msg_set_trajectory(self, plugin): def msg_set_trajectory(self, message):
plugin = message.data
if not plugin.is_parent(self): if not plugin.is_parent(self):
return return
......
...@@ -344,7 +344,7 @@ class AtomSelectionPlugin(UserDefinitionPlugin): ...@@ -344,7 +344,7 @@ class AtomSelectionPlugin(UserDefinitionPlugin):
self._selectionSummary.Clear() self._selectionSummary.Clear()
PUBLISHER.sendMessage('msg_clear_selection',plugin=self) PUBLISHER.sendMessage('msg_clear_selection',data=self)
def on_display_keyword_values(self, event=None): def on_display_keyword_values(self, event=None):
...@@ -384,7 +384,7 @@ class AtomSelectionPlugin(UserDefinitionPlugin): ...@@ -384,7 +384,7 @@ class AtomSelectionPlugin(UserDefinitionPlugin):
def msg_select_atoms_from_viewer(self, message): def msg_select_atoms_from_viewer(self, message):
dataPlugin,selection = message dataPlugin,selection = message.data
if dataPlugin != get_data_plugin(self): if dataPlugin != get_data_plugin(self):
return return
...@@ -397,7 +397,7 @@ class AtomSelectionPlugin(UserDefinitionPlugin): ...@@ -397,7 +397,7 @@ class AtomSelectionPlugin(UserDefinitionPlugin):
_, self._selection = self._query.parse() _, self._selection = self._query.parse()
PUBLISHER.sendMessage("msg_set_selection", plugin=self) PUBLISHER.sendMessage("msg_set_selection", data=self)
@property @property
def selection(self): def selection(self):
......
...@@ -158,7 +158,7 @@ class IPlugin(wx.Panel): ...@@ -158,7 +158,7 @@ class IPlugin(wx.Panel):
self._currentWindow = self self._currentWindow = self
PUBLISHER.sendMessage('msg_set_plugins_tree', plugin=self) PUBLISHER.sendMessage('msg_set_plugins_tree', data=self)
def build_dialog(self): def build_dialog(self):
...@@ -198,6 +198,6 @@ class IPlugin(wx.Panel): ...@@ -198,6 +198,6 @@ class IPlugin(wx.Panel):
self._currentWindow = window self._currentWindow = window
PUBLISHER.sendMessage('msg_set_plugins_tree', plugin=window) PUBLISHER.sendMessage('msg_set_plugins_tree', data=window)
\ No newline at end of file
...@@ -123,7 +123,7 @@ class JobPlugin(ComponentPlugin): ...@@ -123,7 +123,7 @@ class JobPlugin(ComponentPlugin):
time.sleep(1) time.sleep(1)
PUBLISHER.sendMessage("msg_start_job",message=None) PUBLISHER.sendMessage("msg_start_job",data=None)
def on_save(self, event=None): def on_save(self, event=None):
...@@ -152,7 +152,7 @@ class JobPlugin(ComponentPlugin): ...@@ -152,7 +152,7 @@ class JobPlugin(ComponentPlugin):
self._parent.mgr.Update() self._parent.mgr.Update()
PUBLISHER.sendMessage("msg_set_data", plugin=self) PUBLISHER.sendMessage("msg_set_data", data=self)
def on_close(self, event): def on_close(self, event):
...@@ -179,7 +179,7 @@ class JobFrame(wx.Frame): ...@@ -179,7 +179,7 @@ class JobFrame(wx.Frame):
plugin = REGISTRY['plugin'][self._jobType](self) plugin = REGISTRY['plugin'][self._jobType](self)
PUBLISHER.sendMessage("msg_set_data", plugin=plugin) PUBLISHER.sendMessage("msg_set_data", data=plugin)
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -231,8 +231,9 @@ class MolecularViewerPanel(ComponentPlugin): ...@@ -231,8 +231,9 @@ class MolecularViewerPanel(ComponentPlugin):
del self._surface del self._surface
self._surface = None self._surface = None
def msg_set_selection(self,plugin): def msg_set_selection(self,message):
plugin = message.data
if not self.is_parent(plugin): if not self.is_parent(plugin):
return return
...@@ -240,7 +241,7 @@ class MolecularViewerPanel(ComponentPlugin): ...@@ -240,7 +241,7 @@ class MolecularViewerPanel(ComponentPlugin):
def on_show_selection_box(self,message): def on_show_selection_box(self,message):
window,show = message window,show = message.data
if get_data_plugin(self) != get_data_plugin(window): if get_data_plugin(self) != get_data_plugin(window):
return return
...@@ -249,7 +250,7 @@ class MolecularViewerPanel(ComponentPlugin): ...@@ -249,7 +250,7 @@ class MolecularViewerPanel(ComponentPlugin):
def on_enable_picking(self,message): def on_enable_picking(self,message):
window,state = message window,state = message.data
if get_data_plugin(self) != get_data_plugin(window): if get_data_plugin(self) != get_data_plugin(window):
return return
...@@ -334,7 +335,7 @@ class MolecularViewerPanel(ComponentPlugin): ...@@ -334,7 +335,7 @@ class MolecularViewerPanel(ComponentPlugin):
self._trajectoryLoaded = True self._trajectoryLoaded = True
PUBLISHER.sendMessage('msg_set_trajectory', plugin=self) PUBLISHER.sendMessage('msg_set_trajectory', data=self)
def color_string_to_RGB(self, s): def color_string_to_RGB(self, s):
...@@ -597,7 +598,7 @@ class MolecularViewerPanel(ComponentPlugin): ...@@ -597,7 +598,7 @@ class MolecularViewerPanel(ComponentPlugin):
self.set_configuration(self._timerCounter) self.set_configuration(self._timerCounter)
self._timerCounter += 1 self._timerCounter += 1
PUBLISHER.sendMessage("msg_timer", plugin=self) PUBLISHER.sendMessage("msg_timer", data=self)
def set_rendering_mode(self, mode): def set_rendering_mode(self, mode):
if not self._trajectoryLoaded: if not self._trajectoryLoaded:
...@@ -677,7 +678,7 @@ class MolecularViewerPanel(ComponentPlugin): ...@@ -677,7 +678,7 @@ class MolecularViewerPanel(ComponentPlugin):
self.show_selection(list(self.__pickedAtoms)) self.show_selection(list(self.__pickedAtoms))
PUBLISHER.sendMessage('msg_select_atoms_from_viewer', message = (self.dataplugin,list(self.__pickedAtoms))) PUBLISHER.sendMessage('msg_select_atoms_from_viewer', data=(self.dataplugin,list(self.__pickedAtoms)))
def box_atoms(self, atomsList): def box_atoms(self, atomsList):
...@@ -733,7 +734,7 @@ class MolecularViewerPanel(ComponentPlugin): ...@@ -733,7 +734,7 @@ class MolecularViewerPanel(ComponentPlugin):
UD_STORE.save() UD_STORE.save()
PUBLISHER.sendMessage("msg_set_ud") PUBLISHER.sendMessage("msg_set_ud",data=None)
LOGGER('User definition %r successfully set.' % name,'info',['console']) LOGGER('User definition %r successfully set.' % name,'info',['console'])
...@@ -784,15 +785,16 @@ class MolecularViewerPanel(ComponentPlugin): ...@@ -784,15 +785,16 @@ class MolecularViewerPanel(ComponentPlugin):
self.stop_animation() self.stop_animation()
if check: if check:
PUBLISHER.sendMessage("msg_switch_viewers_state", viewer=self) PUBLISHER.sendMessage("msg_switch_viewers_state", data=self)
PUBLISHER.sendMessage('msg_animate_trajectory', plugin=self) PUBLISHER.sendMessage('msg_animate_trajectory', data=self)
def msg_switch_viewers_state(self, viewer): def msg_switch_viewers_state(self, message):
if not self._animationLoop: if not self._animationLoop:
return return
viewer = message.data
if viewer==self: if viewer==self:
return return
...@@ -1002,8 +1004,9 @@ class MolecularViewerPanel(ComponentPlugin): ...@@ -1002,8 +1004,9 @@ class MolecularViewerPanel(ComponentPlugin):
return assembly return assembly
def msg_clear_selection(self,plugin): def msg_clear_selection(self,message):
plugin = message.data
if not self.is_parent(plugin): if not self.is_parent(plugin):
return return
......
...@@ -87,7 +87,7 @@ class UserDefinitionPlugin(ComponentPlugin): ...@@ -87,7 +87,7 @@ class UserDefinitionPlugin(ComponentPlugin):
UD_STORE.set_definition(self._target,self.type,name,value) UD_STORE.set_definition(self._target,self.type,name,value)
PUBLISHER.sendMessage("msg_set_ud") PUBLISHER.sendMessage("msg_set_ud",data=None)
LOGGER('User definition %r successfully set.' % name,'info',['console']) LOGGER('User definition %r successfully set.' % name,'info',['console'])
......
...@@ -169,11 +169,12 @@ class PluginsTreePanel(wx.Panel): ...@@ -169,11 +169,12 @@ class PluginsTreePanel(wx.Panel):
self.set_plugins_tree(subnode, v) self.set_plugins_tree(subnode, v)
def msg_set_plugins_tree(self, plugin): def msg_set_plugins_tree(self,message):
if self._tree.GetCount() !=0: if self._tree.GetCount() !=0:
self._tree.DeleteChildren(self._root) self._tree.DeleteChildren(self._root)
plugin = message.data
if plugin is None: if plugin is None:
return return
......
...@@ -203,7 +203,7 @@ class UserDefinitionViewer(wx.Dialog): ...@@ -203,7 +203,7 @@ class UserDefinitionViewer(wx.Dialog):
self._udTree.clear() self._udTree.clear()
self._info.Clear() self._info.Clear()
PUBLISHER.sendMessage("msg_set_ud") PUBLISHER.sendMessage("msg_set_ud",data=None)
def on_save_ud(self,event): def on_save_ud(self,event):
......
...@@ -129,7 +129,7 @@ class AtomSelectionWidget(UserDefinitionWidget): ...@@ -129,7 +129,7 @@ class AtomSelectionWidget(UserDefinitionWidget):
else: else:
return uds return uds
def msg_set_ud(self): def msg_set_ud(self,message):
uds = UD_STORE.filter(self._basename, self.type) uds = UD_STORE.filter(self._basename, self.type)
......
...@@ -108,8 +108,9 @@ class IWidget(wx.Panel): ...@@ -108,8 +108,9 @@ class IWidget(wx.Panel):
def set_data(self,datakey): def set_data(self,datakey):
pass pass
def _set_data(self,plugin): def _set_data(self,message):
plugin = message.data
if not plugin.is_parent(self): if not plugin.is_parent(self):
return return
......
...@@ -80,7 +80,7 @@ class McStasInstrumentWidget(IWidget): ...@@ -80,7 +80,7 @@ class McStasInstrumentWidget(IWidget):
self._instrument.Append(path) self._instrument.Append(path)
self._instrument.Select(self._instrument.GetCount()-1) self._instrument.Select(self._instrument.GetCount()-1)
PUBLISHER.sendMessage("msg_set_instrument", message = (self, instrParams)) PUBLISHER.sendMessage("msg_set_instrument", data=(self, instrParams))
def on_select_instrument(self, event): def on_select_instrument(self, event):
......
...@@ -64,7 +64,7 @@ class NetCDFInputWidget(IWidget): ...@@ -64,7 +64,7 @@ class NetCDFInputWidget(IWidget):
filename = event.GetString() filename = event.GetString()
PUBLISHER.sendMessage("msg_set_netcdf", message=(self,filename)) PUBLISHER.sendMessage("msg_set_netcdf", data=(self,filename))
def set_data(self, datakey): def set_data(self, datakey):
...@@ -77,7 +77,7 @@ class NetCDFInputWidget(IWidget): ...@@ -77,7 +77,7 @@ class NetCDFInputWidget(IWidget):
self._selectNetCDF.SetStringSelection(datakey) self._selectNetCDF.SetStringSelection(datakey)
PUBLISHER.sendMessage("msg_set_netcdf", message = (self,datakey)) PUBLISHER.sendMessage("msg_set_netcdf", data=(self,datakey))
def get_widget_value(self): def get_widget_value(self):
......
...@@ -59,7 +59,7 @@ class UserDefinitionDialog(wx.Dialog): ...@@ -59,7 +59,7 @@ class UserDefinitionDialog(wx.Dialog):
self._plugin.set_trajectory(trajectory) self._plugin.set_trajectory(trajectory)
PUBLISHER.sendMessage("msg_set_data", plugin=self._plugin) PUBLISHER.sendMessage("msg_set_data", data=self._plugin)
@property @property
def plugin(self): def plugin(self):
...@@ -129,7 +129,7 @@ class UserDefinitionWidget(IWidget): ...@@ -129,7 +129,7 @@ class UserDefinitionWidget(IWidget):
self.msg_set_ud() self.msg_set_ud()
def msg_set_ud(self): def msg_set_ud(self,message):
uds = UD_STORE.filter(self._basename, self.type) uds = UD_STORE.filter(self._basename, self.type)
......
...@@ -121,7 +121,7 @@ class WorkingPanel(wx.Panel): ...@@ -121,7 +121,7 @@ class WorkingPanel(wx.Panel):
dataPlugin = self._notebook.GetPage(self._notebook.GetSelection()) dataPlugin = self._notebook.GetPage(self._notebook.GetSelection())
PUBLISHER.sendMessage('msg_set_plugins_tree', plugin=dataPlugin) PUBLISHER.sendMessage('msg_set_plugins_tree', data=dataPlugin)
def on_close_page(self, event): def on_close_page(self, event):
...@@ -131,5 +131,5 @@ class WorkingPanel(wx.Panel): ...@@ -131,5 +131,5 @@ class WorkingPanel(wx.Panel):
return return
if self._notebook.GetPageCount() == 1: if self._notebook.GetPageCount() == 1:
PUBLISHER.sendMessage('msg_set_plugins_tree', plugin=None) PUBLISHER.sendMessage('msg_set_plugins_tree', data=None)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment