本文整理汇总了Python中preferences.Preferences类的典型用法代码示例。如果您正苦于以下问题:Python Preferences类的具体用法?Python Preferences怎么用?Python Preferences使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Preferences类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSaveLoad
def testSaveLoad(self):
prefs = Preferences('prefstest.conf')
self.assertEqual(None, prefs.btDevice)
self.assertEqual('bluetooth', prefs.connectionMethod)
self.assertEqual('', prefs.customDevice)
self.assertEqual(0, prefs.gammuIndex)
prefs.btDevice = BluetoothDevice('00:00:00:00', 42, 'deviceName', 'serviceName')
prefs.connectionMethod = 'connection'
prefs.customDevice = '/dev/rfcomm0'
prefs.gammuIndex = 2
prefs.save()
prefsLoaded = Preferences('prefstest.conf')
prefsLoaded.load()
self.assertNotEqual(None, prefsLoaded.btDevice, "Device has not been loaded")
self.assertEqual('00:00:00:00', prefsLoaded.btDevice.address)
self.assertEqual(42, prefsLoaded.btDevice.port)
self.assertEqual('deviceName', prefsLoaded.btDevice.deviceName)
self.assertEqual('serviceName', prefsLoaded.btDevice.serviceName)
self.assertEqual('connection', prefsLoaded.connectionMethod)
self.assertEqual('/dev/rfcomm0', prefsLoaded.customDevice)
self.assertEqual(2, prefsLoaded.gammuIndex)
示例2: _sync_children
def _sync_children(self):
from list import List
from preferences import Preferences
Preferences.sync()
List.sync()
User.sync()
示例3: __init__
class GUI:
def __init__(self):
"""Initializes the window and create pointers for all the important widgets.
This function also runs some code to add functionality.
"""
# Initialize the window and several other objects in the instance
self.initialize_window()
# Properties instance to handle the preferences window
self.preferences = Preferences(self.main_window)
# Now setup the variables needed for file access
try:
self.setup_file_access()
except Exception, e:
# In case of error, the user must change the preferences
log(e.__class__.__name__)
log(e)
self.preferences.run()
self.setup_file_access()
self.modified = set() # Store the names of the modified files
# The next variable takes care of each file by holding the choices made for
# it. The values of the dictionary are Annotator objects, where information
# about the annotations made in the file
self.results = {}
# This flag determines whether signal handling should take place. It is True
# when the interface is being adjusted programatically
self.backend = False
开发者ID:davidsbatista,项目名称:Toponym-Disambiguation-Using-Ontology-Based-Semantic-Similarity,代码行数:33,代码来源:annota.py
示例4: __init__
class Main:
def __init__(self):
pygame.init()
pygame.display.init()
pygame.font.init()
self.screen_w = pygame.display.Info().current_w
self.screen_h = pygame.display.Info().current_h
self.w = int(self.screen_h * 1.2)
self.h = int(self.screen_h * 0.8)
self.preferences = Preferences()
self.fullscreen = self.preferences.get("fullscreen")
self.go_mode()
pygame.mouse.set_visible(False)
pygame.display.set_caption(Constants.CAPTION)
def go_mode(self):
if self.fullscreen:
self.mode = (self.screen_w, self.screen_h)
if not self.mode in pygame.display.list_modes():
self.mode = pygame.display.list_modes()[0]
self.screen = pygame.display.set_mode(self.mode, pygame.FULLSCREEN)
else:
self.mode = (self.w, self.h)
self.screen = pygame.display.set_mode(self.mode)
self.unit = int(self.mode[1] / Constants.UNITS)
def main(self):
self.boot_screen()
while True:
if not self.title_screen():
break
if self.preferences.edit_flag:
self.preferences.save()
fullscreen = self.preferences.get("fullscreen")
if self.fullscreen != fullscreen:
self.fullscreen = fullscreen
self.go_mode()
else:
self.play_game()
def boot_screen(self):
bs = BootScreen(self.screen, self.unit)
bs.main()
return bs.running
def title_screen(self):
self.go_mode()
ts = TitleScreen(self.screen, self.unit, self.preferences)
ts.main()
return ts.running
def play_game(self):
gm = Game(self.screen, self.unit, self.preferences)
gm.main()
return gm.running
示例5: write
def write(domain, key, value=None, user=kCFPreferencesCurrentUser, host=kCFPreferencesAnyHost):
"""Writes value as the value for key in domain, also accepts a dictionary of multiple key_value pairs to write"""
domain = Preferences(domain, user, host)
if type(key) is dict:
domain.set_multiple(key)
elif value is not None:
domain[key] = value
示例6: delete
def delete(domain, key=None, user=kCFPreferencesCurrentUser, host=kCFPreferencesAnyHost):
"""Removes the default named key from domain, also accepts a list of keys to remove"""
domain = Preferences(domain, user, host)
if type(key) is list:
domain.delete_multiple(key)
else:
del domain[key]
示例7: on_actionPreferences_triggered
def on_actionPreferences_triggered(self):
'''Display preferences dialog.
'''
prefs = Preferences(self.book_manager, parent=self)
#prefs.setModal(True)
#prefs.show()
prefs.exec_()
self.reload_books_list()
self.reload_search_menu()
示例8: signInIfNecessary
def signInIfNecessary(parent=None):
"""Sign into SRS Collector, and return the API key."""
apiKey = Preferences.apiKey()
if not apiKey:
dialog = SignInDialog()
dialog.exec_()
apiKey = dialog.apiKey
if apiKey:
Preferences.setApiKey(apiKey)
return apiKey
示例9: read
def read(domain, key=None, default=None, user=kCFPreferencesCurrentUser, host=kCFPreferencesAnyHost):
"""Prints the value for the default of domain identified by key, also accepts a list of keys"""
domain = Preferences(domain, user, host)
if key is None:
return domain
if type(key) is list:
return domain.get_multiple(key)
return domain[key]
示例10: _do_load
def _do_load(self):
self.load_config()
component.get("TorrentView").add_text_column(DISPLAY_NAME,
col_type=[str, str], status_field=[STATUS_NAME, STATUS_ID])
component.get("TorrentView").treeview.connect(
"button-press-event", self.on_tv_button_press)
self.menu = self._create_context_menu()
self.sep = component.get("MenuBar").add_torrentmenu_separator()
component.get("MenuBar").torrentmenu.append(self.menu)
self.label_sidebar = LabelSidebar()
self.preferences = Preferences()
self.add_torrent_ext = AddTorrentExt()
self.enable_dnd()
self.status_item = None
self.initialized = True
示例11: importCards
def importCards():
"""Import cards from the server."""
apiKey = SignInDialog.signInIfNecessary()
if apiKey:
try:
Importer().run(apiKey)
except UpgradeRequiredException:
showInfo("Please upgrade your copy of the SRS Collector addon.")
except urllib2.HTTPError as e:
if e.code == 401:
Preferences.setApiKey(None)
showInfo("Sign in expired. Please try again.")
else:
showInfo("Unknown network error.")
except urllib2.URLError:
# Generally a DNS error.
showInfo("Network error. Are you online?")
示例12: RhythmWeb
class RhythmWeb(rb.Plugin, Loggable):
config = None
preferences = None
def __init__(self):
base_path = os.path.dirname(__file__)
config_path = os.path.join(base_path, 'cfg', 'rb-serve.conf')
config = Configuration()
config.load_configuration(config_path)
serve.log.get_factory().configure(config)
self.base_path = base_path
self.config = config
self.config_path = config_path
resource_path = os.path.join(base_path, 'resources')
config.put('*resources', resource_path)
def activate(self, shell):
config = self.config
config.print_configuration(self)
rbhandler = RBHandler(shell)
components = {'config' : config, 'RB' : rbhandler}
application = CGIApplication('RhythmWeb', self.base_path, components)
server = CGIServer(application, config)
server.start()
shell.server = server
self.preferences = Preferences(config, self.config_path)
def deactivate(self, shell):
if not shell.server is None:
shell.server.stop()
del shell.server
del self.config
del self.config_path
del self.base_path
if not self.preferences.button == None:
self.preferences.button.disconnect(self.connect_id_pref2)
del self.preferences
def create_configure_dialog(self, dialog=None):
dialog = self.preferences.show_dialog()
self.connect_id_pref2 = self.preferences.button.connect('clicked', lambda x: dialog.destroy() )
return dialog
示例13: on_preferences_activated
def on_preferences_activated(self, event=None):
"""Raises the preferences dialog. If it's already open, it's
focused"""
if self._preferences_dialog is not None:
self._preferences_dialog.present()
return
self._preferences_dialog = Preferences(self)
self._preferences_dialog.run()
self._preferences_dialog = None
示例14: __init__
def __init__(self):
pygame.init()
#get preferences
self.preferences = Preferences()
# self.nickname = raw_input('Choose a username: ')
# self.color = raw_input('Choose a color (red, green, blue, yellow, white): ')
#resolution, flags, depth, display
self.unit=Constants.RESOLUTION[0]/Constants.UNITS
self.banner = Banner()
self.score_width=self.unit*15
if self.preferences.fullscreen:
self.screen = pygame.display.set_mode((Constants.RESOLUTION[0]+self.score_width,\
Constants.RESOLUTION[1]),pygame.FULLSCREEN)
else:
self.screen = pygame.display.set_mode((Constants.RESOLUTION[0]+self.score_width,\
Constants.RESOLUTION[1]),0,32)
pygame.display.set_caption(Constants.CAPTION)
#game area surface
self.gamescreen = pygame.Surface(Constants.RESOLUTION)
#score area rectangle surface
self.scorescreen = pygame.Surface((self.score_width,Constants.RESOLUTION[1]))
#Snake and foods manager
self.me=Snake(color=pygame.color.THECOLORS[self.preferences.get("color")],\
nickname=self.preferences.get("nickname"))
self.f=Foods()
self.others = {}
#Score manager
self.scores=Scores((self.score_width,Constants.RESOLUTION[1]))
#add our own score, the server will send us the remaining one at connection
self.scores.new_score(self.preferences.get("nickname"),\
pygame.color.THECOLORS[self.preferences.get("color")])
#game area background color
self.gamescreen.fill(Constants.COLOR_BG)
self.scorescreen.fill((100,100,100))
#timers
self.clock=pygame.time.Clock();
self.current_time=0
self.move_snake_timer=Timer(1.0/Constants.SNAKE_SPEED*1000,self.current_time,periodic=True)
self.blink_snake_timer=Timer(1.0/Constants.SNAKE_BLINKING_SPEED*1000,self.current_time,periodic=True)
self.blink_banner_timer=Timer(500,self.current_time,periodic=True)
self.new_apple_timer=Timer(Constants.NEW_APPLE_PERIOD*1000,self.current_time,periodic=True)
示例15: __init__
def __init__(self, photolist, photoframe):
self.gui = Gtk.Builder()
self.gui.add_from_file(os.path.join(constants.SHARED_DATA_DIR, 'menu.ui'))
self.photoimage = photoframe.photoimage
self.photolist = photolist
self.preferences = Preferences(photolist)
self.about = AboutDialog()
self.is_show = False