当前位置: 首页>>代码示例>>Python>>正文


Python Settings.save方法代码示例

本文整理汇总了Python中Settings.Settings.save方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.save方法的具体用法?Python Settings.save怎么用?Python Settings.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Settings.Settings的用法示例。


在下文中一共展示了Settings.save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MainWindow

# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import save [as 别名]
class MainWindow(QtGui.QMainWindow, Ui_MainWindow, ManagementTasks.ManagementTasks, Slabs.Slabs, Stats.Stats):
    def __init__(self):
        #Build out UI
        QtGui.QMainWindow.__init__(self)
        self.setupUi(self)
        
        #Setup Inherited Tab Classes
        ManagementTasks.ManagementTasks.__init__(self)
        Slabs.Slabs.__init__(self)
        Stats.Stats.__init__(self)
        self.currentTab = 'MTasks'
        
        #Startup the Dialogs
        self.addDialog = Add.AddServersClusters()
        self.preferencesDialog = Preferences.Preferences()
        self.aboutDialog = About.About()
        self.cachedItemDialog = CachedItem.CachedItem()
        
        #Load Settings
        self.settings = Settings()
        
        #Bind to events
        self.connect(self.actionAddClusterServer, QtCore.SIGNAL("triggered()"), self.displayAdd)
        self.connect(self.actionAbout, QtCore.SIGNAL("triggered()"), self.displayAbout)
        self.connect(self.addDialog, QtCore.SIGNAL('savedCluster'), self.addCluster)
        
        self.connect(self.actionSave, QtCore.SIGNAL('triggered()'), self.save)
        self.connect(self.actionPreferences, QtCore.SIGNAL('triggered()'), self.displayPreferences)
        self.connect(self.tabsMain, QtCore.SIGNAL('currentChanged(QWidget*)'), self.mainTabChanged)
        
        self.treeCluster.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.connect(self.treeCluster, QtCore.SIGNAL('itemDoubleClicked(QTreeWidgetItem*, int)'), self.setClusterByTree)
        self.connect(self.treeCluster, QtCore.SIGNAL('customContextMenuRequested(QPoint)'), self.displayTreeContextMenu)
        
        self.currentCluster = None
        
        #Build out Cluster Tree
        for cluster in self.settings.servers.getClusters():
            self.addCluster(cluster)
            
        #Create the Icons
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(Main.getIconPath("memLogo.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        addIcon = QtGui.QIcon()
        addIcon.addPixmap(QtGui.QPixmap(Main.getIconPath("Add.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
        removeIcon = QtGui.QIcon()
        removeIcon.addPixmap(QtGui.QPixmap(Main.getIconPath("Remove.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
        activeIcon = QtGui.QIcon()
        activeIcon.addPixmap(QtGui.QPixmap(Main.getIconPath("Active.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
        
        #Reset the Window Icon as paths change
        self.setWindowIcon(icon)
        
        #Build out the Cluster Tree Context Menus
        self.treeCMServer = QtGui.QMenu()
        self.treeCMServerActions = {"addServer": QtGui.QAction(self),
                                "deleteServer": QtGui.QAction(self)}
        
        self.treeCMServerActions['addServer'].setText("Add Server/Cluster")
        self.treeCMServerActions['addServer'].setIcon(addIcon)
        self.treeCMServer.addAction(self.treeCMServerActions['addServer'])
        
        self.treeCMServerActions['deleteServer'].setText("Delete")
        self.treeCMServerActions['deleteServer'].setIcon(removeIcon)
        self.treeCMServer.addAction(self.treeCMServerActions['deleteServer'])
        
        self.connect(self.treeCMServerActions['addServer'], QtCore.SIGNAL("triggered()"), self.displayAdd)
        self.connect(self.treeCMServerActions['deleteServer'], QtCore.SIGNAL("triggered()"), self.deleteServer)


        self.treeCMCluster = QtGui.QMenu()
        self.treeCMClusterActions = {"addServer": QtGui.QAction(self),
                                    "deleteCluster": QtGui.QAction(self), 
                                    "makeActive": QtGui.QAction(self)}
        
        self.treeCMClusterActions['addServer'].setText("Add Server/Cluster")
        self.treeCMClusterActions['addServer'].setIcon(addIcon)
        self.treeCMCluster.addAction(self.treeCMClusterActions['addServer'])
        
        self.treeCMClusterActions['deleteCluster'].setText("Delete")
        self.treeCMClusterActions['deleteCluster'].setIcon(removeIcon)
        self.treeCMCluster.addAction(self.treeCMClusterActions['deleteCluster'])
        
        self.treeCMClusterActions['makeActive'].setText("Make Active")
        self.treeCMClusterActions['makeActive'].setIcon(activeIcon)
        self.treeCMCluster.addAction(self.treeCMClusterActions['makeActive'])
        
        self.connect(self.treeCMClusterActions['addServer'], QtCore.SIGNAL("triggered()"), self.displayAdd)
        self.connect(self.treeCMClusterActions['deleteCluster'], QtCore.SIGNAL("triggered()"), self.deleteCluster)
        self.connect(self.treeCMClusterActions['makeActive'], QtCore.SIGNAL("triggered()"), self.setClusterByContextMenu)
            
    def displayAbout(self):
        self.aboutDialog.show()
    
    def closeEvent(self, *args):
        Stats.Stats.closeEvent(self)
        Slabs.Slabs.closeEvent(self)
        ManagementTasks.ManagementTasks.closeEvent(self)
        
        self.addDialog.close()
#.........这里部分代码省略.........
开发者ID:hungud,项目名称:MemcachedManager,代码行数:103,代码来源:MainWindow.py

示例2: MainWindow

# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import save [as 别名]
class MainWindow(QMainWindow):

    l = logging.getLogger('MainWindow')

    def __init__(self, app):
        QMainWindow.__init__(self, None)
        self.l.debug('Initializing MainWindow ...')

        self.setWindowTitle('MynPad')
        app.setWindowIcon(QIcon(':/icons/mynpad.png'))

        if os.name == 'nt':
            # On Windows, make sure to use a unique Application User Model Id, otherwise
            # Windows shows the default python icon in the taskbar
            # see http://stackoverflow.com/questions/1551605/how-to-set-applications-taskbar-icon-in-windows-7
            myappid = 'afester.mynpad'
            import ctypes; ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)

        self.theApplication = app
        app.aboutToQuit.connect(self.saveState)

        # read the local configuration file
        iniPath = 'mynpad.ini'
        if not os.path.exists(iniPath):
            iniPath = os.path.join(expanduser("~"), iniPath)
        self.settings = Settings(iniPath)
        self.settings.load()

        # Set up the menu bar
        menuBar = QMenuBar(self)

        exitAction = QAction("Exit", self, triggered=self.theApplication.exit)
        fileMenu = menuBar.addMenu("&File")
        fileMenu.addAction(exitAction)

        aboutAction = QAction("About ...", self, triggered = self.handleAbout)
        helpMenu = menuBar.addMenu("&Help")
        helpMenu.addAction(aboutAction)

        self.setMenuBar(menuBar)

        # Setup the status bar
        self.statusBar = QStatusBar()
        self.statusBar.showMessage("Ready.")
        self.setStatusBar(self.statusBar)
        self.mainWidget = CentralWidget(self, self.settings)
        self.mainWidget.updateWindowTitle.connect(self.updateWindowTitle)
        self.setCentralWidget(self.mainWidget)

        # Reset main window size and position
        pos = self.settings.getMainWindowPos()
        self.move(pos.x(), pos.y())
        size = self.settings.getMainWindowSize()
        self.resize(size)

        # initialize the browser tree (add the top nodes and expand the saved path)
        self.mainWidget.browserWidget.initialize()


    def updateWindowTitle(self, title):
        self.setWindowTitle('{} - MynPad'.format(title))


    def saveState(self):
        # Make sure that the current notepad page is saved
        self.mainWidget.editorWidget.save()

        # Note: there is no way to have eclipse shutdown the application faithfully,
        # see also http://stackoverflow.com/questions/677531/is-it-possible-for-eclipse-to-terminate-gently-instead-of-using-sigkill
        path = self.mainWidget.browserWidget.getCurrentPath()
        self.settings.setBrowserPath(path)
        self.settings.setMainWindowPos(self.pos())
        self.settings.setMainWindowSize(self.size())
        self.settings.save()

        # Close all notepads - TODO (HACK)
        for x in range (0, self.mainWidget.browserWidget.browserView.topLevelItemCount()):
            notepad = self.mainWidget.browserWidget.browserView.topLevelItem(x).getNotepad()
            notepad.close()


    def handleAbout(self):
        appVersion = "Development version"
        pythonVersion = "%s.%s.%s (%s)" % (sys.version_info[0], sys.version_info[1], sys.version_info[2], sys.version_info[3])
        pyQtVersion = PYQT_VERSION_STR
        pyQtQtVersion = QT_VERSION_STR
        qtRuntimeVersion = qVersion()
        
        platformSystem = platform.system()
        platformRelease = platform.release()

        QMessageBox.about(self, "About MynPad",
                          "Copyright \u00a9 2015 by Andreas Fester<br/>"+
                          "<table>"+
                          "<tr><th align=\"right\">Application version:</th><td>{}</td></tr>".format(appVersion) +
                          "<tr><th align=\"right\">Python version:</th><td>{}</td></tr>".format(pythonVersion) +
                          "<tr><th align=\"right\">PyQt version:</th><td>{} for Qt {}</td></tr>".format(pyQtVersion, pyQtQtVersion) +
                          "<tr><th align=\"right\">Qt runtime version:</th><td>{}</td></tr>".format(qtRuntimeVersion)+
                          "<tr><th align=\"right\">Operating System:</th><td>{} {}</td></tr>".format(platformSystem, platformRelease)+
                          "<tr><th align=\"right\">sqlite version:</th><td>{}</td></tr>".format(sqlite3.version) +
#.........这里部分代码省略.........
开发者ID:afester,项目名称:CodeSamples,代码行数:103,代码来源:MainWindow.py

示例3: MainWindow

# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import save [as 别名]
class MainWindow(QMainWindow):
# 
    l = logging.getLogger('MainWindow')
    # timeZones = [ ('UTC-12', -12), ('UTC-11', -11), ('UTC', 0), ('UTC+1', 1), ('UTC+2', 2)]

    def __init__(self, app):
        QMainWindow.__init__(self, None)
        self.l.debug('Initializing MainWindow ...')

        self.theSun = SunSimulator()

        self.timeZones = []
        for x in QTimeZone.availableTimeZoneIds():
            tz = QTimeZone(x)
            self.timeZones.append(tz)
            #print(" {} {} {}".format(str(tz.id()), tz.comment(), tz.hasDaylightTime()))

        #self.revLookup = {}
        #idx = 0
        #for d in self.timeZones:
        #    self.revLookup[d[1]] = idx
        #    idx += 1

        self.setWindowTitle('Shadow')
#         app.setWindowIcon(QIcon(':/icons/mynpad.png'))
# 
#         if os.name == 'nt':
#             # On Windows, make sure to use a unique Application User Model Id, otherwise
#             # Windows shows the default python icon in the taskbar
#             # see http://stackoverflow.com/questions/1551605/how-to-set-applications-taskbar-icon-in-windows-7
#             myappid = 'afester.mynpad'
#             import ctypes; ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
 
        self.theApplication = app
        app.aboutToQuit.connect(self.saveState)
 
        # read the local configuration file
        iniPath = 'shadow.ini'
        if not os.path.exists(iniPath):
            iniPath = os.path.join(expanduser("~"), iniPath)
        self.settings = Settings(iniPath)
        self.settings.load()

        # Set up the menu bar
        menuBar = QMenuBar(self)

        exitAction = QAction("Exit", self, triggered=self.theApplication.exit)
        fileMenu = menuBar.addMenu("&File")
        fileMenu.addAction(exitAction)
 
        aboutAction = QAction("About ...", self, triggered = self.handleAbout)
        helpMenu = menuBar.addMenu("&Help")
        helpMenu.addAction(aboutAction)

        self.setMenuBar(menuBar)

        self.centralWidget = QWidget()
        self.left = DataWidget(self.centralWidget)
        self.right = ShadowWidget(self.centralWidget)

        # Create time zone selector
        self.left.ui.timeZoneComboBox.clear()
        for tz in self.timeZones:
            # TODO: Hack (?)
            displayId = tz.id().data().decode(encoding="UTF-8")
            if not displayId.startswith('UTC'):
                utcOffset = tz.displayName(QTimeZone.GenericTime, QTimeZone.OffsetName)
                #self.left.ui.timeZoneComboBox.addItem("({}) {} - {}".format(utcOffset, displayId, tz.comment()))
                self.left.ui.timeZoneComboBox.addItem("({}) {}".format(utcOffset, displayId))

        self.left.ui.timeZoneComboBox.setCurrentIndex(self.settings.getTzIndex())
        self.left.ui.timeZoneComboBox.currentIndexChanged.connect(self.setTimeZone)

        self.left.ui.dateEdit.dateChanged.connect(self.updateDate)
        self.left.ui.timeEdit.timeChanged.connect(self.updateTime)
        self.left.ui.timeSlider.valueChanged.connect(self.slideTime)

        layout = QHBoxLayout()
        self.centralWidget.setLayout(layout)
        layout.addWidget(self.left)
        layout.addWidget(self.right)
        layout.setStretch(0, 0);
        layout.setStretch(1, 1);

        self.setCentralWidget(self.centralWidget)

        # Reset main window size and position
        pos = self.settings.getMainWindowPos()
        self.move(pos.x(), pos.y())
        size = self.settings.getMainWindowSize()
        self.resize(size)

        # sample values
        self.left.ui.treeHeightLineEdit.setValue(10)
        self.left.ui.latitudeLineEdit.setValue(48.1)
        self.left.ui.LongitudeLineEdit.setValue(11.6)
        self.left.ui.dateEdit.setDate(QDate(2015, 9, 11))
        self.left.ui.timeEdit.setTime(QTime(8, 0))
        #self.left.ui.latitudeLineEdit.setValue(50)
        #self.left.ui.LongitudeLineEdit.setValue(10)
#.........这里部分代码省略.........
开发者ID:afester,项目名称:CodeSamples,代码行数:103,代码来源:MainWindow.py


注:本文中的Settings.Settings.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。