Skip to content

Commit

Permalink
gui: Add Copy command feature on right-click to GUI History panel (#4927
Browse files Browse the repository at this point in the history
)
  • Loading branch information
aniket2405 authored Jan 10, 2025
1 parent 6e3a9a1 commit f11fc00
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions gui/wxpython/history/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ def _popupMenuCommand(self):
"""Create popup menu for commands"""
menu = Menu()

copyItem = wx.MenuItem(menu, wx.ID_ANY, _("&Copy"))
menu.AppendItem(copyItem)
self.Bind(wx.EVT_MENU, self.OnCopyCmd, copyItem)

item = wx.MenuItem(menu, wx.ID_ANY, _("&Remove"))
menu.AppendItem(item)
self.Bind(wx.EVT_MENU, self.OnRemoveCmd, item)
Expand Down Expand Up @@ -658,3 +662,25 @@ def OnDoubleClick(self, node):
self.CollapseNode(node, recursive=False)
else:
self.ExpandNode(node, recursive=False)

def OnCopyCmd(self, event):
"""Copy selected cmd to clipboard"""
self.DefineItems(self.GetSelected())
if not self.selected_command:
return

selected_command = self.selected_command[0]
command = selected_command.data["name"]

# Copy selected command to clipboard
try:
if wx.TheClipboard.Open():
try:
wx.TheClipboard.SetData(wx.TextDataObject(command))
self.showNotification.emit(
message=_("Command <{}> copied to clipboard").format(command)
)
finally:
wx.TheClipboard.Close()
except wx.PyWidgetError:
self.showNotification.emit(message=_("Failed to copy command to clipboard"))

0 comments on commit f11fc00

Please sign in to comment.