Пример #1
0
    def save_file_as(self):
        if self.currentIndex() == -1:
            return
        print('saving as')
        options = QFileDialog.Options()
        options |= QFileDialog.DontUseNativeDialog
        name = g_programs_folder + '\\' + self.tabText(self.currentIndex())
        if self.currentWidget().editor.existing is False:
            name += str(self.ff)
        path, _ = QFileDialog.getSaveFileName(None, "Save As", name,
                                              self.filter_files, options=options)

        if path in current_files:
            simple_warning('Nope, not recommended!', 'File name already \ntaking part in session')
            return
        if path:
            text = self.currentWidget().editor.toPlainText()
            with open(path, 'w') as file:
                file.write(text)
            self.currentWidget().editor.changed = False
            self.currentWidget().editor.existing = path
            #self.currentWidget().editor.set_syntax()
            try:
                name_open_file = path[path.rindex('/') + 1:]
            except ValueError:
                name_open_file = path
            self.setTabText(self.currentIndex(), name_open_file)
            self.window().setWindowTitle(path)
            add_new_name(name)

            directory_to_remember = path[: path.rindex('/')]
            names = [['g_programs_folder ', " '{}'".format(directory_to_remember)]]
            change_setting.change_settins(names)
Пример #2
0
    def processor_accepted(self):
        i = self.selectedItems()
        if i:
            item = i[0]
            if item.my_type == 'file':
                ad = item.adress
                print('ad = ', ad)
                ad_dot = ad.replace('\\', '.')
                new_adress_slash = ad.replace('\\', '/')  # 'Modelling_clay/Processors/Fanuc_NT'
                names = [['default_processor ', " '{}'".format(new_adress_slash)]]

                if self.main_interface.centre.note.currentIndex() == -1:
                    if self.sim_panel.use_by_default_processor.isChecked() is True:
                        change_settins(names)
                        self.main_interface.centre.note.default_processor = ad.replace("\\", "/")
                    else:
                        simple_warning('warning', "Doc for connecting not opened \n and box not checked")
                else:

                    if self.main_interface.centre.note.currentWidget().set_syntax(adress=ad_dot):



                        if self.sim_panel.use_by_default_processor.isChecked() is True:
                            change_settins(names)
                            self.main_interface.centre.note.default_processor = ad.replace("\\", "/")

                    else:
                        simple_warning('warning', "The {} \n is not a processor!".format(ad))
Пример #3
0
    def open_file(self):
        #options = QFileDialog.Options()

        #options |= QFileDialog.DontUseNativeDialog
        print('QFileDialog.DontUseNativeDialog')
        path, _ = QFileDialog.getOpenFileName(None, "Open file", g_programs_folder, self.filter_files)
        print(path)
        if path:
            self.make_open_DRY(path)
            directory_to_remember = path[: path.rindex('/')]
            names = [['g_programs_folder ', " '{}'".format(directory_to_remember)]]
            change_setting.change_settins(names)
Пример #4
0
    def save_options(self):
        """
        :return: changing exact values of exact names
        """
        name1 = "interface_settings ", " {{'main_width': {}, 'main_height':{} }}".format(
            self.width(), self.height())
        name2 = "splitter_parameters ", " {{'lefty': {}, 'righty': {}, 'flag': {} }}".format(
            self.centre.splitter.sizes()[0],
            self.centre.splitter.sizes()[1], self.splitter_flag)
        name3 = "saved_toolbars ", " {}".format(self.saveState())
        names = [name1, name2, name3]
        print(self.centre.splitter.sizes())

        change_setting.change_settins(names)

        toolbars_plasemnt = self.saveState()
        print('tolbars:', toolbars_plasemnt)
        print('toolbasrs type', type(toolbars_plasemnt))
Пример #5
0
    def machine_accepted(self):
        i = self.selectedItems()
        if i:
            item = i[0]
            if item.my_type == 'machine':

                ad = item.adress
                print('ad = ', ad)
                ad_dot = ad.replace('\\', '.')
                new_adress_slash = ad.replace('\\', '/')  # 'Modelling_clay/Processors/Fanuc_NT'
                names = [['default_machine ', " '{}'".format(new_adress_slash)]]

                if self.main_interface.centre.note.currentIndex() == -1:
                    if self.sim_panel.use_by_default_machine.isChecked():# is True
                        change_settins(names)
                    else:
                       simple_warning('warning', "Doc for connecting not opened \n and box not checked")
                else:
                    if self.main_interface.centre.note.currentWidget().set_machine(address=ad_dot):
                        saved_processor_address = self.main_interface.centre.note.currentWidget().current_processor_address
                        self.main_interface.centre.note.currentWidget().set_syntax(saved_processor_address)
                        self.sim_panel.choose_processor_item.after_set_syntax()
                        if self.sim_panel.use_by_default_machine.isChecked():
                            change_settins(names)