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


Python Client.setRoot方法代码示例

本文整理汇总了Python中Client.Client.setRoot方法的典型用法代码示例。如果您正苦于以下问题:Python Client.setRoot方法的具体用法?Python Client.setRoot怎么用?Python Client.setRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Client.Client的用法示例。


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

示例1: testClientConnection

# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import setRoot [as 别名]
class testClientConnection(unittest.TestCase):

    def setUp(self):
        self.done = False
        self.cFactory = pb.PBClientFactory()
        self.realm = WBRealm()
        self.realm.server = WbServer()
        self.wbServer = self.realm.server
        self.p = portal.Portal(self.realm)
        self.c = WBChecker()
        self.p.registerChecker(self.c)
        self.sFactory = pb.PBServerFactory(self.p)
        self.sFactory.protocol = WBBroker
        self.server = reactor.listenTCP(28789, self.sFactory)

        self.myClient = Client()
        self.myClient2 = Client()
        self.client = reactor.connectTCP("localhost", 28789, self.cFactory)
        self.client2 = reactor.connectTCP("localhost", 28789, self.cFactory)
        def1 = self.cFactory.login(credentials.UsernamePassword("Waldo","waldo"), client=self.myClient.cc)
        def1.addCallback(self.getRoot, 1)
        def1.addErrback(self.failure, "Error al conectarse el cliente1")
        deferredResult(def1)

        def2 = self.cFactory.login(credentials.UsernamePassword("Matias","matias"), client=self.myClient2.cc)
        def2.addCallback(self.getRoot, 2)
        def2.addErrback(self.failure, "Error al conectarse el cliente2")
        deferredResult(def2)

    def tearDown(self):
        reactor.removeAll()
        deferredResult(self.server.stopListening())

    def testAddTextBox(self):
        deferredResult(self.myClient.wb.addTextBox(20, 20))
        self.assertEqual(self.myClient.wb.foreignObjectsCount(), 0)
        self.assertEqual(self.myClient2.wb.foreignObjectsCount(), 1)

    def testInsertChars(self):
        deferredResult(self.myClient.wb.addTextBox(20, 20))
        deferredResult(self.myClient.wb.insertChars(self.myClient.wb.wbCurrent, 0, "fooBarBaz"))
        self.assertEqual(self.myClient.wb.foreignObjectsCount(), 0)
        wb2 = self.myClient2.wb
        self.assertEqual(wb2.foreignObjectsCount(), 1)
        self.assertEqual(wb2.itemcget(wb2.foreignObjects.values()[0], "text"), "fooBarBaz")

    def testDeleteChars(self):
        deferredResult(self.myClient.wb.addTextBox(20, 20))
        deferredResult(self.myClient.wb.insertChars(self.myClient.wb.wbCurrent, 0, "fooBarBaz"))
        deferredResult(self.myClient.wb.deleteChars(self.myClient.wb.wbCurrent, 3, 4))
        self.assertEqual(self.myClient.wb.foreignObjectsCount(), 0)
        wb2 = self.myClient2.wb
        self.assertEqual(wb2.foreignObjectsCount(), 1)
        self.assertEqual(wb2.itemcget(wb2.foreignObjects.values()[0], "text"), "foorBaz")

    def failure(self, msg, who=0):
        print "error: ", msg
        self.done = True

    def getRoot(self, perspective, who):
        d = perspective.callRemote("getWbServer")
        d.addCallback(self.success, who)

    def success(self, root, who):
        if who == 1:
            self.myClient.setRoot(root)
        else:
            self.myClient2.setRoot(root)

    def localDeleteChars(self, data):
        self.myClient.wb.deleteChars(self.myClient.wb.wbCurrent, 3, 4)

    def finished(self):
        self.done = True
        try:
            self.timeout.cancel()
        except (error.AlreadyCancelled, error.AlreadyCalled):
            pass

    def testServerStatusNewText(self):
        deferredResult(self.myClient.wb.addTextBox(20, 20))
        current = self.myClient.wb.wbCurrent
        self.assert_(self.wbServer.wbStatus.has_key(self.wbServer.itemId(3, current)))

    def testServerStatusEditText(self):
        deferredResult(self.myClient.wb.addTextBox(20, 20))
        deferredResult(self.myClient.wb.insertChars(self.myClient.wb.wbCurrent, 0, "fooBarBaz"))
        current = self.myClient.wb.wbCurrent
        dict = self.wbServer.wbStatus[self.wbServer.itemId(3, current)]
        self.assertEqual(dict["text"], "fooBarBaz")
        self.assertEqual(dict["x"], 20)
        self.assertEqual(dict["y"], 20)
        self.assertEqual(dict["owner"].avId, 3)

    def testServerStatusClientConnect(self):
        dict = self.wbServer.wbStatus
        for a in dict.keys():
            self.assert_(self.myClient.wb.foreignObjects.has_key(a))

    def testServerStatusClientDisconnect(self):
#.........这里部分代码省略.........
开发者ID:mgaitan,项目名称:beppo,代码行数:103,代码来源:testClientConnection.py

示例2: __init__

# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import setRoot [as 别名]
class Login:
    PORTNO = 10102
    #BACKGROUND = "#c0a9cf"
    BACKGROUND = "#c098af"

    def __init__(self):
        self.window = Tk()
        self.window["bg"] = self.BACKGROUND
        self.window.title(APP_NAME)
        self.window.minsize(700, 550)

        tksupport.install(self.window)
        self.window.protocol("WM_DELETE_WINDOW", self.application_quit)

        self.createMenu()

        selectionGet = self.window.selection_get
        self.client = Client(self, selectionGet)
        self.client.pack()

        self.factory = pb.PBClientFactory()
        self.window.wait_visibility()
        self.logindialog = LoginDialog(self.window, self.loginSuccess, self.application_quit, REMOTE_SERVER, self.PORTNO, self.factory, self.client.cc)
        reactor.callWhenRunning(self.logindialog.run)
        reactor.run()

    def loginSuccess(self, avatar):
        self.client.setAvatar(avatar)
        #self.client.swb.focus_set()
        self.window.bind("<FocusIn>", lambda e: self.client.swb.focus_set())
        df = avatar.callRemote("getWbServer")
        df.addCallback(self.gotRootObject)
        df2 = avatar.callRemote("whoami")
        df2.addCallback(self.updateMenu)
        df3 = avatar.callRemote("myName")
        df3.addCallback(self.client.setName)
        df3.addCallback(lambda a: self.setWindowStatus())

    def setWindowStatus(self, desc=OUT):
        self.window.title(APP_NAME + " - " + self.client.name + " (" + statusMsg[desc] +")")

    def showRoomAdmin(self, event=None):
        self.client.showRooms()

    def showPostAdmin(self, event=None):
        self.client.showPost()

    def showQuestionAdmin(self, event=None):
        self.client.showQuestions()

    def showSubjectAdmin(self, event=None):
        self.client.showSubjects()

    def gotRootObject(self, root):
        self.client.setRoot(root)

    def createMenu(self):
        menubar = Menu(self.window)

        self.fileMenu = Menu(menubar, tearoff=0)
        self.fileMenu.add_command(label=_("Lista de aulas"), command=self.showRoomAdmin)
        self.fileMenu.add_command(label=_("Lista de materias"), command=self.showSubjectAdmin)
        self.fileMenu.add_separator()
        self.fileMenu.add_command(label=_("Imprimir"))
        self.fileMenu.add_separator()
        self.fileMenu.add_command(label=_("Salir"), command=self.application_quit)
        menubar.add_cascade(label=_("Archivo"), menu=self.fileMenu)

        self.editMenu = Menu(menubar, tearoff=0)
        menubar.add_cascade(label=_("Edicion"), menu=self.editMenu)

        self.emoticMenu = Menu(menubar, tearoff=0)
        menubar.add_cascade(label=_("Emoticonos"), menu=self.emoticMenu)

        self.symbolMenu = Menu(menubar, tearoff=0)
        menubar.add_cascade(label=_("Simbolos"), menu=self.symbolMenu)

        self.mathMenu = Menu(self.symbolMenu, tearoff=0)
        self.symbolMenu.add_cascade(label=_("Matematica"), menu=self.mathMenu)

        self.greekMenu = Menu(self.symbolMenu, tearoff=0)
        self.symbolMenu.add_cascade(label=_("Griego"), menu=self.greekMenu)

        self.helpMenu = Menu(menubar, tearoff=0)
        self.helpMenu.add_command(label=_("Manual de instrucciones"), command=self.showHelp)
        self.helpMenu.add_command(label=_("Acerca de..."), command=self.showAbout)
        menubar.add_cascade(label=_("Ayuda"), menu=self.helpMenu)

        self.linksMenu = Menu(menubar, tearoff=0)
        self.linksMenu.add_command(label=_("Links utiles"), command=self.showLinks)
        menubar.add_cascade(label=_("Links"), menu=self.linksMenu)

        self.window.config(menu=menubar)

    def showHelp(self):
        webbrowser.open(APP_URL + '/content/help.html', new=0)

    def showLinks(self):
        webbrowser.open(APP_URL + '/content/links.html', new=0)

#.........这里部分代码省略.........
开发者ID:mgaitan,项目名称:beppo,代码行数:103,代码来源:Login.py


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