Skip to content

Commit 07a15b0

Browse files
committed
add some tips
1 parent b4d92cc commit 07a15b0

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

devsimpy/plugins/verbose.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,28 @@ def start_print_data(*args, **kwargs):
181181
global verbose_log
182182

183183
frame = wx.Frame(parent, wx.ID_ANY, _("Simulation Report"))
184-
184+
# create a toolbar with copy icon
185+
tb = frame.CreateToolBar()
186+
copy_tool = tb.AddTool(wx.ID_COPY, _("Copy"), wx.ArtProvider.GetBitmap(wx.ART_COPY, wx.ART_TOOLBAR))
187+
saveas_tool = tb.AddTool(wx.ID_SAVEAS, _("Save As"), wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_TOOLBAR))
188+
tb.Realize()
189+
185190
# Add a panel so it looks the correct on all platforms
186191
panel = wx.Panel(frame, wx.ID_ANY)
187192
log = wx.richtext.RichTextCtrl(panel, wx.ID_ANY, size=wx.DefaultSize, style=wx.richtext.RE_READONLY|wx.richtext.RE_MULTILINE)
188193

194+
# copy button action
195+
def on_copy(event):
196+
text = log.GetValue()
197+
if wx.TheClipboard.Open():
198+
wx.TheClipboard.SetData(wx.TextDataObject(text))
199+
wx.TheClipboard.Close()
200+
else:
201+
wx.MessageBox(_("Unable to open clipboard"), _("Error"))
202+
203+
tb.Bind(wx.EVT_TOOL, on_copy, copy_tool)
204+
205+
189206
# Filter controls
190207
filter_sizer = wx.BoxSizer(wx.HORIZONTAL)
191208
filter_label = wx.StaticText(panel, wx.ID_ANY, _("Filter by model name:"))
@@ -339,6 +356,8 @@ def on_save_as(event):
339356
wx.LogError(_("Cannot save current data in file '%s'.") % pathname)
340357

341358
frame.Bind(wx.EVT_MENU, on_save_as, saveas_item)
359+
# also bind toolbar save button
360+
tb.Bind(wx.EVT_TOOL, on_save_as, saveas_tool)
342361

343362
# Add widgets to a sizer
344363
sizer = wx.BoxSizer(wx.VERTICAL)

0 commit comments

Comments
 (0)