Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for SetFocus when disabling keypad entry controls #170

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BibEnter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import Utils
import Model
from EditEntry import DoDNF, DoDNS, DoPull, DoDQ
from NumKeypad import getRiderNumsFromText, enterCodes, validKeyCodes
from Keypad import getRiderNumsFromText, enterCodes, validKeyCodes

class BibEnter( wx.Dialog ):
def __init__( self, parent, id = wx.ID_ANY ):
Expand Down
61 changes: 42 additions & 19 deletions BibTimeRecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,31 @@

import Model
import Utils
from Log import CrossMgrLogger, getLogger
from ManualTimeEntryPanel import ManualTimeEntryPanel, TimeEntryController
from ReorderableGrid import ReorderableGrid
from EditEntry import DoDNF, DoDNS, DoPull, DoDQ
from InputUtils import enterCodes, validKeyCodes, clearCodes, actionCodes, getRiderNumsFromText, MakeKeypadButton

class BibTimeRecord( wx.Panel ):
def __init__( self, parent, controller, id = wx.ID_ANY ):
super().__init__(parent, id)
# self.SetBackgroundColour( wx.Colour(173, 216, 230) )
self.SetBackgroundColour( wx.WHITE )
class BibTimeRecord( ManualTimeEntryPanel, TimeEntryController ):
__log: CrossMgrLogger

@property
def log(self):
if self.__log is None:
self.__log = getLogger('CrossMgr.BibTimeRecord')
return self.__log

def __init__( self, parent: wx.Window, controller: ManualTimeEntryPanel|None = None, id = wx.ID_ANY ):
super().__init__(parent=parent, controller=controller, id=id)

self.controller = controller

fontPixels = 36
font = wx.Font((0,fontPixels), wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
dc = wx.WindowDC( self )
dc.SetFont( font )
wNum, hNum = dc.GetTextExtent( '999' )
wNum += 8
hNum += 8
hNum += 8

outsideBorder = 4

Expand Down Expand Up @@ -101,14 +107,7 @@ def handleNumKeypress(self, event):
elif keycode in clearCodes:
self.numEdit.SetValue( '' )
elif keycode in actionCodes:
if keycode == ord('/'): # DNF
pass
elif keycode == ord('*'): # DNS
pass
elif keycode == ord('-'): # PUL
pass
elif keycode == ord('+'): # DQ
pass
pass
elif keycode < 255:
if keycode in validKeyCodes:
event.Skip()
Expand Down Expand Up @@ -138,8 +137,7 @@ def doSetTime( self, event ):
mainWin = Utils.getMainWin()
if mainWin is not None:
mainWin.forecastHistory.logNum( int(num) )
if self.controller:
self.controller.refreshLaps()
self.refreshLaps()
if row < self.grid.GetNumberRows():
self.grid.DeleteRows( row, 1 )

Expand Down Expand Up @@ -258,14 +256,39 @@ def OnPopupChart( self, event ):
mainWin = Utils.getMainWin()
if self.bibCur and mainWin:
mainWin.forecastHistory.SelectNumShowPage( self.bibCur, 'iChartPage' )

def _EnableControls(self) -> None:
self.log.todo('BibTimeRecord._EnableControls() not yet implemented.')

def _DisableControls(self) -> None:
self.log.todo('BibTimeRecord._DisableControls() not yet implemented.')

def __SafeSetFocus(self):
try:
super().SetFocus()
try:
self.numEdit.SetFocus()
except Exception as e:
self.log.error( f'Error setting on BibTimeRecord numEdit: {e}' )
except Exception as e:
self.log.error( f'Error setting on BibTimeRecord: {e}' )

def SetFocus(self):
self.__SafeSetFocus()


if __name__ == '__main__':
Utils.disable_stdout_buffering()
app = wx.App(False)
mainWin = wx.Frame(None,title="CrossMan", size=(600,600))
Model.setRace( Model.Race() )
Model.getRace()._populate()
bibTimeRecord = BibTimeRecord(mainWin, None)

AnonymousTimeEntryController = type('TimeEntryController', (object,), {'refreshLaps': lambda self: print ('Laps refreshed')})
testController = AnonymousTimeEntryController()

bibTimeRecord = BibTimeRecord(mainWin, testController)
bibTimeRecord.Disable()
bibTimeRecord.refresh()
mainWin.Show()
app.MainLoop()
2 changes: 1 addition & 1 deletion ForecastHistory.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from Utils import formatTime, formatTimeGap
import ColGrid
import OutputStreamer
import NumKeypad
import Keypad
from PhotoFinish import TakePhoto, okTakePhoto
from GetResults import GetResults, GetResultsWithData, IsRiderFinished
from EditEntry import CorrectNumber, SplitNumber, ShiftNumber, InsertNumber, DeleteEntry
Expand Down
Loading