This forum has been archived. All content is frozen. Please use KDE Discuss instead.

konsolepart - how to access the "profile"

Tags: None
(comma "," separated)
Presto
Registered Member
Posts
2
Karma
0
Hi all,

How can i access and manipulate the running "profile" for a hosted "konsolepart" from my KParts.MainWindow?

I did find the Terminal Interface but it doesn't seem to have that exposed. The page seems to imply KParts interface can do other things.

Can someone point me in the right direction?
https://api.kde.org/frameworks/kparts/h ... rface.html

Thanks
Brent

Code: Select all
#!/usr/bin/python

import sys, os
from PyKDE4.kparts import KParts
from PyKDE4.kdecore import i18n, ki18n, KAboutData, KCmdLineArgs, KPluginLoader, KUrl, KService
from PyKDE4.kdeui import KApplication, KTabWidget, KMenu

class MainWindow(KParts.MainWindow):
    def __init__(self):
        # super(MainWindow, self).__init__()
        KParts.MainWindow.__init__ (self)
        self.resize (800, 600)
        self.setWindowTitle("My Terminal")
        tc = TabControl(self)
        self.setCentralWidget(tc)
        tc.newTabActionClick()
        # end of MainWindow.__init__
        pass


class TabControl(KTabWidget):
    def __init__(self, parent):
        KTabWidget.__init__(self, parent)
        pass
   
    def contextMenuEvent(self, e):
        menu = KMenu(self)
        newTabAction = menu.addAction("Add Tab")
        action = menu.exec_(self.mapToGlobal(e.pos()))
        if not action:
            pass
        elif action == newTabAction:
            self.newTabActionClick()
            pass
        else:
            pass
        # end of TabControl.contextMenuEvent
        pass

    def newTabActionClick(self):
        service = KService.serviceByDesktopName("konsolepart")
        factory = KPluginLoader(service.library()).factory()
        m_part = factory.create()
        m_part.openUrl(KUrl(os.environ["HOME"]))
        self.addTab(m_part.widget(), i18n("terminal"))
        pass


def main ():
    aboutData = MyAboutData()
    KCmdLineArgs.init (sys.argv, aboutData)
    kapp = KApplication ()
    mainWindow = MainWindow()
    kapp.setTopWidget(mainWindow)
    mainWindow.show()
    sys.exit(kapp.exec_())

def MyAboutData():
    appName     = "KApplication"
    catalog     = ""
    programName = ki18n ("KApplication")
    version     = "1.0"
    description = ki18n ("KApplication/KMainWindow/KAboutData example")
    license     = KAboutData.License_GPL
    copyright   = ki18n ("(c) 2016 Brent Williams")
    text        = ki18n ("none")
    homePage    = ""
    bugEmail    = "BrentW.2112@gmail.com"
    aboutData = KAboutData (appName, catalog, programName, version,
                            description, license, copyright, text, homePage, bugEmail)
   
    return aboutData

if __name__ == '__main__':
    main()
Presto
Registered Member
Posts
2
Karma
0


Bookmarks



Who is online

Registered users: Bing [Bot], daret, Google [Bot], Sogou [Bot]