Home Download Buy Blog Forum Support

Get settings only once

Get settings only once

Postby LONGMAN on Tue Nov 26, 2013 11:15 am

In plugin how I can access settings object only once and after use it?
Is it correctly code?
Code: Select all
class MyPluginEventListener(sublime_plugin.EventListener):
   platform = sublime.platform().title()
   settings = sublime.load_settings('MyPlugin ('+platform+').sublime-settings')

   def on_post_save(self, view):
            val = self.settings.get('val')
            print(val)

In some times val is None. Why?
AutoBackups: ST2 / ST3
CodeFormatter: ST2 / ST3
StringUtilities: ST2 / ST3
LONGMAN
 
Posts: 68
Joined: Mon Nov 26, 2012 5:03 pm
Location: Tbilisi, Georgia

Re: Get settings only once

Postby LONGMAN on Tue Nov 26, 2013 11:23 am

Actually val is None on startup
AutoBackups: ST2 / ST3
CodeFormatter: ST2 / ST3
StringUtilities: ST2 / ST3
LONGMAN
 
Posts: 68
Joined: Mon Nov 26, 2012 5:03 pm
Location: Tbilisi, Georgia

Re: Get settings only once

Postby sapphirehamster on Thu Nov 28, 2013 10:10 pm

I made a writeup a while back explaining how settings work, it may help you: viewtopic.php?f=6&t=9076#p36601

Do not include the platform, Sublime does that automatically.
sapphirehamster
 
Posts: 91
Joined: Sun Jul 01, 2012 11:19 pm


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 17 guests