-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbcLogging.py
More file actions
30 lines (22 loc) · 1000 Bytes
/
bcLogging.py
File metadata and controls
30 lines (22 loc) · 1000 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import wx
from pubsub import pub
class bcLogging(wx.Log):
def __init__(self, parent) -> None:
super().__init__()
self.InfoBar = wx.InfoBar(parent)
self.InfoBar.SetShowHideEffects(wx.SHOW_EFFECT_SLIDE_TO_TOP, wx.SHOW_EFFECT_SLIDE_TO_BOTTOM)
self.LogWindow = wx.LogWindow(parent, "Log Window", show = False, passToOld = False)
self.LogWindow.GetFrame().SetSize(1000,300)
self.LogInterposer = bcLogInterposer(self)
pub.subscribe(self.ShowLogWindow, 'showlogwindow')
self.SetLogLevel(wx.LOG_Message)
def ShowLogWindow(self):
self.LogWindow.Show()
class bcLogInterposer(wx.LogInterposer):
def __init__(self, logger) -> None:
super().__init__()
self.InfoBar = logger.InfoBar
def DoLogTextAtLevel(self, level, msg) -> None:
if level <= wx.LOG_Warning:
iconflag = wx.ICON_ERROR if level == wx.LOG_Error else wx.ICON_WARNING
self.InfoBar.ShowMessage(msg, iconflag)