Beispiel #1
0
def restoreSession(key):
    """Restore a session specified by key, previously saved by the session manager."""
    settings = sessionSettings(key)
    ## restore current named session name
    session_name = settings.value('session_name', "", str)
    if session_name:
        import sessions
        sessions.setCurrentSession(session_name)
    ## restore documents
    numdocuments = settings.value('numdocuments', 0, int)
    doc = None
    for index in range(numdocuments):
        settings.beginGroup("document{0}".format(index))
        url = settings.value("url", QUrl(), QUrl)
        if url.isEmpty():
            import document
            doc = document.EditorDocument()
        else:
            try:
                doc = app.openUrl(url)
            except IOError:
                pass
        settings.endGroup()
    # open at least one
    if doc is None:
        doc = app.openUrl(QUrl())
    ## restore windows
    numwindows = settings.value('numwindows', 0, int)
    if numwindows > 0:
        for index in range(numwindows):
            settings.beginGroup("mainwindow{0}".format(index))
            win = mainwindow.MainWindow()
            win.readSessionSettings(settings)
            win.show()
            app.qApp.processEvents()  # init (re)size dock tools
            u = settings.value("active_document", QUrl(), QUrl)
            # we don't use app.findDocument because it does not allow empty url
            for d in app.documents:
                if u == d.url():
                    win.setCurrentDocument(d)
                    break
            else:
                win.setCurrentDocument(app.documents[0])
            settings.endGroup()
    else:
        win = mainwindow.MainWindow()
        win.show()
        app.qApp.processEvents()  # init (re)size dock tools
Beispiel #2
0
def run():
    """Run the GUI."""
    config.app.tk_root = tk.Tk()
    config.app.tk_root.columnconfigure(0, weight=1)
    config.app.tk_root.rowconfigure(0, weight=1)
    config.app.gui_environment = mainwindow.MainWindow(config.app.tk_root)
    config.app.tk_root.mainloop()
Beispiel #3
0
    def __init__(self, argv=[], parent=None):
        '''Performs the main logic/connections in the application'''

        QtCore.QObject.__init__(self, parent)

        self._openFrameGroup = None

        self._processframerandom = {}
        self._processgrouprandom = {}

        # load settings file
        if len(argv) == 2:
            self.settings = sportsreview.settings.settingsmanager.SettingsManager(
                argv[1])
        else:
            self.settings = sportsreview.settings.settingsmanager.SettingsManager(
            )

        # setup main window
        self.mainwindow = mainwindow.MainWindow(self.settings, self)

        # connect signals
        self.mainwindow.openFile.connect(self.openFile)
        self.mainwindow.processFrame.connect(self.processFrame)
        self.mainwindow.processGroup.connect(self.processGroup)

        # frame playback timer
        self._playing = 0  #speed, 1 = normal, 0.5 = half speed (in future: -ve for reverse)
        self._playStartOffset = 0  #the difference between system time and frameset timestamps
        self._playingTimer = QtCore.QTimer(self)
        self._playingTimer.timeout.connect(self._playFrame)

        # show main window
        self.mainwindow.show()
Beispiel #4
0
    def __init__(self, argv=sys.argv, project=None):

        self.app = QtGui.QApplication(sys.argv)
        self.ui = mainwindow.MainWindow(self)
        self.ui.setWindowIcon(QtGui.QIcon(':/res/res/DNA.ico'))
        self.project = None
        self.run_status = RUN_STATUS_TOBEINITED
        param = "zoom_state"
        if self.hasParam(param):
            self.zoom_state = project.parameters.zoom_state
        else:
            self.zoom_state = False

        self.start_logging()

        self.QSettings_init()

        if len(argv) > 1:
            self.LoadProject(argv[1])
            if len(argv) > 2:
                self.LoadSwmmFile(argv[2])
                if len(argv) > 3:
                    self.project.slotted_swmmfilename = argv[3]
                    self.initialize_optimization()

        self.ups()
Beispiel #5
0
def mainwindow():
    """Create, show() and return a new MainWindow."""
    import mainwindow
    w = mainwindow.MainWindow()
    w.show()
    w.activateWindow()
    return w
Beispiel #6
0
    def startup(self):

        self.load_boss()
        self.load_editor()

        shell_plug = self.add_plugin('contentbook')
        buffer_plug = self.add_plugin('buffer')

        opt_plugs = []
        for plugname in OPTPLUGINS:
            plugin = self.add_plugin(plugname)
            if plugin and plugin.VISIBLE:
                opt_plugs.append(plugin)

        self.registry.load()

        for pluginname in self.OPTPLUGINS:
            if not self.opts.get('plugins', pluginname):
                # slow but only once
                for plugin in self.plugins:
                    if plugin and plugin.NAME == pluginname:
                        self.plugins.remove(plugin)
                        opt_plugs.remove(plugin)

        self.mainwindow = mainwindow.MainWindow()

        self.evt('populate')
        self.mainwindow.set_plugins(self.editor, buffer_plug, shell_plug,
                                    opt_plugs)
        self.mainwindow.show_all()

        self.evt('shown')
        self.evt('started')
        self.evt('reset')
Beispiel #7
0
    def command(self, command):
        """Perform one command."""
        command = command.split()
        cmd = command[0]
        args = command[1:]

        win = QApplication.activeWindow()
        if win not in app.windows:
            if not app.windows:
                import mainwindow
                mainwindow.MainWindow().show()
            win = app.windows[0]

        if cmd == b'open':
            url = QUrl.fromEncoded(args[0])
            win.openUrl(url, self.encoding)
        elif cmd == b'encoding':
            self.encoding = str(args[0])
        elif cmd == b'activate_window':
            win.activateWindow()
            win.raise_()
        elif cmd == b'set_current':
            url = QUrl.fromEncoded(args[0])
            win.setCurrentDocument(app.openUrl(url, self.encoding))
        elif cmd == b'set_cursor':
            line, column = map(int, args)
            cursor = win.textCursor()
            pos = cursor.document().findBlockByNumber(line -
                                                      1).position() + column
            cursor.setPosition(pos)
            win.currentView().setTextCursor(cursor)
        elif cmd == b'bye':
            self.close()
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_()
Beispiel #9
0
    def addNote(self, _id=-1):
        if _id == -1:
            # It's a real new note
            self.counter_noteID += 1
            _id = self.counter_noteID

        self.LogFile("CONTROLLER: Adding note {}".format(_id))
        newIndex = len(self.notes)

        mw = mainwindow.MainWindow(_id, newIndex)
        self.notes.append(mw)

        # CONNECTING SIGNALS
        mw.newNoteAdded.connect(self.addNote)
        mw.noteDeleted.connect(self.deleteNote)
        mw.noteSaved.connect(self.saveNote)
        mw.synced.connect(self.Sync)
        mw.logFile.connect(self.LogFile)
        mw.initUI()

        self.LogFile(
            "CONTROLLER: addNote. Setting index {} to note ID {}".format(
                mw.myIndex, mw.noteID))

        if self.dropbox.client is not None:
            self.notes[mw.myIndex].updateStatusBar('Connected to Dropbox')
Beispiel #10
0
def main():
    root = tk.Tk()
    new_window = tk.Toplevel(root)
    my_canvas = canvas.MyCanvas(root)
    main_window = mainwindow.MainWindow(new_window, my_canvas)

    root.mainloop()
Beispiel #11
0
def window():
    # By Kyaw
    app = QApplication(sys.argv)
    # window() creates a MainWindow object and shows it.
    win = main_window.MainWindow()
    win.show()
    # When application signals exit, meaning when the user presses the close button, the program will also stop running
    sys.exit(app.exec_())
Beispiel #12
0
 def menu_context(self):
     app_hold = mainwindow.config.app
     mainwindow.config.app = mainwindow.config.Config(
         TEST_TITLE, TEST_VERSION)
     self.root_pane = mainwindow.MainWindow(mainwindow.tk.Tk())
     try:
         yield
     finally:
         mainwindow.config.app = app_hold
Beispiel #13
0
def main():
    #Initialisation des ports GPIO
    GPIO.setup(22, GPIO.OUT, initial=GPIO.LOW)
    GPIO.setup(32, GPIO.OUT, initial=GPIO.LOW)
    #Affichage de la GUI Capsula
    app = QApplication(sys.argv)
    form = mw.MainWindow()
    form.show()
    sys.exit(app.exec_())
Beispiel #14
0
    def __init__(self, interface, prog_args):
        Policy.__init__(self, interface)
        global policy
        assert policy is None
        policy = self

        import mainwindow
        self.window = mainwindow.MainWindow(prog_args)
        self.window.browser.set_root(policy.get_interface(policy.root))
Beispiel #15
0
 def shutdown_context(self):
     app_hold = mainwindow.config.app
     mainwindow.config.app = mainwindow.config.Config(
         TEST_TITLE, TEST_VERSION)
     self.root_window = mainwindow.MainWindow(InstrumentedTk())
     self.root_window.tk_shutdown()
     try:
         yield
     finally:
         mainwindow.config.app = app_hold
Beispiel #16
0
 def geometry_context(self, desired_geometry):
     app_hold = mainwindow.config.app
     mainwindow.config.app = mainwindow.config.Config(
         TEST_TITLE, TEST_VERSION)
     mainwindow.config.app.geometry = desired_geometry
     self.root_pane = mainwindow.MainWindow(mainwindow.tk.Tk())
     try:
         yield self.root_pane.set_geometry()
     finally:
         mainwindow.config.app = app_hold
Beispiel #17
0
    def do_activate(self):
        """ Override the 'activate' signal of GLib.Application. """
        try:
            import mainwindow
        except Exception as err:
            logging.exception(err)
            logging.error(_("Can't create Cnchi's main window. Exiting..."))
            sys.exit(1)

        window = mainwindow.MainWindow(self, cmd_line)
Beispiel #18
0
 def init_context(self):
     app_hold = mainwindow.config.app
     mainwindow.config.app = mainwindow.config.Config(
         TEST_TITLE, TEST_VERSION)
     self.tk_root = InstrumentedTk()
     self.root_pane = mainwindow.MainWindow(self.tk_root)
     try:
         yield
     finally:
         mainwindow.config.app = app_hold
Beispiel #19
0
def restoreSession():
    """Restore a session saved by the session manager."""
    settings = sessionSettings()
    settings.beginGroup(sessionKey())
    for index in range(settings.value('numwindows', 0, int)):
        settings.beginGroup("mainwindow{0}".format(index))
        win = mainwindow.MainWindow()
        win.readSessionSettings(settings)
        win.show()
        settings.endGroup()
    settings.endGroup()
Beispiel #20
0
def runGUI(ippath, ipsettings):
    # Run GUI version
    from PySide import QtGui
    import mainwindow

    # Makes it possible to close program with ctrl+c in a terminal
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    app = QtGui.QApplication(sys.argv)
    app.setStyle("plastique")
    mainwindow = mainwindow.MainWindow(path=ippath, settings=ipsettings)
    mainwindow.show()
    sys.exit(app.exec_())
Beispiel #21
0
def main():

    window = mainwindow.MainWindow()

    # Connect the cross to the quit function.
    window.connect("destroy", Gtk.main_quit)

    # Show the window.
    window.show_all()

    # Main loop.
    Gtk.main()
    print("Exiting...")
Beispiel #22
0
    def __init__(self, _a):
        super().__init__()

        try:
            self.logFileDescriptor = open(main.getLogFilePath(), 'a+')
        except IOError as e:
            self.trayIcon.showMessage("LogFile Error",
                                      e.strerror,
                                      icon=QSystemTrayIcon.Critical,
                                      msecs=3000)
            exit(1)

        self.app = _a
        self.notes = []
        self.counter_noteID = 1
        self.pcPath = main.getAccessTokenPath()

        self.w = QWidget()
        self.trayIcon = systray.SystemTrayIcon(self.w)

        self.dropbox = controller_dropbox.Dropbox(self)
        mw = mainwindow.MainWindow(self.counter_noteID, 0)
        self.notes.append(mw)

        # CONNECTING SIGNALS
        # Main Window
        mw.showed.connect(self.authentication)
        mw.newNoteAdded.connect(self.addNote)
        mw.noteDeleted.connect(self.deleteNote)
        mw.noteSaved.connect(self.saveNote)
        mw.synced.connect(self.Sync)
        mw.logFile.connect(self.LogFile)

        # Dropbox
        self.dropbox.bd.uploaded.connect(self.update)
        self.dropbox.logFile.connect(self.LogFile)
        self.dropbox.bd.logFile.connect(self.LogFile)

        # System Tray
        self.trayIcon.newNote.connect(self.addNote)
        self.trayIcon.synchronized.connect(self.Sync)
        self.trayIcon.quited.connect(self.appQuit)
        self.trayIcon.showAll.connect(self.showAll)
        self.trayIcon.hideAll.connect(self.hideAll)
        self.trayIcon.stop.connect(self.stopSync)
        self.trayIcon.status.connect(self.showStatus)

        mw.initUI()
Beispiel #23
0
def openUrl(url):
    """Open Url.

    If there is an active MainWindow, the document is made the current
    document in that window. If there is no MainWindow at all, it is
    created.

    """
    win = app.activeWindow()
    if not win:
        import mainwindow
        win = mainwindow.MainWindow()
        win.show()
    d = win.openUrl(url)
    if d:
        win.setCurrentDocument(d)
Beispiel #24
0
def main():
    app = QApplication(sys.argv)
    common.app_icon = common.complete_icon("nimbus")
    common.trayIcon = tray_icon.SystemTrayIcon()
    network.setup()
    filtering.setup()
    common.downloadManager = nwebkit.DownloadManager(
        windowTitle=tr("Downloads"))
    common.downloadManager.loadSession()
    settings.settingsDialog = settings_dialog.SettingsDialog()
    session.loadSession()
    if len(browser.windows) == 0:
        win = mainwindow.MainWindow()
        win.show()
        win.addTab()
    app.aboutToQuit.connect(prepareQuit)
    sys.exit(app.exec_())
def openUrl(url):
    """Open Url.
    
    If there is an active MainWindow, the document is made the current
    document in that window. If there is no MainWindow at all, it is
    created.
    
    """
    if not app.windows:
        import mainwindow
        mainwindow.MainWindow().show()
    win = QApplication.activeWindow()
    if win not in app.windows:
        win = app.windows[0]
    doc = win.openUrl(url)
    if doc:
        win.setCurrentDocument(doc)
Beispiel #26
0
    def command(self, command):
        """Perform one command."""
        command = command.split()
        cmd = command[0]
        args = command[1:]

        win = QApplication.activeWindow()
        if win not in app.windows:
            if not app.windows:
                import mainwindow
                mainwindow.MainWindow().show()
            win = app.windows[0]

        if cmd == b'open':
            url = QUrl.fromEncoded(args[0])
            try:
                win.openUrl(url, self.encoding)
            except IOError as e:
                filename = url.toLocalFile()
                msg = _("{message}\n\n{strerror} ({errno})").format(
                    message=_("Could not read from: {url}").format(
                        url=filename),
                    strerror=e.strerror,
                    errno=e.errno)
                QMessageBox.critical(win, app.caption(_("Error")), msg)

        elif cmd == b'encoding':
            self.encoding = str(args[0])
        elif cmd == b'activate_window':
            win.activateWindow()
            win.raise_()
        elif cmd == b'set_current':
            url = QUrl.fromEncoded(args[0])
            try:
                win.setCurrentDocument(app.openUrl(url))  # already loaded
            except IOError:
                pass
        elif cmd == b'set_cursor':
            line, column = map(int, args)
            cursor = win.textCursor()
            pos = cursor.document().findBlockByNumber(line -
                                                      1).position() + column
            cursor.setPosition(pos)
            win.currentView().setTextCursor(cursor)
        elif cmd == b'bye':
            self.close()
Beispiel #27
0
def main():
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    args = parse_cli()

    import qtcompat
    qtcompat.load_modules(args.pyside)
    QtCore = qtcompat.QtCore
    QtGui = qtcompat.QtGui
    import mainwindow

    context = sr.Context_create()
    try:
        loglevel = sr.LogLevel.get(args.loglevel)
        context.log_level = loglevel
    except:
        sys.exit('Error: invalid log level.')

    app = QtGui.QApplication([])
    s = mainwindow.MainWindow(context, args.drivers)
    s.show()

    sys.exit(app.exec_())
Beispiel #28
0
def main():
    """Main function."""
    args = parse_commandline()

    if args.version_debug:
        import debuginfo
        sys.stdout.write(debuginfo.version_info_string() + '\n')
        sys.exit(0)

    if args.python_ly:
        # The python-ly path has to be inserted at the *second* position
        # because the first element in sys.path is the directory of the invoked
        # script (an information we need in determining if Frescobaldi is run
        # from its Git repository)
        sys.path.insert(1, args.python_ly)

    check_ly()

    if args.list_sessions:
        import sessions
        for name in sessions.sessionNames():
            sys.stdout.write(name + '\n')
        sys.exit(0)

    urls = list(map(url, args.files))

    if not app.qApp.isSessionRestored():
        if not args.new and remote.enabled():
            api = remote.get()
            if api:
                api.command_line(args, urls)
                api.close()
                sys.exit(0)

        if QSettings().value("splash_screen", True, bool):
            import splashscreen
            splashscreen.show()

    # application icon
    import icons
    QApplication.setWindowIcon(icons.get("frescobaldi"))

    QTimer.singleShot(0, remote.setup)  # Start listening for IPC

    import mainwindow  # contains MainWindow class
    import session  # Initialize QSessionManager support
    import sessions  # Initialize our own named session support

    # boot Frescobaldi-specific stuff that should be running on startup
    import viewhighlighter  # highlight arbitrary ranges in text
    import progress  # creates progress bar in view space
    import musicpos  # shows music time in statusbar
    import autocomplete  # auto-complete input
    import wordboundary  # better wordboundary behaviour for the editor

    if sys.platform.startswith('darwin'):
        import macosx.setup
        macosx.setup.initialize()

    if app.qApp.isSessionRestored():
        # Restore session, we are started by the session manager
        session.restoreSession(app.qApp.sessionKey())
        return

    # load specified session?
    doc = None
    if args.session and args.session != "-":
        doc = sessions.loadSession(args.session)

    # Just create one MainWindow
    win = mainwindow.MainWindow()
    win.show()
    win.activateWindow()

    # load documents given as arguments
    import document
    for u in urls:
        doc = win.openUrl(u, args.encoding, ignore_errors=True)
        if not doc:
            doc = document.EditorDocument(u, args.encoding)

    # were documents loaded?
    if not doc:
        if app.documents:
            doc = app.documents[-1]
        elif not args.session:
            # no docs, load default session
            doc = sessions.loadDefaultSession()

    if doc:
        win.setCurrentDocument(doc)
    else:
        win.cleanStart()

    if urls and args.line is not None:
        # set the last loaded document active and apply navigation if requested
        pos = doc.findBlockByNumber(args.line - 1).position() + args.column
        cursor = QTextCursor(doc)
        cursor.setPosition(pos)
        win.currentView().setTextCursor(cursor)
        win.currentView().centerCursor()
Beispiel #29
0
import os
import mainwindow
from tkinter import *
from PIL import Image, ImageTk

if (__name__ == "__main__"):
    root = Tk()
    root.geometry("495x515")
    root.title("MainWindow")
    root.resizable(False, False)
    icon = Image.open("img/icon")
    bticon = ImageTk.PhotoImage(icon)
    root.wm_iconphoto(True, bticon)
    imgrsz = mainwindow.MainWindow(root)
    root.mainloop()
sys.path.append(ppqt_path)
# Create an app and empty settings
from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
import constants as C
app.setOrganizationName("PGDP")
app.setOrganizationDomain("pgdp.net")
app.setApplicationName("PPQT2")
from PyQt5.QtCore import QSettings
settings = QSettings()

import mainwindow
from PyQt5.QtCore import Qt, QPoint, QSize
settings.clear()
settings.setValue("mainwindow/position", QPoint(0, 0))
mw = mainwindow.MainWindow(settings)

mw.show()
app.exec_()

# idle a bit after quit to let garbage be collected
from PyQt5.QtTest import QTest
QTest.qWait(200)

#app.quit()

#mw = None
#mwp = mw.pos()
#mws = mw.size()
#mwmid = QPoint(mwp.x()+mws.width()/2, mwp.y()+mws.height()/2)