Example #1
0
class Channel:
  def __init__(self, client, channel, start=False, interval=120):
    self.on = start
    self.client = client
    self.channel = channel
    self.interval = interval
    self.timer = QTimer()
    self.timer.connect(self.timer, SIGNAL("timeout()"), self.doquestion)
    if self.on:
      self.timer.start(1000)#kind of a hack.  problem is client.channels doesnt have the channel yet
      
  def nobodygotit(self):
    self.post("Nobody got it!  The answer was \x0310" + self.answer + "\x03.")
    self.doquestion()
  def doquestion(self):
    self.category, self.topics = random.choice(trivia.items())
    self.topic, (self.desc, self.questions) = random.choice(self.topics.items())
    self.question, (self.answer, self.explanation) = random.choice(self.questions)
    self.hint = re.sub("[a-zA-Z0-9]", '*', self.answer)
    self.post("Category:\x039 " + self.category)
    self.post("Topic:\x0313 " + self.topic + (" - " + self.desc if self.desc else ""))
    self.post("\x0312" + self.question)
    if self.on:  
      self.timer.stop()
      self.timer.start(self.interval*1000)
      self.timer.disconnect(self.timer, SIGNAL("timeout()"), self.nobodygotit)
      self.timer.disconnect(self.timer, SIGNAL("timeout()"), self.doquestion)
      self.timer.connect(self.timer, SIGNAL("timeout()"), self.nobodygotit)
  def post(self, message):
    self.client.channels[self.client.conn.irclower(self.channel)].post(message)
Example #2
0
	def __init__(self, parent=None):
		super(MainWindow, self).__init__(parent)
		uic.loadUi('./guis/main.ui', self)
		self.centerOnScreen()
		self.sendBtn.clicked.connect(self._sendBtnClick)
		self.loginBtn.clicked.connect(self._loginBtnClick)
		self.stateLabel.setText(UserState.OFFLINE)

		io_loop = IOLoop()
		io_loop.prepare()
		self._io_loop = io_loop
		netAddress = NetAddress('127.0.0.1', 8002)
		client = RpcClient(io_loop, netAddress)
		client.channel_up_event += self._channel_up
		client.register_service(ChatClientImp(self))
		client.connect()
		self._client = client

		timer = QTimer()
		timer.connect(timer, SIGNAL("timeout()"), self._handle_network)
		timer.start(0)
		self._network_timer = timer

		self._user_token = None
		self._account = None
		self._is_login = False
Example #3
0
 def _connect_signals(self):
     # Connect pyqt signals
     QTerminal.connect(self, SIGNAL("selectionChanged()"), self.on_selection_changed)
     Connection.connect(self._connection, SIGNAL("add_text(QString)"), self.add_received_text)
     Connection.connect(self._connection, SIGNAL("clear_all()"), self.clear)
     Connection.connect(self._connection, SIGNAL("reset_timer()"), lambda: self.timer.start(self._timeout))
     Connection.connect(self._connection, SIGNAL("stop_timer()"), self.timer.stop)
     QTimer.connect(self.timer, SIGNAL("timeout()"), self._connection.timeout)
    def do():
        #Generate
        #array[:] = np.random.randint(0,255,500*500).reshape(shape).astype(np.uint8)
        a = np.zeros(500*500).reshape(500,500).astype(np.uint8)
        ii=np.random.randint(0,500,1)
        jj=np.random.randint(0,500,1)
        a[ii,jj]=1

        a=vigra.filters.discDilation(a,radius=20)
        array[:]=a.reshape(shape).view(np.ndarray)*255
        op.Input.setDirty()

    do()

    cron.connect(cron, SIGNAL('timeout()'), do)
    ds = LazyflowSource( op.Output )
    layer = ColortableLayer(ds,jet())

    mainwin=Viewer()

    mainwin.layerstack.append(layer)
    mainwin.dataShape=(1,h,w,1,1)
    print mainwin.centralWidget()


    BoxContr=BoxController(mainwin.editor,op.Output,boxListModel)
    BoxInt=BoxInterpreter(mainwin.editor.navInterpret,mainwin.editor.posModel,BoxContr,mainwin.centralWidget())


    mainwin.editor.setNavigationInterpreter(BoxInt)
Example #5
0
class PageKde(PageBase):
    plugin_breadcrumb = 'ubiquity/text/breadcrumb_language'
    plugin_is_language = True

    def __init__(self, controller, *args, **kwargs):
        self.controller = controller
        self.wget_retcode = None
        self.wget_proc = None
        if self.controller.oem_user_config:
            self.only = True
        else:
            self.only = False

        try:
            from PyQt4 import uic
            from PyQt4.QtGui import QWidget, QPixmap
            self.page = uic.loadUi('/usr/share/ubiquity/qt/stepLanguage.ui')
            self.combobox = self.page.language_combobox
            self.combobox.currentIndexChanged[str].connect(
                self.on_language_selection_changed)
            if not self.controller.oem_config:
                self.page.oem_id_label.hide()
                self.page.oem_id_entry.hide()

            def inst(*args):
                self.page.try_ubuntu.setEnabled(False)
                self.controller.go_forward()
            self.page.install_ubuntu.clicked.connect(inst)
            self.page.try_ubuntu.clicked.connect(self.on_try_ubuntu_clicked)
            picture1 = QPixmap(
                "/usr/share/ubiquity/pixmaps/kubuntu-live-session.png")
            self.page.image1.setPixmap(picture1)
            self.page.image1.resize(picture1.size())
            picture2 = QPixmap(
                "/usr/share/ubiquity/pixmaps/kubuntu-install.png")
            self.page.image2.setPixmap(picture2)
            self.page.image2.resize(picture2.size())

            self.release_notes_url = ''
            self.update_installer = True
            self.updating_installer = False
            if self.controller.oem_config or auto_update.already_updated():
                self.update_installer = False
            self.release_notes_found = False
            try:
                with open(_release_notes_url_path) as release_notes:
                    self.release_notes_url = release_notes.read().rstrip('\n')
                self.release_notes_found = True
            except (KeyboardInterrupt, SystemExit):
                raise
            except:
                pass

            if self.release_notes_url:
                self.page.release_notes_label.linkActivated.connect(
                    self.on_release_notes_link)
            else:
                self.page.release_notes_label.hide()

            if not 'UBIQUITY_GREETER' in os.environ:
                self.page.try_ubuntu.hide()
                self.page.try_install_text_label.hide()
                self.page.install_ubuntu.hide()
                self.page.image1.hide()
                self.page.image2.hide()

            if self.only:
                self.page.alpha_warning_label.hide()
            # We do not want to show the yet to be substituted strings
            # (${MEDIUM}, etc), so don't show the core of the page until
            # it's ready.
            self.widgetHidden = []
            for w in self.page.children():
                if isinstance(w, QWidget) and not w.isHidden():
                    self.widgetHidden.append(w)
                    w.hide()

        except Exception as e:
            self.debug('Could not create language page: %s', e)
            self.page = None

        self.plugin_widgets = self.page

    @plugin.only_this_page
    def on_try_ubuntu_clicked(self, *args):
        if not self.controller.allowed_change_step():
            # The button's already been clicked once, so stop reacting to it.
            # LP: #911907.
            return
        # Spinning cursor.
        self.controller.allow_change_step(False)
        # Queue quit.
        self.page.install_ubuntu.setEnabled(False)
        self.controller._wizard.current_page = None
        self.controller.dbfilter.ok_handler()

    def set_alpha_warning(self, show):
        if not show and not self.only:
            self.page.alpha_warning_label.hide()
            if self.page.alpha_warning_label in self.widgetHidden:
                self.widgetHidden.remove(self.page.alpha_warning_label)

    def on_release_notes_link(self, link):
        lang = self.selected_language()
        if link == "release-notes":
            if lang:
                lang = lang.split('.')[0].lower()
                url = self.release_notes_url.replace('${LANG}', lang)
                self.openURL(url)
        elif link == "update":
            if self.updating_installer:
                return
            self.updating_installer = True
            if not auto_update.update(self.controller._wizard):
                # no updates, so don't check again
                text = i18n.get_string('release_notes_only', lang)
                self.page.release_notes_label.setText(text)
            self.updating_installer = False

    def openURL(self, url):
        from PyQt4.QtGui import QDesktopServices
        from PyQt4.QtCore import QUrl
        from ubiquity.misc import drop_privileges_save, regain_privileges_save

        # this nonsense is needed because kde doesn't want to be root
        drop_privileges_save()
        QDesktopServices.openUrl(QUrl(url))
        regain_privileges_save()

    def set_language_choices(self, choices, choice_map):
        PageBase.set_language_choices(self, choices, choice_map)
        self.combobox.clear()
        for choice in choices:
            self.combobox.addItem(str(choice))

    def set_language(self, language):
        index = self.combobox.findText(str(language))
        if index < 0:
            self.combobox.addItem("C")
        else:
            self.combobox.setCurrentIndex(index)

        if not self.only and 'UBIQUITY_GREETER' in os.environ:
            self.page.try_ubuntu.setEnabled(True)
            self.page.install_ubuntu.setEnabled(True)

    def get_language(self):
        lang = self.selected_language()
        return lang if lang else 'C'

    def selected_language(self):
        lang = self.combobox.currentText()
        if not lang or not hasattr(self, 'language_choice_map'):
            return None
        else:
            return self.language_choice_map[str(lang)][1]

    def on_language_selection_changed(self):
        lang = self.selected_language()
        if not lang:
            return
        # strip encoding; we use UTF-8 internally no matter what
        lang = lang.split('.')[0]
        self.controller.translate(lang)
        if not self.only:
            release = misc.get_release()
            install_medium = misc.get_install_medium()
            install_medium = i18n.get_string(install_medium, lang)
            for widget in (self.page.try_install_text_label,
                           self.page.try_ubuntu,
                           self.page.install_ubuntu,
                           self.page.alpha_warning_label):
                text = widget.text()
                text = text.replace('${RELEASE}', release.name)
                text = text.replace('${MEDIUM}', install_medium)
                text = text.replace('Ubuntu', 'Kubuntu')
                widget.setText(text)

        self.update_release_notes_label()
        for w in self.widgetHidden:
            w.show()
        self.widgetHidden = []

    def plugin_set_online_state(self, state):
        from PyQt4.QtCore import QTimer, SIGNAL
        if self.page.release_notes_label:
            if state:
                self.page.release_notes_label.show()
                QTimer.singleShot(300, self.check_returncode)
                self.timer = QTimer(self.page)
                self.timer.connect(
                    self.timer, SIGNAL("timeout()"), self.check_returncode)
                self.timer.start(300)
            else:
                self.page.release_notes_label.hide()

    def check_returncode(self, *args):
        import subprocess
        from PyQt4.QtCore import SIGNAL
        if self.wget_retcode is not None or self.wget_proc is None:
            self.wget_proc = subprocess.Popen(
                ['wget', '-q', _wget_url, '--timeout=15', '--tries=1',
                 '-O', '/dev/null'])
        self.wget_retcode = self.wget_proc.poll()
        if self.wget_retcode is None:
            return True
        else:
            if self.wget_retcode == 0:
                self.update_installer = True
            else:
                self.update_installer = False
            self.update_release_notes_label()
            self.timer.disconnect(
                self.timer, SIGNAL("timeout()"), self.check_returncode)

    def update_release_notes_label(self):
        lang = self.selected_language()
        if not lang:
            return
        # strip encoding; we use UTF-8 internally no matter what
        lang = lang.split('.')[0]
        # Either leave the release notes label alone (both release notes and a
        # critical update are available), set it to just the release notes,
        # just the critical update, or neither, as appropriate.
        if self.page.release_notes_label:
            if self.release_notes_found and self.update_installer:
                text = i18n.get_string('release_notes_label', lang)
                self.page.release_notes_label.setText(text)
            elif self.release_notes_found:
                text = i18n.get_string('release_notes_only', lang)
                self.page.release_notes_label.setText(text)
            elif self.update_installer:
                text = i18n.get_string('update_installer_only', lang)
                self.page.release_notes_label.setText(text)

    def set_oem_id(self, text):
        return self.page.oem_id_entry.setText(text)

    def get_oem_id(self):
        return str(self.page.oem_id_entry.text())
    op.Input.setValue(array)

    def do():
        # Generate
        # array[:] = np.random.randint(0,255,500*500).reshape(shape).astype(np.uint8)
        a = np.zeros(500 * 500).reshape(500, 500).astype(np.uint8)
        ii = np.random.randint(0, 500, 1)
        jj = np.random.randint(0, 500, 1)
        a[ii, jj] = 1
        a = vigra.filters.discDilation(a, radius=20)
        array[:] = a.reshape(shape).view(np.ndarray) * 255
        op.Input.setDirty()

    do()

    cron.connect(cron, SIGNAL("timeout()"), do)
    ds = LazyflowSource(op.Output)
    layer = ColortableLayer(ds, jet())

    mainwin = Viewer()

    def _addNewLabel():
        """
        Add a new label to the label list GUI control.
        Return the new number of labels in the control.
        """
        erase = Label("Dummy", QColor(255, 255, 255))
        label = Label("Foreground", QColor(255, 0, 0))
        back = Label("Background", QColor(0, 255, 0))

        newRow = labelListModel.rowCount()
Example #7
0
class PageKde(PageBase):
    plugin_breadcrumb = 'ubiquity/text/breadcrumb_language'
    plugin_is_language = True

    def __init__(self, controller, *args, **kwargs):
        self.controller = controller
        self.wget_retcode = None
        self.wget_proc = None
        if self.controller.oem_user_config:
            self.only = True
        else:
            self.only = False

        try:
            from PyQt4 import uic
            from PyQt4.QtGui import QWidget, QPixmap, QIcon
            self.page = uic.loadUi('/usr/share/ubiquity/qt/stepLanguage.ui')
            self.combobox = self.page.language_combobox
            # Tell layout that all items are of uniform sizes
            # Fixes LP:1187762
            self.combobox.view().setUniformItemSizes(True)
            self.combobox.currentIndexChanged[str].connect(
                self.on_language_selection_changed)
            if not self.controller.oem_config:
                self.page.oem_widget.hide()

            def init_big_button(button, image_name):
                pix = QPixmap('/usr/share/ubiquity/qt/images/' + image_name)
                icon = QIcon(pix)
                button.setIcon(icon)
                button.setIconSize(pix.size())
                # Set a fixed height to ensure the button text is not cropped
                # when the window is resized
                button.setFixedHeight(button.sizeHint().height())

            def inst(*args):
                self.page.try_ubuntu.setEnabled(False)
                self.controller.go_forward()

            self.page.install_ubuntu.clicked.connect(inst)
            self.page.try_ubuntu.clicked.connect(self.on_try_ubuntu_clicked)
            init_big_button(self.page.install_ubuntu, 'install.png')
            init_big_button(self.page.try_ubuntu, 'try.png')

            self.release_notes_url = ''
            self.update_installer = True
            self.updating_installer = False
            if self.controller.oem_config or auto_update.already_updated():
                self.update_installer = False
            self.release_notes_found = False
            try:
                with open(_release_notes_url_path) as release_notes:
                    self.release_notes_url = release_notes.read().rstrip('\n')
                self.release_notes_found = True
            except (KeyboardInterrupt, SystemExit):
                raise
            except:
                pass

            if self.release_notes_url:
                self.page.release_notes_label.linkActivated.connect(
                    self.on_release_notes_link)
            else:
                self.page.release_notes_label.hide()

            if 'UBIQUITY_GREETER' not in os.environ:
                self.page.try_ubuntu.hide()
                self.page.try_install_text_label.hide()
                self.page.install_ubuntu.hide()

            # We do not want to show the yet to be substituted strings
            # (${MEDIUM}, etc), so don't show the core of the page until
            # it's ready.
            self.widgetHidden = []
            for w in self.page.children():
                if isinstance(w, QWidget) and not w.isHidden():
                    self.widgetHidden.append(w)
                    w.hide()

        except Exception as e:
            self.debug('Could not create language page: %s', e)
            self.page = None

        self.plugin_widgets = self.page

    @plugin.only_this_page
    def on_try_ubuntu_clicked(self, *args):
        if not self.controller.allowed_change_step():
            # The button's already been clicked once, so stop reacting to it.
            # LP: #911907.
            return
        # Spinning cursor.
        self.controller.allow_change_step(False)
        # Queue quit.
        self.page.install_ubuntu.setEnabled(False)
        self.controller._wizard.current_page = None
        self.controller.dbfilter.ok_handler()

    def on_release_notes_link(self, link):
        lang = self.selected_language()
        if link == "release-notes":
            if lang:
                lang = lang.split('.')[0].lower()
                url = self.release_notes_url.replace('${LANG}', lang)
                self.openURL(url)
        elif link == "update":
            if self.updating_installer:
                return
            self.updating_installer = True
            if not auto_update.update(self.controller._wizard):
                # no updates, so don't check again
                text = i18n.get_string('release_notes_only', lang)
                self.page.release_notes_label.setText(text)
            self.updating_installer = False

    def openURL(self, url):
        from PyQt4.QtGui import QDesktopServices
        from PyQt4.QtCore import QUrl
        import shutil
        import os

        # this nonsense is needed because kde doesn't want to be root
        misc.drop_privileges()
        misc.drop_privileges_save()
        # copy over gtkrc-2.0 to get the themeing right
        if os.path.exists("/usr/share/netrunner-default-settings"):
            shutil.copy(
                "/usr/share/netrunner-default-settings/" +
                "dot-gtkrc-2.0-kde4",
                os.getenv("HOME") + "/.gtkrc-2.0")
        QDesktopServices.openUrl(QUrl(url))
        misc.regain_privileges()
        misc.regain_privileges_save()

    def set_language_choices(self, choices, choice_map):
        PageBase.set_language_choices(self, choices, choice_map)
        self.combobox.clear()
        self.combobox.addItems(choices)

    def set_language(self, language):
        index = self.combobox.findText(str(language))
        if index < 0:
            self.combobox.addItem("C")
        else:
            self.combobox.setCurrentIndex(index)

        if not self.only and 'UBIQUITY_GREETER' in os.environ:
            self.page.try_ubuntu.setEnabled(True)
            self.page.install_ubuntu.setEnabled(True)

    def get_language(self):
        lang = self.selected_language()
        return lang if lang else 'C'

    def selected_language(self):
        lang = self.combobox.currentText()
        if not lang or not hasattr(self, 'language_choice_map'):
            return None
        else:
            return self.language_choice_map[str(lang)][1]

    def on_language_selection_changed(self):
        lang = self.selected_language()
        if not lang:
            return
        # strip encoding; we use UTF-8 internally no matter what
        lang = lang.split('.')[0]
        self.controller.translate(lang)
        if not self.only:
            release = misc.get_release()
            install_medium = misc.get_install_medium()
            install_medium = i18n.get_string(install_medium, lang)
            for widget in (self.page.try_install_text_label,
                           self.page.try_ubuntu, self.page.install_ubuntu):
                text = widget.text()
                text = text.replace('${RELEASE}', release.name)
                text = text.replace('${MEDIUM}', install_medium)
                text = text.replace('Ubuntu', 'Kubuntu')
                widget.setText(text)

        self.update_release_notes_label()
        for w in self.widgetHidden:
            w.show()
        self.widgetHidden = []

    def plugin_set_online_state(self, state):
        from PyQt4.QtCore import QTimer, SIGNAL
        if self.page.release_notes_label:
            if state:
                self.page.release_notes_label.show()
                QTimer.singleShot(300, self.check_returncode)
                self.timer = QTimer(self.page)
                self.timer.connect(self.timer, SIGNAL("timeout()"),
                                   self.check_returncode)
                self.timer.start(300)
            else:
                self.page.release_notes_label.hide()

    def check_returncode(self, *args):
        import subprocess
        from PyQt4.QtCore import SIGNAL
        if self.wget_retcode is not None or self.wget_proc is None:
            self.wget_proc = subprocess.Popen([
                'wget', '-q', _wget_url, '--timeout=15', '--tries=1', '-O',
                '/dev/null'
            ])
        self.wget_retcode = self.wget_proc.poll()
        if self.wget_retcode is None:
            return True
        else:
            if self.wget_retcode == 0:
                self.update_installer = True
            else:
                self.update_installer = False
            self.update_release_notes_label()
            self.timer.disconnect(self.timer, SIGNAL("timeout()"),
                                  self.check_returncode)

    def update_release_notes_label(self):
        lang = self.selected_language()
        if not lang:
            return
        # strip encoding; we use UTF-8 internally no matter what
        lang = lang.split('.')[0]
        # Either leave the release notes label alone (both release notes and a
        # critical update are available), set it to just the release notes,
        # just the critical update, or neither, as appropriate.
        if self.page.release_notes_label:
            if self.release_notes_found and self.update_installer:
                text = i18n.get_string('release_notes_label', lang)
                self.page.release_notes_label.setText(text)
            elif self.release_notes_found:
                text = i18n.get_string('release_notes_only', lang)
                self.page.release_notes_label.setText(text)
            elif self.update_installer:
                text = i18n.get_string('update_installer_only', lang)
                self.page.release_notes_label.setText(text)

    def set_oem_id(self, text):
        return self.page.oem_id_entry.setText(text)

    def get_oem_id(self):
        return str(self.page.oem_id_entry.text())
    op.Input.setValue(array)

    def do():
        #Generate
        #array[:] = np.random.randint(0,255,500*500).reshape(shape).astype(np.uint8)
        a = np.zeros(500 * 500).reshape(500, 500).astype(np.uint8)
        ii = np.random.randint(0, 500, 1)
        jj = np.random.randint(0, 500, 1)
        a[ii, jj] = 1
        a = vigra.filters.discDilation(a, radius=20)
        array[:] = a.reshape(shape).view(np.ndarray) * 255
        op.Input.setDirty()

    do()

    cron.connect(cron, SIGNAL('timeout()'), do)
    ds = LazyflowSource(op.Output)
    layer = ColortableLayer(ds, jet())

    mainwin = Viewer()

    mainwin.layerstack.append(layer)
    mainwin.dataShape = (1, 500, 500, 1, 1)
    print mainwin.centralWidget()

    BoxContr = BoxController(mainwin.editor.imageScenes[2], op.Output,
                             boxListModel)
    BoxInt = BoxInterpreter(mainwin.editor.navInterpret,
                            mainwin.editor._posModel, BoxContr,
                            mainwin.centralWidget())
Example #9
0
 def set_timer():
     timer = QTimer(mw)
     timer.setSingleShot(True)
     timer.connect(timer, SIGNAL('timeout()'), handler)
     timer.start(delay)
Example #10
0
def main():
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    global app
    app = QtGui.QApplication(sys.argv)
    app.setApplicationName("Liquor Cabinet")
    
    if not NOSPLASH:
        pixmap = QtGui.QPixmap("resources/splashscreen.png")
        splash = QtGui.QSplashScreen(pixmap, Qt.WindowStaysOnTopHint)
    
        #~ splash.setMask(pixmap.mask())
        splash.show()
        splash.showMessage(u'Starting...', Qt.AlignVCenter | Qt.AlignBottom)
        time.sleep(SPLASH_MESSAGE_DELAY)
    
    #Load our database...
    global client
    client = baseclient.BaseClient(DATABASE_PATH, DEBUG)
    
    if not NOSPLASH:
        splash.showMessage(u'Loading database...', Qt.AlignVCenter | Qt.AlignBottom)
        time.sleep(SPLASH_MESSAGE_DELAY)
    
    
    client.import_dump()
    client.load_defaults()
    
    if not NOSPLASH:
        splash.showMessage(u'Populating Menus...', Qt.AlignVCenter | Qt.AlignBottom)
        time.sleep(SPLASH_MESSAGE_DELAY)

    app.processEvents()

    appIcon = QtGui.QIcon(TRAY_ICON)
    app.setWindowIcon(appIcon)
    
    global trayIcon
    trayIcon = SystemTrayIcon(appIcon)
    trayIcon.show()
    
    #Do our main window.
    mainwindow = MainWindow()
    
    if not NOSPLASH:
        splash.showMessage(u'Building Main Window...', Qt.AlignVCenter | Qt.AlignBottom)
    
        for m in random.sample(LOADING_MESSAGES, len(LOADING_MESSAGES)):
            splash.showMessage(m, Qt.AlignVCenter | Qt.AlignBottom)
            if SPLASH_MESSAGE_DELAY is 0:
                s = 0
            else:
                s = abs(SPLASH_MESSAGE_DELAY-(random.random()/2.0))
            time.sleep(s)
    
        splash.finish(w)
    
    mainwindow.show()
    
    #slist = ShoppingList()
    #slist.show()
    
    #ied = IngredientsEditor()
    #ied.show()
    
    #ivp = IngredientViewerPane(client.get_ingredients()[0])
    #ivp.show()
    
    #inged = IngredientsEditor()
    #inged.show()
    
    #b = BottleFullnessGuage()
    #b.show()
    
    print("There is now a red and white potion bottle in your system tray. That's where all your icons go. Click to get a window, right click to get a menu.")
    print("CTRL+C will exit the program, but will not save data automatically. Closing from the program will save your data automatically.")

    app.setQuitOnLastWindowClosed(False)
    
    savetimer = QTimer()
    savetimer.connect(savetimer, SIGNAL("timeout()"), functools.partial(safe_client_dump, DATABASE_FILENAME))
    
    length = 0
    for i in (client.get_ingredients(), client.get_amounts(), client.session.query(models.Log).all()):
        length += len(i)
    delaymod = length/100.0
        
    savetimer.start(WRITE_DATA_DELAY*delaymod)
    print "Automatically saving every %.2f minutes" % (((((WRITE_DATA_DELAY*delaymod)/1000.0)/60.0)))

    safe_client_dump(DATABASE_FILENAME)

    rval = app.exec_()
    
    safe_client_dump(DATABASE_FILENAME)
    
    sys.exit(rval)