Python gi.repository.Gtk 模块,events_pending() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用gi.repository.Gtk.events_pending()

项目:my-weather-indicator    作者:atareao    | 项目源码 | 文件源码
def work(self):
        while Gtk.events_pending():
            Gtk.main_iteration()
        # again = False
        msg = self.web_recv()
        if msg:
            try:
                msg = from_json(msg)
                print('This is the message %s' % (msg))
            except BaseException:
                msg = None
            # again = True
        if msg == 'exit':
            self.close_application(None)

    # ###################################################################
    # ########################BROWSER####################################
    # ###################################################################
项目:my-weather-indicator    作者:atareao    | 项目源码 | 文件源码
def title_changed(self, widget, frame, title):
        if title != 'null':
            self.message_queue.put(title)
            while Gtk.events_pending():
                Gtk.main_iteration()
            msg = self.web_recv()
            if msg:
                try:
                    msg = from_json(msg)
                    print('This is the message %s' % (msg))
                    if msg['status'] == 'ready':
                        self.web_send('title="%s";subtitle="%s";humidity=%s;\
cloudiness=%s;temperature=%s;draw_graph(title,subtitle,temperature,humidity,\
cloudiness);' % (self.title, self.subtitle, self.humidity, self.cloudiness,
                            self.temperature))
                    elif msg['status'] == 'exit':
                        self.close_application(None)
                except BaseException:
                    pass
项目:ubi-virtual-assistant    作者:Alzemand    | 项目源码 | 文件源码
def __init__(self,title,parent,max_value):
        #
        Gtk.Dialog.__init__(self,title,parent)
        self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        self.set_size_request(330, 40)
        self.set_resizable(False)
        self.connect('destroy', self.close)
        #
        vbox1 = Gtk.VBox(spacing = 5)
        vbox1.set_border_width(5)
        self.get_content_area().add(vbox1)
        #
        self.progressbar = Gtk.ProgressBar()
        vbox1.pack_start(self.progressbar,True,True,0)
        #
        self.show_all()
        #
        self.max_value=max_value
        self.value=0.0
        self.map()
        while Gtk.events_pending():
            Gtk.main_iteration()
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def start_app(datadir):
    global splash_win
    if not options.no_splash:
        solfege.splash_win = splash_win = SplashWin()
        time.sleep(0.1)
        Gdk.flush()
        while Gtk.events_pending():
            Gtk.main_iteration()

    else:
        solfege.splash_win = splash_win = None
    style_provider = Gtk.CssProvider()
    with open("solfege.css", "r") as f:
        css = f.read()
    try:
        style_provider.load_from_data(css)
    except GObject.GError, e:
        print e
        pass
    Gtk.StyleContext.add_provider_for_screen(
        Gdk.Screen.get_default(), style_provider,
        Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
    GObject.timeout_add(1, start_gui, datadir)
    Gtk.main()
项目:ubuntu-cleaner    作者:gerardpuig    | 项目源码 | 文件源码
def on_find_object(self, plugin, cruft, count, iters):
        while Gtk.events_pending():
            Gtk.main_iteration()

        plugin_iter, result_iter = iters

        self.result_model.append(result_iter, (False,
                                               cruft.get_icon(),
                                               cruft.get_name(),
                                               cruft.get_name(),
                                               cruft.get_size_display(),
                                               plugin,
                                               cruft))

        self.result_view.expand_row(self.result_model.get_path(result_iter), True)

        # Update the janitor title
        if count:
            self.janitor_model[plugin_iter][self.JANITOR_DISPLAY] = "<b>[%d] %s</b>" % (count, plugin.get_title())
        else:
            self.janitor_model[plugin_iter][self.JANITOR_DISPLAY] = "[0] %s" % plugin.get_title()
项目:dell-recovery    作者:dell    | 项目源码 | 文件源码
def update_progress_gui(self, progress_text, progress):
        """Updates the progressbar to show what we are working on"""

        progressbar = self.widgets.get_object('progressbar')
        self.widgets.get_object('progress_dialog').show()

        if float(progress) < 0:
            progressbar.pulse()
        else:
            progressbar.set_fraction(float(progress)/100)
        if progress_text != None:
            self.widgets.get_object('action').set_markup("<i>" +\
                                                        _(progress_text)+"</i>")
        while Gtk.events_pending():
            Gtk.main_iteration()
        return True
项目:ibus-typing-booster    作者:mike-fabian    | 项目源码 | 文件源码
def on_delete_learned_data_clicked(self, dummy_widget):
        '''
        The button requesting to delete all data learned from
        user input or text files has been clicked.
        '''
        SETUP_UI.delete_learned_data_button.set_sensitive(False)
        confirm_question = Gtk.Dialog(
            title=_('Are you sure?'),
            parent=SETUP_UI.builder.get_object('main_dialog'),
            buttons=(
                Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                Gtk.STOCK_OK, Gtk.ResponseType.OK))
        box = confirm_question.get_content_area()
        box.add(Gtk.Label(
            _('Do you really want to delete all language \n'
              + 'data learned from typing or reading files?')))
        confirm_question.show_all()
        response = confirm_question.run()
        confirm_question.destroy()
        while Gtk.events_pending():
            Gtk.main_iteration()
        if response == Gtk.ResponseType.OK:
            SETUP_UI.tabsqlitedb.remove_all_phrases()
        SETUP_UI.delete_learned_data_button.set_sensitive(True)
项目:games_nebula_goglib_scripts    作者:yancharkin    | 项目源码 | 文件源码
def watch_process(self, io, condition, process_name):

        if condition is GLib.IO_HUP:

            self.progressbar.pulse()

            self.n_files -= 1

            if self.n_files == 0:
                self.config_save_crop(self.crop)

            return False

        while Gtk.events_pending():
            Gtk.main_iteration_do(False)

        return True
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def launch_game(self):

        self.switch_monitor('ON')

        self.main_window.hide()

        while Gtk.events_pending():
            Gtk.main_iteration()

        if self.launcher_type == 'gog':
            launch_command = self.install_dir + '/' + self.game_name + '/start_gog.sh'
        else:
            launch_command = self.install_dir + '/' + self.game_name + '/start_gn.sh'

        os.system(self.command_before)
        os.system(launch_command)
        os.system(self.command_after)

        self.switch_monitor('OFF')

        self.config_save()

        sys.exit()
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_settings(self, button):

        self.main_window.hide()

        while Gtk.events_pending():
            Gtk.main_iteration()

        launch_command = self.install_dir + '/' + self.game_name + '/settings.sh ' + \
        self.install_dir + ' ' + nebula_dir

        os.system(launch_command)

        self.config_save()
        os.execl(sys.executable, 'python', __file__, self.game_name)
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_wine_settings(self, button):

        self.main_window.hide()

        while Gtk.events_pending():
            Gtk.main_iteration()

        self.set_wineprefix()
        self.create_link()

        self.set_environ()
        self.set_win_ver_command()
        self.set_additions_command()

        launch_command = 'python2 ' + nebula_dir + '/settings_wine.py'

        full_command = self.win_ver_command + '\n' + \
        self.additions_command + '\n' + \
        launch_command

        os.system(full_command)

        self.main_window.show()
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_settings(self, button):

        self.main_window.hide()

        while Gtk.events_pending():
            Gtk.main_iteration()

        self.set_wineprefix()
        self.create_link()

        self.set_environ()
        self.set_win_ver_command()
        self.set_additions_command()

        launch_command = self.install_dir + '/' + self.game_name + '/settings.sh'

        full_command = self.win_ver_command + '\n' + \
        self.additions_command + '\n' + \
        launch_command

        os.system(full_command)

        self.config_save()

        self.exe_path = self.get_new_exe_path()

        os.execl(sys.executable, 'python', __file__, self.game_name, self.exe_path)
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def launch_game(self):

        self.switch_monitor('ON')

        self.main_window.hide()

        while Gtk.events_pending():
            Gtk.main_iteration()

        self.set_environ()
        self.set_win_ver_command()
        self.set_mouse_capture_command()
        self.set_additions_command()
        self.set_launch_command()

        exe_name, exe_path_no_exe = self.get_exe_path()
        cd_command =    'cd "' + self.install_dir + '/' + self.game_name + \
                        '/game/' + exe_path_no_exe + '"'

        full_command = cd_command + '\n' + \
        self.win_ver_command + '\n' + \
        self.mouse_capture_command + '\n' + \
        self.additions_command + '\n' + \
        self.launch_command

        os.system(self.command_before)
        os.system(full_command)
        os.system(self.command_after)

        self.switch_monitor('OFF')

        sys.exit()
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def launch_game(self):

        output = self.combobox_monitor.get_active_text().split()[0]
        os.system('xrandr --output '+ output + ' --primary')

        self.main_window.hide()

        while Gtk.events_pending():
            Gtk.main_iteration()

        dosbox_bin = self.set_dosbox_bin()

        self.create_link()

        launch_command = dosbox_bin + ' -conf ' + \
        os.getenv('HOME') + '/.games_nebula/config/dosbox.conf' + \
        ' -conf ' + self.install_dir + '/' + self.game_name + '/dosbox.conf' + \
        ' -conf ' + self.install_dir + '/' + self.game_name + '/dosbox_game.conf'

        os.system(self.command_before)
        os.system('export SDL_VIDEO_FULLSCREEN_HEAD=0 && ' + launch_command)
        os.system(self.command_after)

        output = self.monitor_primary.split()[0]
        os.system('xrandr --output '+ output + ' --primary')

        self.config_save()

        sys.exit()
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_settings(self, button):

        output = self.combobox_monitor.get_active_text().split()[0]
        os.system('xrandr --output '+ output + ' --primary')

        self.main_window.hide()

        while Gtk.events_pending():
            Gtk.main_iteration()

        dosbox_bin = self.set_dosbox_bin()

        self.create_link()

        launch_command = dosbox_bin + ' -conf ' + \
        os.getenv('HOME') + '/.games_nebula/config/dosbox.conf' + \
        ' -conf ' + self.install_dir + '/' + self.game_name + '/dosbox.conf' + \
        ' -conf ' + self.install_dir + '/' + self.game_name + '/dosbox_settings.conf'

        os.system('export SDL_VIDEO_FULLSCREEN_HEAD=0 && ' + launch_command)

        output = self.monitor_primary.split()[0]
        os.system('xrandr --output '+ output + ' --primary')

        self.main_window.show()
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_settings(self, button):

        output = self.combobox_monitor.get_active_text().split()[0]
        os.system('xrandr --output '+ output + ' --primary')

        self.main_window.hide()

        while Gtk.events_pending():
            Gtk.main_iteration()

        if self.scummvm == 'global':

            if global_scummvm == 'system':
                launch_command = 'scummvm --no-fullscreen -c ' + self.install_dir \
                + '/' + self.game_name + '/scummvmrc'
            if global_scummvm == 'path':
                launch_command = global_scummvm_path + '/' + global_scummvm_version + \
                '/bin/scummvm --no-fullscreen -c ' + self.install_dir \
                + '/' + self.game_name + '/scummvmrc'

        elif self.scummvm == 'system':
            launch_command = 'scummvm --no-fullscreen -c ' + self.install_dir \
            + '/' + self.game_name + '/scummvmrc'

        elif self.scummvm == 'path':
            launch_command = self.scummvm_path + '/' + self.scummvm_version + \
            '/bin/scummvm --no-fullscreen -c ' + self.install_dir \
            + '/' + self.game_name + '/scummvmrc'

        os.system(launch_command)

        output = self.monitor_primary.split()[0]
        os.system('xrandr --output '+ output + ' --primary')

        self.main_window.show()
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def launch_game(self):

        output = self.combobox_monitor.get_active_text().split()[0]
        os.system('xrandr --output '+ output + ' --primary')

        self.main_window.hide()

        while Gtk.events_pending():
            Gtk.main_iteration()

        if self.scummvm == 'global':
            if global_scummvm == 'system':
                scummvm_bin = 'scummvm'
            if global_scummvm == 'path':
                scummvm_bin = global_scummvm_path + '/' + global_scummvm_version + '/bin/scummvm'

        elif self.scummvm == 'system':
            scummvm_bin = 'scummvm'

        elif self.scummvm == 'path':
            scummvm_bin = self.scummvm_path + '/' + self.scummvm_version + '/bin/scummvm'

        launch_command = scummvm_bin + ' -c ' + self.install_dir + '/' +\
        self.game_name + '/scummvmrc ' + self.scummvm_game_name

        os.system(self.command_before)
        os.system(launch_command)
        os.system(self.command_after)

        output = self.monitor_primary.split()[0]
        os.system('xrandr --output '+ output + ' --primary')

        self.config_save()

        sys.exit()
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def watch_process(self, io, condition, process_name):

        if condition is GLib.IO_HUP:

            self.progressbar.pulse()

            self.n_files_to_copy -= 1

            if self.n_files_to_copy == 0:

                message_dialog = Gtk.MessageDialog(
                    self.main_window,
                    0,
                    Gtk.MessageType.ERROR,
                    Gtk.ButtonsType.OK,
                    _("Done!"),
                    width_request = 360
                    )
                content_area = message_dialog.get_content_area()
                content_area.set_property('margin-left', 10)
                content_area.set_property('margin-right', 10)
                content_area.set_property('margin-top', 10)
                content_area.set_property('margin-bottom', 10)
                action_area = message_dialog.get_action_area()
                action_area.set_property('spacing', 10)

                self.main_window.hide()
                message_dialog.run()
                message_dialog.destroy()

                Gtk.main_quit()

            return False

        while Gtk.events_pending():
            Gtk.main_iteration_do(False)

        return True
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def mylib_launch_game(self, button):

        self.switch_monitor('ON')

        self.main_window.hide()
        if len(self.additional_windows_list) != 0:
            for window in self.additional_windows_list:
                window.hide()

        while Gtk.events_pending():
            Gtk.main_iteration()

        game_name = button.get_name()

        self.set_environ(game_name, self.mylib_download_dir, self.mylib_install_dir)

        start_path = self.mylib_install_dir + '/' + game_name + '/start.sh'
        os.system('chmod +x ' + start_path)
        os.system(start_path)

        self.switch_monitor('OFF')

        self.main_window.show()
        if len(self.additional_windows_list) != 0:
            for window in self.additional_windows_list:
                window.show()
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def goglib_launch_game(self, button):

        self.switch_monitor('ON')

        self.main_window.hide()
        if len(self.additional_windows_list) != 0:
            for window in self.additional_windows_list:
                window.hide()

        while Gtk.events_pending():
            Gtk.main_iteration()

        game_name = button.get_name()

        self.set_environ(game_name, self.goglib_download_dir, self.goglib_install_dir)

        start_file_path = self.goglib_install_dir + '/' + game_name + '/start.sh'
        os.system('chmod +x ' + start_file_path)
        os.system(start_file_path)

        self.switch_monitor('OFF')

        self.main_window.show()
        if len(self.additional_windows_list) != 0:
            for window in self.additional_windows_list:
                window.show()
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_wine_settings(self, button):

        self.main_window.hide()
        if len(self.additional_windows_list) != 0:
            for window in self.additional_windows_list:
                window.hide()

        while Gtk.events_pending():
            Gtk.main_iteration()

        if self.wine == 'system':
            os.environ['WINELOADER'] = 'wine'
        elif self.wine == 'path':
            wine_path = self.wine_path + '/' + self.wine_version
            os.environ['WINE'] = wine_path + '/bin/wine'
            os.environ['WINELOADER'] = wine_path + '/bin/wine'
            os.environ['WINESERVER'] = wine_path + '/bin/wineserver'
            os.environ['WINEDLLPATH'] = wine_path + '/lib'

        os.environ['WINEPREFIX'] = os.getenv('HOME') + '/.games_nebula/wine_prefix'

        os.system('python2 ' + nebula_dir + '/settings_wine.py')

        self.main_window.show()
        if len(self.additional_windows_list) != 0:
            for window in self.additional_windows_list:
                window.show()
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_winetricks_cache(self, button):

        self.main_window.hide()
        if len(self.additional_windows_list) != 0:
            for window in self.additional_windows_list:
                window.hide()

        while Gtk.events_pending():
            Gtk.main_iteration()

        os.system('python2 ' + nebula_dir + '/winetricks_cache_backup.py')

        self.main_window.show()
        if len(self.additional_windows_list) != 0:
            for window in self.additional_windows_list:
                window.show()
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_get_scripts(self, button):

        lib = button.get_name()

        if lib == 'goglib':
            overwrite = self.checkbutton_goglib_scripts.get_active()
        elif lib == 'mylib':
            overwrite = self.checkbutton_mylib_scripts.get_active()

        self.main_window.hide()
        if len(self.additional_windows_list) != 0:
            for window in self.additional_windows_list:
                window.hide()

        while Gtk.events_pending():
            Gtk.main_iteration()

        mylib_has_new_scripts = os.system('python2 ' + nebula_dir + '/get_scripts.py ' + lib + ' ' + str(overwrite))

        # Ugly but works
        if mylib_has_new_scripts == 0:
            print("No new scripts.")
        else:
            print("New scripts downloaded!")
            os.execl(sys.executable, 'python2', __file__)

        self.main_window.show()
        if len(self.additional_windows_list) != 0:
            for window in self.additional_windows_list:
                window.show()
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_dosbox_settings(self, button):

        self.main_window.hide()
        if len(self.additional_windows_list) != 0:
            for window in self.additional_windows_list:
                window.hide()

        while Gtk.events_pending():
            Gtk.main_iteration()

        if self.dosbox == 'system':
            dosbox_bin = 'dosbox'
        elif self.dosbox == 'path':
            dosbox_bin = self.dosbox_path + '/' + self.dosbox_version + '/bin/dosbox'

        dosbox_version = self.check_dosbox_version(dosbox_bin)

        dosbox_global_config = os.getenv('HOME') + '/.games_nebula/config/dosbox.conf'

        os.system('python2 ' + nebula_dir + '/settings_dosbox.py ' \
        + dosbox_global_config + ' global ' + dosbox_version)

        # TODO Use if special config tool for svn-daum build exists (settings_dosbox_svn_daum.py)
        #~ if (dosbox_version == 'stable') or (dosbox_version == 'svn'):
            #~ os.system('python2 ' + nebula_dir + '/settings_dosbox.py ' + \
            #~ dosbox_global_config + ' global ' + dosbox_version)
        #~ elif dosbox_version == 'svn_daum':
            #~ os.system('python2 ' + nebula_dir + '/dosbox_settings_svn_daum.py ' + \
            #~ dosbox_global_config + ' global ' + dosbox_version)

        self.main_window.show()
        if len(self.additional_windows_list) != 0:
            for window in self.additional_windows_list:
                window.show()
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_add_remove(self, button):

        self.main_window.hide()

        while Gtk.events_pending():
            Gtk.main_iteration()

        command = '$WINELOADER uninstaller'
        os.system(command)

        self.main_window.show()
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_controllers(self, button):

        self.main_window.hide()

        while Gtk.events_pending():
            Gtk.main_iteration()

        command = '$WINELOADER control joy.cpl'
        os.system(command)

        self.main_window.show()
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_winetricks(self, button):

        self.main_window.hide()

        while Gtk.events_pending():
            Gtk.main_iteration()

        command = 'winetricks --gui'
        os.system(command)

        self.main_window.show()
项目:my-weather-indicator    作者:atareao    | 项目源码 | 文件源码
def set_wait_cursor(self):
        self.get_root_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH))
        while Gtk.events_pending():
            Gtk.main_iteration()
项目:my-weather-indicator    作者:atareao    | 项目源码 | 文件源码
def set_normal_cursor(self):
        self.get_root_window().set_cursor(Gdk.Cursor(Gdk.CursorType.ARROW))
        while Gtk.events_pending():
            Gtk.main_iteration()
项目:my-weather-indicator    作者:atareao    | 项目源码 | 文件源码
def __init__(self, lat=39.36873, lon=-2.417274645879, units='F'):
        self.images = {}
        self.echo = True
        Gtk.Window.__init__(self)
        self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        self.set_title(comun.APP)
        self.set_default_size(900, 600)
        self.set_icon_from_file(comun.ICON)
        self.connect('destroy', self.close_application)
        #
        vbox = Gtk.VBox(spacing=5)
        self.get_content_area().add(vbox)
        hbox1 = Gtk.HBox()
        vbox.pack_start(hbox1, True, True, 0)
        self.scrolledwindow1 = Gtk.ScrolledWindow()
        self.scrolledwindow1.set_policy(
            Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        self.scrolledwindow1.set_shadow_type(Gtk.ShadowType.IN)
        hbox1.pack_start(self.scrolledwindow1, True, True, 0)
        self.viewer = WebKit.WebView()
        self.scrolledwindow1.add(self.viewer)
        self.scrolledwindow1.set_size_request(900, 600)
        self.viewer.connect('title-changed', self.title_changed)
        self.viewer.open('file://' + comun.HTML)
        self.lat = lat
        self.lon = lon
        self.units = units
        self.set_focus(self.viewer)
        self.show_all()
        self.message_queue = queue.Queue()
        while Gtk.events_pending():
            Gtk.main_iteration()
        self.show_all()
        self.inicialize()
        self.run()
        self.destroy()

    # ###################################################################
    # #########################ENGINE####################################
    # ###################################################################
项目:Dict-O-nator    作者:theawless    | 项目源码 | 文件源码
def update_gui():
        """Updates GUI by completing all tasks in the main event loop"""
        while Gtk.events_pending():
            Gtk.main_iteration_do(True)
项目:ubi-virtual-assistant    作者:Alzemand    | 项目源码 | 文件源码
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()
项目:ubi-virtual-assistant    作者:Alzemand    | 项目源码 | 文件源码
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()
项目:ubi-virtual-assistant    作者:Alzemand    | 项目源码 | 文件源码
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()
项目:ubi-virtual-assistant    作者:Alzemand    | 项目源码 | 文件源码
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")
项目:ubi-virtual-assistant    作者:Alzemand    | 项目源码 | 文件源码
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()
项目:ubi-virtual-assistant    作者:Alzemand    | 项目源码 | 文件源码
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()
项目:ubi-virtual-assistant    作者:Alzemand    | 项目源码 | 文件源码
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()
项目:ubi-virtual-assistant    作者:Alzemand    | 项目源码 | 文件源码
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")
项目:mastodon-gtk    作者:GabMus    | 项目源码 | 文件源码
def wait_for_thread(thread):
    while thread.is_alive():
            while Gtk.events_pending():
                Gtk.main_iteration()
    return
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
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()
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
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)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def show_progress(self, txt):
        self.g_infolabel.set_text(txt)
        while Gtk.events_pending():
            Gtk.main_iteration()
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
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()
项目:ubuntu-cleaner    作者:gerardpuig    | 项目源码 | 文件源码
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()
项目:dell-recovery    作者:dell    | 项目源码 | 文件源码
def hide_progress(self):
        """Hides the progress bar"""
        self.widgets.get_object('progress_dialog').hide()
        while Gtk.events_pending():
            Gtk.main_iteration()
项目:dell-recovery    作者:dell    | 项目源码 | 文件源码
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()
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
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)
项目:ibus-typing-booster    作者:mike-fabian    | 项目源码 | 文件源码
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)
项目:pytestshot    作者:openpaperwork    | 项目源码 | 文件源码
def wait(self):
        self.condition.acquire()
        try:
            while Gtk.events_pending():
                GLib.idle_add(self._wake_up)
                self.condition.wait()
        finally:
            self.condition.release()