Skip to content

Commit bffaf32

Browse files
committed
added ConsoleFunctions class for convience methods
1 parent 632d739 commit bffaf32

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

exception_viewer.py

+46
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,44 @@
44
from collections import namedtuple
55
from PyQt5.QtWidgets import *
66
from PyQt5.QtCore import *
7+
from PyQt5.QtGui import *
78

89
def connect(signal, slot):
910
signal.connect(slot)
1011

12+
class ConsoleFunctions:
13+
"""Functions to be used in console for convience"""
14+
15+
@staticmethod
16+
def clear():
17+
"""Clears console"""
18+
#_app_.processEvents()
19+
_exceptConsole_.clearExceptions()
20+
#_app_.processEvents()
21+
22+
@staticmethod
23+
def show():
24+
"""Shows console"""
25+
_exceptConsole_.show()
26+
_exceptConsole_.raise_()
27+
#_app_.processEvents()
28+
29+
@staticmethod
30+
def hide():
31+
"""Hides console"""
32+
_exceptConsole_.hide()
33+
#_app_.processEvents()
34+
35+
@staticmethod
36+
def doc(object):
37+
"""Prints docstring of object
38+
for now just prints to console.
39+
TODO: make a widget that displays docstring"""
40+
color = '\033[36m'
41+
endColor = '\033[0m'
42+
print(color + str(object.__doc__) + endColor)
43+
44+
1145
class ViewerWidget(QWidget):
1246
"""Viewer widget that displays exception detailed
1347
information preformatted and with convience set methods.
@@ -87,6 +121,8 @@ def __init__(self, parent=None):
87121
self.toolbar.setFloatable(False)
88122
self.toolbar.addAction(self.actionClear)
89123
self.addToolBar(self.toolbar)
124+
125+
self.listWidget.setAttribute(Qt.WA_MacShowFocusRect, False)
90126
##
91127

92128
# Configure layout
@@ -151,6 +187,16 @@ def excepthook(self, cls, err, tb):
151187
exceptConsole.show()
152188
exceptConsole.raise_()
153189

190+
# Provide name console functions
191+
clear = ConsoleFunctions.clear
192+
show = ConsoleFunctions.show
193+
hide = ConsoleFunctions.hide
194+
doc = ConsoleFunctions.doc
195+
196+
#TODO: ps Colors might be breaking previous command up arrow
197+
#sys.ps1 = '\033[92m>>> \033[0m'
198+
#sys.ps2 = '\033[42m \033[0m '
199+
154200
sys.excepthook = exceptConsole.excepthook
155201

156202
print('Try making exceptions and testing console.')

0 commit comments

Comments
 (0)