Update of /cvsroot/pythoncard/PythonCard/samples/sudoku
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3277
Modified Files:
sudoku.py
Log Message:
Now that helpful.py is in PythonCard, use the pop-up menus fom there,
rather than using the local copy.
Index: sudoku.py
===================================================================
RCS file: /cvsroot/pythoncard/PythonCard/samples/sudoku/sudoku.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** sudoku.py 29 Sep 2005 22:05:23 -0000 1.1
--- sudoku.py 2 Nov 2005 13:25:35 -0000 1.2
***************
*** 10,14 ****
import wx
from wx.html import HtmlEasyPrinting
! from PythonCard import configuration, dialog, model
import copy
--- 10,14 ----
import wx
from wx.html import HtmlEasyPrinting
! from PythonCard import configuration, dialog, model, helpful
import copy
***************
*** 16,75 ****
'i': (200,255,200), 'o': (200,200,255), }
! # copied from helpful.py
! # This function will, I hope, at some point become part of PythonCard
!
! import types
!
! VERSION = "0.1"
!
! class PopUpMenu:
! def __init__(self, aBg, items, pos):
! # Yet another alternate way to do IDs. Some prefer them up top to
! # avoid clutter, some prefer them close to the object of interest
! # for clarity.
! self.popup = {}
! self.reverse = {}
! self.selected = None
! # make a menu
! self.menu = wx.Menu()
! # add the items
! for it in items:
! if type(it) == types.StringType:
! Id = wx.NewId()
! self.popup[it] = Id
! self.reverse[Id] = it
! aBg.Bind(wx.EVT_MENU, self.OnPopup, id=self.popup[it])
! self.menu.Append(self.popup[it], it)
! else:
! # make a menu
! submenu = wx.Menu()
! Id = wx.NewId()
! aBg.Bind(wx.EVT_MENU, self.OnPopup, id=Id)
! for that in it:
! if type(that) == types.StringType:
! Id = wx.NewId()
! self.popup[that] = Id
! self.reverse[Id] = that
! aBg.Bind(wx.EVT_MENU, self.OnPopup, id=self.popup[that])
! submenu.Append(self.popup[that], that)
!
! self.menu.AppendMenu(Id, "Test Submenu", submenu)
!
! # Popup the menu. If an item is selected then its handler
! # will be called before PopupMenu returns.
! aBg.PopupMenu(self.menu, pos)
! self.menu.Destroy()
!
!
! def OnPopup(self, event):
! self.selected = self.reverse[event.GetId()]
!
! def popUpMenu(aBg, items, pos):
! menu = PopUpMenu(aBg, items, pos)
!
! return menu.selected
!
! # end of section from helpful.py
!
def textToHtml(txt):
--- 16,20 ----
'i': (200,255,200), 'o': (200,200,255), }
! VERSION = "0.2"
def textToHtml(txt):
***************
*** 641,651 ****
if selected == 0:
# Popup the menu.
! selected = popUpMenu(self, items, comp.position)
! ###selected = helpful.popUpMenu(self, items, comp.position)
if selected:
selected = int(selected)
else:
selected = 0
- #rint "comp, val", comp.name, selected, type(selected)
if selected > 0:
--- 586,594 ----
if selected == 0:
# Popup the menu.
! selected = helpful.popUpMenu(self, items, comp.position)
if selected:
selected = int(selected)
else:
selected = 0
if selected > 0:
|