Skip to content
This repository has been archived by the owner on Feb 2, 2022. It is now read-only.

Fix a variety of wx related errors #143

Closed
wants to merge 10 commits into from
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
patreon: bastula
19 changes: 2 additions & 17 deletions dicompyler/baseplugins/2dview.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import wx
from wx.xrc import XmlResource, XRCCTRL, XRCID
from wx.lib.pubsub import pub
from pubsub import pub
from matplotlib import _cntr as cntr
from matplotlib import __version__ as mplversion
import numpy as np
Expand Down Expand Up @@ -589,13 +589,6 @@ def OnZoomOut(self, evt):
def OnKeyDown(self, evt):
"""Change the image when the user presses the appropriate keys."""

# Needed to work around a bug in Windows. See main.py for more details.
if guiutil.IsMSWindows():
try:
evt = evt.data
except AttributeError:
keyname = evt.GetKeyCode()

if len(self.images):
keyname = evt.GetKeyCode()
prevkey = [wx.WXK_UP, wx.WXK_PAGEUP]
Expand Down Expand Up @@ -624,14 +617,6 @@ def OnKeyDown(self, evt):
def OnMouseWheel(self, evt):
"""Change the image when the user scrolls the mouse wheel."""

# Needed to work around a bug in Windows. See main.py for more details.
if guiutil.IsMSWindows():
try:
evt = evt.data
except AttributeError:
delta = evt.GetWheelDelta()
rot = evt.GetWheelRotation()

if len(self.images):
delta = evt.GetWheelDelta()
rot = evt.GetWheelRotation()
Expand Down Expand Up @@ -689,7 +674,7 @@ def OnMouseMotion(self, evt):
# Custom cursors with > 2 colors only works on Windows currently
if guiutil.IsMSWindows():
image = wx.Image(util.GetResourcePath('contrast_high.png'))
self.SetCursor(wx.CursorFromImage(image))
self.SetCursor(wx.Cursor(image))
# Update the positon and values of the mouse cursor
self.mousepos = evt.GetPosition()
self.OnUpdatePositionValues(evt)
Expand Down
2 changes: 1 addition & 1 deletion dicompyler/baseplugins/anonymize.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import wx
from wx.xrc import XmlResource, XRCCTRL, XRCID
from wx.lib.pubsub import pub
from pubsub import pub
import os, threading
from dicompyler import guiutil, util

Expand Down
16 changes: 8 additions & 8 deletions dicompyler/baseplugins/anonymize.xrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
</object>
</object>
</object>
<flag>wxALL|wxEXPAND|wxALIGN_CENTRE</flag>
<flag>wxALL|wxEXPAND</flag>
</object>
<label>Folder for Anonymized DICOM Files</label>
<orient>wxVERTICAL</orient>
</object>
<flag>wxALL|wxEXPAND|wxALIGN_CENTRE</flag>
<flag>wxALL|wxEXPAND</flag>
<border>3</border>
</object>
<object class="sizeritem">
Expand Down Expand Up @@ -63,7 +63,7 @@
<object class="sizeritem">
<object class="wxTextCtrl" name="txtFirstName"/>
<option>2</option>
<flag>wxALL|wxEXPAND|wxALIGN_CENTRE</flag>
<flag>wxALL|wxEXPAND</flag>
</object>
<object class="spacer">
<size>7,0</size>
Expand All @@ -83,12 +83,12 @@
<value>anonymous</value>
</object>
<option>2</option>
<flag>wxALL|wxEXPAND|wxALIGN_CENTRE</flag>
<flag>wxALL|wxEXPAND</flag>
</object>
<orient>wxHORIZONTAL</orient>
</object>
<option>1</option>
<flag>wxALL|wxEXPAND|wxALIGN_CENTRE</flag>
<flag>wxALL|wxEXPAND</flag>
</object>
<object class="spacer">
<size>0,5</size>
Expand Down Expand Up @@ -124,7 +124,7 @@
<flag>wxALIGN_CENTRE</flag>
</object>
</object>
<flag>wxALL|wxEXPAND|wxALIGN_CENTRE</flag>
<flag>wxALL|wxEXPAND</flag>
</object>
<object class="spacer">
<size>0,5</size>
Expand Down Expand Up @@ -169,7 +169,7 @@
<label>Options</label>
<orient>wxVERTICAL</orient>
</object>
<flag>wxALL|wxEXPAND|wxALIGN_CENTRE</flag>
<flag>wxALL|wxEXPAND</flag>
<border>3</border>
</object>
<object class="spacer">
Expand All @@ -191,7 +191,7 @@
</object>
</object>
</object>
<flag>wxALL|wxEXPAND|wxALIGN_CENTRE</flag>
<flag>wxALL|wxEXPAND</flag>
<border>3</border>
</object>
<object class="spacer">
Expand Down
2 changes: 1 addition & 1 deletion dicompyler/baseplugins/dvh.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import wx
from wx.xrc import XmlResource, XRCCTRL, XRCID
from wx.lib.pubsub import pub
from pubsub import pub
from dicompyler import guiutil, util
from dicompyler import guidvh
import numpy as np
Expand Down
18 changes: 9 additions & 9 deletions dicompyler/baseplugins/dvh.xrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<object class="sizeritem">
<object class="unknown" name="panelDVH"/>
<option>1</option>
<flag>wxALL|wxEXPAND|wxALIGN_CENTRE|wxADJUST_MINSIZE</flag>
<flag>wxALL|wxEXPAND|wxADJUST_MINSIZE</flag>
<border>4</border>
</object>
</object>
<option>5</option>
<flag>wxALL|wxEXPAND|wxALIGN_CENTRE</flag>
<flag>wxALL|wxEXPAND</flag>
</object>
<object class="sizeritem">
<object class="wxBoxSizer">
Expand All @@ -27,7 +27,7 @@
<object class="wxStaticText" name="lblType">
<label>Type:</label>
</object>
<flag>wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL</flag>
<flag>wxALIGN_CENTRE_VERTICAL</flag>
</object>
<object class="spacer">
<size>3,0</size>
Expand All @@ -42,7 +42,7 @@
</content>
<selection>0</selection>
</object>
<flag>wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL</flag>
<flag>wxALIGN_CENTRE_VERTICAL</flag>
</object>
<object class="spacer">
<size>5,0</size>
Expand All @@ -52,7 +52,7 @@
<object class="wxStaticText" name="lblConstraintType">
<label> Dose:</label>
</object>
<flag>wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL</flag>
<flag>wxALIGN_CENTRE_VERTICAL</flag>
</object>
<object class="spacer">
<size>3,0</size>
Expand All @@ -74,7 +74,7 @@
<min>0</min>
</object>
<option>4</option>
<flag>wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag>
<flag>wxALL|wxEXPAND</flag>
</object>
<object class="spacer">
<size>3,0</size>
Expand All @@ -83,7 +83,7 @@
<object class="wxStaticText" name="lblConstraintTypeUnits">
<label>% </label>
</object>
<flag>wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL</flag>
<flag>wxALIGN_CENTRE_VERTICAL</flag>
</object>
<object class="spacer">
<size>5,0</size>
Expand Down Expand Up @@ -126,12 +126,12 @@
</object>
</object>
<option>2</option>
<flag>wxALL|wxEXPAND|wxALIGN_CENTRE</flag>
<flag>wxALL|wxEXPAND</flag>
</object>
<orient>wxHORIZONTAL</orient>
</object>
<option>0</option>
<flag>wxALL|wxEXPAND|wxALIGN_CENTRE</flag>
<flag>wxALL|wxEXPAND</flag>
</object>
<orient>wxVERTICAL</orient>
</object>
Expand Down
2 changes: 1 addition & 1 deletion dicompyler/baseplugins/quickopen.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import logging
logger = logging.getLogger('dicompyler.quickimport')
import wx
from wx.lib.pubsub import pub
from pubsub import pub
from dicompylercore import dicomparser
from dicompyler import util

Expand Down
2 changes: 1 addition & 1 deletion dicompyler/baseplugins/treeview.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from six.moves import queue
import wx
from wx.xrc import XmlResource, XRCCTRL, XRCID
from wx.lib.pubsub import pub
from pubsub import pub
from wx.dataview import TreeListCtrl as tlc
from dicompyler import guiutil, util
try:
Expand Down
8 changes: 4 additions & 4 deletions dicompyler/baseplugins/treeview.xrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<orient>wxVERTICAL</orient>
</object>
<option>0</option>
<flag>wxALL|wxEXPAND|wxALIGN_CENTRE</flag>
<flag>wxALL|wxEXPAND</flag>
<border>1</border>
</object>
<object class="spacer">
Expand All @@ -39,16 +39,16 @@
<object class="sizeritem">
<object class="unknown" name="tlcTreeView"/>
<option>1</option>
<flag>wxALL|wxEXPAND|wxALIGN_CENTRE|wxADJUST_MINSIZE</flag>
<flag>wxALL|wxEXPAND|wxADJUST_MINSIZE</flag>
</object>
</object>
<option>3</option>
<flag>wxALL|wxEXPAND|wxALIGN_CENTRE</flag>
<flag>wxALL|wxEXPAND</flag>
</object>
<orient>wxVERTICAL</orient>
</object>
<option>5</option>
<flag>wxALL|wxEXPAND|wxALIGN_CENTRE</flag>
<flag>wxALL|wxEXPAND</flag>
</object>
<orient>wxVERTICAL</orient>
</object>
Expand Down
2 changes: 1 addition & 1 deletion dicompyler/dicomgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import hashlib, os, threading
import wx
from wx.xrc import *
from wx.lib.pubsub import pub
from pubsub import pub
import numpy as np
from dicompylercore import dicomparser
from dicompyler import guiutil, util
Expand Down
4 changes: 2 additions & 2 deletions dicompyler/guiutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from dicompyler import util
import wx
from wx.xrc import XmlResource, XRCCTRL, XRCID
from wx.lib.pubsub import pub
from pubsub import pub

def IsMSWindows():
"""Are we running on Windows?
Expand Down Expand Up @@ -200,7 +200,7 @@ def __init__(self, parent, item, data=None, color=None, pubsubname=''):
grid.Add((3,0), 0)
grid.Add(self.colorbox, 0, flag=wx.ALIGN_CENTRE)
grid.Add((5,0), 0)
grid.Add(self.checkbox, 1, flag=wx.EXPAND|wx.ALL|wx.ALIGN_CENTRE)
grid.Add(self.checkbox, 1, flag=wx.EXPAND|wx.ALL)

# Decrease the font size on Mac
if IsMac():
Expand Down
12 changes: 6 additions & 6 deletions dicompyler/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import wx.adv
import wx.lib.dialogs, webbrowser
import pydicom
from wx.lib.pubsub import pub
from pubsub import pub
from dicompylercore import dvhcalc
from dicompyler import __version__
from dicompyler import guiutil, util
Expand Down Expand Up @@ -129,11 +129,11 @@ def LogExcepthook(*exc_info):
mainGrid = wx.BoxSizer(wx.VERTICAL)
hGrid = wx.BoxSizer(wx.HORIZONTAL)
if guiutil.IsMac():
hGrid.Add(self.panelGeneral, 1, flag=wx.EXPAND|wx.ALL|wx.ALIGN_CENTRE, border=4)
hGrid.Add(self.panelGeneral, 1, flag=wx.EXPAND|wx.ALL, border=4)
else:
hGrid.Add(self.panelGeneral, 1, flag=wx.EXPAND|wx.ALL|wx.ALIGN_CENTRE)
hGrid.Add(self.panelGeneral, 1, flag=wx.EXPAND|wx.ALL)

mainGrid.Add(hGrid, 1, flag=wx.EXPAND|wx.ALL|wx.ALIGN_CENTRE)
mainGrid.Add(hGrid, 1, flag=wx.EXPAND|wx.ALL)

# Load the menu for the frame
menuMain = self.res.LoadMenuBar('menuMain')
Expand Down Expand Up @@ -833,15 +833,15 @@ def OnKeyDown(self, evt):
notebook tab instead of the panel receives focus."""

if guiutil.IsMSWindows():
pub.sendMessage('main.key_down', msg=evt)
pub.sendMessage('main.key_down', evt=evt)

def OnMouseWheel(self, evt):
"""Capture the mousewheel event when the notebook tab is focused.
Currently this is used to workaround a bug in Windows since the
notebook tab instead of the panel receives focus."""

if guiutil.IsMSWindows():
pub.sendMessage('main.mousewheel', msg=evt)
pub.sendMessage('main.mousewheel', evt=evt)

def OnPreferences(self, evt):
"""Load and show the Preferences dialog box."""
Expand Down
2 changes: 1 addition & 1 deletion dicompyler/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import imp, os
import wx
from wx.xrc import *
from wx.lib.pubsub import pub
from pubsub import pub
from dicompyler import guiutil, util

def import_plugins(userpath=None):
Expand Down
4 changes: 2 additions & 2 deletions dicompyler/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import os
import wx
from wx.xrc import *
from wx.lib.pubsub import pub
from pubsub import pub
from dicompyler import guiutil, util

try:
Expand Down Expand Up @@ -377,7 +377,7 @@ def main():

import tempfile, os
import wx
from wx.lib.pubsub import Publisher as pub
from pubsub import pub

app = wx.App(False)

Expand Down
Loading