Repository: psychopy/psychopy

Issue:
"Tools" > "csv from psydat" still crashes
Clicking on the menu item still crashes in Coder with the following error.

```
Traceback (most recent call last):
  File "C:\Users\matth\PycharmProjects\psychopy\psychopy\app\coder\coder.py", line 2662, in onUnitTests
    self.unitTestFrame = UnitTestFrame(app=self.app)
  File "C:\Users\matth\PycharmProjects\psychopy\psychopy\app\coder\coder.py", line 337, in __init__
    self.menuTests.Append(self.IDs.openCoderView,
  File "C:\Users\matth\PycharmProjects\psychopy\psychopy\app\_psychopyApp.py", line 126, in __getattr__
    return self[attr]
KeyError: 'openCoderView'
```


Discussion:

Resolving patch:
diff --git a/psychopy/app/builder/builder.py b/psychopy/app/builder/builder.py
--- a/psychopy/app/builder/builder.py
+++ b/psychopy/app/builder/builder.py
@@ -1056,6 +1056,7 @@ def runFile(self, event=None):
                 return  # save file before compiling script
 
         self.stdoutFrame.addTask(fileName=self.filename)
+        self.app.runner.Raise()
         if event:
             if event.Id in [self.bldrBtnRun.Id, self.bldrRun.Id]:
                 self.app.runner.panel.runLocal(event)
@@ -2122,9 +2123,11 @@ def addComponentButton(self, name, panel):
         for redundant in ['component', 'Component', "ButtonBox"]:
             shortName = shortName.replace(redundant, "")
         # Convert from CamelCase to Title Case for button label
-        label = shortName
-        for c in "".join(c if c.isupper() else "" for c in name[1:]):
-            label = label.replace(c, "\n"+c)
+        label = ""
+        for i, c in enumerate(shortName):
+            if c.isupper() and i > 0:
+                label += "\n"
+            label += c
         # set size
         size = 48
         # get tooltip
diff --git a/psychopy/app/coder/coder.py b/psychopy/app/coder/coder.py
--- a/psychopy/app/coder/coder.py
+++ b/psychopy/app/coder/coder.py
@@ -10,6 +10,7 @@
 # from future import standard_library
 # standard_library.install_aliases()
 import json
+from past.builtins import unicode
 from builtins import chr
 from builtins import range
 import wx
@@ -240,6 +241,8 @@ def __init__(self, parent, style, size=None, **kwargs):
         def write(self, inStr):
             self.MoveEnd()  # always 'append' text rather than 'writing' it
             for thisLine in inStr.splitlines(True):
+                if not isinstance(thisLine, unicode):
+                    thisLine = unicode(thisLine)
                 if thisLine.startswith('OK'):
                     self.BeginBold()
                     self.BeginTextColour(self.good)
@@ -339,10 +342,10 @@ def __init__(self, parent=None, ID=-1,
             "&Close tests panel\t%s") % self.app.keys['close'])
         self.Bind(wx.EVT_MENU, self.onCloseTests, id=wx.ID_CLOSE)
         _switch = self.app.keys['switchToCoder']
-        self.menuTests.Append(self.IDs.openCoderView,
+        self.menuTests.Append(wx.ID_ANY,
                               _translate("Go to &Coder view\t%s") % _switch,
                               _translate("Go to the Coder view"))
-        self.Bind(wx.EVT_MENU, self.app.showCoder, id=self.IDs.openCoderView)
+        self.Bind(wx.EVT_MENU, self.app.showCoder)
         # -------------quit
         self.menuTests.AppendSeparator()
         _quit = self.app.keys['quit']
@@ -351,7 +354,7 @@ def __init__(self, parent=None, ID=-1,
                               _translate("Terminate PsychoPy"))
         self.Bind(wx.EVT_MENU, self.app.quit, id=wx.ID_EXIT)
         item = self.menuTests.Append(
-            wx.ID_PREFERENCES, text=_translate("&Preferences"))
+            wx.ID_PREFERENCES, _translate("&Preferences"))
         self.Bind(wx.EVT_MENU, self.app.showPrefs, item)
         self.SetMenuBar(menuBar)
 
@@ -2481,9 +2484,11 @@ def runFile(self, event=None):
             elif resp == wx.ID_NO:
                 pass  # just run
         self.app.runner.addTask(fileName=fullPath)
+        self.app.runner.Raise()
         if event:
             if event.Id in [self.cdrBtnRun.Id, self.IDs.cdrRun]:
                 self.app.runner.panel.runLocal(event)
+                self.Raise()
             else:
                 self.app.showRunner()
 


Test patch: