Пример #1
0
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    = "*****@*****.**"
        
        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
0
def createApp (args=sys.argv):
    #########################################
    # all the bureaucratic init of a KDE App
    # the appName must not contain any chars besides a-zA-Z0-9_
    # because KMainWindowPrivate::polish() calls QDBusConnection::sessionBus().registerObject()
    # see QDBusUtil::isValidCharacterNoDash()
    appName     = "satyr"
    catalog     = ""
    programName = ki18n ("satyr")                 #ki18n required here
    version     = "0.5.0"
    description = ki18n ("I need a media player that thinks about music the way I think about it. This is such a program.")         #ki18n required here
    license     = KAboutData.License_GPL
    copyright   = ki18n ("(c) 2009, 2010 Marcos Dione")    #ki18n required here
    text        = ki18n ("none")                    #ki18n required here
    homePage    = "http://savannah.nongnu.org/projects/satyr/"
    bugEmail    = "*****@*****.**"

    aboutData   = KAboutData (appName, catalog, programName, version, description,
                                license, copyright, text, homePage, bugEmail)

    # ki18n required for first two addAuthor () arguments
    aboutData.addAuthor (ki18n ("Marcos Dione"), ki18n ("design and implementation"))
    aboutData.addAuthor (ki18n ("Sebastián Álvarez"), ki18n ("features, bugfixes and testing"))

    KCmdLineArgs.init (args, aboutData)
    options= KCmdLineOptions ()
    options.add ("s").add ("skin <skin-name>", ki18n ("skin"), "")
    options.add ("+path", ki18n ("paths to your music collections"))
    KCmdLineArgs.addCmdLineOptions (options)

    app= App ()
    args= KCmdLineArgs.parsedArgs ()

    return app, args
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'),
                    '*****@*****.**')
    about.addCredit(ki18n('Valentyn Pavliuchenko'),
                    ki18n('Debian packaging, russian translation, '
                          'bug reporting and testing'),
                    '*****@*****.**')
    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_()
Пример #4
0
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 = "*****@*****.**"

    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_()
 def __init__(self, argv, opts):
     """
     Constructor
     
     @param argv command line arguments
     @param opts acceptable command line options
     """
     loc = _localeString()
     os.environ["KDE_LANG"] = loc
     
     aboutData = KAboutData(
         Program, "kdelibs", ki18n(Program), Version, ki18n(""), 
         KAboutData.License_GPL, ki18n(Copyright), ki18n ("none"), 
         Homepage, BugAddress)
     sysargv = argv[:]
     KCmdLineArgs.init(sysargv, aboutData)
     
     if opts:
         options = KCmdLineOptions()
         for opt in opts:
             if len(opt) == 2:
                 options.add(opt[0], ki18n(opt[1]))
             else:
                 options.add(opt[0], ki18n(opt[1]), opt[2])
         KCmdLineArgs.addCmdLineOptions(options)
     
     KApplication.__init__(self, True)
     KQApplicationMixin.__init__(self)
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'),
                    '*****@*****.**')
    about.addCredit(
        ki18n('Valentyn Pavliuchenko'),
        ki18n('Debian packaging, russian translation, '
              'bug reporting and testing'), '*****@*****.**')
    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_()
  def __init__( self ):
    bus = dbus.SessionBus()
    try:
      app_proxy = bus.get_object( 'org.kde.amarok', '/' )
      self.app = dbus.Interface( app_proxy, 'org.freedesktop.MediaPlayer' )
      player_proxy = bus.get_object( 'org.kde.amarok', '/Player' )
      self.player = dbus.Interface( player_proxy, 'org.freedesktop.MediaPlayer' )
      tList_proxy = bus.get_object( 'org.kde.amarok', '/TrackList')
      self.trackList = dbus.Interface( tList_proxy, 'org.freedesktop.MediaPlayer' )
    except dbus.exceptions.DBusException:
      import sys
      from PyKDE4.kdecore import ki18n, KAboutData, KCmdLineArgs
      from PyKDE4.kdeui import KMainWindow, KMessageBox, KApplication

      about = KAboutData("msgbox", "msgbox", ki18n ("TAmarok"), "0.1", ki18n(""), KAboutData.License_GPL,
                          ki18n ( "(c) 2009 Thomas Eichinger" ), ki18n(""), "", "")
      KCmdLineArgs.init(sys.argv, about)
      app = KApplication()
      win = KMainWindow()
      if KMessageBox.warningYesNo(win, "Oops, found no Amarok instance.\n Start Amarok now?" ) == 3 :
        import subprocess
        self.out = ""
        subprocess.Popen("amarok")
        import time
        time.sleep(3)
        app_proxy = bus.get_object( 'org.kde.amarok', '/' )
        self.app = dbus.Interface( app_proxy, 'org.freedesktop.MediaPlayer' )
        player_proxy = bus.get_object( 'org.kde.amarok', '/Player' )
        self.player = dbus.Interface( player_proxy, 'org.freedesktop.MediaPlayer' )
        tList_proxy = bus.get_object( 'org.kde.amarok', '/TrackList')
        self.trackList = dbus.Interface( tList_proxy, 'org.freedesktop.MediaPlayer' )
      else:
        print "*E* Sorry no Amarok running"
        quit()
Пример #8
0
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 = "*****@*****.**"

    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_()
Пример #9
0
    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"),
                            "*****@*****.**", "")
        aboutData.addAuthor(ki18n("Chris Dekter"), ki18n("Developer"),
                            "*****@*****.**", "")
        aboutData.addAuthor(ki18n("Sam Peterson"), ki18n("Original developer"),
                            "*****@*****.**", "")
        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)
            # Create data directory (for log file)
            if not os.path.exists(DATA_DIR):
                os.makedirs(DATA_DIR)
            # Create run directory (for lock file)
            if not os.path.exists(RUN_DIR):
                os.makedirs(RUN_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)
Пример #10
0
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 = "*****@*****.**"

    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_()
Пример #11
0
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 = "*****@*****.**"

    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
Пример #12
0
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 = "*****@*****.**"

    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_()
Пример #13
0
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
        )
        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)
Пример #14
0
    def __init__(self):
        
        aboutData = KAboutData(APP_NAME, CATALOG, PROGRAM_NAME, VERSION, DESCRIPTION,
                                    LICENSE, COPYRIGHT, TEXT, HOMEPAGE, BUG_EMAIL)

        aboutData.addAuthor(ki18n("Chris Dekter"), ki18n("Developer"), "*****@*****.**", "")
        aboutData.addAuthor(ki18n("Sam Peterson"), ki18n("Original developer"), "*****@*****.**", "")
        aboutData.setProgramIconName(common.ICON_FILE)
        self.aboutData = aboutData

        aboutData_py3 = KAboutData(APP_NAME, CATALOG, PROGRAM_NAME_PY3, VERSION, DESCRIPTION_PY3,
                                    LICENSE, COPYRIGHT_PY3, TEXT, HOMEPAGE_PY3, BUG_EMAIL_PY3)
        aboutData_py3.addAuthor(ki18n("GuoCi"), ki18n("Python 3 port maintainer"), "*****@*****.**", "")
        aboutData_py3.addAuthor(ki18n("Chris Dekter"), ki18n("Developer"), "*****@*****.**", "")
        aboutData_py3.addAuthor(ki18n("Sam Peterson"), ki18n("Original developer"), "*****@*****.**", "")
        aboutData_py3.setProgramIconName(common.ICON_FILE)
        self.aboutData_py3 = aboutData_py3
        
        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)
Пример #15
0
    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 = "*****@*****.**"

        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()
Пример #16
0
    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    = "*****@*****.**"

        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()
Пример #17
0
def main():
    about = make_about_data(ki18nc('tray application description',
                                   'touchpad management application'))

    KCmdLineArgs.init(sys.argv, about)
    KUniqueApplication.addCmdLineOptions()

    if not KUniqueApplication.start():
        return

    app = SynaptiksApplication()
    app.exec_()
Пример #18
0
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_())
Пример #19
0
Файл: Kuad.py Проект: szilm/Kuad
def main(argv=None):
    appName     = "Kuad"
    catalog     = ""
    programName = ki18n ("Kuad")
    version     = "1.0"
    description = ki18n ("Tiled Multi-Konsole")
    license     = KAboutData.License_GPL
    copyright   = ki18n ("(c) 2010 Stuart Zilm")
    text        = ki18n ("none")
    homePage    = "www.stuartzilm.com"
    bugEmail    = "*****@*****.**"

    aboutData   = KAboutData (appName, catalog, programName, version, description,
        license, copyright, text, homePage, bugEmail)

    KCmdLineArgs.init (sys.argv, aboutData)
    app = KuadApplication ()
    
    return exit(app.exec_())
Пример #20
0
    def __init__(self, args):
        self.getLogin()
        self.providerPluginManager = PluginManager("providerplugins","providerplugins", providerplugins.Provider.Provider)
        aboutData = KAboutData (
            "Wrapper", 
            "blubb", 
            ki18n("Wrapper for kontact"), 
            "sdaf", 
            ki18n("Displays a KMessageBox popup"), 
            KAboutData.License_GPL, 
            ki18n("(c) 2010"), 
            ki18n("This is a wrapper for kontact to access the multimobileservice"), 
            "http://puzzle.ch", 
            "*****@*****.**"
        )
 
        KCmdLineArgs.init(sys.argv, aboutData)
        
        cmdoptions = KCmdLineOptions()
        cmdoptions.add("nr <speed>", ki18n("The phone nr"))
        cmdoptions.add("smsfile <file>", ki18n("The smsfile"))
        cmdoptions.add("smstext <text>", ki18n("The smstext"))
        cmdoptions.add("plugin <string>", ki18n("The pluginname"))
        KCmdLineArgs.addCmdLineOptions(cmdoptions)
        app = KApplication()
        lineargs = KCmdLineArgs.parsedArgs()
        plugin = self.getRightPlugin(lineargs.getOption("plugin"))
        plugin.addNr(lineargs.getOption("nr"))
        if lineargs.getOption("smsfile") != "":
            plugin.setText(self.file2String(lineargs.getOption("smsfile")))
        elif lineargs.getOption("smstext") != "":
            plugin.setText(lineargs.getOption("smstext"))
        else:
            KMessageBox.error(None, i18n("No text defined.."), i18n("Text undefined"))
            raise RuntimeError("No text defined!")
        plugin.setConfig(self.config)
        try:
            plugin.execute()
            KMessageBox.information(None, i18n("Your SMS was sendet successfull to "+lineargs.getOption("nr")+" with Plugin "+plugin.getObjectname()), i18n("Success"))
        except Exception, e:
            KMessageBox.error(None, i18n(e), i18n("Error"))
Пример #21
0
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 = "*****@*****.**"

    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_()
Пример #22
0
    def newInstance(self):
        args = KCmdLineArgs.parsedArgs()

        component = None
        if args.isSet("select-component"):
            component = str(args.getOption("select-component"))
            self.manager.cw.selectComponent(component)

        # Check if show-mainwindow used in sys.args to show mainWindow
        if args.isSet("show-mainwindow"):
            self.manager.show()

        # If system tray disabled show mainwindow at first
        if not config.PMConfig().systemTray():
            self.manager.show()

        return super(PmApp, self).newInstance()
Пример #23
0
    def newInstance(self):
        args = KCmdLineArgs.parsedArgs()

        component = None
        if args.isSet("select-component"):
            component = str(args.getOption("select-component"))
            self.manager.cw.selectComponent(component)

        # Check if show-mainwindow used in sys.args to show mainWindow
        if args.isSet("show-mainwindow"):
            self.manager.show()

        # If system tray disabled show mainwindow at first
        if not config.PMConfig().systemTray():
            self.manager.show()

        return super(PmApp, self).newInstance()
Пример #24
0
    def start(self):
        """
        Called when the window has been set up and is ready to receive
        commands. E.g. opening documents.

        This can be extended to auto-reopen documents that were open
        when pynal was closed the last time.
        """
        args = KCmdLineArgs.parsedArgs()

        errors = ""
        for i in range(args.count()):
            filename = os.path.basename(str(args.arg(i)))
            if os.path.isfile(args.arg(i)):
                self.open_document(PynalDocument(args.arg(i)), filename)
            else:
                errors += args.arg(i) + "\n"

        if errors is not "":
            self.errorDialog.showMessage("Could not open file(s):\n" + errors)
Пример #25
0
    def setup_actions(self):
        self.touchpad_on_action = KToggleAction(
            i18nc('@action:inmenu', 'Touchpad on'), self.actionCollection())
        self.actionCollection().addAction(
            'touchpadOn', self.touchpad_on_action)
        self.touchpad_on_action.setGlobalShortcut(
            KShortcut(i18nc('Touchpad toggle shortcut', 'Ctrl+Alt+T')))
        self.contextMenu().addAction(self.touchpad_on_action)

        self.contextMenu().addSeparator()

        shortcuts = self.actionCollection().addAction(
            KStandardAction.KeyBindings, 'shortcuts')
        shortcuts.triggered.connect(self.show_shortcuts_dialog)
        self.contextMenu().addAction(shortcuts)

        self.preferences_action = self.actionCollection().addAction(
            KStandardAction.Preferences, 'preferences')
        self.preferences_action.triggered.connect(
            self.show_configuration_dialog)
        self.contextMenu().addAction(self.preferences_action)

        help_menu = KHelpMenu(self.contextMenu(), KCmdLineArgs.aboutData())
        self.contextMenu().addMenu(help_menu.menu())
Пример #26
0
        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    = "*****@*****.**"
    
    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_())
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_())
Пример #28
0
    """
    logger.error("".join(traceback.format_exception(exception, value, tb)))

# Package Manager Main App
if __name__ == '__main__':

    # Catch signals
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    # Create a dbus mainloop if its not exists
    if not dbus.get_default_main_loop():
        from dbus.mainloop.qt import DBusQtMainLoop
        DBusQtMainLoop(set_as_default = True)

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

    # Add Command Line options
    options = KCmdLineOptions()
    options.add("show-mainwindow", ki18n("Show main window"))
    KCmdLineArgs.addCmdLineOptions(options)

    # Create a unique KDE Application
    app = KUniqueApplication(True, True)

    # Set system Locale, we may not need it anymore
    # It should set just before MainWindow call
    setSystemLocale()

    # Create MainWindow
    manager = MainWindow()
Пример #29
0
    def __init__(self):
        BaseFrontend.__init__(self)

        self.previous_excepthook = sys.excepthook
        sys.excepthook = self.excepthook

        self.debconf_callbacks = {}
        self.language_questions = ('oem_config', 'language_label',
                                   'language_heading_label',
                                   'timezone_heading_label',
                                   'keyboard_heading_label',
                                   'user_heading_label',
                                   'back', 'next')
        self.current_step = None
        # Set default language.
        dbfilter = language.Language(self, self.debconf_communicator())
        dbfilter.cleanup()
        dbfilter.db.shutdown()
        self.allowed_change_step = True
        self.allowed_go_forward = True
        self.mainLoopRunning = False
        self.apply_changes = False

        appName = "oem-config"
        catalog = ""
        programName = ki18n("OEM Config")
        version = "1.0"
        description = ki18n("Sets up the system")
        license = KAboutData.License_GPL
        copyright = ki18n("2006, 2007 Anirudh Ramesh. 2008 Canonical Ltd.")
        text = ki18n("none")
        homePage = "http://www.kubuntu.org"
        bugEmail = ""

        aboutData = KAboutData(appName, catalog, programName, version, description,
                               license, copyright, text, homePage, bugEmail)

        KCmdLineArgs.init(['oem-config', '-style=oxygen'], aboutData)

        self.app = KApplication()
        # We want to hide the minimise button if running in the ubiquity-only mode (no desktop)
        # To achieve this we need to set window flags to Dialog but we also need a parent widget which is showing
        # else Qt tried to be clever and puts the minimise button back
        self.parentWidget = QWidget()
        self.parentWidget.show()

        # The parent for our actual user interface window, this is needed only because Oxygen widget 
        # style refuses to draw our background on a top level widget
        self.parent2 = QWidget(self.parentWidget)
        self.parent2.setAutoFillBackground(True)
        self.parent2.setWindowState(Qt.WindowFullScreen)
        self.parent2.setWindowFlags(Qt.Dialog)
        layout = QVBoxLayout(self.parent2)
        layout.setContentsMargins(0, 0, 0, 0)

        self.userinterface = OEMConfUI(self.parent2)
        self.userinterface.setFrontend(self)
        layout.addWidget(self.userinterface)
        self.parent2.show()

        self.userinterface.next.setIcon(KIcon("go-next"))
        self.userinterface.back.setIcon(KIcon("go-previous"))

        self.translate_widgets()

        self.customize_installer()
        
        self.tzmap = TimezoneMap(self)
        map_vbox = QVBoxLayout(self.userinterface.map_frame)
        map_vbox.setMargin(0)
        map_vbox.addWidget(self.tzmap)
Пример #30
0
# Package Manager Main App
if __name__ == '__main__':

    # Catch signals
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    # Create a dbus mainloop if its not exists
    if not dbus.get_default_main_loop():
        from dbus.mainloop.qt import DBusQtMainLoop
        DBusQtMainLoop(set_as_default = True)

    # Use raster to make it faster
    QApplication.setGraphicsSystem('raster')

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

    # Add Command Line options
    options = KCmdLineOptions()
    options.add("show-mainwindow", ki18n("Show main window"))
    options.add("select-component <component>", ki18n("Show main window"))
    KCmdLineArgs.addCmdLineOptions(options)

    app = PmApp()

    # Set exception handler
    sys.excepthook = handleException

    # Run the Package Manager
    app.exec_()
Пример #31
0
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    if not dbus.get_default_main_loop():
        from dbus.mainloop.qt import DBusQtMainLoop
        DBusQtMainLoop(set_as_default = True)

    from optparse import OptionParser

    usage = ctx.Pds.i18n("%prog packages_to_install")
    parser = OptionParser(usage=usage)
    args = filter(lambda x: not x.startswith('-'), sys.argv[1:])
    if len(sys.argv) > 1:

        from mainwindow import MainWindow
        if ctx.Pds.session == ctx.pds.Kde4:
            KCmdLineArgs.init([], aboutData)
            app = KApplication()
        else:
            app = QtGui.QApplication(sys.argv)
            font = ctx.Pds.settings('font','Dejavu Sans,10').split(',')
            app.setFont(QtGui.QFont(font[0], int(font[1])))

        setSystemLocale()
        manager = MainWindow(app, silence = True)

        manager.centralWidget().state._selected_packages = args
        manager.centralWidget().state.operationAction(args, silence = True)
        manager.centralWidget().progressDialog.show()

        sys.excepthook = handleException
        ctx._time()
Пример #32
0
from PyQt4 import QtGui
from PyQt4 import QtCore

from PyKDE4.kdeui import KUniqueApplication
from PyKDE4.kdecore import KCmdLineArgs

from maindialog import MainDialog
from about import aboutData
from dumlogging import logger

def handleException(exception, value, tb):
    logger.error("".join(traceback.format_exception(exception, value, tb)))

if __name__ == '__main__':

    KCmdLineArgs.init(sys.argv, aboutData)

    app = KUniqueApplication(True, True)
    args = KCmdLineArgs.parsedArgs()

    if not dbus.get_default_main_loop():
        from dbus.mainloop.qt import DBusQtMainLoop
        DBusQtMainLoop(set_as_default = True)

    manager = MainDialog()
    manager.show()

    sys.excepthook = handleException

    app.exec_()
Пример #33
0
	optlist = getopt.getopt(sys.argv[0:], 'h', ['help','help-all', 'm','appname'])
    except getopt.GetoptError, err:
        print "ERROR:", str(err)
        usage()
        sys.exit(2)

    if not sys.argv[1:]:
    	sysarg = sys.argv
    else:
    	sysarg = sys.argv[1:]
    	for opt in optlist[1:]:
    	    if "-m" in opt:
    		sysarg = sys.argv[1:]
    	    else:
    		sysarg = sys.argv


    KCmdLineArgs.init(sysarg, aboutData)
    app =  kdeui.KApplication()

    if not dbus.get_default_main_loop():
        from dbus.mainloop.qt import DBusQtMainLoop
        DBusQtMainLoop(set_as_default = True)

    profiler = Profiler()
    profiler.show()
    rect  = QtGui.QDesktopWidget().screenGeometry()
    profiler.move(rect.width()/2 - profiler.width()/2, rect.height()/2 - profiler.height()/2)
    app.exec_()

Пример #34
0
    appName = "Koo"
    catalog = ""
    programName = ki18n("Koo")
    version = "1.0"
    description = ki18n("KDE OpenObject Client")
    license = KAboutData.License_GPL
    copyright = ki18n("(c) 2009 Albert Cervera i Areny")
    text = ki18n("none")
    homePage = "www.nan-tic.com"
    bugEmail = "*****@*****.**"

    aboutData = KAboutData(appName, catalog, programName, version, description,
                           license, copyright, text, homePage, bugEmail)

    KCmdLineArgs.init(arguments, aboutData)

    app = KApplication()
else:
    app = QApplication(arguments)

app.setApplicationName('Koo')
app.setOrganizationDomain('www.nan-tic.com')
app.setOrganizationName('NaN')

try:
    f = open(Settings.value('koo.stylesheet'), 'r')
    try:
        app.setStyleSheet(f.read())
    finally:
        f.close()
Пример #35
0
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    = "*****@*****.**"

    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"),
        "*****@*****.**", "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"),
        '*****@*****.**', '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_()
Пример #36
0
    from optparse import OptionParser

    usage = unicode(i18n("%prog packages_to_install"))
    parser = OptionParser(usage=usage)

    packages = filter(lambda x: not x.startswith('-'), sys.argv[1:])

    argv = list(set(sys.argv[1:]) - set(packages))
    argv.append('--nofork')
    argv.insert(0, sys.argv[0])

    if len(sys.argv) > 1:

        aboutData.setAppName("pm-install")
        KCmdLineArgs.init(argv, aboutData)

        # Add Command Line options
        options = KCmdLineOptions()
        options.add("hide-summary", ki18n("Hide summary screen"))
        KCmdLineArgs.addCmdLineOptions(options)

        app = KUniqueApplication(True, True)
        setSystemLocale()

        args = KCmdLineArgs.parsedArgs()

        window = PmWindow(app,
                          packages,
                          hide_summary=args.isSet("hide-summary"))
        window.show()
Пример #37
0
            self.resize(640, 480)
            self.setCentralWidget(MainFrame(self))

    #-------------------- main ------------------------------------------------

    appName = "default"
    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.riverbank.com"
    bugEmail = "*****@*****.**"

    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_()
Пример #38
0
        self.assertTrue('Uname' in r)
        self.assertEqual(r['MachineType'], 'Laptop')

        # No URL in this mode
        self.assertEqual(self.app.open_url.call_count, 0)

    def test_administrator_disabled_reporting(self):
        QTimer.singleShot(0, QCoreApplication.quit)
        self.app.ui_present_report_details(False)
        self.assertFalse(self.app.dialog.send_error_report.isVisible())
        self.assertFalse(self.app.dialog.send_error_report.isChecked())


appName = 'apport-kde'
catalog = 'apport'
programName = ki18n(b'Apport KDE')
version = '1.0'
description = ki18n(b'KDE 4 frontend tests for the apport')
license = KAboutData.License_GPL
copyright = ki18n(b'2012 Canonical Ltd.')
text = KLocalizedString()
homePage = 'https://wiki.ubuntu.com/AutomatedProblemReports'
bugEmail = '*****@*****.**'

aboutData = KAboutData(appName, catalog, programName, version, description,
                       license, copyright, text, homePage, bugEmail)

KCmdLineArgs.init([''], aboutData)
app = KApplication()
unittest.main()
Пример #39
0
def main():
    from argparse import ArgumentParser, RawTextHelpFormatter
    parser = ArgumentParser(description=__doc__,
            formatter_class=RawTextHelpFormatter)

    parser.add_argument('-v', '--version', action='version', version='%(prog)s ' + __version__)

    parser.add_argument('file', nargs='?', help='PDF file to open')
    parser.add_argument('-o', '--output', help='where to save the cropped PDF')
    parser.add_argument('--rotate', type=int, choices=[0,90,180,270], help='how much to rotate the cropped pdf clockwise (default: 0)')
    parser.add_argument('--whichpages', help='which pages (e.g. "1-5" or "1,3-") to include in cropped PDF (default: all)')
    parser.add_argument('--initialpage', help='which page to open initially (default: 1)')
    parser.add_argument('--autotrim', action='store_true', help='create a selection for the entire initial page minus blank margins')
    parser.add_argument('--autotrim-padding', help='how much padding to include when auto trimming (default: previous value)')
    parser.add_argument('--go', action='store_true', help='output PDF without opening the krop GUI (using the choices from --autotrim, --rotate and --whichpages); if used in a script without X server access, you can run krop using xvfb-run')
    parser.add_argument('--selections', type=str, choices=['all','evenodd','individual'], help='to which pages should selections apply')
    parser.add_argument('--no-kde', action='store_true', help='do not use KDE libraries (default: use if available)')
    parser.add_argument('--no-qt5', action='store_true', help='do not use PyQt5 instead of PyQt4 (default: use PyQt5 if available)')
    parser.add_argument('--no-PyPDF2', action='store_true', help='do not use PyPDF2 instead of pyPdf (default: use PyPDF2 if available)')

    args = parser.parse_args()

    # start the GUI
    if KDE:
        #TODO also use PyKDE5 once more easily available
        from PyKDE4.kdecore import ki18n, KCmdLineArgs, KAboutData
        from PyKDE4.kdeui import KApplication
        appName     = "krop"
        catalog     = ""
        programName = ki18n("krop")
         
        aboutData = KAboutData(appName, catalog, programName, __version__)
         
        KCmdLineArgs.init(aboutData)
        app = KApplication()
    else:
        from krop.qt import QApplication
        app = QApplication(sys.argv)
        app.setApplicationName("krop")

    app.setOrganizationName("arminstraub.com")
    app.setOrganizationDomain("arminstraub.com")

    from krop.mainwindow import MainWindow
    window=MainWindow()

    if args.file is not None:
        fileName = args.file
        try:
            fileName = fileName.decode(sys.stdin.encoding or sys.getdefaultencoding())
        except AttributeError:
            # not necessary (or possible) in python3, which uses unicode
            pass
        window.openFile(fileName)
    if args.output is not None:
        window.ui.editFile.setText(args.output)
    if args.whichpages is not None:
        window.ui.editWhichPages.setText(args.whichpages)
    if args.rotate is not None:
        window.ui.comboRotation.setCurrentIndex({0:0,90:2,180:3,270:1}[args.rotate])
    if args.selections is not None:
        if args.selections == 'all':
            window.ui.radioSelAll.setChecked(True)
        elif args.selections == 'evenodd':
            window.ui.radioSelEvenOdd.setChecked(True)
        elif args.selections == 'individual':
            window.ui.radioSelIndividual.setChecked(True)
    if args.initialpage is not None:
        window.ui.editCurrentPage.setText(args.initialpage)
        window.slotCurrentPageEdited(args.initialpage)
    if args.autotrim_padding is not None:
        window.ui.editPadding.setText(args.autotrim_padding)
    if args.autotrim:
        window.slotTrimMarginsAll()

    # shut down on ctrl+c when pressed in terminal (not gracefully, though)
    # http://stackoverflow.com/questions/4938723/
    import signal
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    if args.go:
        #  sys.stdout.write('kropping...\n')
        from krop.qt import QTimer
        QTimer.singleShot(0, window.slotKrop)
        QTimer.singleShot(0, window.close)
    else:
        window.show()

    # using exec_ because exec is a reserved keyword before python 3
    sys.exit(app.exec_())
Пример #40
0
# Package Manager Main App
if __name__ == '__main__':

    # Catch signals
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    # Create a dbus mainloop if its not exists
    if not dbus.get_default_main_loop():
        from dbus.mainloop.qt import DBusQtMainLoop
        DBusQtMainLoop(set_as_default=True)

    # Use raster to make it faster
    QApplication.setGraphicsSystem('raster')

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

    # Add Command Line options
    options = KCmdLineOptions()
    options.add("show-mainwindow", ki18n("Show main window"))
    options.add("select-component <component>", ki18n("Show main window"))
    KCmdLineArgs.addCmdLineOptions(options)

    app = PmApp()

    # Set exception handler
    sys.excepthook = handleException

    # Run the Package Manager
    app.exec_()