|
4 | 4 | from collections import namedtuple
|
5 | 5 | from PyQt5.QtWidgets import *
|
6 | 6 | from PyQt5.QtCore import *
|
| 7 | +from PyQt5.QtGui import * |
7 | 8 |
|
8 | 9 | def connect(signal, slot):
|
9 | 10 | signal.connect(slot)
|
10 | 11 |
|
| 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 | + |
11 | 45 | class ViewerWidget(QWidget):
|
12 | 46 | """Viewer widget that displays exception detailed
|
13 | 47 | information preformatted and with convience set methods.
|
@@ -87,6 +121,8 @@ def __init__(self, parent=None):
|
87 | 121 | self.toolbar.setFloatable(False)
|
88 | 122 | self.toolbar.addAction(self.actionClear)
|
89 | 123 | self.addToolBar(self.toolbar)
|
| 124 | + |
| 125 | + self.listWidget.setAttribute(Qt.WA_MacShowFocusRect, False) |
90 | 126 | ##
|
91 | 127 |
|
92 | 128 | # Configure layout
|
@@ -151,6 +187,16 @@ def excepthook(self, cls, err, tb):
|
151 | 187 | exceptConsole.show()
|
152 | 188 | exceptConsole.raise_()
|
153 | 189 |
|
| 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 | + |
154 | 200 | sys.excepthook = exceptConsole.excepthook
|
155 | 201 |
|
156 | 202 | print('Try making exceptions and testing console.')
|
|
0 commit comments