def __init__(self, app): self.app = app self.xs = xmms.get() self.on_display = False self.info = None self.fetcher_thread = None self.results_fetcher_thread = None self.lock = threading.RLock() self.input = widgets.InputEdit(caption='search lyricwiki.org > ') urwid.connect_signal(self.input, 'done', self.search) self.info_w = urwid.Text('') self.llb = LyricsListBox([]) self.llbw = urwid.Padding(self.llb, 'center', ('relative', 95)) self.rlb = ResultsListBox(self, []) blank = urwid.Text('') self.__super.__init__([('flow', self.input), ('flow', self.info_w), ('flow', blank), self.llbw], 3) signals.connect('xmms-playback-current-info', self.on_xmms_playback_current_info)
def __init__(self, addFunc): assert callable( addFunc ) self.clients = {} self.addFunc = addFunc signals.connect( self.addClient, signals.CONNECTED ) signals.connect( self.removeClient, signals.DISCONNECTED )
def __init__(self, addFunc): assert callable(addFunc) self.clients = {} self.addFunc = addFunc signals.connect(self.addClient, signals.CONNECTED) signals.connect(self.removeClient, signals.DISCONNECTED)
def __init__(self, app, info, bgwidget): dkeys = sorted(info) cols = [] source = None self.list_length = 0 for i, k in enumerate(dkeys): self.list_length += 1 attr = i % 2 == 0 and 'infodialog-even' or 'infodialog-odd' if k[0] != source: source = k[0] cols.append( urwid.AttrWrap(urwid.Text(unicode(source)), 'marked')) self.list_length += 1 cols.append( urwid.AttrWrap( urwid.Columns([ urwid.Text(u' ' + unicode(k[1])), ('weight', 2, urwid.Text(unicode(info[k]))) ]), attr)) self.lb = urwid.AttrWrap(urwid.ListBox(cols), 'infodialog-even') width, height = self.calculate_size(app.size) self.__super.__init__(self.lb, bgwidget, width, height, 'mediainfo') signals.connect('window-resized', self.on_resize)
def __init__(self, pls_name, fields, size=100): self.xs = xmms.get() self.name = pls_name c = self.xs.coll_get(pls_name, 'Playlists') super(PlaylistFeeder, self).__init__(c, fields, size) signals.connect('xmms-playlist-changed', self._on_playlist_changed)
def __init__(self, collection, format): self.format = format self.parser = mif.FormatParser(format) self.widgets = {} self.focus = 0 self.feeder = collutil.CollectionFeeder(collection, self.parser.fields()) signals.connect('xmms-medialib-entry-changed', self.on_medialib_entry_changed)
def __init__(self, app): self.__super.__init__(PlaylistSwitcherWalker()) self.xs = xmms.get() self.app = app self.cur_active = self.xs.playlist_current_active() self.active_pos = 0 self._set_active_attr(None, self.cur_active) signals.connect('xmms-playlist-loaded', self.on_xmms_playlist_loaded) signals.connect('xmms-collection-changed', self.on_xmms_collection_changed)
def __init__(self): self.xs = xmms.get() self.focus = 0 self.rows = {} self.playlists = [] self.nplaylists = 0 signals.connect('xmms-collection-changed', self.on_xmms_collection_changed) signals.connect('xmms-playlist-changed', self.on_xmms_playlist_changed) self._load()
def init(self, **options): if options.get('stop_other_instance', False): if not checkSingleInstance(): retryCount = 5 logging.warning( 'running instance detected, trying to shut it down') sendRemoteMsg('shut_down') ready = False for i in range(retryCount): time.sleep(1) if checkSingleInstance(): ready = True break if not ready: logging.warning('timeout for shuting down other instance') return False else: if not checkSingleInstance(): logging.warning('running instance detected') return False self.loadConfig() if self.initialized: return True self.openProject() #scan packages excludePackages = self.getProject().getConfig('excluded_packages') self.packageManager.addExcludedPackage(excludePackages) if not self.packageManager.scanPackages( self.getPath(_GII_BUILTIN_PACKAGES_PATH)): return False if self.getProject().isLoaded(): self.packageManager.scanPackages(self.getProject().envPackagePath) #modules EditorModuleManager.get().loadAllModules() signals.emitNow('module.loaded') #some pre app-ready activities signals.dispatchAll() self.getProject().loadAssetLibrary() self.initialized = True self.running = True signals.connect('app.remote', self.onRemote) return True
def init( self, **options ): if options.get( 'stop_other_instance', False ): if not checkSingleInstance(): retryCount = 5 logging.warning( 'running instance detected, trying to shut it down' ) sendRemoteMsg( 'shut_down' ) ready = False for i in range( retryCount ): time.sleep( 1 ) if checkSingleInstance(): ready = True break if not ready: logging.warning( 'timeout for shuting down other instance' ) return False else: if not checkSingleInstance(): logging.warning( 'running instance detected' ) return False self.loadConfig() if self.initialized: return True self.openProject() #scan packages excludePackages = self.getProject().getConfig( 'excluded_packages' ) self.packageManager.addExcludedPackage( excludePackages ) if not self.packageManager.scanPackages( self.getPath( _GII_BUILTIN_PACKAGES_PATH ) ): return False if self.getProject().isLoaded(): self.packageManager.scanPackages( self.getProject().envPackagePath ) #modules EditorModuleManager.get().loadAllModules() signals.emitNow( 'module.loaded' ) #some pre app-ready activities signals.dispatchAll() self.getProject().loadAssetLibrary() self.initialized = True self.running = True signals.connect( 'app.remote', self.onRemote ) return True
def __init__(self, collection, fields, size=100): super(CollectionFeeder, self).__init__() self.xs = xmms.get() self._collection = collection self.fields = fields self.infos = {} self.size = size self.window = [0, 0] self.ids = None self.len = 0 self.reload_ids() signals.connect('xmms-medialib-entry-changed', self.on_medialib_entry_changed)
def __init__(self, config_path=None): self.xs = xmms.get() self.config = config.Config(config_path) self.cm = commands.CommandManager(self.config) self.colors = 8 self.show_key = False self._pipe = os.pipe() self.need_redraw = True def _need_redraw(): self.need_redraw = True signals.connect('need-redraw', _need_redraw) if not self.xs.connected: if self.config.autostart_server: os.system('xmms2-launcher') if not self.xs.connect(): print >> sys.stderr, "error: couldn't connect to server" sys.exit(0)
def __init__(self, app, info, bgwidget): dkeys = sorted(info) cols = [] source = None self.list_length = 0 for i, k in enumerate(dkeys): self.list_length += 1 attr = i % 2 == 0 and 'infodialog-even' or 'infodialog-odd' if k[0] != source: source = k[0] cols.append(urwid.AttrWrap(urwid.Text(unicode(source)), 'marked')) self.list_length += 1 cols.append(urwid.AttrWrap(urwid.Columns([urwid.Text(u' ' + unicode(k[1])), ('weight', 2, urwid.Text(unicode(info[k])))]), attr)) self.lb = urwid.AttrWrap(urwid.ListBox(cols), 'infodialog-even') width, height = self.calculate_size(app.size) self.__super.__init__(self.lb, bgwidget, width, height, 'mediainfo') signals.connect('window-resized', self.on_resize)
def __init__(self): assert(not EditorApp._singleton) EditorApp._singleton = self EditorModuleManager.get()._app = self self.defaultMainloopBudget = 0.005 self.initialized = False self.projectLoaded = False self.flagModified = False self.debugging = False self.running = False self.basePath = getMainModulePath() self.dataPaths = [] self.config = {} self.packageManager = PackageManager() self.commandRegistry = EditorCommandRegistry.get() self.remoteCommandRegistry = RemoteCommandRegistry.get() self.registerDataPath( self.getPath('data') ) signals.connect( 'module.register', self.onModuleRegister )
def __init__(self): assert (not EditorApp._singleton) EditorApp._singleton = self EditorModuleManager.get()._app = self self.defaultMainloopBudget = 0.005 self.initialized = False self.projectLoaded = False self.flagModified = False self.debugging = False self.running = False self.basePath = getMainModulePath() self.dataPaths = [] self.config = {} self.packageManager = PackageManager() self.commandRegistry = EditorCommandRegistry.get() self.remoteCommandRegistry = RemoteCommandRegistry.get() self.registerDataPath(self.getPath('data')) signals.connect('module.register', self.onModuleRegister)
def __init__(self, app): self.__super.__init__(app, []) self.body.current_pos = -1 # filthy filthy self.format = 'playlist' self._walkers = {} # pls => walker self.active_pls = self.xs.playlist_current_active() self.view_pls = self.active_pls signals.connect('xmms-collection-changed', self.on_xmms_collection_changed) signals.connect('xmms-playlist-loaded', self.load) signals.connect('xmms-playlist-changed', self.on_xmms_playlist_changed) signals.connect('xmms-playlist-current-pos', self.on_xmms_playlist_current_pos) self.load(self.active_pls)
def __init__(self): self.status = urwid.AttrWrap(urwid.Text(''), 'status') self._empty = urwid.Text('') self.last_type = None self.__super.__init__([self.status, self._empty], 1) signals.connect('xmms-playback-volume-changed', self.on_xmms_playback_volume_changed) signals.connect('show-message', self.set_message) signals.connect('clear-message', lambda: self.clear_message(clear_loading=True))
def __init__(self, app): self.app = app self.xs = xmms.get() self.info = {} self.ctx = {} self.time = 0 self.status = self.xs.playback_status() self.parser = mif.FormatParser(self.app.config.format('header')) self.text = urwid.Text('') self.__super.__init__(self.text) signals.connect('xmms-playback-status', self.on_xmms_playback_status) signals.connect('xmms-playback-current-info', self.on_xmms_playback_current_info) signals.connect('xmms-playback-playtime', self.on_xmms_playback_playtime) self.xs.playback_current_info(self.on_xmms_playback_current_info, sync=False)
def __init__(self, pls, format): self.pls = pls self.format = format self.parser = mif.FormatParser(format) self.song_widgets = {} self.row_widgets = {} self.focus = 0 self.feeder = collutil.PlaylistFeeder(self.pls, self.parser.fields()) try: self.current_pos = int(self.feeder.collection.attributes.get('position', -1)) except ValueError: self.current_pos = -1 signals.connect('xmms-medialib-entry-changed', self.on_medialib_entry_changed) signals.connect('xmms-playlist-current-pos', self.on_xmms_playlist_current_pos) signals.connect('xmms-playlist-changed', self.on_xmms_playlist_changed)
def __init__(self, app, show_cover=True, formatname='nowplaying'): self.xs = xmms.get() self.app = app self.show_cover = show_cover self.format = formatname self.parser = mif.FormatParser(self.app.config.format(formatname)) self.ctx = self.info = {} self.cur_hash = None self.status = self.xs.playback_status() self.time = 0 self.progress = urwid.ProgressBar('progress-normal', 'progress-complete', 0, 100, 'progress-smooth') self.song = urwid.Text('', align='right') if self.show_cover: self.cover = AlbumCoverWidget(maxcols=65, align='center', valign='top') cover_w = self.cover else: cover_w = urwid.SolidFill(' ') fill = urwid.SolidFill(' ') w = urwid.Columns([ ('fixed', 1, fill), cover_w, ('fixed', 2, fill), urwid.Filler( urwid.Pile([('flow', self.song), ('fixed', 1, urwid.SolidFill(' ')), ('flow', self.progress)]), 'top'), ('fixed', 1, fill), ]) self.__super.__init__(w) signals.connect('xmms-playback-status', self.on_xmms_playback_status) signals.connect('xmms-playback-current-info', self.on_xmms_playback_current_info) signals.connect('xmms-playback-playtime', self.on_xmms_playback_playtime) self.xs.playback_current_info(self.on_xmms_playback_current_info, sync=False)
def __init__(self, pls, format): self.pls = pls self.format = format self.parser = mif.FormatParser(format) self.song_widgets = {} self.row_widgets = {} self.focus = 0 self.feeder = collutil.PlaylistFeeder(self.pls, self.parser.fields()) try: self.current_pos = int( self.feeder.collection.attributes.get('position', -1)) except ValueError: self.current_pos = -1 signals.connect('xmms-medialib-entry-changed', self.on_medialib_entry_changed) signals.connect('xmms-playlist-current-pos', self.on_xmms_playlist_current_pos) signals.connect('xmms-playlist-changed', self.on_xmms_playlist_changed)
def __init__(self, app, show_cover=True, formatname='nowplaying'): self.xs = xmms.get() self.app = app self.show_cover = show_cover self.format = formatname self.parser = mif.FormatParser(self.app.config.format(formatname)) self.ctx = self.info = {} self.cur_hash = None self.status = self.xs.playback_status() self.time = 0 self.progress = urwid.ProgressBar('progress-normal', 'progress-complete', 0, 100, 'progress-smooth') self.song = urwid.Text('', align='right') if self.show_cover: self.cover = AlbumCoverWidget(maxcols=65, align='center', valign='top') cover_w = self.cover else: cover_w = urwid.SolidFill(' ') fill = urwid.SolidFill(' ') w = urwid.Columns([('fixed', 1, fill), cover_w, ('fixed', 2, fill), urwid.Filler(urwid.Pile([('flow', self.song), ('fixed', 1, urwid.SolidFill(' ')), ('flow', self.progress)]), 'top'), ('fixed', 1, fill), ]) self.__super.__init__(w) signals.connect('xmms-playback-status', self.on_xmms_playback_status) signals.connect('xmms-playback-current-info', self.on_xmms_playback_current_info) signals.connect('xmms-playback-playtime', self.on_xmms_playback_playtime) self.xs.playback_current_info(self.on_xmms_playback_current_info, sync=False)
class CodeBoxFieldEditor(LongTextFieldEditor): def startEdit(self): editor = getCodeBoxEditorWidget() pos = QtGui.QCursor.pos() editor.move(pos) restrainWidgetToScreen(editor) editor.startEdit(self, self.text) editor.show() editor.raise_() editor.setFocus() ##----------------------------------------------------------------## class CodeBoxFieldEditorFactory(FieldEditorFactory): def getPriority(self): return 10 def build(self, parentEditor, field, context=None): dataType = field._type if dataType != str: return None widget = field.getOption('widget', None) if widget == 'codebox': editor = CodeBoxFieldEditor(parentEditor, field) return editor return None signals.connect('app.pre_start', getCodeBoxEditorWidget) registerFieldEditorFactory(CodeBoxFieldEditorFactory())
from pydispatch import dispatcher from mud.parser.cmdMap import CmdMap from cmds import pushCmdHandler from send import sendToClient import signals def invalidCmd( clientId, remaining ): sendToClient( clientId, "Invalid command. ({!{FCcommands{@ for help)\r\n") rootCmdMap = CmdMap( invalidCmd ) rootCmdMap.addCmd("commands", lambda clientId, remaining: sendToClient( clientId, rootCmdMap.commands() ) ) def addRootMap( clientId ): pushCmdHandler( clientId, rootCmdMap ) signals.connect( addRootMap, signals.CONNECTED )
self._schema_temp = schema_store.current_schema() schema_store.set_schema(schema=self.name, force=True) if settings.DEBUG: print ' ** Using database with schema "%s" **' % self def exit( self ): #Needs fixing. Doesn't actually get current schema. Possibly do the same as Site framework if hasattr(self, '_schema_temp'): if getattr(settings, 'APPSCHEMA_RESET_PATH', True): schema_store.set_schema(schema=self._schema_temp or 'public', force=True) if settings.DEBUG: print '\n ** Restoring database to schema "%s" **' % ( self._schema_temp or 'public', ) del self._schema_temp def __unicode__(self): return u'%s (%s)' % (self.name, self.public_name) def __enter__(self): self.enter() return self def __exit__(self, *args, **kwargs): self.exit() from signals import connect connect()
cursor = connection.cursor() cursor.execute("SELECT schemata.schema_name FROM information_schema.schemata WHERE schemata.schema_name = %s;", [self.name]) row = cursor.fetchone() return row is not None def enter(self): self._schema_temp = schema_store.current_schema() schema_store.set_schema(schema=self.name, force=True) if settings.DEBUG: print ' ** Using database with schema "%s" **' % self def exit(self): #Needs fixing. Doesn't actually get current schema. Possibly do the same as Site framework if hasattr(self, '_schema_temp'): if getattr(settings, 'APPSCHEMA_RESET_PATH', True): schema_store.set_schema(schema=self._schema_temp or 'public', force=True) if settings.DEBUG: print '\n ** Restoring database to schema "%s" **' % (self._schema_temp or 'public', ) del self._schema_temp def __unicode__(self): return u'%s (%s)' % (self.name, self.public_name) def __enter__(self): self.enter() return self def __exit__(self, *args, **kwargs): self.exit() from signals import connect connect()
def onLoad(self): self.window = self.requestToolWindow('GamePreview', title='Game Preview', area='right') self.canvas = self.window.addWidget(GamePreviewCanvas(self.window)) self.canvas.startRefreshTimer(self.nonActiveFPS) self.paused = None tool = self.window.addWidget(QtWidgets.QToolBar(self.window), expanding=False) self.qtool = tool self.toolbar = self.addToolBar('game_preview', tool) self.canvas.module = self self.updateTimer = None self.window.setFocusPolicy(Qt.StrongFocus) signals.connect('app.activate', self.onAppActivate) signals.connect('app.deactivate', self.onAppDeactivate) # signals.connect ( 'debug.enter', self.onDebugEnter ) # signals.connect ( 'debug.exit', self.onDebugExit ) # signals.connect ( 'debug.stop', self.onDebugStop ) # signals.connect ( 'game.pause', self.onGamePause ) # signals.connect ( 'game.resume', self.onGameResume ) signals.connect('moai.reset', self.onMoaiReset) self.menu = self.addMenu('main/preview', dict(label='Game')) self.menu.addChild( [ { 'name': 'start_game', 'label': 'Resume Preview', 'shortcut': 'meta+]' }, { 'name': 'pause_game', 'label': 'Pause Preview', 'shortcut': 'meta+shit+]' }, { 'name': 'stop_game', 'label': 'Stop Preview', 'shortcut': 'meta+[' }, '----', { 'name': 'start_external_scene', 'label': 'Run Scene', 'shortcut': 'meta+alt+]' }, { 'name': 'start_external_game', 'label': 'Run Game', 'shortcut': 'meta+alt+shift+]' }, '----', { 'name': 'pause_on_leave', 'label': 'Pause On Leave', 'type': 'check', 'checked': self.getConfig('pause_on_leave') }, # '----', # {'name':'reset_moai', 'label':'RESET MOAI', 'shortcut':'Ctrl+Shift+R'} '----', { 'name': 'toggle_game_preview_window', 'label': 'Show Game Preview', 'shortcut': 'f4' }, ], self) # label = QtWidgets.QLabel () # label.setMinimumSize ( 300, 20 ) # label.setMaximumSize ( 300, 20 ) # self.toolbar.addWidget ( label ) # self.labelScreen = label # self.addTool ( 'game_preview/----' ) # self.addTool ( 'game_preview/toggle_stay_top', label = 'Stay Top', type = 'check' ) # self.addTool ( 'game_preview/switch_screen_profile', label = 'Screen Profile' ) self.onMoaiReset() ##----------------------------------------------------------------## self.previewToolBar = self.addToolBar( 'game_preview_tools', self.getMainWindow().requestToolBar('view_tools')) # self.addTool ( 'game_preview_tools/play', # widget = SceneToolButton ( 'scene_view_selection', # icon = 'tools/selection', # label = 'Selection' # ) # ) # # self.addTool ( 'game_preview_tools/stop', # widget = SceneToolButton ( 'scene_view_translation', # icon = 'tools/translation', # label = 'Translation' # ) # ) self.addTool( 'game_preview_tools/run_external', label='Play External', icon='tools/run_external', ) self.addTool( 'game_preview_tools/run_game_external', label='Play Game External', icon='tools/run_game_external', ) self.enableMenu('main/preview/pause_game', False) self.enableMenu('main/preview/stop_game', False)
import signals signals.connect()
self.cmds = [] self.cmdHandlers = [] def handleNextCmdFromClientID( clientId ): """ Internal use only """ client = clients[ clientId ] if len(client.cmds) == 0: return if len(client.cmdHandlers) == 0: return handleCmd( clientId, client.cmds.pop(0), client.cmdHandlers[-1]) def addClient( clientId ): """ Internal use only """ clients[ clientId ] = Input() signals.connect( addClient, signals.CONNECTED ) def removeClient( clientId ): """ Internal use only """ del clients[ clientId ] signals.connect( removeClient, signals.DISCONNECTED )