Browse Source

allow control+scrollwheel to zoom rich text console #432

pull/616/head
eladeyal 5 years ago
committed by Chris
parent
commit
2205206b2e
1 changed files with 16 additions and 1 deletions
  1. 17
      gooey/gui/components/widgets/richtextconsole.py

17
gooey/gui/components/widgets/richtextconsole.py

@ -60,6 +60,9 @@ class RichTextConsole(wx.richtext.RichTextCtrl):
wxcolor = wx.Colour(int(hex[1:3],16), int(hex[3:5],16), int(hex[5:],16), alpha=wx.ALPHA_OPAQUE) wxcolor = wx.Colour(int(hex[1:3],16), int(hex[3:5],16), int(hex[5:],16), alpha=wx.ALPHA_OPAQUE)
# NB : we use a default parameter to force the evaluation of the binding # NB : we use a default parameter to force the evaluation of the binding
self.actionsMap[escSeq] = lambda bindedColor=wxcolor: self.BeginTextColour(bindedColor) self.actionsMap[escSeq] = lambda bindedColor=wxcolor: self.BeginTextColour(bindedColor)
self.Bind(wx.EVT_MOUSEWHEEL, self.onMouseWheel)
def PreprocessAndWriteText(self, content): def PreprocessAndWriteText(self, content):
"""Write text into console, while capturing URLs and making """Write text into console, while capturing URLs and making
@ -105,4 +108,16 @@ class RichTextConsole(wx.richtext.RichTextCtrl):
unprocIndex = endEsc + 1 unprocIndex = endEsc + 1
# Invariant : unprocessed end of buffer is escape-free, ready to be printed # Invariant : unprocessed end of buffer is escape-free, ready to be printed
self.PreprocessAndWriteText(content[unprocIndex:]) self.PreprocessAndWriteText(content[unprocIndex:])
self.ShowPosition(self.GetInsertionPoint())
self.ShowPosition(self.GetInsertionPoint())
def onMouseWheel(self, event):
if event.GetModifiers()==2 and event.GetWheelAxis()==wx.MOUSE_WHEEL_VERTICAL:
if event.GetWheelRotation() >= event.GetWheelDelta():
r=1.1
elif event.GetWheelRotation() <= -event.GetWheelDelta():
r=1.0/1.1
else:
return
self.SetFontScale(self.GetFontScale() * r, True)
else:
event.Skip()
Loading…
Cancel
Save