Control: tags -1 +patch

On Sun, Sep 07, 2014 at 10:53:10AM +0200, Ana Guerrero Lopez wrote:
> After this, cycle segfaults with wxpython3.0 :/

I had a poke - the problem seems to with be the calendar date attribute
objects - I'm not quite clear what's going on, but creating a new one
and setting it after we've finished changing it works.  And fixing that,
the set colours aren't use with the GTK calendar control, so we have to
force the generic version (which I think 2.8 probably always uses for
GTK).

The key constant names were wrong (missing "wx." prefix - that must be
wrong for 2.8 too).

And there's no need to explicitly set image handlers now - they're all
initialised implicitly at start up in both 2.8 and 3.0 - and doing so
now gives a warning because the handler's already set.

These changes should be fine with 2.8 too, but I suspect not with
earlier versions - you generally have to start conditionalising code
to support more than two wx release series at once, though simpler
programs can sometimes work more broadly.  But 2.6 has been dead a
long time now anyway.

With the patch, cycle seems to work well with wxPython 3.0, but I'm not
a user of the program, so a more thorough test would be good.

> I won't be able to dedicate time to this in the next 4-5 weeks. When
> are you aiming to remove wxpython2.8 from Debian?

I'm very keen not to have it in jessie - there's only me currently
very active in wx maintenance, and 2.8 hasn't really been supported
upstream for a long time.

Cheers,
    Olly
Description: Update for wxPython 3.0
 These changes should remain compatible with wxPython 2.8.
Bug-Debian: https://bugs.debian.org/758955
Forwarded: no
Last-Update: 2014-09-07

Index: cycle-0.3.1/cal_year.py
===================================================================
--- cycle-0.3.1.orig/cal_year.py
+++ cycle-0.3.1/cal_year.py
@@ -28,11 +28,11 @@ MARK_T22_28 = 1<<10 #tablets 22-28 or pa
 MARK_NEXT_TABLET = 1<<11 
 
 #-------------------- class Month_Cal -------------------
-class Month_Cal(wx.calendar.CalendarCtrl):
+class Month_Cal(wx.calendar.GenericCalendarCtrl):
     def __init__(self, parent, id, dt, pos=wx.DefaultPosition,
 		size=wx.DefaultSize, style=0 ):
 		
-	style = wx.calendar.CAL_NO_YEAR_CHANGE | wx.calendar.CAL_NO_MONTH_CHANGE | wx.NO_BORDER
+	style = wx.calendar.CAL_NO_MONTH_CHANGE | wx.NO_BORDER
 	if cycle.first_week_day==0:
 	    style = style | wx.calendar.CAL_MONDAY_FIRST
 	else:
@@ -42,7 +42,7 @@ class Month_Cal(wx.calendar.CalendarCtrl
 	except NameError:
 	    pass
 		    
-	wx.calendar.CalendarCtrl.__init__(self, parent, id, dt, pos, size, style)
+	wx.calendar.GenericCalendarCtrl.__init__(self, parent, id, dt, pos, size, style)
 	self.SetBackgroundColour(wx.WHITE)
 	self.SetHeaderColours(wx.BLACK,wx.WHITE)
 	if '__WXMSW__' in wx.PlatformInfo:
@@ -139,8 +139,8 @@ class Month_Cal(wx.calendar.CalendarCtrl
 
     def OnKey(self, event):
 	k=event.GetKeyCode()
-	if k==WXK_LEFT or k==WXK_RIGHT or \
-	   k==WXK_UP or k==WXK_DOWN:
+	if k==wx.WXK_LEFT or k==wx.WXK_RIGHT or \
+	   k==wx.WXK_UP or k==wx.WXK_DOWN:
 	    pass
 	else:
 	    event.Skip()
@@ -208,10 +208,8 @@ class Cal_Year(wx.ScrolledWindow):
 	Val.frame.SetTitle(cycle.name+" - "+str(self.year))
 	for m in range(12):
 	    t=wx.DateTimeFromDMY(1, m, self.year)
-	    self.month[m].EnableYearChange(True)
 	    self.month[m].EnableMonthChange(True)
 	    self.month[m].SetDate(t)
-	    self.month[m].EnableYearChange(False)
 	    self.month[m].EnableMonthChange(False)
 	    self.month[m].Refresh()
 
@@ -234,15 +232,8 @@ class Cal_Year(wx.ScrolledWindow):
 	    for d in range(1,wx.DateTime_GetNumberOfDaysInMonth(m, self.year)+1):
 		can_hide=True
 		lab=cycle.mark.get(k,0)
-		at=self.month[m].GetAttr(d)
-		if at is None :
-		    at=wx.calendar.CalendarDateAttr(wx.BLACK)
-		    self.month[m].SetAttr(d,at)
-		
-		# reset attributes
-		at.SetBorder(wx.calendar.CAL_BORDER_NONE)
+ 		at=wx.calendar.CalendarDateAttr(wx.BLACK)
 		at.SetBackgroundColour(wx.WHITE)
-		at.SetTextColour(wx.BLACK)
 		at.SetFont(f_norm)
 		
 		dt=wx.DateTimeFromDMY(d, m, self.year)
@@ -297,6 +288,8 @@ class Cal_Year(wx.ScrolledWindow):
 		    self.month[m].SetHighlightColours(at.GetTextColour(),
 				at.GetBackgroundColour())
 
+		self.month[m].SetAttr(d,at)
+
 		k+=1
 
 	# so visual refresh is more fast
Index: cycle-0.3.1/cycle.py
===================================================================
--- cycle-0.3.1.orig/cycle.py
+++ cycle-0.3.1/cycle.py
@@ -10,7 +10,7 @@ import os, sys, gettext
 import locale
 
 import wxversion 
-wxversion.ensureMinimal('2.5.3')
+wxversion.ensureMinimal('2.8')
 import wx
 import wx.html
 import wx.lib.colourdb
@@ -69,7 +69,6 @@ class MyFrame(wx.Frame):
 	wx.Frame.__init__(self, parent, ID, title,
 		       wx.DefaultPosition, wx.Size(800, 600))
 
-	wx.Image_AddHandler(wx.PNGHandler())
 #	self.printer = wx.HtmlEasyPrinting()
 	icon = wx.Icon(os.path.join(icons_dir,'mini/cycle.xpm'), wx.BITMAP_TYPE_XPM)
 	self.SetIcon(icon)
@@ -142,7 +141,7 @@ class MyFrame(wx.Frame):
 
     def Export(self, event):
         dlg = wx.FileDialog(self, _("Export to iCal"),
-                            style=wx.SAVE)
+                            style=wx.FD_SAVE)
 
         if dlg.ShowModal() == wx.ID_OK:
             try:

Reply via email to