PrEditor 0.8.0__py2.py3-none-any.whl → 0.9.0__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of PrEditor might be problematic. Click here for more details.

preditor/__init__.py CHANGED
@@ -93,7 +93,7 @@ def configure(name, parent_callback=None, excepthook=True, logging=True, streams
93
93
  # Store the core_name,.
94
94
  _global_config['core_name'] = name
95
95
  if parent_callback:
96
- _global_config['parent_callback'] = parent_callback
96
+ set_parent_callback(parent_callback)
97
97
 
98
98
  if streams:
99
99
  # Install the stream manager to capture output
@@ -229,6 +229,39 @@ def root_window():
229
229
  return App.root_window()
230
230
 
231
231
 
232
+ def parent_callback():
233
+ """Returns the parent_callback or None.
234
+
235
+ This is a callback that returns a QWidget to use as the parent of the
236
+ LoggerWindow when its first created. This can be used by DCC's to set the
237
+ parent to their main window.
238
+ """
239
+ return _global_config.get("parent_callback")
240
+
241
+
242
+ def set_parent_callback(parent_callback, if_unset=True):
243
+ """Update the parent_callback even if it was already set.
244
+
245
+ This is useful for cases where `configure` is called before it's possible to
246
+ provide the parent_callback.
247
+
248
+ Note: Changing this does not re-parent an existing instance of LoggerWindows.
249
+ If you change this after the LoggerWindow instance has been created you will
250
+ need to manually re-parent it.
251
+
252
+ Args:
253
+ if_unset(bool): If True then only set this value if the parent_callback
254
+ hasn't already been set.
255
+
256
+ Returns:
257
+ bool: Returns False if if_unset is True and it was already set.
258
+ """
259
+ if "parent_callback" in _global_config and not if_unset:
260
+ return False
261
+ _global_config["parent_callback"] = parent_callback
262
+ return True
263
+
264
+
232
265
  def connect_preditor(
233
266
  parent, sequence='F2', text='Show PrEditor', obj_name='uiShowPreditorACT', name=None
234
267
  ):
preditor/cores/core.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from __future__ import absolute_import, print_function
2
2
 
3
- from Qt.QtCore import QObject, Signal
3
+ from Qt.QtCore import QObject
4
4
 
5
5
 
6
6
  class Core(QObject):
@@ -9,17 +9,11 @@ class Core(QObject):
9
9
  be distributed between different pacakges.
10
10
  """
11
11
 
12
- # ----------------------------------------------------------------
13
- # blurdev signals
14
- aboutToClearPaths = Signal() # Emitted before environment is changed or reloaded
15
-
16
- # ----------------------------------------------------------------
17
-
18
12
  def __init__(self, objectName=None):
19
- QObject.__init__(self)
13
+ super(Core, self).__init__()
20
14
  if objectName is None:
21
- objectName = 'blurdev'
22
- QObject.setObjectName(self, objectName)
15
+ objectName = 'PrEditor'
16
+ self.setObjectName(objectName)
23
17
 
24
18
  # create custom properties
25
19
  self._headless = False
preditor/gui/__init__.py CHANGED
@@ -3,6 +3,7 @@ from __future__ import absolute_import
3
3
  from functools import partial
4
4
 
5
5
  from Qt.QtCore import Property
6
+ from Qt.QtWidgets import QStackedWidget
6
7
 
7
8
  from .dialog import Dialog # noqa: F401
8
9
  from .window import Window # noqa: F401
@@ -82,3 +83,11 @@ def loadUi(filename, widget, uiname=''):
82
83
  uiname = os.path.basename(filename).split('.')[0]
83
84
 
84
85
  QtCompat.loadUi(os.path.split(filename)[0] + '/ui/%s.ui' % uiname, widget)
86
+
87
+
88
+ def tab_widget_for_tab(tab_widget):
89
+ """Returns the `QTabWidget` `tab_widget` is parented to or `None`."""
90
+ tab_parent = tab_widget.parent()
91
+ if not isinstance(tab_parent, QStackedWidget):
92
+ return None
93
+ return tab_parent.parent()
preditor/gui/dialog.py CHANGED
@@ -3,7 +3,7 @@ from __future__ import absolute_import
3
3
  from Qt.QtCore import Qt
4
4
  from Qt.QtWidgets import QDialog
5
5
 
6
- from .. import core, relativePath, root_window
6
+ from .. import relativePath, root_window
7
7
 
8
8
 
9
9
  class Dialog(QDialog):
@@ -25,9 +25,6 @@ class Dialog(QDialog):
25
25
  cls._instance = cls(parent=parent)
26
26
  # protect the memory
27
27
  cls._instance.setAttribute(Qt.WA_DeleteOnClose, False)
28
- # but make sure that if we reload the environment, everything gets deleted
29
- # properly
30
- core.aboutToClearPaths.connect(cls._instance.shutdown)
31
28
  return cls._instance
32
29
 
33
30
  def __init__(
@@ -80,9 +77,6 @@ class Dialog(QDialog):
80
77
  # If this value is set to False calling setGeometry on this dialog will not
81
78
  # adjust the geometry to ensure the dialog is on a valid screen.
82
79
  self.checkScreenGeo = True
83
- # If this value is set to True the dialog will listen for
84
- # core.aboutToClearPaths and call shutdown on the dialog.
85
- self.aboutToClearPathsEnabled = True
86
80
  # attempt to set the dialog icon
87
81
  import os
88
82
  import sys
@@ -128,13 +122,6 @@ class Dialog(QDialog):
128
122
 
129
123
  WinWidget.uncache(wwidget)
130
124
 
131
- # only disconnect here if deleting on close
132
- if self.aboutToClearPathsEnabled and self.testAttribute(Qt.WA_DeleteOnClose):
133
- try:
134
- core.aboutToClearPaths.disconnect(self.shutdown)
135
- except TypeError:
136
- pass
137
-
138
125
  def exec_(self):
139
126
  # do not use the DeleteOnClose attribute when executing a dialog as often times
140
127
  # a user will be accessing information from the dialog instance after it closes.
@@ -158,13 +145,6 @@ class Dialog(QDialog):
158
145
 
159
146
  ensureWindowIsVisible(self)
160
147
 
161
- def showEvent(self, event):
162
- # listen for aboutToClearPaths signal if requested
163
- # but only connect here if deleting on close
164
- if self.aboutToClearPathsEnabled and self.testAttribute(Qt.WA_DeleteOnClose):
165
- core.aboutToClearPaths.connect(self.shutdown)
166
- super(Dialog, self).showEvent(event)
167
-
168
148
  def shutdown(self):
169
149
  # use a @classmethod to make inheritance magically work
170
150
  self._shutdown(self)
@@ -178,8 +158,6 @@ class Dialog(QDialog):
178
158
  # allow the global instance to be cleared
179
159
  if this == cls._instance:
180
160
  cls._instance = None
181
- if this.aboutToClearPathsEnabled:
182
- core.aboutToClearPaths.disconnect(this.shutdown)
183
161
  this.setAttribute(Qt.WA_DeleteOnClose, True)
184
162
  try:
185
163
  this.close()
@@ -70,7 +70,7 @@ class GroupTabWidget(OneTabWidget):
70
70
  self.uiCornerBTN = corner
71
71
  self.setCornerWidget(self.uiCornerBTN, Qt.TopRightCorner)
72
72
 
73
- def add_new_tab(self, group, title="Workbox"):
73
+ def add_new_tab(self, group, title="Workbox", group_fmt=None):
74
74
  """Adds a new tab to the requested group, creating the group if the group
75
75
  doesn't exist.
76
76
 
@@ -79,6 +79,11 @@ class GroupTabWidget(OneTabWidget):
79
79
  existing tab, or the name of the group and it will create the group
80
80
  if needed. If None is passed it will add a new tab `Group {last+1}`.
81
81
  If True is passed, then the current group tab is used.
82
+ title (str, optional): The name to give the newly created tab inside
83
+ the group.
84
+ group_fmt(str, optional): If None is passed to group, this string is
85
+ used to search for existing tabs to calculate the last number
86
+ and generate the new group tab name.
82
87
 
83
88
  Returns:
84
89
  GroupedTabWidget: The tab group for this group.
@@ -86,12 +91,14 @@ class GroupTabWidget(OneTabWidget):
86
91
  """
87
92
  parent = None
88
93
  if not group:
94
+ if group_fmt is None:
95
+ group_fmt = r'Group {}'
89
96
  last = 0
90
97
  for i in range(self.count()):
91
- match = re.match(r'Group (\d+)', self.tabText(i))
98
+ match = re.match(group_fmt.format(r'(\d+)'), self.tabText(i))
92
99
  if match:
93
100
  last = max(last, int(match.group(1)))
94
- group = "Group {}".format(last + 1)
101
+ group = group_fmt.format(last + 1)
95
102
  elif group is True:
96
103
  group = self.currentIndex()
97
104
  if isinstance(group, int):
@@ -212,9 +212,7 @@ class HandlerMenu(LazyMenu):
212
212
  self.logger = logger
213
213
 
214
214
  def install_handler(self, name):
215
- for _, cls in plugins.logging_handlers(name):
216
- handler = cls()
217
- self.logger.addHandler(handler)
215
+ plugins.add_logging_handler(self.logger, name)
218
216
 
219
217
  def refresh(self):
220
218
  self.clear()
@@ -224,7 +222,7 @@ class HandlerMenu(LazyMenu):
224
222
  act = handler_install.addAction(name)
225
223
  act.triggered.connect(partial(self.install_handler, name))
226
224
  for h in self.logger.handlers:
227
- if isinstance(h, cls):
225
+ if type(h) is cls:
228
226
  act.setEnabled(False)
229
227
  act.setToolTip('Already installed for this logger.')
230
228
  break
@@ -1,13 +1,12 @@
1
1
  from __future__ import absolute_import
2
2
 
3
3
  import logging
4
- import weakref
5
4
 
6
5
  from .. import instance
7
6
 
8
7
 
9
8
  class LoggerWindowHandler(logging.Handler):
10
- """A logging handler that writes directly to the Python Logger.
9
+ """A logging handler that writes directly to the PrEditor instance.
11
10
 
12
11
  Args:
13
12
  error (bool, optional): Write the output as if it were written
@@ -22,7 +21,6 @@ class LoggerWindowHandler(logging.Handler):
22
21
 
23
22
  def __init__(self, error=True, formatter=default_format):
24
23
  super(LoggerWindowHandler, self).__init__()
25
- self.console = weakref.ref(instance().console())
26
24
  self.error = error
27
25
  if formatter is not None:
28
26
  if not isinstance(formatter, logging.Formatter):
@@ -30,10 +28,14 @@ class LoggerWindowHandler(logging.Handler):
30
28
  self.setFormatter(formatter)
31
29
 
32
30
  def emit(self, record):
31
+ _instance = instance(create=False)
32
+ if _instance is None:
33
+ # No gui has been created yet, so nothing to do
34
+ return
33
35
  try:
34
36
  # If the python logger was closed and garbage collected,
35
37
  # there is nothing to do, simply exit the call
36
- console = self.console()
38
+ console = _instance.console()
37
39
  if not console:
38
40
  return
39
41
 
@@ -0,0 +1,32 @@
1
+ class LoggerWindowPlugin:
2
+ """Base class for LoggerWindow plugins.
3
+
4
+ These plugins are loaded using the `preditor.plug.loggerwindow` entry point.
5
+ This entry point is loaded when `LoggerWindow` is initialized. For each entry
6
+ point defined a single instance of the plugin is created per instance of
7
+ a LoggerWindow.
8
+
9
+ To save preferences override `record_prefs` and `restore_prefs` methods. These
10
+ are used to save and load preferences any time the PrEditor save/loads prefs.
11
+ """
12
+
13
+ def __init__(self, parent):
14
+ self.parent = parent
15
+
16
+ def record_prefs(self, name):
17
+ """Returns any prefs to save with the PrEditor's preferences.
18
+
19
+ Returns:
20
+ dict: A dictionary that will be saved using json or None.
21
+ """
22
+
23
+ def restore_prefs(self, name, prefs):
24
+ """Restore the preferences saved from a previous launch.
25
+
26
+ Args:
27
+ name(str): The name specified by the `preditor.plug.loggerwindow`
28
+ entry point.
29
+ prefs(dict or None): The prefs returned by a previous call to
30
+ `record_prefs()` from the last preference save. None is passed
31
+ if no prefs were recorded.
32
+ """
@@ -37,7 +37,7 @@ from .. import (
37
37
  resourcePath,
38
38
  )
39
39
  from ..delayable_engine import DelayableEngine
40
- from ..gui import Dialog, Window, loadUi
40
+ from ..gui import Dialog, Window, loadUi, tab_widget_for_tab
41
41
  from ..gui.fuzzy_search.fuzzy_search import FuzzySearch
42
42
  from ..gui.group_tab_widget.grouped_tab_models import GroupTabListItemModel
43
43
  from ..logging_config import LoggingConfig
@@ -55,6 +55,31 @@ class WorkboxPages:
55
55
  Workboxes = 1
56
56
 
57
57
 
58
+ class WorkboxName(str):
59
+ """The joined name of a workbox `group/workbox` with access to its parts.
60
+
61
+ This subclass provides properties for the group and workbox values separately.
62
+ """
63
+
64
+ def __new__(cls, group, workbox):
65
+ txt = "/".join((group, workbox))
66
+ ret = super().__new__(cls, txt)
67
+ # Preserve the imitable nature of str's by using properties without setters.
68
+ ret._group = group
69
+ ret._workbox = workbox
70
+ return ret
71
+
72
+ @property
73
+ def group(self):
74
+ """The tab name of the group tab that contains the workbox."""
75
+ return self._group
76
+
77
+ @property
78
+ def workbox(self):
79
+ """The workbox of the tab for this workbox inside of the group."""
80
+ return self._workbox
81
+
82
+
58
83
  class LoggerWindow(Window):
59
84
  _instance = None
60
85
  styleSheetChanged = Signal(str)
@@ -62,7 +87,6 @@ class LoggerWindow(Window):
62
87
  def __init__(self, parent, name=None, run_workbox=False, standalone=False):
63
88
  super(LoggerWindow, self).__init__(parent=parent)
64
89
  self.name = name if name else get_core_name()
65
- self.aboutToClearPathsEnabled = False
66
90
  self._stylesheet = 'Bright'
67
91
 
68
92
  # Create timer to autohide status messages
@@ -237,7 +261,6 @@ class LoggerWindow(Window):
237
261
  self.uiBackupPreferencesACT.triggered.connect(self.backupPreferences)
238
262
  self.uiBrowsePreferencesACT.triggered.connect(self.browsePreferences)
239
263
  self.uiAboutPreditorACT.triggered.connect(self.show_about)
240
- core.aboutToClearPaths.connect(self.pathsAboutToBeCleared)
241
264
  self.uiSetFlashWindowIntervalACT.triggered.connect(self.setFlashWindowInterval)
242
265
 
243
266
  self.uiSetPreferredTextEditorPathACT.triggered.connect(
@@ -264,6 +287,12 @@ class LoggerWindow(Window):
264
287
  self.addAction(self.uiClearLogACT)
265
288
 
266
289
  self.dont_ask_again = []
290
+
291
+ # Load any plugins that modify the LoggerWindow
292
+ self.plugins = {}
293
+ for name, plugin in plugins.loggerwindow():
294
+ self.plugins[name] = plugin(self)
295
+
267
296
  self.restorePrefs()
268
297
 
269
298
  # add stylesheet menu options.
@@ -335,16 +364,48 @@ class LoggerWindow(Window):
335
364
 
336
365
  @classmethod
337
366
  def name_for_workbox(cls, workbox):
338
- """Returns the name for a given workbox.
339
- The name is the group tab text and the workbox tab text joined by a `/`"""
340
- ret = []
341
- logger = cls.instance()
342
- index = logger.uiWorkboxTAB.currentIndex()
343
- ret.append(logger.uiWorkboxTAB.tabText(index))
344
- group_widget = logger.uiWorkboxTAB.currentWidget()
345
- index = group_widget.currentIndex()
346
- ret.append(group_widget.tabText(index))
347
- return "/".join(ret)
367
+ """Returns the name for a given workbox or None if not valid.
368
+
369
+ The name is a `WorkboxName` object showing the group and name joined by
370
+ a `/`.
371
+
372
+ Args:
373
+ workbox: The workbox to get the name of. If None is passed then it
374
+ will return the name of the current workbox.
375
+
376
+ Returns:
377
+ The name of the widget as a `WorkboxName` object showing the group
378
+ and name joined by a `/`. If workbox is not valid for the LoggerWindow
379
+ instance then None is returned.
380
+ """
381
+
382
+ if workbox is None:
383
+ # if the workbox was not provided use the current workbox
384
+ logger = cls.instance()
385
+ index = logger.uiWorkboxTAB.currentIndex()
386
+ group = logger.uiWorkboxTAB.tabText(index)
387
+ group_widget = logger.uiWorkboxTAB.currentWidget()
388
+ index = group_widget.currentIndex()
389
+ name = group_widget.tabText(index)
390
+ return WorkboxName(group, name)
391
+
392
+ # Otherwise resolve from the parent widgets.
393
+ # Get the parent QTabWidget of the workbox
394
+ workbox_tab_widget = tab_widget_for_tab(workbox)
395
+ if not workbox_tab_widget:
396
+ return None
397
+ # Get the group QTabWidget of the parent QTabWidget of the workbox
398
+ group_widget = tab_widget_for_tab(workbox_tab_widget)
399
+ if not group_widget:
400
+ return None
401
+
402
+ # Get the group name
403
+ index = group_widget.indexOf(workbox_tab_widget)
404
+ group = group_widget.tabText(index)
405
+
406
+ index = workbox_tab_widget.indexOf(workbox)
407
+ name = workbox_tab_widget.tabText(index)
408
+ return WorkboxName(group, name)
348
409
 
349
410
  @classmethod
350
411
  def workbox_for_name(cls, name, show=False, visible=False):
@@ -699,10 +760,6 @@ class LoggerWindow(Window):
699
760
  else:
700
761
  super(LoggerWindow, self).keyPressEvent(event)
701
762
 
702
- def pathsAboutToBeCleared(self):
703
- if self.uiClearLogOnRefreshACT.isChecked():
704
- self.clearLog()
705
-
706
763
  def clearExecutionTime(self):
707
764
  """Update status text with hyphens to indicate execution has begun."""
708
765
  self.setStatusText('Exec: -.- Seconds')
@@ -734,7 +791,6 @@ class LoggerWindow(Window):
734
791
  'spellCheckEnabled': self.uiSpellCheckEnabledACT.isChecked(),
735
792
  'wordWrap': self.uiWordWrapACT.isChecked(),
736
793
  'clearBeforeRunning': self.uiClearBeforeRunningACT.isChecked(),
737
- 'clearBeforeEnvRefresh': self.uiClearLogOnRefreshACT.isChecked(),
738
794
  'uiSelectTextACT': self.uiSelectTextACT.isChecked(),
739
795
  'toolbarStates': six.text_type(self.saveState().toHex(), 'utf-8'),
740
796
  'consoleFont': self.console().font().toString(),
@@ -773,6 +829,13 @@ class LoggerWindow(Window):
773
829
 
774
830
  pref['editor_cls'] = self.editor_cls_name
775
831
 
832
+ # Allow any plugins to add their own preferences dictionary
833
+ pref["plugins"] = {}
834
+ for name, plugin in self.plugins.items():
835
+ plugin_pref = plugin.record_prefs(name)
836
+ if plugin_pref:
837
+ pref["plugins"][name] = plugin_pref
838
+
776
839
  self.save_prefs(pref)
777
840
 
778
841
  def load_prefs(self):
@@ -893,7 +956,6 @@ class LoggerWindow(Window):
893
956
  self.uiWordWrapACT.setChecked(pref.get('wordWrap', True))
894
957
  self.setWordWrap(self.uiWordWrapACT.isChecked())
895
958
  self.uiClearBeforeRunningACT.setChecked(pref.get('clearBeforeRunning', False))
896
- self.uiClearLogOnRefreshACT.setChecked(pref.get('clearBeforeEnvRefresh', False))
897
959
  self.setClearBeforeRunning(self.uiClearBeforeRunningACT.isChecked())
898
960
  self.uiSelectTextACT.setChecked(pref.get('uiSelectTextACT', True))
899
961
 
@@ -924,6 +986,10 @@ class LoggerWindow(Window):
924
986
 
925
987
  self.dont_ask_again = pref.get('dont_ask_again', [])
926
988
 
989
+ # Allow any plugins to restore their own preferences
990
+ for name, plugin in self.plugins.items():
991
+ plugin.restore_prefs(name, pref.get("plugins", {}).get(name))
992
+
927
993
  def restoreToolbars(self, pref=None):
928
994
  if pref is None:
929
995
  pref = self.load_prefs()
@@ -92,7 +92,7 @@
92
92
  <x>0</x>
93
93
  <y>0</y>
94
94
  <width>796</width>
95
- <height>29</height>
95
+ <height>21</height>
96
96
  </rect>
97
97
  </property>
98
98
  <widget class="QMenu" name="uiDebugMENU">
@@ -105,7 +105,7 @@
105
105
  <addaction name="uiLogToFileACT"/>
106
106
  <addaction name="uiLogToFileClearACT"/>
107
107
  </widget>
108
- <widget class="QMenu" name="uiScriptingMENU">
108
+ <widget class="QMenu" name="uiFileMENU">
109
109
  <property name="title">
110
110
  <string comment="File Menu">&amp;File</string>
111
111
  </property>
@@ -120,19 +120,19 @@
120
120
  <property name="title">
121
121
  <string>Help</string>
122
122
  </property>
123
- <widget class="QMenu" name="menuPreferences">
123
+ <widget class="QMenu" name="uiPreferencesMENU">
124
124
  <property name="title">
125
125
  <string>Preferences</string>
126
126
  </property>
127
127
  <addaction name="uiBrowsePreferencesACT"/>
128
128
  <addaction name="uiBackupPreferencesACT"/>
129
129
  </widget>
130
- <addaction name="menuPreferences"/>
130
+ <addaction name="uiPreferencesMENU"/>
131
131
  <addaction name="uiEnvironmentVarsACT"/>
132
132
  <addaction name="separator"/>
133
133
  <addaction name="uiAboutPreditorACT"/>
134
134
  </widget>
135
- <widget class="QMenu" name="menu_Run">
135
+ <widget class="QMenu" name="uiRunMENU">
136
136
  <property name="title">
137
137
  <string>Run</string>
138
138
  </property>
@@ -144,7 +144,7 @@
144
144
  <addaction name="uiClearToLastPromptACT"/>
145
145
  <addaction name="uiSelectTextACT"/>
146
146
  </widget>
147
- <widget class="QMenu" name="uiFileMENU">
147
+ <widget class="QMenu" name="uiOptionsMENU">
148
148
  <property name="title">
149
149
  <string>&amp;Options</string>
150
150
  </property>
@@ -178,7 +178,6 @@
178
178
  <addaction name="uiHighlightExactCompletionACT"/>
179
179
  <addaction name="separator"/>
180
180
  <addaction name="uiClearLogACT"/>
181
- <addaction name="uiClearLogOnRefreshACT"/>
182
181
  <addaction name="separator"/>
183
182
  <addaction name="uiSelectFontsMENU"/>
184
183
  <addaction name="uiStyleMENU"/>
@@ -197,11 +196,11 @@
197
196
  <addaction name="uiSetPreferredTextEditorPathACT"/>
198
197
  <addaction name="uiSetWorkboxEditorACT"/>
199
198
  </widget>
200
- <widget class="QMenu" name="menuEdit">
199
+ <widget class="QMenu" name="uiEditMENU">
201
200
  <property name="title">
202
201
  <string>Edit</string>
203
202
  </property>
204
- <widget class="QMenu" name="menuFocus_to_Group">
203
+ <widget class="QMenu" name="uiFocus_to_GroupMENU">
205
204
  <property name="title">
206
205
  <string>Focus to Group</string>
207
206
  </property>
@@ -216,7 +215,7 @@
216
215
  <addaction name="separator"/>
217
216
  <addaction name="uiGroupLastACT"/>
218
217
  </widget>
219
- <widget class="QMenu" name="menuFocus_to_Tab">
218
+ <widget class="QMenu" name="uiFocus_to_TabMENU">
220
219
  <property name="title">
221
220
  <string>Focus to Tab</string>
222
221
  </property>
@@ -316,17 +315,17 @@
316
315
  <addaction name="uiNextTabACT"/>
317
316
  <addaction name="uiPrevTabACT"/>
318
317
  <addaction name="separator"/>
319
- <addaction name="menuFocus_to_Group"/>
320
- <addaction name="menuFocus_to_Tab"/>
318
+ <addaction name="uiFocus_to_GroupMENU"/>
319
+ <addaction name="uiFocus_to_TabMENU"/>
321
320
  <addaction name="separator"/>
322
321
  <addaction name="uiFindInWorkboxesACT"/>
323
322
  <addaction name="uiFocusNameACT"/>
324
323
  </widget>
325
- <addaction name="uiScriptingMENU"/>
326
- <addaction name="menuEdit"/>
327
- <addaction name="uiDebugMENU"/>
328
- <addaction name="menu_Run"/>
329
324
  <addaction name="uiFileMENU"/>
325
+ <addaction name="uiEditMENU"/>
326
+ <addaction name="uiDebugMENU"/>
327
+ <addaction name="uiRunMENU"/>
328
+ <addaction name="uiOptionsMENU"/>
330
329
  <addaction name="uiHelpMENU"/>
331
330
  </widget>
332
331
  <widget class="QToolBar" name="uiConsoleTOOLBAR">
@@ -507,14 +506,6 @@
507
506
  <string>Editor Vertical</string>
508
507
  </property>
509
508
  </action>
510
- <action name="uiClearLogOnRefreshACT">
511
- <property name="checkable">
512
- <bool>true</bool>
513
- </property>
514
- <property name="text">
515
- <string>Clear Log on Environment Refresh</string>
516
- </property>
517
- </action>
518
509
  <action name="uiClearToLastPromptACT">
519
510
  <property name="text">
520
511
  <string>Clear to Last Prompt</string>
preditor/gui/window.py CHANGED
@@ -3,7 +3,7 @@ from __future__ import absolute_import
3
3
  from Qt.QtCore import Qt
4
4
  from Qt.QtWidgets import QMainWindow
5
5
 
6
- from .. import core, relativePath, root_window
6
+ from .. import relativePath, root_window
7
7
 
8
8
 
9
9
  class Window(QMainWindow):
@@ -26,9 +26,6 @@ class Window(QMainWindow):
26
26
  cls._instance = cls(parent=parent)
27
27
  # protect the memory
28
28
  cls._instance.setAttribute(Qt.WA_DeleteOnClose, False)
29
- # but make sure that if we reload the environment, everything gets deleted
30
- # properly
31
- core.aboutToClearPaths.connect(cls._instance.shutdown)
32
29
  return cls._instance
33
30
 
34
31
  def __init__(self, parent=None, flags=0):
@@ -74,9 +71,6 @@ class Window(QMainWindow):
74
71
  # If this value is set to False calling setGeometry on this window will not
75
72
  # adjust the geometry to ensure the window is on a valid screen.
76
73
  self.checkScreenGeo = True
77
- # If this value is set to True the window will listen for
78
- # preditor.core.aboutToClearPaths and call shutdown on the window.
79
- self.aboutToClearPathsEnabled = True
80
74
  # attempt to set the dialog icon
81
75
  import os
82
76
  import sys
@@ -122,13 +116,6 @@ class Window(QMainWindow):
122
116
 
123
117
  WinWidget.uncache(wwidget)
124
118
 
125
- # only disconnect here if deleting on close
126
- if self.aboutToClearPathsEnabled and self.testAttribute(Qt.WA_DeleteOnClose):
127
- try:
128
- core.aboutToClearPaths.disconnect(self.shutdown)
129
- except TypeError:
130
- pass
131
-
132
119
  def setGeometry(self, *args):
133
120
  """
134
121
  Sets the window's geometry, It will also check if the geometry is visible on any
@@ -141,13 +128,6 @@ class Window(QMainWindow):
141
128
 
142
129
  ensureWindowIsVisible(self)
143
130
 
144
- def showEvent(self, event):
145
- # listen for aboutToClearPaths signal if requested
146
- # but only connect here if deleting on close
147
- if self.aboutToClearPathsEnabled and self.testAttribute(Qt.WA_DeleteOnClose):
148
- core.aboutToClearPaths.connect(self.shutdown)
149
- super(Window, self).showEvent(event)
150
-
151
131
  def shutdown(self):
152
132
  # use a @classmethod to make inheritance magically work
153
133
  self._shutdown(self)
@@ -161,8 +141,6 @@ class Window(QMainWindow):
161
141
  # allow the global instance to be cleared
162
142
  if this == cls._instance:
163
143
  cls._instance = None
164
- if this.aboutToClearPathsEnabled:
165
- core.aboutToClearPaths.disconnect(this.shutdown)
166
144
  this.setAttribute(Qt.WA_DeleteOnClose, True)
167
145
  try:
168
146
  this.close()
preditor/plugins.py CHANGED
@@ -9,7 +9,7 @@ if six.PY3:
9
9
  else:
10
10
  import pkg_resources
11
11
 
12
- logger = logging.getLogger(__name__)
12
+ _logger = logging.getLogger(__name__)
13
13
 
14
14
 
15
15
  class Plugins(object):
@@ -18,7 +18,7 @@ class Plugins(object):
18
18
  for ep in self.iterator("preditor.plug.about_module"):
19
19
  name = ep.name
20
20
  if name in plugs:
21
- logger.warning(
21
+ _logger.warning(
22
22
  'Duplicate "preditor.plug.about_module" plugin found with '
23
23
  'name "{}"'.format(name)
24
24
  )
@@ -35,6 +35,44 @@ class Plugins(object):
35
35
 
36
36
  yield name, result
37
37
 
38
+ def add_logging_handler(self, logger, handler_cls, *args, **kwargs):
39
+ """Add a logging handler to a logger if not already installed.
40
+
41
+ Checks for an existing handler on logger for the specific class(does not
42
+ use isinstance). If not then it will create an instance of the handler
43
+ and add it to the logger.
44
+
45
+ Args:
46
+ logger (logging.RootLogger): The logger instance to add the handler.
47
+ handler_cls (logging.Handler or str): If a string is passed it will
48
+ use `self.logging_handlers` to get the class. If not found then
49
+ exits with success marked as False. Other values are treated as
50
+ the handler class to add to the logger.
51
+ *args: Passed to the handler_cls if a new instance is created.
52
+ **kargs: Passed to the handler_cls if a new instance is created.
53
+
54
+ Returns:
55
+ logging.Handler or None: The handler instance that was added, already
56
+ has been added, or None if the handler name isn't a valid plugin.
57
+ bool: True only if the handler_cls was not already added to this logger.
58
+ """
59
+ if isinstance(handler_cls, str):
60
+ handlers = dict(self.logging_handlers(handler_cls))
61
+ if not handlers:
62
+ # No handler to add for this name
63
+ return None, False
64
+ handler_cls = handlers[handler_cls]
65
+
66
+ # Attempt to find an existing handler instance and return it
67
+ for h in logger.handlers:
68
+ if type(h) is handler_cls:
69
+ return h, False
70
+
71
+ # No handler installed create and install it
72
+ handler = handler_cls(*args, **kwargs)
73
+ logger.addHandler(handler)
74
+ return handler, True
75
+
38
76
  def editor(self, name):
39
77
  for plug_name, ep in self.editors(name):
40
78
  return plug_name, ep.load()
@@ -50,6 +88,20 @@ class Plugins(object):
50
88
  for ep in self.iterator(group="preditor.plug.initialize"):
51
89
  yield ep.load()
52
90
 
91
+ def loggerwindow(self, name=None):
92
+ """Returns instances of "preditor.plug.loggerwindow" plugins.
93
+
94
+ These plugins are used by the LoggerWindow to extend its interface. For
95
+ example it can be used to add a toolbar or update the menus.
96
+
97
+ When using this plugin, make sure the returned class is a subclass of
98
+ `preditor.gui.logger_window_plugin.LoggerWindowPlugin`.
99
+ """
100
+ for ep in self.iterator(group="preditor.plug.loggerwindow"):
101
+ if name and ep.name != name:
102
+ continue
103
+ yield ep.name, ep.load()
104
+
53
105
  def logging_handlers(self, name=None):
54
106
  for ep in self.iterator(group="preditor.plug.logging_handlers"):
55
107
  yield ep.name, ep.load()
preditor/version.py CHANGED
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
2
  # file generated by setuptools_scm
3
3
  # don't change, don't track in version control
4
- version = '0.8.0'
5
- version_tuple = (0, 8, 0)
4
+ version = '0.9.0'
5
+ version_tuple = (0, 9, 0)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PrEditor
3
- Version: 0.8.0
3
+ Version: 0.9.0
4
4
  Summary: A python REPL and Editor and console based on Qt.
5
5
  Home-page: https://github.com/blurstudio/PrEditor.git
6
6
  Author: Blur Studio
@@ -208,6 +208,11 @@ added in [setup.cfg](setup.cfg).
208
208
  implementing a workbox. See [workbox_mixin.py](preditor/gui/workbox_mixin.py)
209
209
  for the full interface to implement all features of an editor.
210
210
 
211
+ * `preditor.plug.loggerwindow`: Used to customize the LoggerWindow instance when
212
+ the LoggerWindow is created. For example, this can be used to create extra Toolbars
213
+ or add menu items. When using this plugin, make sure to use the
214
+ `preditor.gui.logger_window_plugin.LoggerWindowPlugin` class for your base class.
215
+
211
216
  * `preditor.plug.logging_handlers`: Used to add custom python logging handlers
212
217
  to the LoggingLevelButton's handlers sub-menus. This allows you to install a
213
218
  handler instance on a specific logging object.
@@ -1,4 +1,4 @@
1
- preditor/__init__.py,sha256=MDcjs6rNu92NDVu-fH3sZWgLtVKnWqDojREeIFU6fII,10735
1
+ preditor/__init__.py,sha256=LGEa5WqdedxVmOm_MeQ2kFDs3xodaWnOMGA8hLubg5E,11843
2
2
  preditor/__main__.py,sha256=boRVSmxX6eF8EkzbePtCZbzdcaPseqVae4RPPLp3U1A,449
3
3
  preditor/about_module.py,sha256=KIvCxZrMLhm5TR6lYskM4Y9VctJ0QtSQD5Nu8Ip1CGY,5267
4
4
  preditor/cli.py,sha256=kyVr0V43KYSMLIEWXH54CA0ByFmPcpbFF-8cli6PVow,5300
@@ -7,43 +7,44 @@ preditor/debug.py,sha256=xcOslCByK7nSebh5DR6m-uC6uV9tuJBZu-JAAPBl8aA,9515
7
7
  preditor/enum.py,sha256=snG5V259dH9SI1kwBqZeZdhat36F1iAmIjYErosnDUg,23489
8
8
  preditor/logging_config.py,sha256=aCqBhnHhcTigpR7neVEPbx4Vc_3ADpiqaBQ7uOd4qRQ,1462
9
9
  preditor/osystem.py,sha256=vRr-WaIzYEO38tJeyHMOlAyrvGaWGBuiyaPx0X9JfZ4,13682
10
- preditor/plugins.py,sha256=W3DfdDEE5DtEXOXioEyIe4tuIVV1V-RLcV8LoZJWpWU,1916
10
+ preditor/plugins.py,sha256=ELajZq_ArzZPMvURpwZuLpsURF5vWrL22dLwx0rO3nA,4275
11
11
  preditor/prefs.py,sha256=BPtSsdv2yuiRpIaqEml9fxlVYKHNfqQ77hp5YIQRDBg,2172
12
12
  preditor/settings.py,sha256=DV9_DbJorEnhdIvW15E7h7PswlQUsy0UlA8bXUYN0og,2206
13
13
  preditor/streamhandler_helper.py,sha256=kiU6T9WqJ3JKTTKCa7IUU8brwK7zO5UUpEzLhEfKe44,1788
14
- preditor/version.py,sha256=34zfsmFU3IpCforo9xUCL1BD7vTjh-viyz-BJYB3xL0,142
14
+ preditor/version.py,sha256=OFbGax8ko2nIQ9RQvu77D8Lj3CgldGEFB97k9nRq6WA,142
15
15
  preditor/weakref.py,sha256=b--KomFAHcMWr3DEAIN2j3XxRhjDWKw0WABXyn1nxDg,12177
16
16
  preditor/cores/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
- preditor/cores/core.py,sha256=ZXB4bts05DMQtc-dtkk81chIWNqYXImMuWCYuUHwLdA,2389
17
+ preditor/cores/core.py,sha256=JNcW4Xx9OM-fuAhCLIunu3v501yM9rniia7P7SUyCfM,2127
18
18
  preditor/dccs/maya/PrEditor_maya.mod,sha256=XTZsiqpSj7AjiB0SOZJct06mk1cLivV7sWIZmg1HoFo,46
19
19
  preditor/dccs/maya/plug-ins/PrEditor_maya.py,sha256=7D5MZb9c0-5Nfz4JVG4X2GecQJWUHE7XEtVZuKH_kWM,3855
20
20
  preditor/delayable_engine/__init__.py,sha256=7GNnc2996zCzBtkB3U9Ic0EcXToVYrlewSMq8hlWNl0,11491
21
21
  preditor/delayable_engine/delayables.py,sha256=GWxv4iTcqFeo7703SMrtotKx4cfq1ujJMNdpmtawPqc,2708
22
- preditor/gui/__init__.py,sha256=vie2aDVpGjrDYxK1H2pTVIgFjIk6B8nNf6rWNwCVJ3Y,3132
22
+ preditor/gui/__init__.py,sha256=DeOH5K4_M0YLNx1i7NRvwCgwjyjkre4vVwlr5OEMx9Q,3423
23
23
  preditor/gui/app.py,sha256=RRiaDpUdWYoVkCFThMfsSSFG63jRt7LKx2QOx8lSdK4,5810
24
24
  preditor/gui/codehighlighter.py,sha256=3JxXZpZqN3KVZbQgSmO-JldSlf4zFQ0PojWwucTsy5U,7171
25
25
  preditor/gui/completer.py,sha256=T6fl_4xGVjVtGNuR6ajD1ngjEhrKR6tZ9zPJDYoKn8E,7379
26
26
  preditor/gui/console.py,sha256=qjr1OtAQ0dAUv4_u_j3Tz8XGRMwkdBAw3JYt46FzlwI,34876
27
- preditor/gui/dialog.py,sha256=Vw8Wflb2P3TngO8b-2suWP6JKHBVHdbGgYiRDKzYRlQ,7488
27
+ preditor/gui/dialog.py,sha256=dsB0wdrb8i5OuAMh19QvDajuJqUDmQADR1JFrxfivug,6411
28
28
  preditor/gui/drag_tab_bar.py,sha256=5J-BSKQzS6_WuYxxGqmnUJr6AriTAvwfVK7Q3p7knrM,7933
29
29
  preditor/gui/editor_chooser.py,sha256=lv1eY0UJOulX1l-P-ZQEoneYz6BNX2VkXEbg3GUu1ag,1991
30
30
  preditor/gui/errordialog.py,sha256=Re-rc4r24bwfUL3YkZGELNhAJD9B220xznbDcXC6EEg,3234
31
31
  preditor/gui/find_files.py,sha256=8_b0oQgL6u8U2FqpR2RzMChME9eYdJq3c3bgXXDeceY,4241
32
- preditor/gui/level_buttons.py,sha256=yPFIWKc0bgKLrP2XHyBqNuvvTnXZqGdtN_p27jSb1Og,11925
33
- preditor/gui/logger_window_handler.py,sha256=VTNhaoFUnConE3NHj9KaDZlVoifix8xCbCuN5Ozjz0M,1482
34
- preditor/gui/loggerwindow.py,sha256=zOIzq12ffLF0xp3oChP0bc7KB_4BJ8kK5Oy0gQSGRuI,51303
32
+ preditor/gui/level_buttons.py,sha256=S7JLsK1-Nu9PLOg7WACOU-Ch41PSCiZ2r-xcnajlPwY,11850
33
+ preditor/gui/logger_window_handler.py,sha256=43-DxzuNJq6UV6Ofc4TKRt179Sf5AxDkVDGrtq_Knok,1571
34
+ preditor/gui/logger_window_plugin.py,sha256=x6mTuS6gmeMZtV0UIXHXIif1_B5oKVbJhuIBaW0BFVs,1210
35
+ preditor/gui/loggerwindow.py,sha256=9ziaO1RrekKh8wVt6jkax29ehbFesaO9OJBI2JkkGGU,53544
35
36
  preditor/gui/newtabwidget.py,sha256=5aCWn9xAl5h1oZACqVuEsOAbzKTS2RegrLI41gROC8A,1971
36
37
  preditor/gui/redmine_login_dialog.py,sha256=cMPBuecSZD5yjycNkMwHa1AbdwgGoyHvX8anIvWjEFo,1893
37
38
  preditor/gui/set_text_editor_path_dialog.py,sha256=bTrYM0nU-pE2m8LIpeAUlmvP257wrcAvEdaoOURw9p8,2264
38
39
  preditor/gui/status_label.py,sha256=SlNRmPc28S4E2OFVmErv0DmZstk4011Q_7uLp43SF0A,3320
39
40
  preditor/gui/suggest_path_quotes_dialog.py,sha256=QUJf_9hs8wOO6bFOr8_Z2xnNhSA8TfKFMOzheUqUDnY,1822
40
- preditor/gui/window.py,sha256=bZAEKQDM6V4aew1nlSTPyq_tG-_IoSvyXHcZxrdFMaE,6924
41
+ preditor/gui/window.py,sha256=IrOAuxRiZcrOdUT4kcVa9s6ES-jpPw-RmG09nZS_56k,5838
41
42
  preditor/gui/workbox_mixin.py,sha256=kUVHtK-flyux3PZ9GkOYnjCJMLRcZESFJXipsgNgI0U,13851
42
43
  preditor/gui/workbox_text_edit.py,sha256=B_xObwwobKzpMuTmwkczTGW9cOem2oF8pZDezCqwPCo,4385
43
44
  preditor/gui/workboxwidget.py,sha256=BDmV3tu5HaZPTpc_h8UtiAag-w7pEKUBNSkqAIz_7IU,10056
44
45
  preditor/gui/fuzzy_search/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
46
  preditor/gui/fuzzy_search/fuzzy_search.py,sha256=6npanW6aLmG_ezdHmpsKN7p2zwck_Qq6YUy9duCNN8Q,3595
46
- preditor/gui/group_tab_widget/__init__.py,sha256=rUvlURDiq2nncgEcGv5LvUNUVl3uLqJ_j4lQtZ8fMQE,12568
47
+ preditor/gui/group_tab_widget/__init__.py,sha256=H1Bzfb6eQpcjYr72zQxWC371-tPeAcK6vSvQpregPWQ,12989
47
48
  preditor/gui/group_tab_widget/grouped_tab_menu.py,sha256=lopd3mjHJIE_5xLdlZL0ghuBzsYo36vO1OZE6L6tqbI,1288
48
49
  preditor/gui/group_tab_widget/grouped_tab_models.py,sha256=zlmbcv3JAC5BzjKpm4CM7Hobibm1T_3GjaPoWIQbXiQ,3970
49
50
  preditor/gui/group_tab_widget/grouped_tab_widget.py,sha256=Z08LE8-ABakpM5Lk8cnntfjtdsmoR_T2ycgSEor7iY0,2928
@@ -51,7 +52,7 @@ preditor/gui/group_tab_widget/one_tab_widget.py,sha256=PdZAXjmV9oTHakh8aFYRlLnfw
51
52
  preditor/gui/ui/editor_chooser.ui,sha256=cYSVHK0A4-zst6JyDkrBZK9qcAontbhV4Mmnw5ps72E,2736
52
53
  preditor/gui/ui/errordialog.ui,sha256=H1wJJVU1t7kbnYkzGtGa8SBVpKjesJG_0imdBkJaEUY,2034
53
54
  preditor/gui/ui/find_files.ui,sha256=8mdD3Vg3ofRMChdKntxiDHO3JXHQSKjjY6OLY_1W5lc,3328
54
- preditor/gui/ui/loggerwindow.ui,sha256=IGoeWPDI4Qym01mTkUR49MDhxpZBWYRHr7s746WfYkw,31528
55
+ preditor/gui/ui/loggerwindow.ui,sha256=r3L46h3YNLiQ1dPvWY24D5Zqrd2X2x5Zs6jMjDTDDyg,31279
55
56
  preditor/gui/ui/redmine_login_dialog.ui,sha256=PmGuJWvBcSDLya5UblFj5brwDH9VL2fJEveH-r5-nJ8,2911
56
57
  preditor/gui/ui/set_text_editor_path_dialog.ui,sha256=VLBpTvGneXAi9RX1dRd6oPwKoZhQ_m5HO1j1qXPhTxc,5201
57
58
  preditor/gui/ui/suggest_path_quotes_dialog.ui,sha256=0hcr7kEFmmMVEp7vv18mDpvWZ0zOrojlkTLhIWCFKww,5923
@@ -149,9 +150,9 @@ preditor/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
149
150
  preditor/utils/cute.py,sha256=LfF8gXMAkkQAdo4mm6J9aVkDLwWZbE6prQ0moDbtCys,1045
150
151
  preditor/utils/stylesheets.py,sha256=EVWZNq3WnaRiyUPoYMKQo_dLEwbRyKu26b03I1JDA-s,1622
151
152
  preditor/utils/text_search.py,sha256=21kuSDTpLIPUcriB81WP1kWfzuDBuP13ZtHUtypP5jE,14218
152
- preditor-0.8.0.dist-info/licenses/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
153
- preditor-0.8.0.dist-info/METADATA,sha256=o2K-bjOLQeGKMgba1b9UzwiUOIHVoA5JAdVdrwlMuNk,9278
154
- preditor-0.8.0.dist-info/WHEEL,sha256=egKm5cKfE6OqlHwodY8Jjp4yqZDBXgsj09UsV5ojd_U,109
155
- preditor-0.8.0.dist-info/entry_points.txt,sha256=mpe0HFD_oIEBNPTJNyUEbmMV6Ivrp4EuYyZ34C5d_PU,519
156
- preditor-0.8.0.dist-info/top_level.txt,sha256=iX1_mrUOky_BQr2oG0l_MbEUYF6idyjiWSzu9z3irIw,9
157
- preditor-0.8.0.dist-info/RECORD,,
153
+ preditor-0.9.0.dist-info/licenses/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
154
+ preditor-0.9.0.dist-info/METADATA,sha256=41tycEwN8Wb8SG1zchMUX81zQIRchAoLgO7Un2OIKF4,9590
155
+ preditor-0.9.0.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
156
+ preditor-0.9.0.dist-info/entry_points.txt,sha256=mpe0HFD_oIEBNPTJNyUEbmMV6Ivrp4EuYyZ34C5d_PU,519
157
+ preditor-0.9.0.dist-info/top_level.txt,sha256=iX1_mrUOky_BQr2oG0l_MbEUYF6idyjiWSzu9z3irIw,9
158
+ preditor-0.9.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.8.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any