Ejemplo n.º 1
0
    def flickerWindow(self, times, negColor):
        '''
          Function for giving a flickering-effect as a negative-feedback
        '''
        if self.debug: print "E_UI.flickerWindow"

        negColor = negColor.split("/")
        if len(negColor) > 1:  # this is Hexadecimal-code
            RGBcode = negColor[1].split(",")
            for i in xrange(3):
                RGBcode[i] = commonFunc.HexToDec(
                    RGBcode[i]
                )  # Converting the hexadecimal-code to the decimal number
            negColor = (wx.Colour(RGBcode[0], RGBcode[1], RGBcode[2]))
        else:
            negColor = negColor[0].strip()

        for i in range(times):
            self.mainPanel.SetBackgroundColour(negColor)
            wx.SafeYield()
            time.sleep(0.03)
            self.mainPanel.SetBackgroundColour('white')
            wx.SafeYield()
            time.sleep(0.03)
        self.mainPanel.SetBackgroundColour(self.mainPanelColour)
Ejemplo n.º 2
0
    def negColorWindow(self, negColor):
        '''
          Function for showing negative-feedback screen
        '''
        if self.debug: print "E_UI.negColorWindow"

        negColor = negColor.split("/")
        if len(negColor) > 1:  # this is Hexadecimal-code
            RGBcode = negColor[1].split(",")
            for i in xrange(3):
                RGBcode[i] = commonFunc.HexToDec(
                    RGBcode[i]
                )  # Converting the hexadecimal-code to the decimal number
            negColor = (wx.Colour(RGBcode[0], RGBcode[1], RGBcode[2]))
        else:
            negColor = negColor[0].strip()
        self.mainPanel.SetBackgroundColour(negColor)
        self.mainPanel.Refresh()
        wx.SafeYield()
        wx.FutureCall(1550, self.restore_original_bg_color)
Ejemplo n.º 3
0
    def __init__(self, parent, debugFlag, title=""):
        self.exptApp = exptApp  # connect exptApp to the E_UI class

        if wx.Display.GetCount() > 1 and exptApp.settings[
                "2ND_MONITOR"]:  # if there's more than one monitor, and want to use the 2nd monitor
            self.screenPos = (wx.Display(1).GetGeometry()[0],
                              wx.Display(1).GetGeometry()[1]
                              )  # will be positioned on the 2nd monitor
            self.screenSize = (
                wx.Display(1).GetGeometry()[2], wx.Display(1).GetGeometry()[3]
            )  # full-size will be the size of the 2nd monitor
        else:
            self.screenPos = (0, 0)
            self.screenSize = (wx.Display(0).GetGeometry()[2],
                               wx.Display(0).GetGeometry()[3])

        ### define the style of the window
        frame_style = wx.DEFAULT_FRAME_STYLE
        if exptApp.settings["OPERATING_SYSTEM"] == 'mac':
            if exptApp.settings["WINDOW_STYLE"].upper() == 'MINIMIZE':
                frame_style = wx.MINIMIZE

        # Initialize the Frame
        wx.Frame.__init__(self,
                          parent,
                          -1,
                          title,
                          pos=self.screenPos,
                          size=self.screenSize,
                          style=frame_style)

        # When the 'fullscreen' is True, make it Full-Screen
        if exptApp.settings["FULLSCREEN"]:
            # When the secondary monitor is not used, make it to FullScreen-mode
            if not exptApp.settings["2ND_MONITOR"]:
                self.ShowFullScreen(True, style=wx.FULLSCREEN_ALL)
        else:
            self.SetSize((exptApp.displayWidth, exptApp.displayHeight))

        self.Center()

        self.debug = debugFlag

        self.mainPanel = wx.Panel(
            self,
            pos=self.screenPos,
            size=(self.GetSize()[0], self.GetSize()[1]))  # main-panel set-up
        if exptApp.settings.has_key("MAINPANEL_BGCOLOR"):
            ### Change the background-color
            bgColor = exptApp.settings["MAINPANEL_BGCOLOR"].split("/")
            if len(bgColor) > 1:  # this is Hexadecimal-code
                RGBcode = bgColor[1].split(",")
                for i in xrange(3):
                    RGBcode[i] = commonFunc.HexToDec(
                        RGBcode[i]
                    )  # Converting the hexadecimal-code to the decimal number
                self.mainPanelColour = (wx.Colour(RGBcode[0], RGBcode[1],
                                                  RGBcode[2]))
            else:
                self.mainPanelColour = bgColor[0].strip()
        else:
            self.mainPanelColour = self.GetBackgroundColour()
        self.mainPanel.SetBackgroundColour(self.mainPanelColour)

        # Monitoring.
        # Purpose : When the experiment is going on the 2nd monitor,
        # the experimenter can monitor certain things on the 1st monitor.
        if exptApp.settings["2ND_MONITOR"] and exptApp.settings.has_key(
                "2ND_MONITOR_MONITORING"):
            if exptApp.settings["2ND_MONITOR_MONITORING"] == True:
                self.CreateMonitoringFrame(title)

        self.CreateMediaPanel(
        )  # panel for presenting stimuli. getting response depending on the experiment-type

        self.CreateResponder(
        )  # Connects the panel to receive the response from the subject

        ### Hide cursor on the panels when the setting allows it.
        if exptApp.settings.has_key("HIDE_CURSOR"):
            if exptApp.settings["HIDE_CURSOR"]:
                cursor = wx.StockCursor(wx.CURSOR_BLANK)
                self.set_cursor_on_panels(cursor)

        ### ButtonBox-setup when the setting allows it.
        if exptApp.settings.has_key("BUTTONBOX"):
            if exptApp.settings[
                    "BUTTONBOX"]:  # only if the 'buttonBox' is True
                self.usbbox = ExptModule.USBBox()
                self.usbbox.commands.add_callback(
                    ExptModule.REPORT.KEYDN,
                    self.OnBBPress)  # Binding the ButtonBox-press
                self.usbDeviceFlag = "open"  # a flag to control the incoming information for the buttonbox
                self.pollButtonBox()

        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

        ### Connecting key-inputs with some functions
        if exptApp.settings.has_key("KEY_BINDING"):
            accel_list = []
            for i in range(len(exptApp.settings["KEY_BINDING"])):
                _key = exptApp.settings["KEY_BINDING"][i][0].split(".")
                _bound_func = exptApp.settings["KEY_BINDING"][i][1].split(".")
                special_key = wx.ACCEL_NORMAL
                if _key[0].upper() == "CTRL": special_key = wx.ACCEL_CTRL
                elif _key[0].upper() == "ALT": special_key = wx.ACCEL_ALT
                if _key[1].upper().startswith('WXK'):
                    key_string = eval('wx.%s' % _key[1].upper())
                else:
                    key_string = ord(_key[1].upper())
                if _bound_func[0] == 'main':
                    bound_function = eval('self.%s' % _bound_func[1])
                elif _bound_func[0] == 'expmt_module':
                    bound_function = eval('self.mediaPanel.%s' %
                                          _bound_func[1])
                self.Bind(wx.EVT_MENU, bound_function, id=i)
                accel_list.append((special_key, key_string, i))
            accel_tbl = wx.AcceleratorTable(accel_list)
            self.SetAcceleratorTable(accel_tbl)