python类events_pending()的实例源码

recogspeech.py 文件源码 项目:Dict-O-nator 作者: theawless 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def update_gui():
        """Updates GUI by completing all tasks in the main event loop"""
        while Gtk.events_pending():
            Gtk.main_iteration_do(True)
filedownloader.py 文件源码 项目:ubi-virtual-assistant 作者: Alzemand 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def set_value(self,value):
        if value >=0 and value<=self.max_value:
            self.value = value
            fraction=self.value/self.max_value
            self.progressbar.set_fraction(fraction)
            self.map()
            while Gtk.events_pending():
                Gtk.main_iteration()
            if self.value==self.max_value:
                self.hide()
filedownloader.py 文件源码 项目:ubi-virtual-assistant 作者: Alzemand 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def increase(self,w,a):
        self.value+=1.0
        fraction=self.value/self.max_value
        self.progressbar.set_fraction(fraction)
        while Gtk.events_pending():
            Gtk.main_iteration()
        if self.value==self.max_value:
            self.hide()
filedownloader.py 文件源码 项目:ubi-virtual-assistant 作者: Alzemand 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def decrease(self):
        self.value-=1.0
        fraction=self.value/self.max_value
        self.progressbar.set_fraction(fraction)
        self.map()
        while Gtk.events_pending():
            Gtk.main_iteration()
filedownloader.py 文件源码 项目:ubi-virtual-assistant 作者: Alzemand 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def main():
    sl = SL();os.system("mkdir /tmp/site");os.system("echo False > /tmp/site/site-log.txt")
    if sl.run() == Gtk.ResponseType.ACCEPT:
        sl.hide()
        #if sl.button.get_label()!='Select folder':
        folder = '/tmp/site/';
        extension = sl.entry10.get_text()
        url = sl.entry11.get_text()
        if len(url)>0:
            urls = get_file_urls(url,extension)
            total = len(urls)
            if total>0:
                print(urls)
                workers = []
                print(1)
                cua = queue.Queue(maxsize=total+2)
                progreso = Progreso('Downloading from %s'%url,None,total)
                total_workers = total if NUM_THREADS > total else NUM_THREADS
                for i in range(total_workers):
                    worker = Worker(cua,folder)
                    worker.connect('downloaded',progreso.increase)
                    worker.start()
                    workers.append(worker)
                print(2)
                for aurl in urls:
                    cua.put(aurl)
                # block until all tasks are done
                print(3)
                cua.join()
                # stop workers
                print(4)
                for i in range(total_workers):
                    cua.put(None)
                for worker in workers:
                    worker.join()
                    while Gtk.events_pending():
                        Gtk.main_iteration()

                os.system("echo True > /tmp/site/site-log.txt")
filedownloader.py 文件源码 项目:ubi-virtual-assistant 作者: Alzemand 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def set_value(self,value):
        if value >=0 and value<=self.max_value:
            self.value = value
            fraction=self.value/self.max_value
            self.progressbar.set_fraction(fraction)
            self.map()
            while Gtk.events_pending():
                Gtk.main_iteration()
            if self.value==self.max_value:
                self.hide()
filedownloader.py 文件源码 项目:ubi-virtual-assistant 作者: Alzemand 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def increase(self,w,a):
        self.value+=1.0
        fraction=self.value/self.max_value
        self.progressbar.set_fraction(fraction)
        while Gtk.events_pending():
            Gtk.main_iteration()
        if self.value==self.max_value:
            self.hide()
filedownloader.py 文件源码 项目:ubi-virtual-assistant 作者: Alzemand 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def decrease(self):
        self.value-=1.0
        fraction=self.value/self.max_value
        self.progressbar.set_fraction(fraction)
        self.map()
        while Gtk.events_pending():
            Gtk.main_iteration()
filedownloader.py 文件源码 项目:ubi-virtual-assistant 作者: Alzemand 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def main():
    sl = SL();os.system("mkdir /tmp/site");os.system("echo False > /tmp/site/site-log.txt")
    if sl.run() == Gtk.ResponseType.ACCEPT:
        sl.hide()
        #if sl.button.get_label()!='Select folder':
        folder = '/tmp/site/';
        extension = sl.entry10.get_text()
        url = sl.entry11.get_text()
        if len(url)>0:
            urls = get_file_urls(url,extension)
            total = len(urls)
            if total>0:
                print(urls)
                workers = []
                print(1)
                cua = queue.Queue(maxsize=total+2)
                progreso = Progreso('Downloading from %s'%url,None,total)
                total_workers = total if NUM_THREADS > total else NUM_THREADS
                for i in range(total_workers):
                    worker = Worker(cua,folder)
                    worker.connect('downloaded',progreso.increase)
                    worker.start()
                    workers.append(worker)
                print(2)
                for aurl in urls:
                    cua.put(aurl)
                # block until all tasks are done
                print(3)
                cua.join()
                # stop workers
                print(4)
                for i in range(total_workers):
                    cua.put(None)
                for worker in workers:
                    worker.join()
                    while Gtk.events_pending():
                        Gtk.main_iteration()

                os.system("echo True > /tmp/site/site-log.txt")
main.py 文件源码 项目:mastodon-gtk 作者: GabMus 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def wait_for_thread(thread):
    while thread.is_alive():
            while Gtk.events_pending():
                Gtk.main_iteration()
    return
gu.py 文件源码 项目:Solfege 作者: RannyeriDev 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def write(self, s, tag=None):
        if tag:
            self.g_textbuffer.insert_with_tags_by_name(
                self.g_textbuffer.get_end_iter(),
                s,
                tag)

        else:
            self.g_textbuffer.insert(self.g_textbuffer.get_end_iter(), s)
        self.g_textview.scroll_to_iter(
                self.g_textbuffer.get_end_iter(),
                0.0, False, 0.5, 0.5)
        # This is needed to make the window update:
        while Gtk.events_pending():
            Gtk.main_iteration()
make_screenshots.py 文件源码 项目:Solfege 作者: RannyeriDev 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def screenshot(windowtitle, lang, fn):
    while Gtk.events_pending():
        Gtk.main_iteration()
    time.sleep(2)
    while Gtk.events_pending():
        Gtk.main_iteration()
    fn = "help/%s/figures/%s" % (lang, fn)
    cmd = u'import -window %s %s' % (windowtitle, fn)
    print cmd
    os.system(cmd.encode("utf-8"))
    compress(fn)
mainwin.py 文件源码 项目:Solfege 作者: RannyeriDev 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def show_progress(self, txt):
        self.g_infolabel.set_text(txt)
        while Gtk.events_pending():
            Gtk.main_iteration()
mainwin.py 文件源码 项目:Solfege 作者: RannyeriDev 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def display_error_message(self, msg, title=None, secondary_text=None):
        if solfege.splash_win and solfege.splash_win.props.visible:
            solfege.splash_win.hide()
            reshow_splash = True

        else:
            reshow_splash = False

        if not isinstance(msg, unicode):
            msg = msg.decode(locale.getpreferredencoding(), 'replace')
        m = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR,
                              Gtk.ButtonsType.CLOSE, None)
        m.set_markup(gu.escape(msg))

        if title:
            m.set_title(title)

        if secondary_text:
            m.format_secondary_text(secondary_text)
        m.run()
        m.destroy()

        if reshow_splash:
            solfege.splash_win.show()
            while Gtk.events_pending():
                Gtk.main_iteration()
__init__.py 文件源码 项目:ubuntu-cleaner 作者: gerardpuig 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def on_plugin_object_cleaned(self, plugin, cruft, count, user_data):
        while Gtk.events_pending():
            Gtk.main_iteration()

        plugin_iter, cruft_dict = user_data
        self.result_model.remove(cruft_dict[cruft])

        self.janitor_model[plugin_iter][self.JANITOR_DISPLAY]
        remain = len(cruft_dict) - count

        if remain:
            self.janitor_model[plugin_iter][self.JANITOR_DISPLAY] = "<b>[%d] %s</b>" % (remain, plugin.get_title())
        else:
            self.janitor_model[plugin_iter][self.JANITOR_DISPLAY] = "[0] %s" % plugin.get_title()
recovery_basic_gtk.py 文件源码 项目:dell-recovery 作者: dell 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def hide_progress(self):
        """Hides the progress bar"""
        self.widgets.get_object('progress_dialog').hide()
        while Gtk.events_pending():
            Gtk.main_iteration()
recovery_basic_gtk.py 文件源码 项目:dell-recovery 作者: dell 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def toggle_spinner_popup(self, force):
        wizard = self.widgets.get_object('wizard')
        popup = self.widgets.get_object('spinner_popup')
        if force:
            wizard.set_sensitive(False)
            self.spinner.start()
            popup.show()
        else:
            self.spinner.stop()
            popup.hide()
            wizard.set_sensitive(True)
        while Gtk.events_pending():
            Gtk.main_iteration()
common.py 文件源码 项目:bokken 作者: thestr4ng3r 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def repaint():
    '''Easy function to clean up the event queue and force a repaint.'''

    # I've been unable to find any other way to repaint the interface. :-(
    while Gtk.events_pending():
        # Blocking: True/false
        Gtk.main_iteration_do(False)
main.py 文件源码 项目:ibus-typing-booster 作者: mike-fabian 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
def on_learn_from_file_clicked(self, dummy_widget):
        '''
        The button to learn from a user supplied text file
        has been clicked.
        '''
        SETUP_UI.learn_from_file_button.set_sensitive(False)
        filename = u''
        chooser = Gtk.FileChooserDialog(
            _('Open File ...'), SETUP_UI.builder.get_object('main_dialog'),
            Gtk.FileChooserAction.OPEN,
            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
             Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
        response = chooser.run()
        if response == Gtk.ResponseType.OK:
            filename = chooser.get_filename()
        chooser.destroy()
        while Gtk.events_pending():
            Gtk.main_iteration()
        if filename and os.path.isfile(filename):
            if SETUP_UI.tabsqlitedb.read_training_data_from_file(filename):
                dialog = Gtk.MessageDialog(
                    parent=SETUP_UI.builder.get_object('main_dialog'),
                    flags=Gtk.DialogFlags.MODAL,
                    message_type=Gtk.MessageType.INFO,
                    buttons=Gtk.ButtonsType.OK,
                    message_format=(
                        _("Learned successfully from file %(filename)s.")
                        %{'filename': filename}))
            else:
                dialog = Gtk.MessageDialog(
                    parent=SETUP_UI.builder.get_object('main_dialog'),
                    flags=Gtk.DialogFlags.MODAL,
                    message_type=Gtk.MessageType.ERROR,
                    buttons=Gtk.ButtonsType.OK,
                    message_format=(
                        _("Learning from file %(filename)s failed.")
                        %{'filename': filename}))
            dialog.run()
            dialog.destroy()
        SETUP_UI.learn_from_file_button.set_sensitive(True)
__init__.py 文件源码 项目:pytestshot 作者: openpaperwork 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def wait(self):
        self.condition.acquire()
        try:
            while Gtk.events_pending():
                GLib.idle_add(self._wake_up)
                self.condition.wait()
        finally:
            self.condition.release()


问题


面经


文章

微信
公众号

扫码关注公众号