mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-05 03:20:08 +01:00
Attempts to enforce system settings in the demo page panel.
Adds a block in the wx.stc.StyledTextCtrl version of DemoPageEditor that will try to match system settings for caret period. Also adds the ability to read a switch off of sys.argv to manually disable cursor blinking.
This commit is contained in:
37
demo/Main.py
37
demo/Main.py
@@ -361,6 +361,37 @@ def FindImages(text, widgetName):
|
||||
return winAppearance
|
||||
|
||||
|
||||
def GetCaretPeriod(win = None):
|
||||
"""
|
||||
Attempts to identify the correct caret blinkrate to use in the Demo Code panel.
|
||||
|
||||
:pram wx.Window win: a window to pass to wx.SystemSettings.GetMetric.
|
||||
|
||||
:return: a value in milliseconds that indicates the proper period.
|
||||
:rtype: int
|
||||
|
||||
:raises: ValueError if unable to resolve a proper caret blink rate.
|
||||
"""
|
||||
try:
|
||||
onmsec = wx.SystemSettings.GetMetric(wx.SYS_CARET_ON_MSEC, win)
|
||||
offmsec = wx.SystemSettings.GetMetric(wx.SYS_CARET_OFF_MSEC, win)
|
||||
|
||||
# check values aren't -1
|
||||
if -1 in (onmsec, offmsec):
|
||||
raise ValueError
|
||||
|
||||
# attempt to average.
|
||||
# (wx systemsettings allows on and off time, but scintilla just takes a single period.)
|
||||
return (onmsec +offmsec) / 2.0
|
||||
|
||||
except (AttributeError, ValueError):
|
||||
# Issue where wx.SYS_CARET_ON/OFF_MSEC is unavailable.
|
||||
# Check
|
||||
if '--no-caret-blink' in sys.argv:
|
||||
return 0
|
||||
else:
|
||||
raise ValueError("Unable to determine caret blink rate.")
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Set up a thread that will scan the wxWidgets docs for window styles,
|
||||
# events and widgets screenshots
|
||||
@@ -612,6 +643,12 @@ try:
|
||||
# Selection background
|
||||
self.SetSelBackground(1, '#66CCFF')
|
||||
|
||||
# Attempt to set caret blink rate.
|
||||
try:
|
||||
self.SetCaretPeriod(GetCaretPeriod(self))
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
self.SetSelBackground(True, wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT))
|
||||
self.SetSelForeground(True, wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHTTEXT))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user