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


Python KApplication.setTopWidget方法代码示例

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


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

示例1: ki18n

# 需要导入模块: from PyKDE4.kdeui import KApplication [as 别名]
# 或者: from PyKDE4.kdeui.KApplication import setTopWidget [as 别名]
    catalog     = ""
    programName = ki18n("KApplication")
    version     = "1.0"
    description = ki18n("KApplication example")
    license     = KAboutData.License_GPL
    copyright   = ki18n("(c) 2009 Panthera Pardus")
    text        = ki18n("none")
    homePage    = "www.pardus.org.tr"
    bugEmail    = "[email protected]"

    # Create about data from defined variables
    aboutData   = KAboutData(appName, catalog, programName, version, description,
                                license, copyright, text, homePage, bugEmail)

    # Initialize Command Line arguments
    KCmdLineArgs.init(sys.argv, aboutData)

    # Create the application
    app = KApplication()

    # Create Main Window
    mainWindow = MainWindow()
    mainWindow.show()

    # Set top Widget as our mainWindow
    app.setTopWidget(mainWindow)

    # Run the app
    app.exec_()

开发者ID:dhirajkhatiwada1,项目名称:uludag,代码行数:31,代码来源:kapp.py

示例2: MainApp

# 需要导入模块: from PyKDE4.kdeui import KApplication [as 别名]
# 或者: from PyKDE4.kdeui.KApplication import setTopWidget [as 别名]
class MainApp(DBusItem):
    """Our main application instance.
    
    Also exposes some methods to DBus. Instantiated only once.
    
    Emits four signals to Python others can connect to:
    activeChanged(Document)
    documentCreated(Document)
    documentMaterialized(Document)
    documentClosed(Document)
    
    """
    activeChanged = Signal()
    documentCreated = Signal()
    documentMaterialized = Signal()
    documentClosed = Signal()
    
    iface = DBUS_IFACE_PREFIX + "MainApp"
    defaultEncoding = 'UTF-8'
    defaultMode = None
    fileTypes = []
    
    def __init__(self, servicePrefix):
        # We manage our own documents.
        self.documents = []
        self.history = []       # latest shown documents

        # KApplication needs to be instantiated before any D-Bus stuff
        self.kapp = KApplication()
        
        # Here we can setup config() stuff before MainWindow and its tools 
        # are created.
        config = KGlobal.config().group("") # root group
        self.setupConfiguration(config)
        config.sync()
        
        # DBus init
        serviceName = "{0}{1}".format(servicePrefix, os.getpid())
        DBusItem.__init__(self, serviceName, '/MainApp')

        # We support only one MainWindow.
        self.mainwin = self.createMainWindow()
        self.kapp.setTopWidget(self.mainwin)

        # Get our beloved editor :-)
        self.editor = KTextEditor.EditorChooser.editor()
        self.editor.readConfig()

        # restore session etc.
        self._sessionStartedFromCommandLine = False
        
    def setupConfiguration(self, config):
        """Opportunity to manipulate the root group of the global KConfig.
        
        This method is called after KApplication is created but before
        DBus init and Mainwindow creation.
        
        You can implement this method in a subclass; the default implementation
        does nothing.
        
        """
        pass
        
    @cacheresult
    def stateManager(self):
        return StateManager(self)

    def defaultDirectory(self):
        return ''

    def createMainWindow(self):
        import kateshell.mainwindow
        return kateshell.mainwindow.MainWindow(self)

    def createDocument(self, url="", encoding=None):
        return Document(self, url, encoding)
        
    def findDocument(self, url):
        """ Return the opened document or False. """
        if not isinstance(url, KUrl):
            url = KUrl(url)
        # we use string comparison, because sometimes percent encoding
        # issues make the same QUrls look different, esp when dragged
        # from KMail...
        url = url.toString()
        for d in self.documents:
            if d.url().toString() == url:
                return d
        return False
    
    @method(iface, in_signature='ss', out_signature='o')
    def openUrl(self, url, encoding=None):
        if not isinstance(url, KUrl):
            url = KUrl(url)
        # If no encoding given, set default or check if we can remember it
        if not encoding:
            encoding = self.defaultEncoding
            if self.keepMetaInfo() and not url.isEmpty():
                group = self.stateManager().groupForUrl(url)
                if group:
#.........这里部分代码省略.........
开发者ID:Alwnikrotikz,项目名称:lilykde,代码行数:103,代码来源:app.py


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