Skip to content

Commit 3cb1886

Browse files
committedMay 31, 2020
Python 3 and wxPython 4 fixes
Python 3 and wxPython 4 fixes
1 parent 721fce7 commit 3cb1886

File tree

4 files changed

+53
-32
lines changed

4 files changed

+53
-32
lines changed
 

‎easy_abc.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,11 @@ def unicode(s):
109109
from wx import GetTranslation as _
110110
from wxhelper import *
111111
# from midiplayer import *
112-
from fluidsynthplayer import *
113-
fluidsynth_available = False
114112
try:
115113
from fluidsynthplayer import *
116114
fluidsynth_available = True
117-
except:
118-
pass
115+
except ImportError:
116+
fluidsynth_available = False
119117

120118
from wxmediaplayer import *
121119
from xml2abc_interface import xml_to_abc, abc_to_xml
@@ -4427,7 +4425,6 @@ def show_toolbar_panel(self, panel, visible):
44274425

44284426
def setup_toolbar(self):
44294427
self.toolbar = aui.AuiToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize)#, agwStyle=aui.AUI_TB_DEFAULT_STYLE | aui.AUI_TB_OVERFLOW)
4430-
self.toolbar.SetToolAlignment(wx.ALIGN_CENTER_VERTICAL)
44314428
try:
44324429
self.toolbar.SetAGWWindowStyleFlag(aui.AUI_TB_PLAIN_BACKGROUND)
44334430
except:
@@ -6229,7 +6226,7 @@ def scroll_music_pane(self, x, y):
62296226
if (sx, sy) != orig_scroll:
62306227
#print 'scroll', sx, sy
62316228
ux, uy = self.music_pane.GetScrollPixelsPerUnit()
6232-
self.music_pane.Scroll(sx/ux, sy/uy)
6229+
self.music_pane.Scroll(int(sx/ux), int(sy/uy))
62336230

62346231
def OnMovedToDifferentLine(self, queue_number_movement):
62356232
if self.queue_number_movement != queue_number_movement:

‎music_score_panel.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -282,17 +282,17 @@ def Draw(self):
282282
if not WX4:
283283
dc.BeginDrawing()
284284
try:
285-
try:
286-
dc.SetBackground(wx.WHITE_BRUSH)
287-
dc.Clear()
288-
self.draw_drag_rect(dc)
289-
if self.current_page != self.renderer.empty_page:
290-
self.renderer.draw(page=self.current_page, clear_background=False, dc=dc)
291-
finally:
292-
if not WX4:
293-
dc.EndDrawing()
285+
dc.SetBackground(wx.WHITE_BRUSH)
286+
dc.Clear()
287+
self.draw_drag_rect(dc)
288+
if self.current_page != self.renderer.empty_page:
289+
self.renderer.draw(page=self.current_page, clear_background=False, dc=dc)
294290
except Exception as e:
295291
error_msg = ''.join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]))
296-
# print('Warning: %s' % error_msg)
292+
print('Warning: ' + error_msg)
293+
finally:
294+
if not WX4:
295+
dc.EndDrawing()
296+
297297

298298

‎oldbin/readme.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Place the binaries (executables) for the programs abcm2ps, abc2midi, midi2abc,
2+
abc2abc and nwc2xml here. EasyABC will find them without the need
3+
for any configuration by the user. Also see note.txt.

‎svgrenderer.py

+37-16
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from wxhelper import wx_colour, wx_bitmap
3333
import sys
3434
PY3 = sys.version_info.major > 2
35+
WX4 = wx.version().startswith('4')
3536

3637
# 1.3.6.2 [JWdJ] 2015-02-12 tags evaluated only once
3738
svg_namespace = 'http://www.w3.org/2000/svg'
@@ -307,7 +308,7 @@ def __init__(self, can_draw_sharps_and_flats):
307308
self.empty_page = SvgPage(self, None)
308309
self.buffer = None
309310
# 1.3.6.2 [JWdJ] 2015-02-12 Added voicecolor
310-
self.highlight_color = '#ee0000'
311+
self.highlight_color = '#00cc00' # '#ee0000'
311312
self.default_transform = None
312313
#self.update_buffer(self.empty_page)
313314
if wx.Platform == "__WXMAC__":
@@ -592,22 +593,42 @@ def set_stroke(self, dc, svg_stroke, line_width=1.0, linecap='butt', dasharray=N
592593
pen = self.stroke_cache.get(key)
593594
if pen is None:
594595
if svg_stroke == 'none':
595-
pen = self.renderer.CreatePen(wx.NullPen)
596+
if WX4:
597+
pen = self.renderer.CreatePen(wx.GraphicsPenInfo())
598+
else:
599+
pen = self.renderer.CreatePen(wx.NullPen)
596600
else:
597-
wxpen = wx.Pen(wx_colour(svg_stroke), line_width)
598-
if linecap == 'butt':
599-
wxpen.SetCap(wx.CAP_BUTT)
600-
elif linecap == 'round':
601-
wxpen.SetCap(wx.CAP_ROUND)
601+
if WX4:
602+
wxpen = wx.GraphicsPenInfo(wx_colour(svg_stroke)).Width(line_width)
603+
if linecap == 'butt':
604+
wxpen.Cap(wx.CAP_BUTT)
605+
elif linecap == 'round':
606+
wxpen.Cap(wx.CAP_ROUND)
607+
else:
608+
raise Exception('linecap %s not supported yet' % linecap)
609+
# if dasharray:
610+
# # 1.3.6.3 [JWDJ] 2015-3 dasharray is always a tuple, never a str or unicode
611+
# #if type(dasharray) in (str, unicode):
612+
# # dasharray = [int(x.strip()) for x in dasharray.split(',')]
613+
# wxpen.Dashes(list(dasharray))
614+
# wxpen.Style(wx.USER_DASH)
615+
wxpen.Join(wx.JOIN_MITER)
602616
else:
603-
raise Exception('linecap %s not supported yet' % linecap)
604-
if dasharray:
605-
# 1.3.6.3 [JWDJ] 2015-3 dasharray is always a tuple, never a str or unicode
606-
#if type(dasharray) in (str, unicode):
607-
# dasharray = [int(x.strip()) for x in dasharray.split(',')]
608-
wxpen.SetDashes(list(dasharray))
609-
wxpen.SetStyle(wx.USER_DASH)
610-
wxpen.SetJoin(wx.JOIN_MITER)
617+
wxpen = wx.Pen(wx_colour(svg_stroke), line_width)
618+
if linecap == 'butt':
619+
wxpen.SetCap(wx.CAP_BUTT)
620+
elif linecap == 'round':
621+
wxpen.SetCap(wx.CAP_ROUND)
622+
else:
623+
raise Exception('linecap %s not supported yet' % linecap)
624+
if dasharray:
625+
# 1.3.6.3 [JWDJ] 2015-3 dasharray is always a tuple, never a str or unicode
626+
#if type(dasharray) in (str, unicode):
627+
# dasharray = [int(x.strip()) for x in dasharray.split(',')]
628+
wxpen.SetDashes(list(dasharray))
629+
wxpen.SetStyle(wx.USER_DASH)
630+
wxpen.SetJoin(wx.JOIN_MITER)
631+
611632
pen = self.renderer.CreatePen(wxpen)
612633
self.stroke_cache[key] = pen
613634
dc.SetPen(pen)
@@ -752,7 +773,7 @@ def draw_svg_element(self, page, dc, svg_element, highlight, current_color):
752773
##print repr(text), font_face, attr.get('font-size'), attr.get('font-weight')
753774
wxfont = wx.Font(font_size, font_family, style, weight, False, font_face, wx.FONTENCODING_DEFAULT)
754775
if wx.VERSION >= (3, 0) or '__WXMSW__' in wx.PlatformInfo:
755-
wxfont.SetPixelSize((font_size, font_size))
776+
wxfont.SetPixelSize(wx.Size(0, font_size))
756777
y += 1
757778
else:
758779
wxfont.SetPointSize(font_size)

0 commit comments

Comments
 (0)
Please sign in to comment.