def quit_if_last(*args): windows = [ toplevel for toplevel in gtk.window_list_toplevels() if toplevel.get_property('type') == gtk.WINDOW_TOPLEVEL ] if len(windows) == 1: gtk.main_quit()
def load_app(self): uri = self.application if uri.find("://") == -1: # assume file uri = 'file://' + os.path.abspath(uri) self._browser = pywebkit.WebView(self.width, self.height, uri) self._browser.SetDocumentLoadedCallback(self._loading_stop_cb) # Not the most elegant ... but since the top-level window is created and # realized by C and not Python, we do not have a native reference to the # TOPLEVEL window, or the real WebKitWebView object. for w in gtk.window_list_toplevels(): if w.get_window_type() is gtk.WINDOW_TOPLEVEL: break self._toplevel = w self._view = w.child.child self._toplevel.connect('delete-event', self._toplevel_delete_event_cb) self._view.connect('title-changed', self._title_changed_cb) self._view.connect('icon-loaded', self._icon_loaded_cb) # Security? Allow file URIs to access the filesystem settings = self._view.get_property('settings') settings.set_property('enable-file-access-from-file-uris', True)
def quit_if_last(self, *args): self.htmlview.destroy() # for some reason has to be deleted explicitly windows = [toplevel for toplevel in gtk.window_list_toplevels() if toplevel.get_property('type') == gtk.WINDOW_TOPLEVEL] if len(windows) == 1: reactor.stop()
def run(self): import gtk import zim.gui notebook, page = self.build_notebook() if notebook is None: logger.debug('NotebookDialog cancelled - exit') return gui = None for window in gtk.window_list_toplevels(): if isinstance(window, zim.gui.MainWindow) \ and window.ui.notebook.uri == notebook.uri: gui = window.ui # XXX break if gui: gui.present(page=page, **self.get_options('geometry', 'fullscreen')) else: gui = zim.gui.GtkInterface(notebook=notebook, page=page, **self.get_options( 'geometry', 'fullscreen')) gui.run() return gui._mainwindow # XXX
def _try_close_unused_displays(cls, screen): """@screen is current GdkScreen Try to close inactive displays... Take all GtkWindow that are hidden, and move to the current screen. If no windows remain then we close the display, but we never close the default display. """ def debug(*x): pretty.print_debug(__name__, *x) display = screen.get_display() dm = gtk.gdk.display_manager_get() for disp in list(dm.list_displays()): if disp != display and disp != gtk.gdk.display_get_default(): debug("Trying to close", disp.get_name()) open_windows = 0 for window in gtk.window_list_toplevels(): # find windows on @disp if window.get_screen().get_display() != disp: continue if not window.get_property("visible"): debug("Moving window", window.get_name()) debug("Moving", window.get_title()) window.set_screen(screen) else: debug("Open window blocks close") open_windows += 1 if not open_windows: debug("Closing display", disp.get_name()) disp.close()
def get_toplevel_window(): windows = [x for x in gtk.window_list_toplevels() if x.window and x.props.visible] trans2windows = dict((x.get_transient_for(), x) for x in windows) for window in set(windows) - set(trans2windows.iterkeys()): return window return trans2windows[None]
def _hide_splash_timeout(self): # Hide the splash screen as soon as there is another window # created if len(gtk.window_list_toplevels()) > 1: self.destroy() return False return True
def run(self): notebook, page = self.build_notebook(ensure_uptodate=False) if not notebook: return # Cancelled notebook dialog import gtk import zim.gui gui = None for window in gtk.window_list_toplevels(): if isinstance(window, zim.gui.MainWindow) \ and window.ui.notebook.uri == notebook.uri: gui = window.ui # XXX break if gui: gui.present(page=page, **self.get_options('geometry', 'fullscreen')) else: gui = zim.gui.GtkInterface(notebook=notebook, page=page, **self.get_options( 'geometry', 'fullscreen')) gui.run() return gui._mainwindow # XXX
def __init__(self, excTuple): """ @param excTuple: @type excTuple: """ toplevels = gtk.window_list_toplevels() if toplevels: # FIXME: how do we find the topmost one? parent = toplevels[0] else: parent = None HIGAlertDialog.__init__(self, parent=parent, flags=gtk.DIALOG_MODAL, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_NONE) self.set_primary(_("A programming error occurred.")) self.add_button(_("Report a bug"), ExceptionDialog.RESPONSE_BUG) self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.set_default_response(gtk.RESPONSE_CLOSE) self._dw = self._createTracebackViewer(excTuple) self.set_details_widget(self._dw) # FIXME: Add a kiwi API to set the detail label expander = self._dw.get_parent() expander.set_label(_("Show debug information"))
def load_app(self): uri = self.application if uri.find("://") == -1: # assume file uri = "file://" + os.path.abspath(uri) self._browser = pywebkit.WebView(self.width, self.height, uri) self._browser.SetDocumentLoadedCallback(self._loading_stop_cb) # Not the most elegant ... but since the top-level window is created and # realized by C and not Python, we do not have a native reference to the # TOPLEVEL window, or the real WebKitWebView object. for w in gtk.window_list_toplevels(): if w.get_window_type() is gtk.WINDOW_TOPLEVEL: break self._toplevel = w self._view = w.child.child self._toplevel.connect("delete-event", self._toplevel_delete_event_cb) self._view.connect("title-changed", self._title_changed_cb) self._view.connect("icon-loaded", self._icon_loaded_cb) # Security? Allow file URIs to access the filesystem settings = self._view.get_property("settings") settings.set_property("enable-file-access-from-file-uris", True)
def quit_gtk(m): # disable plugins import quodlibet.plugins quodlibet.plugins.quit() # stop all copools print_d("Quit GTK: Stop all copools") from quodlibet.util import copool copool.remove_all() # events that add new events to the main loop (like copool) # can block the shutdown, so force stop after some time. # gtk.main_iteration will return True if quit gets called here import gobject gobject.timeout_add(4 * 1000, gtk.main_quit, priority=gobject.PRIORITY_HIGH) # destroy all open windows so they hide immediately on close: # destroying all top level windows doesn't work (weird errors), # so we hide them all and only destroy our tracked instances # (browser windows, tag editors, pref window etc.) from quodlibet.qltk import Window map(gtk.Window.hide, gtk.window_list_toplevels()) map(gtk.Window.destroy, Window.instances) print_d("Quit GTK: Process pending events...") while gtk.events_pending(): if gtk.main_iteration(False): print_d("Quit GTK: Timeout occurred, force quit.") break else: gtk.main_quit() print_d("Quit GTK: done.")
def setFullscreen(self, makeFull): """Set the application fullscreen according to makeFull(boolean)""" windows = gtk.window_list_toplevels() # for (i, win) in enumerate(windows): # print i, win.name, "Has focus: %s" % (win.has_toplevel_focus()) # win = windows[0] self._pixbuf = None if makeFull: self.screenImage = None self._isFullscreen = True log.debug("Fullscreen") for win in windows: if self in win.children(): win.fullscreen() self.opQueue.put(lambda : time.sleep(0.1)) # So we don't reset too early self.opQueue.put(lambda : self.resetBackBuffer()) else: self.screenImage = None self._isFullscreen = False log.debug("UNFullscreen") for win in windows: if self in win.children(): win.unfullscreen() self.opQueue.put(lambda : time.sleep(0.1)) self.opQueue.put(lambda : self.resetBackBuffer())
def open_menu (menu, on_open, widgets, args, kwargs, timeout=0): """Generic function to open a menu, wait for the dialog to appear, and then call a user callback with several arguments: one for the newly created dialog, one for each widget whose name is specified in widgets, then *args and **kwargs. The latter are provided so that the callback on_open can be given any number of arguments that your application needs. Do not use this directly in general, but rather open_project_properties, open_project_wizard,...""" def internal_on_open (on_open, widgets, windows, args, kwargs): dialog = [w for w in gtk.window_list_toplevels() \ if not w in windows and w.flags () & gtk.MAPPED] if not dialog: # Will try again after same timeout or idle return True dialog = dialog[0] for name in widgets: if not get_widget_by_name (name, dialog): # Wrong dialog return True params = tuple \ ([dialog] + [get_widget_by_name (name, dialog) for name in widgets]) apply (on_open, params + args, kwargs) windows = gtk.window_list_toplevels() if timeout == 0: gobject.idle_add \ (lambda: internal_on_open (on_open, widgets, windows, args, kwargs)) else: gobject.timeout_add \ (timeout, lambda: internal_on_open (on_open, widgets, windows, args, kwargs)) GPS.Menu.get (menu).pywidget().activate()
def halt(message): """""" for window in gtk.window_list_toplevels(): if isinstance(window, gui.Gui): window.stop_all() window.hide() gobject.idle_add(show_recover, message) gtk.main()
def alertkill(): for a in gtk.window_list_toplevels(): if a.get_title() and (a.get_title() == 'Alert' or 'says' in a.get_title() or 'Warning' in a.get_title()): print(a.get_children()) a.hide() a.destroy() gtk.main_quit() gobject.timeout_add(100, alertkill)
def get_toplevel_window(): windows = [x for x in gtk.window_list_toplevels() if x.window and x.props.visible and x.props.type == gtk.WINDOW_TOPLEVEL] trans2windows = dict((x.get_transient_for(), x) for x in windows) for window in set(windows) - set(trans2windows.iterkeys()): return window return trans2windows[None]
def halt(): """ TODO: Mostrar ventana de error y cerrar apropiadamente. """ for window in gtk.window_list_toplevels(): if isinstance(window, Gui): window.on_close() window.hide()
def _getWindow(self): if not self._window: for w in gtk.window_list_toplevels(): if not w.is_active(): continue self._window = w break return self._window
def onSetupWindowClose(self, window): import gtk windows = [ toplevel for toplevel in gtk.window_list_toplevels() if toplevel.get_property('type') == gtk.WINDOW_TOPLEVEL ] if len(windows) == 1: gtk.main_quit()
def quit_if_last(self, *_): """ Quit if we're the last window. """ windows = [toplevel for toplevel in gtk.window_list_toplevels() if toplevel.get_property('type') == gtk.WINDOW_TOPLEVEL] if len(windows) == 1: reactor.stop()
def hide(self): # close open windows window_list = gtk.window_list_toplevels() for window in window_list: if gtk.WINDOW_TOPLEVEL == window.get_window_type(): window.destroy() self._app.statusIcon.set_status(appindicator.STATUS_PASSIVE) self._app.statusIcon.get_menu().destroy() gtk.main_quit()
def get_current_window(): for w in gtk.window_list_toplevels(): if w.is_active(): while True: par = w.get_transient_for() if par is None: return w else: w = par return None
def is_press_on_menu_grab_window(window): """Is press on menu grab window.""" for toplevel in gtk.window_list_toplevels(): if isinstance(window, gtk.Window): if window == toplevel: return True elif isinstance(window, gtk.gdk.Window): if window == toplevel.window: return True return False
def is_press_on_menu_grab_window(window): '''Is press on menu grab window.''' for toplevel in gtk.window_list_toplevels(): if isinstance(window, gtk.Window): if window == toplevel: return True elif isinstance(window, gtk.gdk.Window): if window == toplevel.window: return True return False
def is_press_on_droplist_grab_window(window): '''Is press on droplist grab window.''' for toplevel in gtk.window_list_toplevels(): if isinstance(window, gtk.Window): if window == toplevel: return True elif isinstance(window, gtk.gdk.Window): if window == toplevel.window: return True return False
def __init__(self, dialog=None, parent=None): logging.Handler.__init__(self) if dialog is None: if parent is None: try: parent = gtk.window_list_toplevels()[0] except IndexError: pass dialog = gtk.MessageDialog(parent, buttons=gtk.BUTTONS_CLOSE) self.dialog = dialog self.formatter = None
def destroy(self): self.page.dialogs.remove(self) # Test if the parent is not already destroyed if self.parent not in gtk.window_list_toplevels(): return self.parent.present() self.sensible_widget.props.sensitive = True for focus in self.parent_focus: if focus and focus.is_ancestor(self.parent): focus.grab_focus() break
def error_msg (title, details): windows = gtk.window_list_toplevels() if len (windows) > 0: parent = windows[0] else: parent = None dialog = gtk.MessageDialog (parent, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, title) dialog.format_secondary_text (details) dialog.run() dialog.destroy()
def __init__(self, style, buttons, title, text, text2=None, parent=None): parent = parent or next( (w for w in gtk.window_list_toplevels() if w.get_title()), None) gtk.MessageDialog.__init__( self, parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, style, buttons, text) self.set_position(gtk.WIN_POS_CENTER) self.set_icon_from_file("/usr/share/icons/live-installer.png") self.set_title(title) self.set_markup(text) self.desc = text[:30] + ' ...' if len(text) > 30 else text self.dialog_type = DIALOG_TYPES[style] if text2: self.format_secondary_markup(text2)
def __init__(self, style, buttons, title, text, text2=None, parent=None): parent = parent or next((w for w in gtk.window_list_toplevels() if w.get_title()), None) gtk.MessageDialog.__init__(self, parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, style, buttons, text) self.set_position(gtk.WIN_POS_CENTER) self.set_icon_from_file("/usr/share/live-installer/logo.png") self.set_title(title) self.set_markup(text) self.desc = text[:30] + ' ...' if len(text) > 30 else text self.dialog_type = DIALOG_TYPES[style] if text2: self.format_secondary_markup(text2)
def test_tooltip_overlapping_widgets(): ''' Ensure that the correct tooltip is shown when two widgets inside a ``gtk.Layout`` overlaps each other. :bug: #550345 ''' b1 = gtk.Button('1') b1.set_size_request(100, 100) b1.set_tooltip_text('button1') b2 = gtk.Button('2') b2.set_size_request(100, 100) b2.set_tooltip_text('button2') # Note that in this layout b2 overlaps b1. layout = gtk.Layout() layout.set_size_request(400, 400) layout.put(b1, 0, 0) layout.put(b2, 50, 0) win = gtk.Window() win.add(layout) win.show_all() # By setting the timeout to 0 the tooltip should show after one # iteration of the mainloop. settings = gtk.settings_get_default() settings.set_property('gtk-tooltip-timeout', 0) # Simulate a motion notify over the second button on a location # where it overlaps the first button. ev = gdk.Event(gdk.MOTION_NOTIFY) ev.window = win.window ev.x = ev.x_root = 80.0 ev.y = ev.y_root = 10.0 ev.is_hint = False # GTK gets the motion notify event and shows the tooltip in # response. gtk.main_do_event(ev) gtk.main_iteration() # Find the tooltip window in the toplevel list. tooltip_win = None for w in gtk.window_list_toplevels(): if w.name == 'gtk-tooltip': tooltip_win = w # The tooltip label shown should be the second buttons. tooltip_label = tooltip_win.get_child().get_child().get_children()[1] assert tooltip_label.get_text() == 'button2'
def is_press_on_popup_grab_window(self, window): ''' Whether press on popup_window of popup_grab_window. @param window: gtk.Window or gtk.gdk.Window ''' for toplevel in gtk.window_list_toplevels(): if isinstance(window, gtk.Window): if window == toplevel: return True elif isinstance(window, gtk.gdk.Window): if window == toplevel.window: return True return False
def is_press_on_droplist_grab_window(window): ''' Whether press on droplist of droplist_grab_window. @param window: gtk.Window or gtk.gdk.Window ''' for toplevel in gtk.window_list_toplevels(): if isinstance(window, gtk.Window): if window == toplevel: return True elif isinstance(window, gtk.gdk.Window): if window == toplevel.window: return True return False
def quit(*args): for window in gtk.window_list_toplevels(): #Hides all windows. try: window.saveMainWindowGeometry() except: pass window.hide() if not Tray.disabled: Tray.remove() gtk.main_quit() if Control['Okeyko'].conectado()[0]: Control['Config'].writeUserConfig() Control['Okeyko'].disconnect() Control['Config'].writeGlobalConfig() sys.exit(0)
def internal_on_open (on_open, widgets, windows, args, kwargs): dialog = [w for w in gtk.window_list_toplevels() \ if not w in windows and w.flags () & gtk.MAPPED] if not dialog: # Will try again after same timeout or idle return True dialog = dialog[0] for name in widgets: if not get_widget_by_name (name, dialog): # Wrong dialog return True params = tuple \ ([dialog] + [get_widget_by_name (name, dialog) for name in widgets]) apply (on_open, params + args, kwargs)
def on_disconnect(self): '''callback called when the disconnect option is selected''' for toplevel in gtk.window_list_toplevels(): toplevel.hide() self.contact_list.contact_selected.unsubscribe( self._on_contact_selected) self.contact_list.group_selected.unsubscribe(self._on_group_selected) self.contact_list.contact_menu_selected.unsubscribe( self._on_contact_menu_selected) self.contact_list.group_menu_selected.unsubscribe( self._on_group_menu_selected) self.session.config.unsubscribe(self._on_show_userpanel_changed, 'b_show_userpanel') self.on_disconnect_cb()
def get_dialog_parent(): """Find the currently active window, if any, and reparent dialog.""" ok_windows = [] max_size = -1 for window in gtk.window_list_toplevels(): if window.get_title() is not None and window.get_toplevel() == window: ok_windows.append(window) size_proxy = window.get_size()[0] * window.get_size()[1] if size_proxy > max_size: max_size = size_proxy for window in ok_windows: if window.is_active(): return window for window in ok_windows: if window.get_size()[0] * window.get_size()[1] == max_size: return window
def get_menu(): """ return parent Menu popuped by right click """ windows = gtk.window_list_toplevels() menu = None for window in windows[::-1]: if not window.get_property("visible"): continue childs = window.get_children() if childs and isinstance(childs[0], gtk.Menu): menu = childs[0] elif menu: break if menu: return TMenu(menu)
def wrapper(self, *args, **kwargs): toplevels = [t for t in gtk.window_list_toplevels() if t.window is not None] for toplevel in toplevels: toplevel.window.set_cursor(gdk.Cursor(gdk.WATCH)) toplevel.set_sensitive(False) self.app.doc.tdw.grab_add() try: func(self, *args, **kwargs) # gtk main loop may be called in here... finally: for toplevel in toplevels: toplevel.set_sensitive(True) # ... which is why we need this check: if toplevel.window is not None: toplevel.window.set_cursor(None) self.app.doc.tdw.grab_remove()
def find_dialogs_by_title(title): import fnmatch windows = gtk.window_list_toplevels() found = [] for window in windows[::-1]: if not window.get_property('visible'): continue if (window.get_title() and fnmatch.fnmatch(window.get_title(),title)): if isinstance(window, gtk.FileChooserDialog): found.append(TFileChooserDialog(window)) elif isinstance(window, gtk.ColorSelectionDialog): found.append(TColorSelectionDialog(window)) elif isinstance(window, gtk.Window): found.append(TDialog(window)) return found
def raise_application(self): raise_cmd = self.app_instance.raise_command() if raise_cmd is None: return True print "Raise cmd: " + raise_cmd self.window.present_with_time(int(time.time())) self.window.window.focus() #self.window.present() if len(raise_cmd) == 0: return True print "Check if the main window is the only top level visible window" for window in gtk.window_list_toplevels(): if window.get_property('visible'): if window != self.window: print "Failed" return True print "OK" folder_and_file = self.get_cmd_startup_folder_and_file(raise_cmd) if folder_and_file is None: return True folder_path, file_name, show_snapshots = folder_and_file #select now self.snapshot_id = '/' self.list_time_line.get_selection().select_iter( self.store_time_line.get_iter_first()) #select the specified file self.folder_path = folder_path self.update_folder_view(1, file_name, show_snapshots) return True
def get_toplevel_window(): for window in gtk.window_list_toplevels(): if window.is_active(): return window from tryton.gui.main import Main return Main.get_main().window
def event_handle_SIGINT(self, signal, frame): for w in gtk.window_list_toplevels(): if w.get_modal(): w.response(gtk.RESPONSE_DELETE_EVENT) sys.exit(0)
def _create_page(self, name, url, browserName): log.debug("Create page: %s (thread: %s)" % (url, thread.get_ident())) if url in self.pages: return False import gtk if browserName == "webkit": import conduit.platform.WebBrowserWebkit as WebBrowserImpl #lazy init to save a bit of time if self.window == None: self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_title("Conduit Login Manager") self.window.set_border_width(12) self.window.connect('delete-event', self._on_window_closed) self.notebook = gtk.Notebook() self.window.add(self.notebook) #If we have been launched from a Gtk.Dialog (usually a configure #dialog), then we should be transient for that dialog, and we #must ensure that the dialog is no longer modal so we can close the browser for w in gtk.window_list_toplevels(): if type(w) == gtk.Dialog: #center the browser window over the dialog self.window.set_transient_for(w) #disable dialog modality w.set_modal(False) self.window.set_default_size(700, 600) self.window.set_position(gtk.WIN_POS_CENTER) self.window.show_all() #create object and connect signals browser = WebBrowserImpl.WebBrowserImpl() browser.connect("open_uri", self._on_open_uri) #create the tab label tab_button = gtk.Button() tab_button.connect('clicked', self._on_tab_close_clicked, url) tab_label = gtk.Label(name) tab_box = gtk.HBox(False, 2) #Add icon to button icon_box = gtk.HBox(False, 0) image = gtk.Image() image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU) tab_button.set_relief(gtk.RELIEF_NONE) icon_box.pack_start(image, True, False, 0) tab_button.add(icon_box) tab_box.pack_start(tab_label, False) tab_box.pack_start(tab_button, False) tab_box.show_all() #add to notebook browserWidget = browser.widget() browserWidget.show_now() self.notebook.append_page(child=browserWidget, tab_label=tab_box) self.notebook.show_all() self.pages[url] = browser browser.load_url(url) return False
def get_toplevel_window(): for window in gtk.window_list_toplevels(): if window.is_active() and window.props.type == gtk.WINDOW_TOPLEVEL: return window from tryton.gui.main import Main return Main.get_main().window
def poll(self, event_cb, initial_repeat_delay=10): """poll for joystick events""" if not pygame_imported: if self.debug: wc.log_msg( "[PYGAME] not imported, returning from poll function", 1) return 0 repeat_delay = 1 # give pygame a chance to do its magic with the joystick pygame.event.pump() # end polling if no joysticks are found if self.num_joysticks == 0 and self.prtjoy == 0: wc.log_msg("[PYGAME] No joysticks found") self.prtjoy = 1 return 0, else: # get the focused window or return active_window = None windows = gtk.window_list_toplevels() for window in windows: if window.is_active(): active_window = window if active_window == None: return 1 # check if any of our defined controls were pressed mw_key_events = [] for mw_key in self.state.iterkeys(): (dev_num, joy_type) = (mw_key.split("_", 1)) dev_num = int(dev_num[3:]) - 1 # if binding is for an unfound joystick, continue to next binding if dev_num > self.num_joysticks - 1: continue if joy_type[:6] == "BUTTON": button_num = joy_type[6:] if self.devices[dev_num].get_button(int(button_num)): self.state[mw_key] += 1 mw_key_events.append(mw_key) elif self.state[mw_key] > 0: self.state[mw_key] = 0 mw_key_events.append(mw_key) elif joy_type in ["LEFT", "RIGHT", "UP", "DOWN"]: if joy_type in ["LEFT", "RIGHT"]: axis_num = 0 else: axis_num = 1 axis_value = self.devices[dev_num].get_axis(axis_num) if joy_type in ["UP", "LEFT"]: if axis_value < -0.5: self.state[mw_key] += 1 mw_key_events.append(mw_key) elif self.state[mw_key] > 0: self.state[mw_key] = 0 mw_key_events.append(mw_key) else: if axis_value > 0.5: self.state[mw_key] += 1 mw_key_events.append(mw_key) elif self.state[mw_key] > 0: self.state[mw_key] = 0 mw_key_events.append(mw_key) # send fake key-press events if len(mw_key_events) > 0: mw_key = mw_key_events[0] if self.state[mw_key] == 0: e = gtk.gdk.Event(gtk.gdk.KEY_RELEASE) self.proc_keys(active_window, e, mw_key) event_cb(active_window, e, "JOYSTICK", mw_key) elif self.state[mw_key] == 1: e = gtk.gdk.Event(gtk.gdk.KEY_PRESS) self.proc_keys(active_window, e, mw_key) event_cb(active_window, e, "JOYSTICK", mw_key) #try clearing event queue try: pygame.event.clear() if self.debug: wc.log_msg("[PYGAME] Cleared pygame events", 1) except: if self.debug: wc.log_msg("[PYGAME] Could not clear PyGame event queue", 1) return 1