本文整理汇总了Python中PyKDE4.kdeui.KApplication.exec_方法的典型用法代码示例。如果您正苦于以下问题:Python KApplication.exec_方法的具体用法?Python KApplication.exec_怎么用?Python KApplication.exec_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyKDE4.kdeui.KApplication
的用法示例。
在下文中一共展示了KApplication.exec_方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from PyKDE4.kdeui import KApplication [as 别名]
# 或者: from PyKDE4.kdeui.KApplication import exec_ [as 别名]
def main ():
appName = "KMainWindow"
catalog = ""
programName = ki18n ("KMainWindow")
version = "1.0"
description = ki18n ("Tutorial - Second Program")
license = KAboutData.License_GPL
copyright = ki18n ("(c) 2007 Jim Bublitz")
text = ki18n ("none")
homePage = "www.riverbankcomputing.com"
bugEmail = "[email protected]"
aboutData = KAboutData (appName, catalog, programName, version, description,
license, copyright, text, homePage, bugEmail)
KCmdLineArgs.init (sys.argv, aboutData)
app = KApplication ()
#------- new stuff added here ----------
mainWindow = MainWindow ()
mainWindow.show ()
app.exec_ ()
示例2: main
# 需要导入模块: from PyKDE4.kdeui import KApplication [as 别名]
# 或者: from PyKDE4.kdeui.KApplication import exec_ [as 别名]
def main():
about = KAboutData(
b'synaptiks', '', ki18n('synaptiks'), str(synaptiks.__version__),
ki18n('touchpad management and configuration application'),
KAboutData.License_BSD,
ki18n('Copyright (C) 2009, 2010 Sebastian Wiesner'))
about.addAuthor(ki18n('Sebastian Wiesner'), ki18n('Maintainer'),
'[email protected]')
about.addCredit(ki18n('Valentyn Pavliuchenko'),
ki18n('Debian packaging, russian translation, '
'bug reporting and testing'),
'[email protected]')
about.setHomepage('http://synaptiks.lunaryorn.de/')
about.setOrganizationDomain('synaptiks.lunaryorn.de')
KCmdLineArgs.init(sys.argv, about)
app = KApplication()
window = KMainWindow()
touchpad = Touchpad.find_first(Display.from_qt())
config = TouchpadConfiguration(touchpad)
config_widget = TouchpadConfigurationWidget(config)
config_widget.configurationChanged.connect(
partial(print, 'config changed?'))
window.setCentralWidget(config_widget)
window.show()
app.exec_()
示例3: main
# 需要导入模块: from PyKDE4.kdeui import KApplication [as 别名]
# 或者: from PyKDE4.kdeui.KApplication import exec_ [as 别名]
def main():
app_name="danbooru_client"
catalog = "danbooru_client"
program_name = ki18n("Danbooru Client")
version = "1.0.0"
description = ki18n("A client for Danbooru sites.")
license = KAboutData.License_GPL
copyright = ki18n("(C) 2009 Luca Beltrame")
text = ki18n("Danbooru Client is a program to"
" access Danbooru image boards.")
home_page = u"http://www.dennogumi.org"
bug_email = "[email protected]"
about_data = KAboutData(app_name, catalog, program_name, version,
description, license, copyright, text, home_page,
bug_email)
about_data.setProgramIconName("internet-web-browser")
component_data = KComponentData(about_data)
component_data.setAboutData(about_data)
KCmdLineArgs.init(sys.argv, about_data)
app = KApplication()
window = mainwindow.MainWindow()
window.show()
app.exec_()
示例4: main
# 需要导入模块: from PyKDE4.kdeui import KApplication [as 别名]
# 或者: from PyKDE4.kdeui.KApplication import exec_ [as 别名]
def main():
app_name = "vlc_snapper"
catalog = "danbooru_client"
program_name = ki18n("KDE VLC Snapper")
version = "0.1"
description = ki18n("A screenshot taker for video clips.")
license = KAboutData.License_GPL
copyright = ki18n("(C) 2011 Luca Beltrame")
text = ki18n("")
home_page = "http://www.dennogumi.org"
bug_email = "[email protected]"
about_data = KAboutData(
app_name, catalog, program_name, version, description, license, copyright, text, home_page, bug_email
)
about_data.setProgramIconName("internet-web-browser")
KCmdLineArgs.init(sys.argv, about_data)
app = KApplication()
dialog = capturewidget.CaptureDialog()
dialog.show()
app.lastWindowClosed.connect(dialog.deleteLater)
app.exec_()
示例5: start
# 需要导入模块: from PyKDE4.kdeui import KApplication [as 别名]
# 或者: from PyKDE4.kdeui.KApplication import exec_ [as 别名]
def start():
appName = Config.appname
catalog = Config.catalog
programName = ki18n(Config.readable_appname)
version = Config.version
description = ki18n("A tablet annotation and journaling application.")
license = KAboutData.License_BSD
copyright = ki18n("(C) 2009 Dominik Schacht")
text = ki18n("Whee, greetings.")
homepage = Config.homepage
bugemail = "[email protected]"
aboutData = KAboutData(appName, catalog, programName, version, description, license, copyright, text, homepage, bugemail)
KCmdLineArgs.init(sys.argv, aboutData)
KCmdLineArgs.addCmdLineOptions(Config.get_param_options())
app = KApplication()
Config.init_config() # Init after the KApplication has been created.
mw = MainWindow()
mw.show()
result = app.exec_()
return result
示例6: main
# 需要导入模块: from PyKDE4.kdeui import KApplication [as 别名]
# 或者: from PyKDE4.kdeui.KApplication import exec_ [as 别名]
def main():
global app, aboutData
import setproctitle
setproctitle.setproctitle("iosshy")
from PyQt4.QtCore import QCoreApplication, QTranslator, QLocale, QSettings
from PyQt4.QtGui import QApplication, QSystemTrayIcon, QImage
from tunneldialog import TunnelDialog
try:
from PyKDE4.kdecore import ki18n, KAboutData, KCmdLineArgs
from PyKDE4.kdeui import KApplication, KIcon
aboutData = KAboutData(
name, #appName
name, #catalogName
ki18n(name), #programName
version,
ki18n(description), #shortDescription
KAboutData.License_BSD, #licenseKey
ki18n("© 2010 Massimiliano Torromeo"), #copyrightStatement
ki18n(""), #text
url #homePageAddress
)
aboutData.setBugAddress("http://github.com/mtorromeo/iosshy/issues")
aboutData.addAuthor(
ki18n("Massimiliano Torromeo"), #name
ki18n("Main developer"), #task
"[email protected]" #email
)
aboutData.setProgramLogo(QImage(":icons/network-server.png"))
KCmdLineArgs.init(sys.argv, aboutData)
app = KApplication()
app.setWindowIcon(KIcon("network-server"))
if app.isSessionRestored():
sys.exit(0)
except ImportError:
app = QApplication(sys.argv)
app.setOrganizationName("MTSoft")
app.setApplicationName(name)
if QSystemTrayIcon.isSystemTrayAvailable():
translator = QTranslator()
qmFile = "tunneller_%s.qm" % QLocale.system().name()
if os.path.isfile(qmFile):
translator.load(qmFile)
app.installTranslator(translator)
dialog = TunnelDialog()
sys.exit(app.exec_())
else:
print "System tray not available. Exiting."
sys.exit(1)
示例7: main
# 需要导入模块: from PyKDE4.kdeui import KApplication [as 别名]
# 或者: from PyKDE4.kdeui.KApplication import exec_ [as 别名]
def main():
"""Creates an application from the cmd line args and starts a editor window"""
KCmdLineArgs.init(sys.argv, ABOUT)
opts = KCmdLineOptions()
opts.add('+[file]', ki18n('File to open'))
KCmdLineArgs.addCmdLineOptions(opts)
args = KCmdLineArgs.parsedArgs()
urls = [args.url(i) for i in range(args.count())] #wurgs
app = KApplication()
#KGlobal.locale().setLanguage(['de']) TODO
win = Markdowner(urls)
win.show()
sys.exit(app.exec_())
示例8: QLabel
# 需要导入模块: from PyKDE4.kdeui import KApplication [as 别名]
# 或者: from PyKDE4.kdeui.KApplication import exec_ [as 别名]
KMainWindow.__init__ (self)
self.resize (640, 480)
label = QLabel ("This is a simple PyKDE4 program", self)
label.setGeometry (10, 10, 200, 20)
#--------------- main ------------------
if __name__ == '__main__':
appName = "KApplication"
catalog = ""
programName = ki18n ("KApplication")
version = "1.0"
description = ki18n ("KApplication/KMainWindow/KAboutData example")
license = KAboutData.License_GPL
copyright = ki18n ("(c) 2007 Jim Bublitz")
text = ki18n ("none")
homePage = "www.riverbankcomputing.com"
bugEmail = "[email protected]"
aboutData = KAboutData (appName, catalog, programName, version, description,
license, copyright, text, homePage, bugEmail)
KCmdLineArgs.init (sys.argv, aboutData)
app = KApplication()
mainWindow = MainWindow()
mainWindow.show()
sys.exit(app.exec_())
示例9: ki18n
# 需要导入模块: from PyKDE4.kdeui import KApplication [as 别名]
# 或者: from PyKDE4.kdeui.KApplication import exec_ [as 别名]
self.setCentralWidget (MainFrame (self))
#-------------------- main ------------------------------------------------
appName = "default.py"
catalog = ""
programName = ki18n ("default") #ki18n required here
version = "1.0"
description = ki18n ("Default Example") #ki18n required here
license = KAboutData.License_GPL
copyright = ki18n ("(c) 2007 Jim Bublitz") #ki18n required here
text = ki18n ("none") #ki18n required here
homePage = "www.riverbankcomputing.com"
bugEmail = "[email protected]"
aboutData = KAboutData (appName, catalog, programName, version, description,
license, copyright, text, homePage, bugEmail)
# ki18n required for first two addAuthor () arguments
aboutData.addAuthor (ki18n ("Troy Melhase"), ki18n ("original concept"))
aboutData.addAuthor (ki18n ("Jim Bublitz"), ki18n ("pykdedocs"))
KCmdLineArgs.init (sys.argv, aboutData)
app = KApplication ()
mainWindow = MainWin (None, "main window")
mainWindow.show()
app.connect (app, SIGNAL ("lastWindowClosed ()"), app.quit)
app.exec_ ()
示例10: __init__
# 需要导入模块: from PyKDE4.kdeui import KApplication [as 别名]
# 或者: from PyKDE4.kdeui.KApplication import exec_ [as 别名]
class Application:
"""
Main application class; starting and stopping of the application is controlled
from here, together with some interactions from the tray icon.
"""
def __init__(self):
aboutData = KAboutData(APP_NAME, CATALOG, PROGRAM_NAME, VERSION, DESCRIPTION,
LICENSE, COPYRIGHT, TEXT, HOMEPAGE, BUG_EMAIL)
aboutData.addAuthor(ki18n("GuoCi"), ki18n("Python 3 port maintainer"), "[email protected]", "")
aboutData.addAuthor(ki18n("Chris Dekter"), ki18n("Developer"), "[email protected]", "")
aboutData.addAuthor(ki18n("Sam Peterson"), ki18n("Original developer"), "[email protected]", "")
aboutData.setProgramIconName(common.ICON_FILE)
self.aboutData = aboutData
KCmdLineArgs.init(sys.argv, aboutData)
options = KCmdLineOptions()
options.add("l").add("verbose", ki18n("Enable verbose logging"))
options.add("c").add("configure", ki18n("Show the configuration window on startup"))
KCmdLineArgs.addCmdLineOptions(options)
args = KCmdLineArgs.parsedArgs()
self.app = KApplication()
try:
# Create configuration directory
if not os.path.exists(CONFIG_DIR):
os.makedirs(CONFIG_DIR)
# Initialise logger
rootLogger = logging.getLogger()
rootLogger.setLevel(logging.DEBUG)
if args.isSet("verbose"):
handler = logging.StreamHandler(sys.stdout)
else:
handler = logging.handlers.RotatingFileHandler(LOG_FILE,
maxBytes=MAX_LOG_SIZE, backupCount=MAX_LOG_COUNT)
handler.setLevel(logging.INFO)
handler.setFormatter(logging.Formatter(LOG_FORMAT))
rootLogger.addHandler(handler)
if self.__verifyNotRunning():
self.__createLockFile()
self.initialise(args.isSet("configure"))
except Exception as e:
self.show_error_dialog(i18n("Fatal error starting AutoKey.\n") + str(e))
logging.exception("Fatal error starting AutoKey: " + str(e))
sys.exit(1)
def __createLockFile(self):
f = open(LOCK_FILE, 'w')
f.write(str(os.getpid()))
f.close()
def __verifyNotRunning(self):
if os.path.exists(LOCK_FILE):
f = open(LOCK_FILE, 'r')
pid = f.read()
f.close()
# Check that the found PID is running and is autokey
with subprocess.Popen(["ps", "-p", pid, "-o", "command"], stdout=subprocess.PIPE) as p:
output = p.communicate()[0].decode()
if "autokey" in output:
logging.debug("AutoKey is already running as pid %s", pid)
bus = dbus.SessionBus()
try:
dbusService = bus.get_object("org.autokey.Service", "/AppService")
dbusService.show_configure(dbus_interface = "org.autokey.Service")
sys.exit(0)
except dbus.DBusException as e:
logging.exception("Error communicating with Dbus service")
self.show_error_dialog(i18n("AutoKey is already running as pid %1 but is not responding", pid), str(e))
sys.exit(1)
return True
def main(self):
self.app.exec_()
def initialise(self, configure):
logging.info("Initialising application")
self.monitor = monitor.FileMonitor(self)
self.configManager = get_config_manager(self)
self.service = service.Service(self)
self.serviceDisabled = False
# Initialise user code dir
if self.configManager.userCodeDir is not None:
sys.path.append(self.configManager.userCodeDir)
#.........这里部分代码省略.........
示例11: run
# 需要导入模块: from PyKDE4.kdeui import KApplication [as 别名]
# 或者: from PyKDE4.kdeui.KApplication import exec_ [as 别名]
def run():
appName = "eclectus"
catalog = "eclectusqt"
programName = ki18n("Eclectus")
version = eclectusqt.__version__
description = ki18n("Han character dictionary")
license = KAboutData.License_GPL_V3
copyright = ki18n("(c) 2008-2009 Christoph Burgmer")
text = ki18n(
"Eclectus is a small Han character dictionary for learners.")
homePage = eclectusqt.__url__
bugEmail = "[email protected]"
bugAddress = "http://code.google.com/p/eclectus/issues/list"
aboutData = KAboutData(appName, catalog, programName, version, description,
license, copyright, text, homePage, bugEmail)
aboutData.addAuthor(ki18n("Christoph Burgmer"), ki18n("Developer"),
"[email protected]", "http://cburgmer.nfshost.com/")
aboutData.setCustomAuthorText(ki18n("Please use %1 to report bugs.")\
.subs(bugAddress),
ki18n('Please use %1 to report bugs.')\
.subs('<a href="%s">%s</a>' % (bugAddress, bugAddress)))
aboutData.addCredit(KLocalizedString(), ki18n("Arrr, Eclectus sits on the shoulders of some fine pirates:"))
aboutData.addCredit(ki18n("Jim Breen and contributors"), ki18n("EDICT"), '',
'http://www.csse.monash.edu.au/~jwb/j_edict.html')
aboutData.addCredit(ki18n("Paul Denisowski and current contributors"),
ki18n("CEDICT"), '', 'http://www.mdbg.net/chindict/chindict.php')
aboutData.addCredit(ki18n("HanDeDict team"), ki18n("HanDeDict"), '',
'http://www.chinaboard.de/chinesisch_deutsch.php')
aboutData.addCredit(ki18n("Tomoe developers"),
ki18n("Tomoe handwriting recognition"),
'[email protected]', 'http://tomoe.sourceforge.jp')
aboutData.addCredit(ki18n("Mathieu Blondel and the Tegaki contributors"),
ki18n("Tegaki handwriting recognition"),
u'mathieu ÂT mblondel DÔT org'.encode('utf8'),
'http://tegaki.sourceforge.net')
aboutData.addCredit(ki18n("Unicode Consortium and contributors"),
ki18n("Unihan database"), '', 'http://unicode.org/charts/unihan.html')
aboutData.addCredit(ki18n("Commons Stroke Order Project"),
ki18n("Stroke order pictures"), '',
'http://commons.wikimedia.org/wiki/Commons:Stroke_Order_Project')
aboutData.addCredit(ki18n("Tim Eyre, Ulrich Apel and the Wadoku Project"),
ki18n("Kanji stroke order font"), '',
'http://sites.google.com/site/nihilistorguk/')
aboutData.addCredit(
ki18n("Yue Tan, Wei Gao, Vion Nicolas and the Shtooka Project"),
ki18n("Pronunciation examples for Mandarin"), '',
'http://shtooka.net')
# find logo file, don't directly use util.getData(), KApplication not
# created yet
aboutLogoFile = u'/usr/share/kde4/apps/eclectus/eclectus_about.png'
if not os.path.exists(aboutLogoFile):
modulePath = os.path.dirname(os.path.abspath(__file__))
aboutLogoFile = os.path.join(modulePath, 'data', 'eclectus_about.png')
if not os.path.exists(aboutLogoFile):
aboutLogoFile = util.getData('eclectus_about.png')
if aboutLogoFile:
aboutData.setProgramLogo(QVariant(QImage(aboutLogoFile)))
KCmdLineArgs.init(sys.argv, aboutData)
# create applicaton
global g_app
g_app = KApplication()
# TODO how to access local .mo file?
#base = os.path.dirname(os.path.abspath(__file__))
#localeDir = os.path.join(base, "locale")
#print localeDir
#if os.path.exists(localeDir):
#print KGlobal.dirs().addResourceDir('locale', localeDir + '/', True)
#print KGlobal.dirs().findResource('locale', 'de/LC_MESSAGES/eclectusqt.mo')
# read config file and make global
global GeneralConfig
global DictionaryConfig
global PluginConfig
config = KConfig()
GeneralConfig = KConfigGroup(config, "General")
DictionaryConfig = KConfigGroup(config, "Dictionary")
PluginConfig = KConfigGroup(config, "Plugin")
# create main window
MainWindow().show()
# react to CTRL+C on the command line
signal.signal(signal.SIGINT, signal.SIG_DFL)
g_app.exec_()
示例12: Magneto
# 需要导入模块: from PyKDE4.kdeui import KApplication [as 别名]
# 或者: from PyKDE4.kdeui.KApplication import exec_ [as 别名]
class Magneto(MagnetoCore):
"""
Magneto Updates Notification Applet class.
"""
def __init__(self):
app_name = "magneto"
catalog = ""
prog_name = ki18n("Magneto")
version = "1.0"
description = ki18n("System Update Status")
lic = KAboutData.License_GPL
cright = ki18n("(c) 2013 Fabio Erculiani")
text = ki18n("none")
home_page = "www.sabayon.org"
bug_mail = "[email protected]"
self._kabout = KAboutData (app_name, catalog, prog_name, version,
description, lic, cright, text, home_page, bug_mail)
argv = [sys.argv[0]]
KCmdLineArgs.init(argv, self._kabout)
self._app = KApplication()
from dbus.mainloop.qt import DBusQtMainLoop
super(Magneto, self).__init__(main_loop_class = DBusQtMainLoop)
self._window = KStatusNotifierItem()
# do not show "Quit" and use quitSelected() signal
self._window.setStandardActionsEnabled(False)
icon_name = self.icons.get("okay")
self._window.setIconByName(icon_name)
self._window.setStatus(KStatusNotifierItem.Passive)
self._window.connect(self._window,
SIGNAL("activateRequested(bool,QPoint)"),
self.applet_activated)
self._menu = KMenu(_("Magneto Entropy Updates Applet"))
self._window.setContextMenu(self._menu)
self._menu_items = {}
for item in self._menu_item_list:
if item is None:
self._menu.addSeparator()
continue
myid, _unused, mytxt, myslot_func = item
name = self.get_menu_image(myid)
action_icon = KIcon(name)
w = KAction(action_icon, mytxt, self._menu)
self._menu_items[myid] = w
self._window.connect(w, SIGNAL("triggered()"), myslot_func)
self._menu.addAction(w)
self._menu.hide()
def _first_check(self):
def _do_check():
self.send_check_updates_signal(startup_check = True)
return False
if self._dbus_service_available:
QTimer.singleShot(10000, _do_check)
def startup(self):
"""
Start user interface.
"""
self._dbus_service_available = self.setup_dbus()
if config.settings["APPLET_ENABLED"] and \
self._dbus_service_available:
self.enable_applet(do_check = False)
else:
self.disable_applet()
if not self._dbus_service_available:
QTimer.singleShot(30000, self.show_service_not_available)
else:
self._first_check()
# Notice Window instance
self._notice_window = AppletNoticeWindow(self)
# Enter main loop
self._app.exec_()
def close_service(self):
super(Magneto, self).close_service()
self._app.quit()
def change_icon(self, icon_name):
name = self.icons.get(icon_name)
self._window.setIconByName(name)
def disable_applet(self, *args):
super(Magneto, self).disable_applet()
#.........这里部分代码省略.........
示例13: Frontend
# 需要导入模块: from PyKDE4.kdeui import KApplication [as 别名]
# 或者: from PyKDE4.kdeui.KApplication import exec_ [as 别名]
#.........这里部分代码省略.........
'privileges, and cannot continue without them.')
result = QMessageBox.critical(self.userinterface, "Must be root",
title)
sys.exit(1)
self.userinterface.setCursor(QCursor(Qt.ArrowCursor))
#Signals and Slots
self.app.connect(self.userinterface.next,SIGNAL("clicked()"),self.on_next_clicked)
self.app.connect(self.userinterface.back,SIGNAL("clicked()"),self.on_back_clicked)
self.app.connect(self.userinterface.language_list, SIGNAL("itemSelectionChanged()"), self.on_language_treeview_selection_changed)
self.app.connect(self.userinterface.keyboard_list_1, SIGNAL("itemSelectionChanged()"), self.on_keyboard_layout_selected)
self.app.connect(self.userinterface.keyboard_list_2, SIGNAL("itemSelectionChanged()"), self.on_keyboard_variant_selected)
first_step = "step_language"
self.userinterface.stackedWidget.setCurrentWidget(self.userinterface.step_language)
self.current_step = self.get_current_step()
self.set_current_page()
while self.current_step is not None:
self.backup = False
self.current_step = self.get_current_step()
if self.current_step == 'step_language':
self.dbfilter = language.Language(self)
elif self.current_step == 'step_keyboard':
self.dbfilter = console_setup.ConsoleSetup(self)
elif self.current_step == 'step_timezone':
self.dbfilter = timezone.Timezone(self)
elif self.current_step == 'step_user':
self.dbfilter = user.User(self)
else:
raise ValueError, "step %s not recognised" % self.current_step
self.allow_change_step(False)
self.dbfilter.start(auto_process=True)
self.app.exec_()
self.app.processEvents()
curr = str(self.get_current_step())
if self.backup:
pass
elif self.current_step == 'step_user':
self.allow_change_step(False)
self.current_step = None
self.apply_changes = True
else:
if self.current_step == 'step_language':
self.translate_widgets()
self.userinterface.stackedWidget.setCurrentIndex(self.pages.index(curr) + 1)
self.set_current_page()
self.app.processEvents()
if self.apply_changes:
dbfilter = language_apply.LanguageApply(self)
dbfilter.run_command(auto_process=True)
dbfilter = timezone_apply.TimezoneApply(self)
dbfilter.run_command(auto_process=True)
dbfilter = console_setup_apply.ConsoleSetupApply(self)
dbfilter.run_command(auto_process=True)
return 0
else:
return 10
def customize_installer(self):
self.step_icon_size = QSize(32,32)
示例14: main
# 需要导入模块: from PyKDE4.kdeui import KApplication [as 别名]
# 或者: from PyKDE4.kdeui.KApplication import exec_ [as 别名]
def main():
" Main Loop "
from getopt import getopt
OPAQUE = True
BORDER = True
try:
opts, args = getopt(sys.argv[1:], "hvob", ["version", "help", "opaque", "borderless"])
pass
except:
pass
for o, v in opts:
if o in ("-h", "--help"):
print(
"""
Usage:
-h, --help Show help informations and exit.
-v, --version Show version information and exit.
-o, --opaque Use Opaque GUI.
-b, --borderless No WM Borders.
Run without parameters and arguments to use the GUI.
"""
)
return sys.exit(1)
elif o in ("-v", "--version"):
print(__version__)
return sys.exit(1)
elif o in ("-o", "--opaque"):
OPAQUE = False
elif o in ("-b", "--borderless"):
BORDER = False
# define our App
try:
app = QApplication(sys.argv)
app.setApplicationName(__doc__)
app.setOrganizationName(__author__)
app.setOrganizationDomain(__author__)
app.setStyle("Plastique")
app.setStyle("Oxygen")
except TypeError:
aboutData = KAboutData(
__doc__,
"",
ki18n(__doc__),
__version__,
ki18n(__doc__),
KAboutData.License_GPL,
ki18n(__author__),
ki18n("none"),
__url__,
__email__,
)
KCmdLineArgs.init(sys.argv, aboutData)
app = QApplication()
app.lastWindowClosed.connect(app.quit)
# w is gonna be the mymainwindow class
w = MyMainWindow()
# set the class with the attribute of translucent background as true
if OPAQUE is True:
w.setAttribute(Qt.WA_TranslucentBackground, True)
# WM Borders
if BORDER is False:
w.setWindowFlags(w.windowFlags() | Qt.FramelessWindowHint)
# run the class
w.show()
# if exiting the loop take down the app
sys.exit(app.exec_())
示例15: MainApp
# 需要导入模块: from PyKDE4.kdeui import KApplication [as 别名]
# 或者: from PyKDE4.kdeui.KApplication import exec_ [as 别名]
#.........这里部分代码省略.........
and self.documents[0].url().isEmpty()):
d = self.documents[0]
d.openUrl(url, encoding)
else:
d = (not url.isEmpty() and self.findDocument(url)
or self.createDocument(url, encoding))
return d
@method(iface, in_signature='', out_signature='o')
def new(self):
return self.createDocument()
def run(self, sender=None):
"""
Last minute setup and enter the KDE event loop.
At the very last, instantiates one empty doc if nothing loaded yet.
"""
if self.kapp.isSessionRestored():
self.mainwin.restore(1, False)
elif (len(self.documents) == 0
and not self._sessionStartedFromCommandLine):
# restore named session?
action = config("preferences").readEntry("default session", "")
if action == "lastused":
self.mainwin.sessionManager().restoreLastSession()
elif action == "custom":
session = config("preferences").readEntry("custom session", "")
if session in self.mainwin.sessionManager().names():
self.mainwin.sessionManager().switch(session)
if len(self.documents) == 0:
self.createDocument().setActive()
sys.excepthook = self.handleException
self.mainwin.show()
self.kapp.exec_()
KGlobal.config().sync()
@method(iface, in_signature='s', out_signature='b')
def isOpen(self, url):
"""Returns true if the specified URL is opened."""
if not isinstance(url, KUrl):
url = KUrl(url)
return bool(self.findDocument(url))
@method(iface, in_signature='', out_signature='o')
def activeDocument(self):
"""Returns the currently active document."""
return self.history[-1]
@method(iface, in_signature='', out_signature='')
def back(self):
"""Sets the previous document active."""
i = self.documents.index(self.activeDocument()) - 1
self.documents[i].setActive()
@method(iface, in_signature='', out_signature='')
def forward(self):
"""Sets the next document active."""
i = self.documents.index(self.activeDocument()) + 1
i %= len(self.documents)
self.documents[i].setActive()
@method(iface, in_signature='', out_signature='b')
def quit(self):
"""Quits the application. Returns True if succeeded."""
return self.mainwin.close()