mirror of
				https://github.com/kovidgoyal/calibre.git
				synced 2025-11-04 03:27:00 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			40 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
#!/usr/bin/env python
 | 
						|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
 | 
						|
 | 
						|
 | 
						|
__license__   = 'GPL v3'
 | 
						|
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
 | 
						|
__docformat__ = 'restructuredtext en'
 | 
						|
 | 
						|
from calibre.utils.config import JSONConfig
 | 
						|
from qt.core import QHBoxLayout, QLabel, QLineEdit, QWidget
 | 
						|
 | 
						|
# This is where all preferences for this plugin will be stored
 | 
						|
# Remember that this name (i.e. plugins/interface_demo) is also
 | 
						|
# in a global namespace, so make it as unique as possible.
 | 
						|
# You should always prefix your config file name with plugins/,
 | 
						|
# so as to ensure you dont accidentally clobber a calibre config file
 | 
						|
prefs = JSONConfig('plugins/interface_demo')
 | 
						|
 | 
						|
# Set defaults
 | 
						|
prefs.defaults['hello_world_msg'] = 'Hello, World!'
 | 
						|
 | 
						|
 | 
						|
class ConfigWidget(QWidget):
 | 
						|
 | 
						|
    def __init__(self):
 | 
						|
        QWidget.__init__(self)
 | 
						|
        self.l = QHBoxLayout()
 | 
						|
        self.setLayout(self.l)
 | 
						|
 | 
						|
        self.label = QLabel('Hello world &message:')
 | 
						|
        self.l.addWidget(self.label)
 | 
						|
 | 
						|
        self.msg = QLineEdit(self)
 | 
						|
        self.msg.setText(prefs['hello_world_msg'])
 | 
						|
        self.l.addWidget(self.msg)
 | 
						|
        self.label.setBuddy(self.msg)
 | 
						|
 | 
						|
    def save_settings(self):
 | 
						|
        prefs['hello_world_msg'] = self.msg.text()
 |