def main(): # recreatedb() config.parse_options() config.parse_filetypes() if config.run_bookmarks_manager: run_bookmarks_manager() sys.exit() import os import gtk from gtk import gdk from mainwindow import odin br = odin() br.main_window.show() if config.opt_files: filename = os.path.abspath(config.opt_files[0]) br.set_current_book(filename) else: br.set_current_book() gdk.threads_init() gtk.main()
def main(argv=None): if argv is None: argv = sys.argv hwg = CfvGTK(argv) gdk.threads_init() gtk.main() print "Bye"
def show(self): config = self.config self.logger = config.get_logger("UI") self.set_default_size(900, 800) self.connect('destroy', self.destroy) self.set_title( 'Panobbgo %s@%s' % (config.version, config.git_head[:8])) self.set_border_width(0) self.top_hbox = gtk.HBox(False, 0) self.notebook = notebook = gtk.Notebook() notebook.set_tab_pos(gtk.POS_LEFT) self.top_hbox.add(notebook) notebook.show() self.add(self.top_hbox) self.add_events(gdk.BUTTON_PRESS_MASK | gdk.KEY_PRESS_MASK | gdk.KEY_RELEASE_MASK) self.show_all() gdk.threads_init() # def run_gtk_main(): # self.mt = Thread(target=run_gtk_main) # self.mt.start() self.start() self._auto_redraw()
def __init__(self, opts): self.logger = logging.getLogger('Skype4Py.api.posix_x11.SkypeAPI') SkypeAPIBase.__init__(self) finalize_opts(opts) # initialize threads if not done already by the user threads_init(gtk=False) # init Xlib display self.disp = x11.XOpenDisplay(None) if not self.disp: raise SkypeAPIError('Could not open XDisplay') self.win_root = x11.XDefaultRootWindow(self.disp) self.win_self = x11.XCreateSimpleWindow(self.disp, self.win_root, 100, 100, 100, 100, 1, 0, 0) x11.XSelectInput(self.disp, self.win_root, PropertyChangeMask) self.win_skype = self.get_skype() ctrl = 'SKYPECONTROLAPI_MESSAGE' self.atom_msg = x11.XInternAtom(self.disp, ctrl, False) self.atom_msg_begin = x11.XInternAtom(self.disp, ctrl + '_BEGIN', False) self.loop_event = threading.Event() self.loop_timeout = 0.0001 self.loop_break = False
def initial_setup(): """ * set up gdk threading * enter it * set up glib mainloop threading """ gdk.threads_init() gdk.threads_enter() gobject.threads_init() #the glib mainloop doesn't love us else
def threads_init(gtk=True): """Enables multithreading support in Xlib and PyGTK. See the module docstring for more info. :Parameters: gtk : bool May be set to False to skip the PyGTK module. """ # enable X11 multithreading x11.XInitThreads() if gtk: from gtk.gdk import threads_init threads_init()
def initial_setup(): """ * set up gdk threading * enter it * set up glib mainloop threading .. versionchanged:: 0.18 Do not execute ``gdk.threads_enter()``. ``gdk.threads_enter()/gdk.threads_leave()`` should only be used to wrap GTK code blocks. See `What are the general tips for using threads with PyGTK? <http://faq.pygtk.org/index.py?req=show&file=faq20.001.htp>`_. """ warnings.warn('Use ', DeprecationWarning) gdk.threads_init() gobject.threads_init() # the glib mainloop doesn't love us else
def __init__(self): self.browsers = [] self.queues = [] self.preferences_window = None self.connect_window = None self.status_icon = None self.config = config.Config() self.config.read() gdk.threads_init() # Load existing queues queues = os.listdir(queues_dir) for q in queues: self.new_queue(name=q, load=True) # If there are no queues, open a connection dialog if not queues: self.new_connect_dialog()
def __init__(self): gnome.program_init(APP_NAME,APP_VERSION) # Create widget tree for the GUI and signal handlers self.__window = gtk.glade.XML('glade/window.glade','window') self.__window.signal_autoconnect( { 'on_window_destroy' : self.on_window_destroy, 'on_new_activate' : self.on_new_activate, 'on_open_activate' : self.on_open_activate, 'on_pause_activate' : self.on_pause_activate, 'on_clear_activate' : self.on_clear_activate, 'on_prefs_activate' : self.on_prefs_activate, 'on_about_activate' : self.on_about_activate, 'on_button_press_event' : self.on_button_press_event, }) # Save some pointers to specifig gui widgets self.__board = self.__window.get_widget('board') #for b in self.__board.get_children(): # b.modify_fg(gtk.STATE_INSENSITIVE,gdk.Color(60255,255,6660)) self.__rowHints = self.__window.get_widget('rowHints') self.__colHints = self.__window.get_widget('columnHints') self.__level = self.__window.get_widget('level') self.__timeLeft = self.__window.get_widget('timeLeft') self.__desiredSkill = SKILL_MEDIUM self.__desiredPlayTime = 1800 self.__gameOver = False self.__prefs_change = False # This will store the picross game self.__game = None self.__board.set_sensitive(False) self.__timer = GameTimer(delay=1,callback=self.__timerCallback) self.__timer.setDaemon(True) # Start the gtk main event loop and allow multiple threads to # serialize access to the Python interpreter gdk.threads_init() #self.__timer.start() gtk.main()
def __init__(self, opts): self.logger = logging.getLogger("Skype4Py.api.posix_x11.SkypeAPI") SkypeAPIBase.__init__(self) finalize_opts(opts) # initialize threads if not done already by the user threads_init(gtk=False) # init Xlib display self.disp = x11.XOpenDisplay(None) if not self.disp: raise SkypeAPIError("Could not open XDisplay") self.win_root = x11.XDefaultRootWindow(self.disp) self.win_self = x11.XCreateSimpleWindow(self.disp, self.win_root, 100, 100, 100, 100, 1, 0, 0) x11.XSelectInput(self.disp, self.win_root, PropertyChangeMask) self.win_skype = self.get_skype() ctrl = "SKYPECONTROLAPI_MESSAGE" self.atom_msg = x11.XInternAtom(self.disp, ctrl, False) self.atom_msg_begin = x11.XInternAtom(self.disp, ctrl + "_BEGIN", False) self.loop_event = threading.Event() self.loop_timeout = 0.0001 self.loop_break = False
# This file is part of Xpra. # Copyright (C) 2011 Serviware (Arthur Huillet, <*****@*****.**>) # Copyright (C) 2010-2015 Antoine Martin <*****@*****.**> # Copyright (C) 2008, 2010 Nathaniel Smith <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import gobject try: #we *have to* do this as early as possible on win32.. gobject.threads_init() except: pass import gtk from gtk import gdk gdk.threads_init() from xpra.gtk_common.gtk_util import gtk_main, color_parse from xpra.client.gtk_base.gtk_client_base import GTKXpraClient from xpra.client.gtk2.tray_menu import GTK2TrayMenu from xpra.client.window_border import WindowBorder from xpra.net.compression import Uncompressed from xpra.log import Logger log = Logger("gtk", "client") clipboardlog = Logger("gtk", "client", "clipboard") grablog = Logger("gtk", "client", "grab") from xpra.client.gtk2.border_client_window import BorderClientWindow
ui_filename = None builder = gtk.Builder() builder.add_from_file(ui_filename) window = builder.get_object("wiitracker_window") window.finish_initializing(builder) return window if __name__ == "__main__": #support for command line options import logging, optparse parser = optparse.OptionParser(version="%prog %ver") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help="Show debug messages") (options, args) = parser.parse_args() #set the logging level to show debug messages if options.verbose: logging.basicConfig(level=logging.DEBUG) logging.debug('logging enabled') #run the application window = NewWiitrackerWindow() window.show() threads_init() gtk.main()
def main(args): if (len(args) == 3): card=int(args[1]) vol=args[2] else: card = 0 vol=args[1] try: mixer = alsaaudio.Mixer("Master", cardindex=card) except alsaaudio.ALSAAudioError: sys.stderr.write("No such mixer\n") sys.exit(1) channel = alsaaudio.MIXER_CHANNEL_ALL if vol == "mute": if mixer.getmute()[0] == 0: vol = 0 mixer.setmute(1, channel) else: vol = mixer.getvolume()[0] mixer.setmute(0, channel) else: if vol == "up": vol = mixer.getvolume()[0] + volume_increment elif vol == "down": vol = mixer.getvolume()[0] - volume_increment if vol > 100: vol = 100 if vol < 0: vol = 0 mixer.setvolume(int(vol), channel) print "Volume on card %d set to %d" % (card, vol) icon = vol_icons[int((float(vol)/100.00) * float(len(vol_icons)-1))] svg = rsvg.Handle(os.path.join(icon_dir, icon)) win = gtk.Window() win.set_position(gtk.WIN_POS_CENTER) win.set_title("Volume Control") win.set_app_paintable(True) win.set_skip_pager_hint(True) win.set_skip_taskbar_hint(True) win.set_decorated(False) win.resize(svg.props.width*4, svg.props.height*4) win.set_keep_above(True) win.connect("delete-event", gtk.main_quit) win.connect("expose-event", expose, svg) win.connect("screen-changed", screen_changed) # this is just for debugging... clickable window # win.add_events(gdk.BUTTON_PRESS_MASK) # win.connect("button-press-event", gtk.main_quit) screen_changed(win) win.show_all() gdk.threads_init() Timer(timeout, gtk.main_quit).start() gtk.main() return True
def run(self): gdk.threads_init() gtk.main()
def __init__(self, args): # Setup gtkbuilder/glade translation setup_translations(setup_gettext=False, setup_pygtk=True) # Setup signals def on_die(*args): log.debug('OS signal "die" caught with args: %s', args) reactor.stop() if windows_check(): from win32api import SetConsoleCtrlHandler SetConsoleCtrlHandler(on_die, True) log.debug('Win32 "die" handler registered') elif osx_check() and WINDOWING == 'quartz': import gtkosx_application self.osxapp = gtkosx_application.gtkosx_application_get() self.osxapp.connect('NSApplicationWillTerminate', on_die) log.debug('OSX quartz "die" handler registered') # Set process name again to fix gtk issue setproctitle(getproctitle()) # Attempt to register a magnet URI handler with gconf, but do not overwrite # if already set by another program. associate_magnet_links(False) # Make sure gtkui.conf has at least the defaults set self.config = ConfigManager('gtkui.conf', DEFAULT_PREFS) # Make sure the gtkui state folder has been created if not os.path.exists(os.path.join(get_config_dir(), 'gtkui_state')): os.makedirs(os.path.join(get_config_dir(), 'gtkui_state')) # Set language if self.config['language'] is not None: set_language(self.config['language']) # Start the IPC Interface before anything else.. Just in case we are # already running. self.queuedtorrents = QueuedTorrents() self.ipcinterface = IPCInterface(args.torrents) # Initialize gdk threading threads_init() # We make sure that the UI components start once we get a core URI client.set_disconnect_callback(self.__on_disconnect) self.trackericons = TrackerIcons() self.sessionproxy = SessionProxy() # Initialize various components of the gtkui self.mainwindow = MainWindow() self.menubar = MenuBar() self.toolbar = ToolBar() self.torrentview = TorrentView() self.torrentdetails = TorrentDetails() self.sidebar = SideBar() self.filtertreeview = FilterTreeView() self.preferences = Preferences() self.systemtray = SystemTray() self.statusbar = StatusBar() self.addtorrentdialog = AddTorrentDialog() if osx_check() and WINDOWING == 'quartz': def nsapp_open_file(osxapp, filename): # Ignore command name which is raised at app launch (python opening main script). if filename == sys.argv[0]: return True process_args([filename]) self.osxapp.connect('NSApplicationOpenFile', nsapp_open_file) from deluge.ui.gtkui.menubar_osx import menubar_osx menubar_osx(self, self.osxapp) self.osxapp.ready() # Initalize the plugins self.plugins = PluginManager() # Show the connection manager self.connectionmanager = ConnectionManager() # Setup RPC stats logging # daemon_bps: time, bytes_sent, bytes_recv self.daemon_bps = (0, 0, 0) self.rpc_stats = LoopingCall(self.log_rpc_stats) self.closing = False # Twisted catches signals to terminate, so have it call a pre_shutdown method. reactor.addSystemEventTrigger('before', 'gtkui_close', self.close) def gtkui_sigint_handler(num, frame): log.debug('SIGINT signal caught, firing event: gtkui_close') reactor.callLater(0, reactor.fireSystemEvent, 'gtkui_close') signal.signal(signal.SIGINT, gtkui_sigint_handler)
else: self.icon.set_from_pixbuf(self.lang_native) def draw_langs(self): self.lang_foreign = self.draw_text(FOREIGN_LANG_TEXT) self.lang_native = self.draw_text(NATIVE_LANG_TEXT) def draw_text(self, text): pixbuf = gdk.Pixbuf(gdk.COLORSPACE_RGB, True, 8, ICON_SIZE, ICON_SIZE) pixbuf.fill(0x00000000) pixmap = pixbuf.render_pixmap_and_mask(alpha_threshold=127)[0] cr = pixmap.cairo_create() cr.select_font_face(FONT_FACE, cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_BOLD) cr.set_source_rgba(0.9, 0.9, 0.9, 1) cr.set_font_size(FONT_SIZE) cr.move_to(0, Y_OFFSET) cr.show_text(text) pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(), 0, 0, 0, 0, ICON_SIZE, ICON_SIZE) pixbuf = pixbuf.add_alpha(True, 0x00, 0x00, 0x00) return pixbuf if __name__ == '__main__': pygtk.require("2.0") gdk.threads_init() KeyboardIcon() gtk.main()
""" #look for the ui file that describes the ui ui_filename = os.path.join(getdatapath(), 'ui', 'WiitrackerWindow.ui') if not os.path.exists(ui_filename): ui_filename = None builder = gtk.Builder() builder.add_from_file(ui_filename) window = builder.get_object("wiitracker_window") window.finish_initializing(builder) return window if __name__ == "__main__": #support for command line options import logging, optparse parser = optparse.OptionParser(version="%prog %ver") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help="Show debug messages") (options, args) = parser.parse_args() #set the logging level to show debug messages if options.verbose: logging.basicConfig(level=logging.DEBUG) logging.debug('logging enabled') #run the application window = NewWiitrackerWindow() window.show() threads_init() gtk.main()
def main(): threads_init() gobject.threads_init() win = MemWindow.MemWindow() win.show_all() gtk.main()