Skip to content

Commit 33203ef

Browse files
committed
Add shortcut to run first workbox
1 parent 4bb274b commit 33203ef

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

preditor/gui/loggerwindow.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ def __init__(self, parent, name=None, run_workbox=False, standalone=False):
218218
self.uiGroup8ACT.triggered.connect(partial(self.gotoGroupByIndex, 8))
219219
self.uiGroupLastACT.triggered.connect(partial(self.gotoGroupByIndex, -1))
220220

221+
self.uiRunFirstWorkboxACT.triggered.connect(self.run_first_workbox)
222+
221223
self.uiFocusNameACT.triggered.connect(self.show_focus_name)
222224

223225
self.uiCommentToggleACT.triggered.connect(self.comment_toggle)
@@ -437,8 +439,13 @@ def workbox_for_name(cls, name, show=False, visible=False):
437439

438440
return workbox
439441

442+
def run_first_workbox(self):
443+
print("# Run first Workbox")
444+
workbox = self.uiWorkboxTAB.widget(0).widget(0)
445+
self.run_workbox("", workbox=workbox)
446+
440447
@classmethod
441-
def run_workbox(cls, name):
448+
def run_workbox(cls, name, workbox=None):
442449
"""This is a function which will be added to __main__, and therefore
443450
available to PythonLogger users. It will accept a string matching the
444451
"{group}/{workbox}" format, or a boolean that will run the current tab
@@ -456,7 +463,8 @@ def run_workbox(cls, name):
456463
run_workbox('some/stuff.py')
457464
(from command line): blurdev launch Python_Logger --run_workbox
458465
"""
459-
workbox = cls.workbox_for_name(name)
466+
if workbox is None:
467+
workbox = cls.workbox_for_name(name)
460468

461469
if workbox is not None:
462470
# if name is True, its ok to run the workbox, this option

preditor/gui/ui/loggerwindow.ui

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
<addaction name="uiClearBeforeRunningACT"/>
144144
<addaction name="uiClearToLastPromptACT"/>
145145
<addaction name="uiSelectTextACT"/>
146+
<addaction name="uiRunFirstWorkboxACT"/>
146147
</widget>
147148
<widget class="QMenu" name="uiOptionsMENU">
148149
<property name="title">
@@ -1013,6 +1014,17 @@ at the indicated line in the specified text editor.
10131014
<string>Visually Separate PrEditor Traceback</string>
10141015
</property>
10151016
</action>
1017+
<action name="uiRunFirstWorkboxACT">
1018+
<property name="text">
1019+
<string>Run First Workbox</string>
1020+
</property>
1021+
<property name="toolTip">
1022+
<string>Run First Workbox, which may have things like common import, helper functions, etc.</string>
1023+
</property>
1024+
<property name="shortcut">
1025+
<string>Alt+1</string>
1026+
</property>
1027+
</action>
10161028
</widget>
10171029
<customwidgets>
10181030
<customwidget>

0 commit comments

Comments
 (0)