Python 如何在Visual Studio 2013中使用UniCourses
我正在尝试学习Python UniCourses,以便在我正在进行的项目中使用它 以下是我正在使用的:Python 如何在Visual Studio 2013中使用UniCourses,python,python-2.7,curses,python-curses,pdcurses,Python,Python 2.7,Curses,Python Curses,Pdcurses,我正在尝试学习Python UniCourses,以便在我正在进行的项目中使用它 以下是我正在使用的: Python 2.7 Visual Studio 2013 Visual Studio 2013的Python工具 我安装了必要的项目,UniCourses和PDCCourses。从Python解释器和IDLE来看,它似乎工作得很好。但不是在Visual Studio中 我一直收到一个错误,说pdcurses.dll丢失了。因此,我决定将PDCurses文件复制到项目的根目录中。这似乎解决
- Python 2.7
- Visual Studio 2013
- Visual Studio 2013的Python工具
属性错误:“c\u void\u p”对象没有属性“TheAttribute”
。每个UniCourses函数都会发生这种情况,但我第一次初始化对象时除外:stdscr=uniCourses.initscr()
所以我开始研究一些教程,以确保我正确安装了所有内容。我按照GitHub上的UniCourses自述和YouTube上的安装教程中的说明进行操作,但我仍然无法让它正常工作
我确实在这里找到了一篇与我的问题有点相似的帖子,但对我的问题没有真正的帮助。您可以在此处查看:
有人知道我做错了什么吗?我花了几个小时寻找解决方案,但什么都没用
非常感谢您的帮助。谢谢大家! 我想出来了不幸的是,我过于关注教程中的示例,而忽略了根本问题。当我在这里找到类似的帖子(我的问题中包含了链接)时,我本应该理解的,但我认为我遇到的问题是不同的 基本上,我认为UniCourse和/或PDCCourse设置不正确,从而导致无法访问这些方法。事实并非如此。相反,我所遵循的教程中的代码实际上是错误地访问了这些方法(不知道为什么它适用于这些方法,可能是旧版本?) 以下是一个例子:
import unicurses
# Init screen object
stdscr = unicurses.initscr()
# Incorrect way to access methods:
stdscr.addstr('Hello World!')
# Correct way to access methods:
unicurses.addstr('Hello World!')
或
直到在线找到此UniCourses安装测试脚本,我才真正了解这个问题:
# Script to test the installation of UniCurses
from unicurses import *
stdscr = initscr() # initializes the standard screen
addstr('Hello World!\n')
addch(ord('A') | A_BOLD)
addstr(' single bold letter\n')
attron(A_BOLD) # Turns on attribute
addstr('\n\nBold string')
attroff(A_BOLD)
addstr("\nNot bold now")
mvaddch(7, 10, 66); #B at row 7, col 10
addstr(' - single letter at row 7, col 10')
start_color()
init_pair(1, COLOR_RED, COLOR_GREEN) # Specifies foreground and background pair 1
init_pair(2, COLOR_YELLOW, COLOR_RED)
attron(COLOR_PAIR(1))
mvaddstr(15, 12, 'Red on green at row 15, col 12')
attroff(COLOR_PAIR(1))
attron(COLOR_PAIR(2))
addstr('\n\nYellow on red')
addstr('\n\nPress up arrow!')
attroff(COLOR_PAIR(2))
cbreak() # Gets raw key inputs but allows CRTL+C to work
keypad(stdscr, True) # Get arrow keys etc.
noecho() # Do not display automatically characters for key presses
a = getch() # Gets the key code
if a == KEY_UP:
beep()
clear()
addstr('Beep! Any key to quit.')
a = getch()
(来源:)
我希望这将对其他遇到这个问题的人有所帮助。我肯定是在责怪自己没能早点理解
# Script to test the installation of UniCurses
from unicurses import *
stdscr = initscr() # initializes the standard screen
addstr('Hello World!\n')
addch(ord('A') | A_BOLD)
addstr(' single bold letter\n')
attron(A_BOLD) # Turns on attribute
addstr('\n\nBold string')
attroff(A_BOLD)
addstr("\nNot bold now")
mvaddch(7, 10, 66); #B at row 7, col 10
addstr(' - single letter at row 7, col 10')
start_color()
init_pair(1, COLOR_RED, COLOR_GREEN) # Specifies foreground and background pair 1
init_pair(2, COLOR_YELLOW, COLOR_RED)
attron(COLOR_PAIR(1))
mvaddstr(15, 12, 'Red on green at row 15, col 12')
attroff(COLOR_PAIR(1))
attron(COLOR_PAIR(2))
addstr('\n\nYellow on red')
addstr('\n\nPress up arrow!')
attroff(COLOR_PAIR(2))
cbreak() # Gets raw key inputs but allows CRTL+C to work
keypad(stdscr, True) # Get arrow keys etc.
noecho() # Do not display automatically characters for key presses
a = getch() # Gets the key code
if a == KEY_UP:
beep()
clear()
addstr('Beep! Any key to quit.')
a = getch()