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


Python Model.loadConfig方法代码示例

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


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

示例1: Controller

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import loadConfig [as 别名]
class Controller():
    '''Main class for controlling the operations of the application'''
    def __init__(self):
        #Create a new Tkinter interface
        self.root = Tk()
        #Set an exit protocol
        self.root.protocol("WM_DELETE_WINDOW", self.exitRoot)

        #Create a model
        self.model = Model()
        self.model.loadConfig() #Load default configuration parameters
        #self.view  = View()

        #Start timer thread
        self.txTimer = TimerThread(self, "tmr")
        #Create joystick interface
        self.jsFrame = JoystickFrame(self.root)
        self.joystick = self.jsFrame.getJSHandle()
        self.statusBox = self.jsFrame.getTextHandle()

        #Initialise a telnet rxtx thread for wireless communication
        self.rxThread = RxTxThread(self,"rxtxthread", self.model.getHost(), self.model.getPort())
        if (self.rxThread.getTN() == 0):
            self.statusBox.setText('Could not establish a connection. Terminating...')
            return
        #Start Threads
        self.rxThread.start()
        self.txTimer.start()

        self.statusBox.setText('Connected\n')

        print self.rxThread.getRXText()

        self.rxThread.checkConnection()
        self.root.mainloop()

    def processMessages(self, messages):
        '''Displays received messages in a window box'''
        for msg in messages:
            self.statusBox.setText(msg + '\n')

    def transmitControl(self):
        '''Transmits the coordinates of the joystick if it it being actuated.
        Not complete in interfacing.'''
        if not self.joystick.isReleased():         #Joystick in use
            spdL,spdR =  self.joystick.getSpeeds() #Retrieve position as speeds
            print spdL, spdR
        if self.jsFrame.keyReady():                # WASD Control
            keyChar = self.jsFrame.getJSKey()      # Retrieve valid keypresses
            self.statusBox.setText("Pressed: "+keyChar+"\n")

            self.rxThread.txCmd(keyChar)           #Transmit typed character

    def exitRoot(self):
        '''Protocol for exiting main application'''
        self.rxThread.txCmd('!') #Stop robot
        self.txTimer.pause(True) #Stop timer
        self.rxThread.stop()     #Stop thread
        self.root.destroy()     
开发者ID:jttaufa,项目名称:Rattus2,代码行数:61,代码来源:Controller.py


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