当前位置: 首页>>代码示例>>Python>>正文


Python viewer.Viewer类代码示例

本文整理汇总了Python中viewer.Viewer的典型用法代码示例。如果您正苦于以下问题:Python Viewer类的具体用法?Python Viewer怎么用?Python Viewer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Viewer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

  def get(self):
    # 編集確認
    person_id = self.request.get("id")
    person_obj = ''
    if (person_id):
      person_obj = Person.get( person_id )

    # 所有しない発言者IDを指定された場合は一覧へリダイレクトする
    if person_obj and person_obj.owner != users.get_current_user():
      self.redirect(urls.APP_PERSON_URL)
      return

    # 所有する発言者を取得します
    query = Person.all()
    query.filter( 'owner = ', users.get_current_user() )
    query.order('-created_on')
    owned_persons = query.fetch(limit = 1000)

    # 所有する発言者の名言を取得する
    meigens = ''
    if person_obj:
      query = Meigen.all()
      query.filter( 'owner = ', users.get_current_user() )
      query.filter( 'person = ', person_obj )
      meigens = query.fetch(limit = 1000)

    # 画面を表示する
    Viewer.generate(Viewer(), self.response, TEMPLATE_PATH, { 'persons': owned_persons, 'current_person': person_obj, 'meigens': meigens } )
开发者ID:sadao,项目名称:meigen-pedia,代码行数:28,代码来源:person.py

示例2: Scheduler

class Scheduler(object):
    '''
    Schedules the content in the playlist to be displayed.
    The scheduling occurs in its own thread. To ensure thread safety,
    the play list should be modified using the
    modify_playlist_atomically() method.
    '''

    def __init__(self):
        self.logger = logging.getLogger(__name__)
        self.logger.debug('Initializing scheduler')
        self.viewer = Viewer()
        self._playlist = []
        self._playlist_lock = Lock()
        self.running = False

    def start(self):
        self.logger.debug('Starting scheduling')
        self.running = True

        def is_interrupted_func(content):
            return content not in self._playlist

        def schedule_worker(scheduler):
            self.logger.debug('Scheduling thread started')
            index = 0
            while scheduler.running:
                lock = scheduler._playlist_lock
                lock.acquire()
                try:
                    playlist = scheduler._playlist
                    content_index = index % len(playlist)
                    content = playlist[content_index]
                finally:
                    lock.release()
                self.logger.debug('Scheduler began displaying %s', content)
                scheduler.viewer.display_content(content, is_interrupted_func)
                index += 1
            scheduler.viewer.shutdown()
            self.logger.debug('Exiting scheduler worker thread')

        self.work_thread = Thread(target=schedule_worker, args=(self,))
        self.work_thread.daemon = True
        self.work_thread.start()

    def shutdown(self):
        self.logger.debug('Scheduler shutdown called')
        self.running = False
        self.viewer.shutdown()
        self.logger.debug('Scheduler waiting for worker thread to stop')
        self.work_thread.join()
        self.logger.debug('Scheduler shut down complete')

    def modify_playlist_atomically(self, modifier_function):
        self.logger.debug('Modifying scheduler playlist atomically')
        self._playlist_lock.acquire()
        try:
            modifier_function(self._playlist)
        finally:
            self._playlist_lock.release()
开发者ID:nullpointer08,项目名称:nullpointer-client,代码行数:60,代码来源:scheduler.py

示例3: get

  def get(self):
    # パラメータ取得
    twitter_id = self.request.get("id")

    # パラメータがなければ一覧へ
    if not twitter_id:
      self.redirect(urls.APP_INDEX_URL)
      return

    # データ取得
    twitter_obj = Twitter.get( twitter_id )

    # データがない!
    if not twitter_obj:
      # 無言で一覧へいかせるのさ
      self.redirect(urls.APP_INDEX_URL)
      return

    # 画面を表示する
    Viewer.generate(
      Viewer(),
      self.response,
      TEMPLATE_APP_INDEX_PATH,
      {
        'current_twitter': twitter_obj,
        'owned_twitters': models.get_owned_twitters( users.get_current_user() )
      })
开发者ID:sadao,项目名称:tweet-with-email,代码行数:27,代码来源:main.py

示例4: get

 def get(self, meigen_id):
   # 名言個別ページを表示する
   if meigen_id:
     PortalMeigenHandler.individual(self, meigen_id)
   # 名言一覧ページを表示する
   else:
     Viewer.generate(Viewer(), self.response, LIST_TEMPLATE_PATH, { 'meigens': Meigen.all().order('-created_on') })
开发者ID:sadao,项目名称:meigen-pedia,代码行数:7,代码来源:meigen.py

示例5: StateView

class StateView(QtGui.QMainWindow):
    def __init__(self, window):
        QtGui.QMainWindow.__init__(self)
        self.ui = Ui_StateView()
        self.ui.setupUi(self)

        self.viewer = Viewer("pydot")

        self.connect(self.ui.btShowSingleState, SIGNAL("clicked()"), self.showSingleState)
        self.connect(self.ui.btShowWholeGraph, SIGNAL("clicked()"), self.showWholeGraph)

        self.window = window

    def showWholeGraph(self):
        editor = self.window.getEditor()
        self.viewer.create_pydot_graph(editor.tm.get_mainparser().graph)
        self.showImage(self.ui.gvStategraph, self.viewer.image)

    def showSingleState(self):
        editor = self.window.getEditor()
        self.viewer.show_single_state(editor.tm.get_mainparser().graph, int(self.ui.leSingleState.text()))
        self.showImage(self.ui.gvStategraph, self.viewer.image)

    def showImage(self, graphicsview, imagefile):
        scene = QGraphicsScene()
        item = QGraphicsPixmapItem(QPixmap(imagefile))
        scene.addItem(item);
        graphicsview.setScene(scene)
        graphicsview.resetMatrix()
开发者ID:willemneal,项目名称:eco,代码行数:29,代码来源:eco.py

示例6: get

  def get(self):
    # 新着名言を指定数取得する
    query = Meigen.all().order('-created_on')
    meigens = query.fetch( limit = DISPLAY_NUMBER )

    # 画面を表示する
    # http://morchin.sakura.ne.jp/effective_python/method.html
    Viewer.generate(Viewer(), self.response, TEMPLATE_PATH, { 'meigens': meigens })
开发者ID:sadao,项目名称:meigen-pedia,代码行数:8,代码来源:index.py

示例7: test_execution_error

    def test_execution_error(self, mock_call, mock_exists):
        mock_call.return_value = 5

        v = Viewer(self.prog)
        deleted_pics = v.show(self.pics)

        self.assertListEqual(deleted_pics, [])
        self.assertTrue(self.viewer_err_logger.called)
开发者ID:irvpriddy,项目名称:picture_clerk,代码行数:8,代码来源:test_viewer.py

示例8: get

def get(arg):
    """defines get command"""
    if arg != "dashboard":
        args = arg.split(' ')

        if args[0] == "avatar":
            viewer = Viewer(client)
            viewer.viewAvatar(args[1])
开发者ID:rfaulhaber,项目名称:TCL,代码行数:8,代码来源:main.py

示例9: test_execution_fail

    def test_execution_fail(self, mock_call, mock_exists):
        mock_call.side_effect = OSError("mock execution failed")

        v = Viewer(self.prog)
        deleted_pics = v.show(self.pics)

        self.assertListEqual(deleted_pics, [])
        self.assertTrue(self.viewer_err_logger.called)
开发者ID:irvpriddy,项目名称:picture_clerk,代码行数:8,代码来源:test_viewer.py

示例10: get

  def get(self):
    # Userモデルに未登録だったら登録する
    user_obj = users.get_current_user()
    account = Account.get_or_insert(
                   user_obj.user_id(),
                   owner = user_obj,
                   user_id = user_obj.user_id() )

    # 画面表示
    Viewer.generate(Viewer(), self.response, TEMPLATE_PATH, {} )
开发者ID:sadao,项目名称:meigen-pedia,代码行数:10,代码来源:settings.py

示例11: view_pics

def view_pics(rep, prog):
    """
    Launch external viewer and keep track of pictures deleted within.
            
    Arguments:
    rep -- View pictures from this repository.
    """
    if not prog:
        prog = rep.config['viewer.prog']
    v = Viewer(prog)
    deleted_pics = v.show(rep.index.pics())
    remove_pics(rep, [pic.filename for pic in deleted_pics])
开发者ID:irvpriddy,项目名称:picture_clerk,代码行数:12,代码来源:app.py

示例12: test_execution_sucess

    def test_execution_sucess(self, mock_call, mock_exists):
        mock_call.return_value = 0
        mock_exists.return_value = True

        v = Viewer(self.prog)
        deleted_pics = v.show(self.pics)

        actual_call_args = mock_call.call_args_list[0][0][0]
        expected_call_args = self.prog.split() + sorted(self.thumbs)
        self.assertItemsEqual(expected_call_args, actual_call_args)
        self.assertListEqual(deleted_pics, [])
        self.assertFalse(self.viewer_err_logger.called)
开发者ID:irvpriddy,项目名称:picture_clerk,代码行数:12,代码来源:test_viewer.py

示例13: _refresh

    def _refresh(self, pillow, path):
        if self._path is None:
            return
        try:
            # selection changed!
            if path == self._path + ".*":
                try:
                    idx = PathHelper.getValue(self._document.selection, path + '._selection') 
                    if self._delegate:
                        self._ignoreSelect = True
                        self._delegate.selectRow(idx)
                except: pass

            elif Viewer.matchPath(self._path, path, mode=Viewer.OUTER):
                value = None
                if self._document:
                    if self._isList:
                        value = self._document.get(self._path, asList=True, wrap=self._wrapInList)
                    else:
                        value = self._document.get(self._path, asDict=True)

                if value and self._credentials:
                    credential = self._credentials.getFlat(self._path)
                    if credential == None or 'view' in credential or self._path == '_id':
                        if self._delegate: self._delegate.dataCB(value)
                        if not self._resolved:  
                            if self._document.hasConflicts():
                                d = self._document.loadConflicts()
                                d.addCallback(self._conflictsArrived)
                            else:
                                self._noConflict()

                        if self._delegate and self._inserted != None:
                            self._delegate.editRow(self._inserted)
                else:
                    if self._delegate: self._delegate.dataCB(None)

                if self._document != None and self._document.selection != None:
                    # FIXME: Should we clear the selection here
                    # if "*" in self._path:
                    #     self._document.select(self._path, None)

                    sel = PathHelper.getValue(self._document.selection, self._path + '.*._selection')
                    if sel != None and self._delegate != None: self._delegate.selectRow(sel)

            elif Viewer.matchPath(self._path, path, mode=Viewer.INNER):
                if self._delegate: self._delegate.changedCB()

        except SelectionNotSpecified as e:
            self._delegate.dataCB(None)

        self._inserted = None
开发者ID:FreshXOpenSource,项目名称:wallaby-base,代码行数:52,代码来源:embeddedViewer.py

示例14: __init__

 def __init__(self):
     self.logger = logging.getLogger(__name__)
     self.logger.debug('Initializing scheduler')
     self.viewer = Viewer()
     self._playlist = []
     self._playlist_lock = Lock()
     self.running = False
开发者ID:nullpointer08,项目名称:nullpointer-client,代码行数:7,代码来源:scheduler.py

示例15: _refresh

    def _refresh(self, pillow, path):
        from wallaby.common.pathHelper import SelectionNotSpecified
        from twisted.internet import defer

        if self._path and Viewer.matchPath(self._path, path, mode=Viewer.OUTER):
            d = None

            try:
                if self._document:
                    name = self._document.get(self._path)

                    if name == None: name = self._path

                    if name != None:
                        d = defer.maybeDeferred(self._document.deferredGetAttachment, name)

                if d and self._credentials:
                    credential = self._credentials.getFlat(self._path)
                    if credential == None or 'view' in credential:
                        self._cb(d, name)
                else:
                    d = defer.Deferred()
                    d.callback(None)
                    self._cb(d, None)

            except SelectionNotSpecified as e:
                d = defer.Deferred()
                d.callback(None)
                self._cb(d, None)
开发者ID:FreshXOpenSource,项目名称:wallaby-base,代码行数:29,代码来源:imageViewer.py


注:本文中的viewer.Viewer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。