Skip to content

Commit

Permalink
wx.lib.pubsub is deprecated because it's being removed from wx so InV…
Browse files Browse the repository at this point in the history
…esalius is using pubsub directly from PubSub lib
  • Loading branch information
tfmoraes committed Apr 2, 2020
1 parent 2c5267e commit 2f686c7
Show file tree
Hide file tree
Showing 49 changed files with 76 additions and 87 deletions.
7 changes: 2 additions & 5 deletions app.py
Expand Up @@ -46,11 +46,8 @@
from wx.adv import SplashScreen
except ImportError:
from wx import SplashScreen
#from wx.lib.pubsub import setupv1 #new wx
# from wx.lib.pubsub import setuparg1# as psv1
#from wx.lib.pubsub import Publisher
#import wx.lib.pubsub as ps
from wx.lib.pubsub import pub as Publisher

from pubsub import pub as Publisher

#import wx.lib.agw.advancedsplash as agw
#if sys.platform.startswith('linux'):
Expand Down
58 changes: 25 additions & 33 deletions docs/devel/example_pubsub.py
Expand Up @@ -3,78 +3,70 @@
# More information about this design pattern can be found at:
# http://wiki.wxpython.org/ModelViewController
# http://wiki.wxpython.org/PubSub
import wx.lib.pubsub as ps
from pubsub import pub as Publisher

# The maintainer of Pubsub module is Oliver Schoenborn.
# Since the end of 2006 Pubsub is now maintained separately on SourceForge at:
# http://pubsub.sourceforge.net/

class Student():

class Student:
def __init__(self, name):
self.name = name
self.mood = ":|"
self.__bind_events()

def __bind_events(self):
ps.Publisher().subscribe(self.ReceiveProject,
'Set Student Project')
ps.Publisher().subscribe(self.ReceiveGrade,
'Set Student Grade')
Publisher.subscribe(self.ReceiveProject, "Set Student Project")
Publisher.subscribe(self.ReceiveGrade, "Set Student Grade")

def ReceiveProject(self, pubsub_evt):
projects_dict = pubsub_evt.data
self.project = projects_dict[self.name]
print "%s: I've received the project %s" %(self.name,
self.project)

print "%s: I've received the project %s" % (self.name, self.project)

def ReceiveGrade(self, pubsub_evt):
grades_dict = pubsub_evt.data
self.grade = grades_dict[self.name]
if (self.grade > 6):
if self.grade > 6:
self.mood = ":)"
else:
self.mood = ":("
print "%s: I've received the grade %d %s" %(self.name,
self.grade,
self.mood)

class Teacher():
print "%s: I've received the grade %d %s" % (self.name, self.grade, self.mood)


class Teacher:
def __init__(self, name, course):
self.name = name
self.course = course

def SendMessage(self):
print "%s: Telling students the projects" %(self.name)
ps.Publisher().sendMessage('Set Student Project',
self.course.projects_dict)

print "\n%s: Telling students the grades" %(self.name)
ps.Publisher().sendMessage('Set Student Grade',
self.course.grades_dict)

class Course():
print "%s: Telling students the projects" % (self.name)
Publisher.sendMessage("Set Student Project", self.course.projects_dict)

print "\n%s: Telling students the grades" % (self.name)
Publisher.sendMessage("Set Student Grade", self.course.grades_dict)


class Course:
def __init__(self, subject):
self.subject = subject
self.grades_dict = {}
self.projects_dict = {}


# Create students:
s1 = Student("Coelho")
s2 = Student("Victor")
s3 = Student("Thomaz")

# Create subject:
cs102 = Course("InVesalius")
cs102.projects_dict = {"Coelho":"wxPython",
"Victor":"VTK",
"Thomaz":"PIL"}
cs102.grades_dict = {"Coelho":7,
"Victor":6.5,
"Thomaz":4}
cs102.projects_dict = {"Coelho": "wxPython", "Victor": "VTK", "Thomaz": "PIL"}
cs102.grades_dict = {"Coelho": 7, "Victor": 6.5, "Thomaz": 4}

# Create teacher:
andre = Teacher("Andre", cs102)




andre.SendMessage()
2 changes: 1 addition & 1 deletion docs/devel/example_singleton_pubsub.py
@@ -1,6 +1,6 @@
# Singleton and Publisher-Subscriber design patterns example.

import wx.lib.pubsub as ps
from pubsub import pub as Publisher

class Singleton(type):
# This is a Gary Robinson implementation:
Expand Down
2 changes: 1 addition & 1 deletion invesalius/control.py
Expand Up @@ -24,7 +24,7 @@
import wx
import numpy as np

from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher

import invesalius.constants as const
import invesalius.data.imagedata_utils as image_utils
Expand Down
2 changes: 1 addition & 1 deletion invesalius/data/coordinates.py
Expand Up @@ -25,7 +25,7 @@

from time import sleep
from random import uniform
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher


def GetCoordinates(trck_init, trck_id, ref_mode):
Expand Down
2 changes: 1 addition & 1 deletion invesalius/data/coregistration.py
Expand Up @@ -22,7 +22,7 @@

from numpy import asmatrix, mat, degrees, radians, identity
import wx
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher

import invesalius.data.coordinates as dco
import invesalius.data.transformations as tr
Expand Down
2 changes: 1 addition & 1 deletion invesalius/data/editor.py
Expand Up @@ -18,7 +18,7 @@
#--------------------------------------------------------------------------

import math
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher
import vtk

AXIAL = 2
Expand Down
2 changes: 1 addition & 1 deletion invesalius/data/geometry.py
Expand Up @@ -23,7 +23,7 @@
import numpy as np
import vtk
from six import with_metaclass
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher

import invesalius.constants as const
import invesalius.utils as utils
Expand Down
2 changes: 1 addition & 1 deletion invesalius/data/imagedata_utils.py
Expand Up @@ -27,7 +27,7 @@
import numpy
import numpy as np
import vtk
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher

from scipy.ndimage import shift, zoom
from vtk.util import numpy_support
Expand Down
2 changes: 1 addition & 1 deletion invesalius/data/mask.py
Expand Up @@ -32,7 +32,7 @@

from invesalius_cy import floodfill

from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher
from scipy import ndimage

class EditionHistoryNode(object):
Expand Down
2 changes: 1 addition & 1 deletion invesalius/data/measures.py
Expand Up @@ -6,7 +6,7 @@
import random
import sys

from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher

import numpy as np
import vtk
Expand Down
2 changes: 1 addition & 1 deletion invesalius/data/polydata_utils.py
Expand Up @@ -21,7 +21,7 @@

import vtk
import wx
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher

import invesalius.constants as const
import invesalius.data.vtk_utils as vu
Expand Down
2 changes: 1 addition & 1 deletion invesalius/data/record_coords.py
Expand Up @@ -23,7 +23,7 @@
import wx
from numpy import array, savetxt, hstack,vstack, asarray
import invesalius.gui.dialogs as dlg
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher


class Record(threading.Thread):
Expand Down
2 changes: 1 addition & 1 deletion invesalius/data/slice_.py
Expand Up @@ -23,7 +23,7 @@
import vtk
from scipy import ndimage
from six import with_metaclass
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher

import invesalius.constants as const
import invesalius.data.converters as converters
Expand Down
2 changes: 1 addition & 1 deletion invesalius/data/styles.py
Expand Up @@ -32,7 +32,7 @@
from scipy.ndimage import generate_binary_structure, watershed_ift
from six import with_metaclass
from skimage.morphology import watershed
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher

import invesalius.constants as const
import invesalius.data.converters as converters
Expand Down
2 changes: 1 addition & 1 deletion invesalius/data/surface.py
Expand Up @@ -38,7 +38,7 @@
import wx
import wx.lib.agw.genericmessagedialog as GMD

from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher

if sys.platform == 'win32':
try:
Expand Down
2 changes: 1 addition & 1 deletion invesalius/data/trigger.py
Expand Up @@ -21,7 +21,7 @@
from time import sleep

import wx
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher


class Trigger(threading.Thread):
Expand Down
2 changes: 1 addition & 1 deletion invesalius/data/viewer_slice.py
Expand Up @@ -31,7 +31,7 @@
import invesalius.data.styles as styles
import wx
import sys
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher

try:
from agw import floatspin as FS
Expand Down
2 changes: 1 addition & 1 deletion invesalius/data/viewer_volume.py
Expand Up @@ -28,7 +28,7 @@
import wx
import vtk
from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher
import random
from scipy.spatial import distance

Expand Down
2 changes: 1 addition & 1 deletion invesalius/data/volume.py
Expand Up @@ -23,7 +23,7 @@
import numpy
import vtk
import wx
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher

import invesalius.constants as const
import invesalius.project as prj
Expand Down
2 changes: 1 addition & 1 deletion invesalius/data/vtk_utils.py
Expand Up @@ -20,7 +20,7 @@

import vtk
import wx
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher
import invesalius.constants as const
from invesalius.gui.dialogs import ProgressDialog

Expand Down
2 changes: 1 addition & 1 deletion invesalius/gui/bitmap_preview_panel.py
Expand Up @@ -5,7 +5,7 @@

from vtk.util import numpy_support
from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher

import invesalius.constants as const
import invesalius.data.vtk_utils as vtku
Expand Down
2 changes: 1 addition & 1 deletion invesalius/gui/brain_seg_dialog.py
Expand Up @@ -8,7 +8,7 @@
import time

import wx
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher

# Linux if installed plaidml with pip3 install --user
if sys.platform.startswith("linux"):
Expand Down
2 changes: 1 addition & 1 deletion invesalius/gui/data_notebook.py
Expand Up @@ -34,7 +34,7 @@
import wx.lib.flatnotebook as fnb

import wx.lib.platebtn as pbtn
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher

import invesalius.constants as const
import invesalius.data.slice_ as slice_
Expand Down
2 changes: 1 addition & 1 deletion invesalius/gui/default_tasks.py
Expand Up @@ -22,7 +22,7 @@
import wx.lib.agw.foldpanelbar as fpb
except ModuleNotFoundError:
import wx.lib.foldpanelbar as fpb
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher

import invesalius.constants as const
import invesalius.gui.data_notebook as nb
Expand Down
4 changes: 2 additions & 2 deletions invesalius/gui/default_viewers.py
Expand Up @@ -21,7 +21,7 @@

import wx
import wx.lib.agw.fourwaysplitter as fws
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher

import invesalius.data.viewer_slice as slice_viewer
import invesalius.data.viewer_volume as volume_viewer
Expand Down Expand Up @@ -316,7 +316,7 @@ def _Exit(self):

import wx.lib.platebtn as pbtn
import wx.lib.buttons as btn
import wx.lib.pubsub as ps
from pubsub import pub as Publisher
import wx.lib.colourselect as csel

[BUTTON_RAYCASTING, BUTTON_VIEW, BUTTON_SLICE_PLANE, BUTTON_3D_STEREO, BUTTON_TARGET] = [wx.NewId() for num in range(5)]
Expand Down
2 changes: 1 addition & 1 deletion invesalius/gui/dialogs.py
Expand Up @@ -46,7 +46,7 @@
from wx.lib import masked
from wx.lib.agw import floatspin
from wx.lib.wordwrap import wordwrap
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher

try:
from wx.adv import AboutDialogInfo, AboutBox
Expand Down
2 changes: 1 addition & 1 deletion invesalius/gui/dicom_preview_panel.py
Expand Up @@ -29,7 +29,7 @@

from vtk.util import numpy_support
from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher

import invesalius.constants as const
import invesalius.reader.dicom_reader as dicom_reader
Expand Down
2 changes: 1 addition & 1 deletion invesalius/gui/frame.py
Expand Up @@ -41,7 +41,7 @@
import wx.lib.popupctl as pc
from invesalius import inv_paths
from wx.lib.agw.aui.auibar import AUI_TB_PLAIN_BACKGROUND, AuiToolBar
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher

try:
from wx.adv import TaskBarIcon as wx_TaskBarIcon
Expand Down
2 changes: 1 addition & 1 deletion invesalius/gui/import_bitmap_panel.py
Expand Up @@ -18,7 +18,7 @@
#--------------------------------------------------------------------------
import wx
import wx.gizmos as gizmos
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher
import wx.lib.splitter as spl

import invesalius.constants as const
Expand Down
2 changes: 1 addition & 1 deletion invesalius/gui/import_network_panel.py
Expand Up @@ -19,7 +19,7 @@
import wx
import sys
import wx.gizmos as gizmos
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher
import wx.lib.splitter as spl

import invesalius.constants as const
Expand Down
2 changes: 1 addition & 1 deletion invesalius/gui/import_panel.py
Expand Up @@ -18,7 +18,7 @@
#--------------------------------------------------------------------------
import wx
import wx.gizmos as gizmos
from wx.lib.pubsub import pub as Publisher
from pubsub import pub as Publisher
import wx.lib.splitter as spl

import invesalius.constants as const
Expand Down

0 comments on commit 2f686c7

Please sign in to comment.