示例#1
0
    def on_activate(self, event):
        # close a bric properties box so this change can be reflected in the box
        win_data.selection_drop_all()

        index = event.GetIndex()
        loc = self.list.GetItemText(index)
        loc_num = int(loc, 10)
        dtype, name = win_data.config_get(loc_num)
        data = (loc, dtype, name)

        dialog = Config_dialog(self, "Edit module name", data)

        #dialog.CenterOnScreen()
        result = dialog.ShowModal()
        if (result == wx.ID_OK):
            new_name = dialog.get_data()
            dialog.Destroy()

            # any change?
            if (new_name == data[2]):
                return

            error_message = ""
            # verify that the new name is not already used
            if ((len(new_name) > 0)
                    and (new_name[0].isupper() or new_name[0].islower())
                    and (len(new_name) <= 16)):
                # good name - convert any whitespace to underscore
                # Don't want to use replace because I want to handle ALL whitespace characters
                name2 = ""
                for i in range(len(new_name)):
                    if (new_name[i].isspace()):
                        name2 += '_'
                    else:
                        name2 += new_name[i]
                new_name = name2

                if (win_data.config_name_already_used(loc_num, new_name)):
                    error_message = "The module name '%s' is already used" % (
                        new_name, )

            else:
                error_message = "Module names must start with a character and are at most 16 characters long"

            if (error_message):
                wx.MessageBox(error_message,
                              caption="Error editing module name.",
                              style=wx.OK | wx.ICON_ERROR)
            else:

                win_data.config_change_name(loc_num, new_name)
                self.update_list()
                #self.Refresh()

        else:
            dialog.Destroy()
示例#2
0
    def on_activate(self, event):
        # close a bric properties box so this change can be reflected in the box
        win_data.selection_drop_all()

        index = event.GetIndex()
        loc = self.list.GetItemText(index)
        loc_num = int(loc, 10)
        dtype,name = win_data.config_get(loc_num)
        data = (loc, dtype, name)

        dialog = Config_dialog(self, "Edit module name", data)

        #dialog.CenterOnScreen()
        result = dialog.ShowModal()
        if (result == wx.ID_OK):
           new_name = dialog.get_data()
           dialog.Destroy()

           # any change?
           if (new_name == data[2]):
               return

           error_message = ""
           # verify that the new name is not already used
           if ((len(new_name) > 0) and
               (new_name[0].isupper() or new_name[0].islower()) and
               (len(new_name) <= 16)):
               # good name - convert any whitespace to underscore
               # Don't want to use replace because I want to handle ALL whitespace characters
               name2 = ""
               for i in range(len(new_name)):
                   if (new_name[i].isspace()):
                       name2 += '_'
                   else:
                       name2 += new_name[i]
               new_name = name2

               if (win_data.config_name_already_used(loc_num, new_name)):
                   error_message = "The module name '%s' is already used" % (new_name,)

           else:
               error_message = "Module names must start with a character and are at most 16 characters long"



           if (error_message):
               wx.MessageBox(error_message, caption="Error editing module name.", style=wx.OK | wx.ICON_ERROR)
           else:

               win_data.config_change_name(loc_num, new_name)
               self.update_list()
               #self.Refresh()


        else:
            dialog.Destroy()
示例#3
0
    def hit_test(self, pt):
        """Is the point on a device?"""
        for loc, name, rect in self.locations_full:
            if (rect.InsideXY(pt.x, pt.y)):
                dtype,name = win_data.config_get(loc)
                if (dtype):
                    return (loc, dtype)
                else:
                    return (-1, None)

        return (-1, None)
示例#4
0
    def hit_test(self, pt):
        """Is the point on a device?"""
        for loc, name, rect in self.locations_full:
            if (rect.InsideXY(pt.x, pt.y)):
                dtype, name = win_data.config_get(loc)
                if (dtype):
                    return (loc, dtype)
                else:
                    return (-1, None)

        return (-1, None)