def OnSave(self, _e):
     correct_data = True
     correct_pattern = "^[0-9a-zA-Z _]+$"
     regex = re.compile(correct_pattern)
     name = self.name_text_ctrl.GetValue()
     if self.randomCheckBox.IsChecked():
         random = "Yes"
     else:
         random = "No"
     tags = self.tag_ctrl.tags
     if not regex.match(name) or len(tags) == 0:
         correct_data = False
     if correct_data:
         if self.modifying:
             self.main_facade.update_activity(SoundPresentation,
                                              self.activity_id, name,
                                              random, tags)
         else:
             self.main_facade.add_activity(SoundPresentation, -1, name,
                                           random, tags)
         self.main_window.refresh_activities()
         self.Destroy()
     else:
         InfoDialog(
             _("Please, don't forget to fill all fields.{0}Also remember to add at least one "
               "tag{0}Name only allows alphanumeric symbols, underscore and space"
               ).format(os.linesep)).show()
Пример #2
0
    def OnSavePreferences(self, _e):
        new_config = self.main_facade.conf
        previous_language = new_config.language
        new_config.language = language_codes[languages.index(self.language_combo_box.GetValue())]
        new_config.checkForUpdatesOnStart = "Yes" if self.check_for_updates_check_box.IsChecked() else "No"
        new_config.defaultMode = "Demo mode" if self.default_mode_list_box.GetStringSelection() == _("Demo mode") \
            else "Device connected mode"
        new_config.bluetoothSupport = "Yes" if self.bluetooth_support_check_box.IsChecked() else "No"
        new_config.antSupport = "Yes" if self.ant_support_check_box.IsChecked() else "No"

        new_config.scanDevicesOnStartup = "Yes" if self.scan_devices_on_startup_check_box.IsChecked() else "No"
        new_config.remoteDebugger = "Yes" if self.remote_debugger_check_box.IsChecked() else "No"

        new_config.rdIP = self.rd_ip_text_ctrl.GetValue()
        if valid_ip(new_config.rdIP):
            new_config.rdPort = self.rd_port_text_ctrl.GetValue()
            self.main_facade.save_config()
            if new_config.remoteDebugger == "Yes":
                self.main_facade.activate_remote_debug(new_config.rdIP, int(new_config.rdPort))
            else:
                self.main_facade.deactivate_remote_debug()
            if previous_language != new_config.language:
                InfoDialog(_("Changing the language requires rebooting application")).show()
            self.Destroy()
        else:
            ErrorDialog(_("Remote debugger IP field must be a valid ip, although it had not been activated.")).show()
Пример #3
0
    def _OnSave(self, _e):
        correct_data = True

        correct_pattern = "^[0-9a-zA-Z _]+$"
        regex = re.compile(correct_pattern)

        name = self.name_text_ctrl.GetValue()
        screentext = self.screentext_text_ctrl.GetValue()
        if self.finish_type_ctrl.GetValue() == _("Timed"):
            finish_type = "Timed"
        elif self.finish_type_ctrl.GetValue() == (_("Key (SPACE BAR)")):
            finish_type = "Key (SPACE BAR)"
        time = self.time_ctrl.GetValue()
        tag = ManualDefinedTag(name, screentext, finish_type, time)

        if not regex.match(name) or not regex.match(
                screentext) or finish_type == "":
            correct_data = False

        if correct_data:
            if self.modifying:
                self.parent.modify_tag(self.tag_id, tag)
                self.Destroy()
            else:
                self.parent.add_tag(tag)
                self.Destroy()
        else:
            InfoDialog(
                _("""Please, don't forget to fill all fields with valid data
- Every fields are mandatory
- Allowed symbols for tag name and screen text:
    alphanumeric, space and underscore""")).show()
    def _OnSave(self, _e):
        correct_data = True

        correct_pattern = r"^[0-9a-zA-Z _]+$"
        regex = re.compile(correct_pattern)

        name = self.name_text_ctrl.GetValue()
        path = self.path_text_ctrl.GetValue()
        if self.associated_sound_checkbox.IsChecked():
            associated_sound = "Yes"
        else:
            associated_sound = "No"
        sounds = [
            Sound(sound_path) for sound_path in self.sounds_listbox.GetItems()
        ]
        tag = PhotoPresentationTag(name, path, associated_sound, sounds)

        if not regex.match(name) or path == "" or not os.path.isdir(path):
            correct_data = False

        if associated_sound == "Yes" and len(sounds) == 0:
            correct_data = False

        if correct_data:
            if self.modifying:
                self.parent.modify_tag(self.tag_id, tag)
                self.Destroy()
            else:
                self.parent.add_tag(tag)
                self.Destroy()
        else:
            InfoDialog(
                _("Please, fill all fields with valid data{0}"
                  "Name only allows alphanumeric symbols, underscore and space"
                  ).format(os.linesep)).show()
Пример #5
0
 def OnTagDown(self, _e):
     selected_row = self.tags_grid.GetFirstSelected()
     if selected_row != -1:
         self.tag_ctrl.down_tag(selected_row)
         self.refresh_tags()
         if selected_row < self.tags_grid.GetItemCount() - 1:
             self.tags_grid.Select(selected_row + 1)
         else:
             self.tags_grid.Select(self.tags_grid.GetItemCount() - 1)
     else:
         InfoDialog(_("You must select a tag")).show()
Пример #6
0
 def OnTagUp(self, _e):
     selected_row = self.tags_grid.GetFirstSelected()
     if selected_row != -1:
         self.tag_ctrl.up_tag(selected_row)
         self.refresh_tags()
         if selected_row > 0:
             self.tags_grid.Select(selected_row - 1)
         else:
             self.tags_grid.Select(0)
     else:
         InfoDialog(_("You must select a tag")).show()
Пример #7
0
    def OnRemoveTag(self, _e):
        selected_row = self.tags_grid.GetFirstSelected()
        if selected_row != -1:
            result = ConfirmDialog(_("Are you sure to delete that tag?"),
                                   _("Confirm delete operation")).get_result()
            if result == wx.ID_YES:
                self.tag_ctrl.remove_tag(selected_row)
                self.refresh_tags()

        else:
            InfoDialog(_("You must select a tag")).show()
    def _OnSave(self, _):
        correct_data = True
        name = self.name_text_ctrl.GetValue()
        path = self.path_text_ctrl.GetValue()
        tag = VideoTag(name, path)

        if name == "" or path == "" or not os.path.isfile(path):
            correct_data = False

        if correct_data:
            if self.modifying:
                self.parent.modify_tag(self.tag_id, tag)
                self.Destroy()
            else:
                self.parent.add_tag(tag)
                self.Destroy()
        else:
            InfoDialog(
                _("Please, don't forget to fill all fields with valid data")
            ).show()
    def _OnSave(self, _e):
        correct_data = True

        correct_pattern = "^[0-9a-zA-Z _]+$"
        regex = re.compile(correct_pattern)

        name = self.name_text_ctrl.GetValue()
        path = self.path_text_ctrl.GetValue()
        if self.random_checkbox.IsChecked():
            random = "Yes"
        else:
            random = "No"
        if self.associated_image_checkbox.IsChecked():
            associated_image = "Yes"
        else:
            associated_image = "No"
        images = [
            Image(image_path) for image_path in self.images_listbox.GetItems()
        ]
        tag = SoundPresentationTag(name, path, random, associated_image,
                                   images)

        if not regex.match(name) or path == "" or not os.path.isfile(path):
            correct_data = False

        if associated_image == "Yes" and len(images) == 0:
            correct_data = False

        if correct_data:
            if self.modifying:
                self.parent.modify_tag(self.tag_id, tag)
                self.Destroy()
            else:
                self.parent.add_tag(tag)
                self.Destroy()
        else:
            InfoDialog(
                _("Please, don't forget to fill all fields with valid data{0}"
                  "Name only allows alphanumeric symbols, underscore and space"
                  ).format(os.linesep)).show()
Пример #10
0
    def _OnSave(self, _e):
        correct_data = True

        correct_pattern = "^[0-9a-zA-Z _]+$"
        regex = re.compile(correct_pattern)

        name = self.name_text_ctrl.GetValue()
        screentext = self.screentext_text_ctrl.GetValue()
        key = self.key_text_ctrl.GetValue()
        tag = AssociatedKeyTag(name, screentext, key)
        if not regex.match(screentext) or not regex.match(
                name) or key == "" or (key in self.used_keys
                                       and key != self.previous_key):
            correct_data = False
        else:
            try:
                keystring = str(key)
                if not keystring.isalnum():
                    correct_data = False
            except UnicodeEncodeError:
                correct_data = False

        if correct_data:
            if self.modifying:
                self.parent.modify_tag(self.tag_id, tag)
                self.Destroy()
            else:
                self.parent.add_tag(tag)
                self.Destroy()
        else:
            InfoDialog(
                _("""Please, don't forget to fill all fields with valid data
- Every fields are mandatory
- The key must be alphanumeric
- Make you sure that you aren't using this key in
other tag
- Allowed symbols for tag name and screen text:
    alphanumeric, space and underscore""")).show()
Пример #11
0
 def OnEditTag(self, _e):
     selected_row = self.tags_grid.GetFirstSelected()
     if selected_row != -1:
         self.insmod_tag_window_class(self, self.tag_ctrl, selected_row)
     else:
         InfoDialog(_("You must select a tag")).show()