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


Python Settings.setMainWindowPos方法代码示例

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


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

示例1: MainWindow

# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import setMainWindowPos [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

示例2: MainWindow

# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import setMainWindowPos [as 别名]

#.........这里部分代码省略.........
        #self.left.ui.latitudeLineEdit.setValue(50)
        #self.left.ui.LongitudeLineEdit.setValue(10)
        #self.left.ui.dateEdit.setDate(QDate(2005, 9, 30))
        #self.left.ui.timeEdit.setTime(QTime(12, 0))


    def updateDate(self, date):
        #self.date = date
        self.recalculate()

    def updateTime(self, time):
        #self.time = time
        self.recalculate()

    def setTimeZone(self, idx):
        tz = self.timeZones[idx]
        print("Time zone: {}", tz)
        self.recalculate()

    def slideTime(self, value):
        minute = value % 60
        hour = value // 60
        self.left.ui.timeEdit.setTime(QTime(hour, minute))

    def recalculate(self):
        longitude = self.left.ui.LongitudeLineEdit.value()  # lambda
        latitude = self.left.ui.latitudeLineEdit.value()    # Phi
        treeHeight = int(self.left.ui.treeHeightLineEdit.value())

        # Step 1: calculate sun set and sun rise
        dateTime = QDateTime(self.left.ui.dateEdit.date(), QTime(12,0), Qt.UTC)
        self.theSun.recalculate(dateTime, longitude, latitude, treeHeight)

        sunRise = QTime(int(self.theSun.Aufgang),  int(60.0*(self.theSun.Aufgang - int(self.theSun.Aufgang))))
        sunSet = QTime(int(self.theSun.Untergang), int(60.0*(self.theSun.Untergang - int(self.theSun.Untergang))))
        self.left.ui.sunriseLineEdit.setText(sunRise.toString(Qt.ISODate))
        self.left.ui.sunsetLineEdit.setText(sunSet.toString(Qt.ISODate))
        minuteStart = sunRise.msecsSinceStartOfDay() / 1000 / 60 
        minuteEnd = sunSet.msecsSinceStartOfDay() / 1000 / 60 
        self.left.ui.timeSlider.setMinimum(minuteStart)
        self.left.ui.timeSlider.setMaximum(minuteEnd)
        
        # Construct a time zone. NOTE: use IDs instead
        tzIdx = self.left.ui.timeZoneComboBox.currentIndex()
        timeZone = self.timeZones[tzIdx]
        dateTime = QDateTime(self.left.ui.dateEdit.date(), self.left.ui.timeEdit.time(), timeZone)

        self.theSun.recalculate(dateTime, longitude, latitude, treeHeight)
        self.left.ui.timeUTCLineEdit.setText(self.theSun.dateTimeUtc.toString(Qt.ISODate))
        self.left.ui.jDLineEdit.setText(str(self.theSun.JD))
        self.left.ui.timeVariableNLineEdit.setText(str(self.theSun.n))
        self.left.ui.LVariableLineEdit.setText(str(self.theSun.L))
        self.left.ui.meanAnomalyGLineEdit.setText(str(self.theSun.g))
        self.left.ui.eclipticLengthLineEdit.setText(str(self.theSun.Lambda))
        self.left.ui.eclipticSkewLineEdit.setText(u"{}\u00B0 / {} rad".format(self.theSun.epsilon, math.radians(self.theSun.epsilon)))
        self.left.ui.rightAscensionLineEdit.setText(u"{}\u00B0 / {} rad".format(self.theSun.alpha, math.radians(self.theSun.alpha)))
        self.left.ui.declinationLineEdit.setText(u"{}\u00B0 / {} rad".format(self.theSun.delta, math.radians(self.theSun.delta)))
        self.left.ui.jD_0LineEdit.setText(str(self.theSun.JD_0))
        self.left.ui.t_0LineEdit.setText(str(self.theSun.T_0))
        self.left.ui.sternzeitH_GLineEdit.setText(str(self.theSun.ThetaH_G))
        self.left.ui.greenwichStundenwinkelFP_GLineEdit.setText(str(self.theSun.Theta_G))
        self.left.ui.stundenwinkelFrHlingspunktLineEdit.setText(str(self.theSun.Theta))
        self.left.ui.stundenwinkelLineEdit.setText(str(self.theSun.tau))

        self.left.ui.azimutALineEdit.setText(u"{:.1f}\u00B0".format(self.theSun.azimut))
        self.left.ui.sunHeightHLineEdit.setText(u"{:.1f}\u00B0".format(math.degrees(self.theSun.sunHeight)))
        self.left.ui.shadowLengthLineEdit.setText("{:.1f} m".format(self.theSun.shadowLength))

        self.right.setAngle(self.theSun.azimut) # shadowAngle)
        self.right.setShadowLength(self.theSun.shadowLength)


    def saveState(self):
#         # 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
        self.settings.setTzIdx(self.left.ui.timeZoneComboBox.currentIndex())
        self.settings.setMainWindowPos(self.pos())
        self.settings.setMainWindowSize(self.size())
        self.settings.save()
 
 
    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 Shadow",
                          "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)+
                          "</table>")
开发者ID:afester,项目名称:CodeSamples,代码行数:104,代码来源:MainWindow.py


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