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


Python WConio.getch方法代码示例

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


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

示例1: death_screen

# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import getch [as 别名]
def death_screen():
    left = C.width / 4
    width = C.width / 2
    height = 12
    top = C.height / 2 - height /2
    
    time = game.state.time - (24*60)
    survived = "%i days, %i hours, and %i minutes" % ((time / 60) / 24, (time / 60) % 60, time % 60)

    death_box = draw.draw_box(left, top, width, height,
                                border_color=W.LIGHTRED, border_background_color=W.RED,
                                interior_background_color=W.RED)
    death_box.text.extend([
        draw.Text(W.WHITE, 1, 3, "UNHANDLED EXCEPTION:".center(width - 2)),
        draw.Text(W.LIGHTRED, 1, 4, ("Killed by %s." % game.state.killer).center(width - 2)),
        draw.Text(W.LIGHTRED, 1, 7, ("You lasted %s. " % survived).center(width - 2)),
        draw.Text(W.WHITE, 1, 10, "Press <ENTER> to quit.".center(width - 2)),
        ])
    draw.draw_box_text(death_box)
    while True:
        (chn, chs) = W.getch()
        #figure out if we're done
        if chs == '\r':
            #enter, exit
            raise game.GameShutdown()
开发者ID:jtruscott,项目名称:ld21,代码行数:27,代码来源:gameprompt.py

示例2: main

# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import getch [as 别名]
def main():

    USB1208LS=MCCDAQ()
    USB1208LS.FlashLED(0)
    
    USB1208LS.GetBoardName(0)
    i=USB1208LS.getStatus()
    print USB1208LS.GetErrMsg(i)

    print USB1208LS.GetConfig(BOARDINFO,0,0,BISERIALNUM)
    
    WConio.clrscr() 

    print "Demonstration of cbAOut() - chan0 pin13 - D/A 10bits"

    ExitFlag = False
    while (ExitFlag==False):

        WConio.gotoxy (0, 3)
        EngUnits = float ( raw_input('Enter a voltage between -5.0 and +5.0:  ') )

        DataValue=USB1208LS.FromEngUnits(0, BIP5VOLTS, EngUnits)
        USB1208LS.AOut (0, 0 , BIP5VOLTS, DataValue)
        
        print "%.2f volts has been sent to D/A 0.\n"\
               "Press Q to quit , any other key to continue: "  %EngUnits
        (ch,)=WConio.getch()
        
        if (ch=='q' or ch=='Q'): ExitFlag=True
开发者ID:countrymarmot,项目名称:mccdaq,代码行数:31,代码来源:ULAO01.py

示例3: run

# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import getch [as 别名]
 def run(self):
    while self.__RUN:
       self.__draw()
       userInput = WConio.getch()
       
       self.__update(userInput)
       self.__turns += 1
       
       spawn = self.__zombieSpawner.incr()
       if spawn:
          self.__spawnThing()
       
       spawn = self.__healthSpawner.incr()
       if spawn:
          self.__spawnThing("h")
开发者ID:elizabeth-matthews,项目名称:atlasChronicle,代码行数:17,代码来源:gameManager.py

示例4: get_input

# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import getch [as 别名]
def get_input():
    buf = []
    while True:
        msg = ''.join(buf)
        matches = display_suggestion(msg)

        W.gotoxy(0, C.height - 1)
        W.clreol()
        W.textcolor(W.GREEN)
        W.cputs(game.state.current_node.command_prompt + '$ '),
        W.textcolor(W.LIGHTGREEN)
        W.cputs(msg)

        if matches and len(matches) == 1:
            #show the argument help text
            match = matches[0]
            x = W.wherex()
            W.textcolor(W.DARKGREY)
            splitted = match.arguments.split()
            splitted = splitted[max(0, len(msg.split())-2):]
            W.cputs('  ' + ' '.join(splitted))
            W.textcolor(W.LIGHTGREEN)
            W.gotoxy(x, C.height - 1)
        else:
            match = None
        
        #Read input
        W.setcursortype(1)
        (chn, chs) = W.getch()
        W.setcursortype(0)

        #figure out if we're done
        if chs == '\r':
            #enter, exit
            break

        if chn == 8: 
            #backspace
            if len(buf):
                buf.pop()
            else:
                MessageBeep()
            continue
        if chn == 3:
            log.debug('took a ctrl-c')
            game.fire('specialkey', 'ctrlc')
            break

        if chn == 0 or chn == 224:
            #special keys come in two parts
            (chn2, _) = W.getch()
            if chn2 in W.__keydict:
                game.fire('specialkey', W.__keydict[chn2])
            continue

        if len(buf) >= C.width:
            #way too long now
            break
        
        if chs not in string.printable:
            #dont care
            continue

        buf.append(chs)
    return buf, match
开发者ID:jtruscott,项目名称:ld21,代码行数:67,代码来源:gameprompt.py

示例5: show_confirmation

# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import getch [as 别名]
def show_confirmation(line1=' ', line2=' '):
    line1 = terminal.Line.parse(line1)[0]
    line2 = terminal.Line.parse(line2)[0]
    width = max(14, max(line1.width, line2.width) + 2)
    height = 8
    left = (C.width - width) / 2
    top = (C.height - height) / 2
    previous_buf = W.gettext(left, top, left + width, top + height)
    btn_width = 7
    btn_height = 4
    btn_offset = 3
    try:
        container = draw.draw_box(left, top, width, height,
                                    border_color=W.LIGHTBLUE, border_background_color = W.BLUE)
        W.puttext(left+1, top + 1, left + line1.width, top + 1, line1.buf)
        W.puttext(left+1, top + 2, left + line2.width, top + 2, line2.buf)

        yes_button = draw.draw_box(left + btn_offset, top + height - btn_height, btn_width, btn_height,
                                    border_color=W.LIGHTBLUE, border_background_color = W.BLUE,
                                    corners = {'bl': 'teeup', 'br': 'teeup'})

        no_button = draw.draw_box(left + width - btn_offset - btn_width, top + height - btn_height, btn_width, btn_height,
                                    border_color=W.LIGHTBLUE, border_background_color = W.BLUE,
                                    corners = {'bl': 'teeup', 'br': 'teeup'})

        yes_text = draw.Text(W.DARKGREY, 1, 1, "YES".center(btn_width -2 ))
        no_text = draw.Text(W.WHITE, 1, 1, "NO".center(btn_width -2 ))
        yes_button.text.append(yes_text)
        no_button.text.append(no_text)
        selected_button = no_button

        while True:
            if selected_button == yes_button:
                yes_text.color = W.WHITE
                no_text.color = W.DARKGREY
            else:
                no_text.color = W.WHITE
                yes_text.color = W.DARKGREY
            draw.draw_box_text(yes_button)
            draw.draw_box_text(no_button)
            (chn, chs) = W.getch()
            #figure out if we're done
            if chs == '\r':
                #enter, exit
                break
            if chs == 'y':
                selected_button = yes_button
                break

            if chs == 'n':
                selected_button = no_button
                break

            if chn == 0 or chn == 224:
                #special keys come in two parts
                (chn2, _) = W.getch()
                if chn2 in W.__keydict:
                    name = W.__keydict[chn2]
                    if 'left' in name or 'right' in name:
                        selected_button = (selected_button == yes_button and no_button or yes_button)

        return (selected_button == yes_button and True or False)

    finally:
        #Restore what we scribbled on
        W.puttext(left, top, left + width, top + height, previous_buf)
开发者ID:jtruscott,项目名称:ld21,代码行数:68,代码来源:gameprompt.py

示例6: Copyright

# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import getch [as 别名]
# Works with Microsoft Windows dos box
# Shows some use of WConio written by Chris Gonnerman

# Written by Priyend Somaroo
# Copyright (c) 2008 Vardaan Enterprises, www.vardaan.com

# Use and distribute freely.
# No liability for any use of this code will be accepted. Use is
# without any warranty whatsoever

# Requires the package WConio by Chris Gonnerman
# E-Mail : [email protected]
# Web : http://newcenturycomputers.net/projects/wconio.html

import WConio

old_setting = WConio.gettextinfo()[4] & 0x00FF
WConio.clrscr()
WConio.textcolor(WConio.LIGHTCYAN)
WConio.settitle("PyBot Control Center")
WConio.gotoxy(2,2)
WConio.cputs("Welcome to the PyBot Control Center\n\r")
WConio.gotoxy(0,4)
WConio.cputs("127.0.0.1\n\r")
WConio.cputs("192.168.1.1\n\r")
WConio.gotoxy(0,25)
WConio.cputs("Random Output...")
WConio.gotoxy(2,23)
WConio.cputs("Enter command: ")
WConio.getch()
WConio.gotoxy(0,25)
开发者ID:r0ot,项目名称:ArxBot-old,代码行数:33,代码来源:WConioExample.py

示例7: display_once

# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import getch [as 别名]
        firmware_version = usb[2]
        disabled = (all_servos[-1][-1] == -1)

        # Servo and Analog Display Page
        servo_mode = IDLE   # Set up variables for running servos
        command_mode = INIT
        accel_dif = False
        accel_list = [1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 255]
        display_once(firmware_version)      # Display static and initial items

        while True:
            if len(all_servos) == 16: #check for valid servo data
                display_update()
            # 'Q' to quit, otherwise sequence through the servo command modes
            if WConio.kbhit():
                key_num, key_str = WConio.getch()
                if key_str.upper() == 'Q':
                    try:
                        rcs.robust_write('C')  #stop all servos at exit
                        del(rcs)        #close serial port
                    except:
                        pass
                    exit()
                elif command_mode is INIT:
                    command_mode = RUN 
                elif command_mode is RUN:
                    command_mode = BRAKE
                elif command_mode is BRAKE:
                    command_mode = IDLE
                else:
                    command_mode = INIT
开发者ID:philips,项目名称:feusb,代码行数:33,代码来源:TestRCS.py


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