本文整理汇总了Python中dialog.Dialog.alert方法的典型用法代码示例。如果您正苦于以下问题:Python Dialog.alert方法的具体用法?Python Dialog.alert怎么用?Python Dialog.alert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dialog.Dialog
的用法示例。
在下文中一共展示了Dialog.alert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: IotConsole
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import alert [as 别名]
class IotConsole(object):
"""
This uses the controller's credentials to provide a management interface
to the user.
It does not go through the security handshake (as it should be run on the
same device as the controller) and so does not inherit from the BaseNode.
"""
def __init__(self, networkName, nodeName):
super(IotConsole, self).__init__()
self.deviceSuffix = Name(nodeName)
self.networkPrefix = Name(networkName)
self.prefix = Name(self.networkPrefix).append(self.deviceSuffix)
self._identityStorage = IotIdentityStorage()
self._policyManager = IotPolicyManager(self._identityStorage)
self._identityManager = IotIdentityManager(self._identityStorage)
self._keyChain = KeyChain(self._identityManager, self._policyManager)
self._policyManager.setEnvironmentPrefix(self.networkPrefix)
self._policyManager.setTrustRootIdentity(self.prefix)
self._policyManager.setDeviceIdentity(self.prefix)
self._policyManager.updateTrustRules()
self.foundCommands = {}
self.unconfiguredDevices = []
# TODO: use xDialog in XWindows
self.ui = Dialog(backtitle="NDN IoT User Console", height=18, width=78)
trolliusLogger = logging.getLogger("trollius")
trolliusLogger.addHandler(logging.StreamHandler())
def start(self):
"""
Start up the UI
"""
self.loop = asyncio.get_event_loop()
self.face = ThreadsafeFace(self.loop, "")
controllerCertificateName = self._identityStorage.getDefaultCertificateNameForIdentity(self.prefix)
self.face.setCommandSigningInfo(self._keyChain, controllerCertificateName)
self._keyChain.setFace(self.face) # shouldn't be necessarym but doesn't hurt
self._isStopped = False
self.face.stopWhen(lambda: self._isStopped)
self.loop.call_soon(self.displayMenu)
try:
self.loop.run_forever()
except KeyboardInterrupt:
pass
except Exception as e:
print(e)
# self.log('Exception', e)
finally:
self._isStopped = True
def stop(self):
self._isStopped = True
#######
# GUI
#######
def displayMenu(self):
menuOptions = OrderedDict(
[
("List network services", self.listCommands),
("Pair a device", self.pairDevice),
("Express interest", self.expressInterest),
("Quit", self.stop),
]
)
(retCode, retStr) = self.ui.mainMenu("Main Menu", menuOptions.keys())
if retCode == Dialog.DIALOG_ESC or retCode == Dialog.DIALOG_CANCEL:
# TODO: ask if you're sure you want to quit
self.stop()
if retCode == Dialog.DIALOG_OK:
menuOptions[retStr]()
#######
# List all commands
######
def listCommands(self):
self._requestDeviceList(self._showCommandList, self.displayMenu)
def _requestDeviceList(self, successCallback, timeoutCallback):
self.ui.alert("Requesting services list...", False)
interestName = Name(self.prefix).append("listCommands")
interest = Interest(interestName)
interest.setInterestLifetimeMilliseconds(3000)
# self.face.makeCommandInterest(interest)
self.face.expressInterest(
interest,
self._makeOnCommandListCallback(successCallback),
self._makeOnCommandListTimeoutCallback(timeoutCallback),
#.........这里部分代码省略.........