예제 #1
0
    def on_left_up(self, event):
        loc = -1
        self.scroll_x, self.scroll_y = 0, 0

        if (self.drag_image):
            pt = event.GetPosition()
            loc, update, which_id = self.local_move_centre_pt(
                pt, self.drag_name, self.drag_image)

            self.drag_bmp = None
            self.drag_image.Hide()
            self.drag_image.EndDrag()
            self.drag_image = None

            if (loc == -1):
                win_data.selection_drop_all()
                if (not win_data.get_ok_to_delete("Program")):
                    win_data.program().abort_move()
                else:
                    win_data.program().end_move(loc, which_id)
                    self.big_x = -1
                    self.Refresh(True)
                    self.Update()
            else:
                win_data.program().end_move(loc, which_id)
                win_data.click_sound()

        # force the work area to redraw
        self.SetCursor(wx.NullCursor)
        self.Refresh()
예제 #2
0
    def on_left_up(self, event):
        loc = -1
        self.scroll_x, self.scroll_y = 0,0
        
        if (self.drag_image):
            pt = event.GetPosition()
            loc,update,which_id = self.local_move_centre_pt(pt, self.drag_name, self.drag_image)

            self.drag_bmp = None
            self.drag_image.Hide()
            self.drag_image.EndDrag()
            self.drag_image = None

            if (loc == -1):
                win_data.selection_drop_all()
                if (not win_data.get_ok_to_delete("Program")):
                    win_data.program().abort_move()
                else:
                    win_data.program().end_move(loc, which_id)
                    self.big_x = -1
                    self.Refresh(True)
                    self.Update()
            else:
                win_data.program().end_move(loc, which_id)
                win_data.click_sound()
                
        # force the work area to redraw
        self.SetCursor(wx.NullCursor)
        self.Refresh()
예제 #3
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()
예제 #4
0
파일: config_win.py 프로젝트: k10a1g/Edware
    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()
예제 #5
0
    def add_variable(self, index=None):
        # close a bric properties box so this change can be reflected in the box
        win_data.selection_drop_all()

        key = None
        old_len = 0

        if (index != None):
            title = "Edit variable"
            key = self.list.GetItemText(index)
            var_data = win_data.vars_get(key)
            data = (key, var_data[0], var_data[1], var_data[2])
            old_len = int(var_data[1])
        else:
            title = "Add variable"
            data = NEW_DATA

        dialog = Var_dialog(self, title, data)

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

            # verify the edit was OK
            error_message = ""
            if (new_data[0] == ""):
                # verify that data[0] was not being used in the program
                if (win_data.vars_used_in_program(data[0])):
                    error_message = "Variable name '"+data[0]+"' is used in the program. "+\
                                    "Change the program before removing this variable."

            else:
                if (new_data[0] != data[0]):
                    if ((new_data[0][0].isupper() or new_data[0][0].islower())
                            and (len(new_data[0]) <= 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_data[0])):
                            if (new_data[0][i].isspace()):
                                name2 += '_'
                            else:
                                name2 += new_data[0][i]
                        new_data[0] = name2

                        # verify that the new name is not already used
                        if (win_data.vars_exists(new_data[0])):
                            error_message = "Variable name '" + new_data[
                                0] + "' is already used."

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

                if (new_data[1] not in VALID_RANGES):
                    # verify that range is valid
                    error_message = "Variable range must be one of: %s, %s" % \
                                    (VALID_RANGES[0], VALID_RANGES[1])

                # verify that initial value is reasonable (if used)
                if (not self.check_length_and_initial(new_data[1], new_data[2],
                                                      new_data[3])):
                    error_message = "Variable length (%s) or initial value (%s) is not in the valid range." %\
                                    (new_data[2], new_data[3])

                # and verify that there is size left
                if (win_data.vars_no_room_left(new_data[1],
                                               int(new_data[2]) - old_len)):
                    error_message = "Not enough room for %s more variable(s) of type %s." %\
                                    (new_data[2], new_data[1])

            if (error_message):
                wx.MessageBox(error_message,
                              caption="Error editing variable.",
                              style=wx.OK | wx.ICON_ERROR)
            else:
                if (key):
                    if (len(new_data[0]) > 0):
                        # is it a major change and in use?
                        #print "Key", key, data[1], new_data[1]
                        if (win_data.vars_used_in_program(key)
                                and (new_data[1] != data[1])):

                            error_message="Error - Can not change the range of a variable that is " +\
                                          "being used in the program."
                            wx.MessageBox(error_message,
                                          caption="Can't change the range.",
                                          style=wx.OK | wx.ICON_ERROR)

                        else:
                            win_data.vars_change(key, new_data[0], new_data[1],
                                                 new_data[2], new_data[3])
                            self.update_list()

                    else:
                        if (not win_data.vars_remove(key)):
                            error_message="Can not delete the variable as it is used in the program.\n" +\
                                           "Delete it from the program before deleting it here."
                            wx.MessageBox(error_message,
                                          caption="Can't delete variable.",
                                          style=wx.OK | wx.ICON_ERROR)
                        else:
                            self.update_list()

                else:
                    if (len(new_data[0]) > 0):
                        win_data.vars_add(new_data[0], new_data[1],
                                          new_data[2], new_data[3])
                        self.update_list()

                #self.Refresh()

        else:
            dialog.Destroy()
예제 #6
0
파일: var_win.py 프로젝트: Bdanilko/Edware
    def add_variable(self, index = None):
        # close a bric properties box so this change can be reflected in the box
        win_data.selection_drop_all()

        key = None
        old_len = 0

        if (index != None):
            title = "Edit variable"
            key = self.list.GetItemText(index)
            var_data = win_data.vars_get(key)
            data = (key, var_data[0], var_data[1], var_data[2])
            old_len = int(var_data[1])
        else:
            title = "Add variable"
            data = NEW_DATA

        dialog = Var_dialog(self, title, data)

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

           # verify the edit was OK
           error_message = ""
           if (new_data[0] == ""):
               # verify that data[0] was not being used in the program
               if (win_data.vars_used_in_program(data[0])):
                   error_message = "Variable name '"+data[0]+"' is used in the program. "+\
                                   "Change the program before removing this variable."

           else:
               if (new_data[0] != data[0]):
                   if ((new_data[0][0].isupper() or new_data[0][0].islower()) and
                       (len(new_data[0]) <= 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_data[0])):
                           if (new_data[0][i].isspace()):
                               name2 += '_'
                           else:
                               name2 += new_data[0][i]
                       new_data[0] = name2

                       # verify that the new name is not already used
                       if (win_data.vars_exists(new_data[0])):
                           error_message = "Variable name '"+new_data[0]+"' is already used."

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

               if (new_data[1] not in VALID_RANGES):
                   # verify that range is valid
                   error_message = "Variable range must be one of: %s, %s" % \
                                   (VALID_RANGES[0], VALID_RANGES[1])

               # verify that initial value is reasonable (if used)
               if (not self.check_length_and_initial(new_data[1], new_data[2], new_data[3])):
                   error_message = "Variable length (%s) or initial value (%s) is not in the valid range." %\
                                   (new_data[2], new_data[3])

               # and verify that there is size left
               if (win_data.vars_no_room_left(new_data[1], int(new_data[2]) - old_len)):
                   error_message = "Not enough room for %s more variable(s) of type %s." %\
                                   (new_data[2], new_data[1])

           if (error_message):
               wx.MessageBox(error_message, caption="Error editing variable.", style=wx.OK | wx.ICON_ERROR)
           else:
               if (key):
                   if (len(new_data[0]) > 0):
                       # is it a major change and in use?
                       #print "Key", key, data[1], new_data[1]
                       if (win_data.vars_used_in_program(key) and
                           (new_data[1] != data[1])):

                           error_message="Error - Can not change the range of a variable that is " +\
                                         "being used in the program."
                           wx.MessageBox(error_message, caption="Can't change the range.", style=wx.OK | wx.ICON_ERROR)

                       else:
                           win_data.vars_change(key, new_data[0], new_data[1], new_data[2], new_data[3])
                           self.update_list()


                   else:
                       if (not win_data.vars_remove(key)):
                           error_message="Can not delete the variable as it is used in the program.\n" +\
                                          "Delete it from the program before deleting it here."
                           wx.MessageBox(error_message, caption="Can't delete variable.", style=wx.OK | wx.ICON_ERROR)
                       else:
                           self.update_list()


               else:
                   if (len(new_data[0]) > 0):
                       win_data.vars_add(new_data[0], new_data[1], new_data[2], new_data[3])
                       self.update_list()

               #self.Refresh()


        else:
            dialog.Destroy()