Example #1
0
    def on_preferences_menuitem_activate(self, widget, data=None):
        self.update_preferences_widgets()
        response = self.preferences_dialog.run()
        if response == gtk.RESPONSE_OK:
            # 常规
            CONFIG["download_folder"] = self.download_folder_entry.get_text()
            CONFIG["filename_template"] = self.filename_template_entry.get_text()
            CONFIG["player_use_internal"] = self.player_internal_radiobutton.get_active()
            CONFIG["downloader_use_internal"] = self.downloader_internal_radiobutton.get_active()
            CONFIG["download_cover"] = self.download_cover_checkbutton.get_active()
            CONFIG["download_lyric"] = self.download_lyric_checkbutton.get_active()
            # 播放器
            CONFIG["player_path"] = self.player_path_entry.get_text()
            CONFIG["player_single"] = self.player_single_entry.get_text()
            CONFIG["player_multi"] = self.player_multi_entry.get_text()
            # 下载程序
            CONFIG["downloader_path"] = self.downloader_path_entry.get_text()
            CONFIG["downloader_single"] = self.downloader_single_entry.get_text()
            CONFIG["downloader_multi"] = self.downloader_multi_entry.get_text()
            CONFIG["downloader_mkdir"]= self.downloader_mkdir_checkbutton.get_active()
            # 杂项
            CONFIG["show_status_icon"] = self.show_status_icon_checkbutton.get_active()
            CONFIG["use_http_proxy"] = self.use_http_proxy_checkbutton.get_active()
            CONFIG["http_proxy_url"] = self.http_proxy_url_entry.get_text()

            # 更新一下状态
            self.update_status_icon()
            self.update_player_widgets()

            # 保存设置到文件
            save_config_file()
        self.preferences_dialog.hide()
Example #2
0
 def save(self):
     """Save the current project as a config file."""
     config.save_config_file('', self, self.project_dir, PROJECT_MAIN_FILE_EXT)
Example #3
0
    def create_project(self, widget):
        if self.ProjectDict["ProjectOpen"]=="Yes":
           print("Project already open. Please close existing project first.")
           self.project_window.hide() 
           return
        self.ProjectDict["ProjectFolder"]= expanduser("~") + "/PyIDE"
        self.ProjectDict["Author"] = self.project_entry_author.get_text()
        self.ProjectDict["ProjectName"] = self.project_entry_name.get_text()
        self.ProjectDict["Email"] = self.project_entry_email.get_text()
        self.ProjectDict["ProjectFiles"]= self.ProjectDict["ProjectName"]+".py"

        
        project_email=self.project_entry_email.get_text()
        project_author=self.project_entry_author.get_text()  

        if not os.path.isdir(self.ProjectDict["ProjectFolder"]):
           os.mkdir(self.ProjectDict["ProjectFolder"])

        if os.path.isdir(self.ProjectDict["ProjectFolder"] + "/" + self.ProjectDict["ProjectName"]):
           project_folder=1
           #Show information that a project with that name already exists.
           #Offer to open that project instead.
           #Cansel this function. 
           return 
        else:
           project_folder=0
           os.mkdir(self.ProjectDict["ProjectFolder"] + "/" + self.ProjectDict["ProjectName"])
           project_file = open(self.ProjectDict["ProjectFolder"] + "/" + self.ProjectDict["ProjectName"] + "/"+self.ProjectDict["ProjectName"]+".prj", "w")
           save_config_file(self, project_file)
           project_file.close()
           #Create the files that are configured to be created in the dialog? Most often, main.py etc.
           Files = self.ProjectDict["ProjectFiles"].split(",")
           #Loop over Files list, and add the files to the notebook in main window.



           for file in Files:
               scrolled_window = Gtk.ScrolledWindow()
               scrolled_window.set_hexpand(True)
               scrolled_window.set_vexpand(True)

               self.sourceview = GtkSource.View.new()
               self.sourceview.set_show_line_marks(True)
               self.sourceview.set_show_line_numbers(True)

               self.lm = GtkSource.LanguageManager.new()

               self.textbuffer = self.sourceview.get_buffer()
               self.textbuffer.set_language(self.lm.get_language('python'))
               self.textbuffer.set_highlight_syntax(True)

               self.textbuffer.connect("notify::cursor-position",
                            self.cursor_changed)
               self.textbuffer.set_text("#!/usr/bin/python\n# -*- coding: utf-8 -*-\n"
                                 )




               scrolled_window.add(self.sourceview)

               tab_label = Gtk.Label(label=file) #The label for the notebooktab.
               self.notebook.append_page(scrolled_window, tab_label)
               self.notebook.show_all()

           self.ProjectDict["ProjectOpen"]="Yes"
           print("Is Project open now? " + self.ProjectDict["ProjectOpen"])
           self.project_window.hide()
Example #4
0
 def save(self):
     """Save config data"""
     cfg.save_config_file(self.__class__.SERIAL_FILE, self, self.CONFIG_DIR)