Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replay events via log control's context menu #49

Merged
merged 1 commit into from Apr 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions eg/Classes/MainFrame/LogCtrl.py
Expand Up @@ -19,6 +19,7 @@
import eg
import wx
import collections
from ast import literal_eval
from time import strftime, localtime
import wx.lib.mixins.listctrl as listmix

Expand Down Expand Up @@ -82,6 +83,10 @@ def __init__(self, parent):
self.Bind(wx.EVT_MENU, self.OnCmdCopy, id=wx.ID_COPY)
menu.AppendSeparator()
menuId = wx.NewId()
menu.Append(menuId, eg.text.MainFrame.Menu.Replay)
self.Bind(wx.EVT_MENU, self.OnCmdReplay, id=menuId)
menu.AppendSeparator()
menuId = wx.NewId()
menu.Append(menuId, eg.text.MainFrame.Menu.ClearLog)
self.Bind(wx.EVT_MENU, self.OnCmdClearLog, id=menuId)
self.contextMenu = menu
Expand Down Expand Up @@ -225,6 +230,19 @@ def OnCmdClearLog(self, dummyEvent=None):
self.Refresh()


def OnCmdReplay(self, dummyEvent=None):
item = self.GetFirstSelected()
while item != -1:
text, icon = self.GetItemData(item)[:2]
if icon == eg.Icons.EVENT_ICON:
parts = text.split(" ", 1)
e = parts[0]
prefix, suffix = e.split(".", 1) if "." in e else [e, ""]
payload = literal_eval(parts[1]) if len(parts) == 2 else None
eg.TriggerEvent(suffix, payload, prefix)
item = self.GetNextSelected(item)


def OnRightUp(self, dummyEvent):
self.PopupMenu(self.contextMenu)

Expand Down
1 change: 1 addition & 0 deletions eg/Classes/Text.py
Expand Up @@ -164,6 +164,7 @@ class Menu:
CheckUpdate = "Check for Update..."
PythonShell = "Python Shell"
Reset = "Reset"
Replay = "&Replay"

class SaveChanges:
mesg = (
Expand Down