我一直在寻找一些关于使用Pygame从Python中的少量图像制作简单精灵动画的好教程.我还没有找到我正在寻找的东西.
我的问题很简单:如何从少量图像制作动画精灵(例如:制作几张爆炸图像,尺寸为20x20px,为一个但动画)
有什么好主意吗?
关于悬挂缩进的PEP 8:
使用悬挂式缩进时,应采用以下注意事项; 第一行应该没有参数,应该使用进一步的缩进来明确区分自己作为延续线.
是否有关于"子参数"的明确文档?例如:
some_method(argument_one, argument_two, argument_three=[
'parameter_one',
'parameter_two',
'parameter_three',
])
Run Code Online (Sandbox Code Playgroud)
相反:
some_method(
argument_one,
argument_two,
argument_three=[
'parameter_one',
'parameter_two',
'parameter_three',
]
)
Run Code Online (Sandbox Code Playgroud)
最好只链接到官方讨论.
我试图从dropzone.js base64编码文件,并使用PJAX将其发送到处理程序页面.但是我有一个base64_data
在POST请求中为空的问题.
$(document).ready(function(){
Dropzone.autoDiscover = false;
$("#file-form").dropzone({
paramName: 'file',
clickable: true,
maxFilesize: 1,
uploadMultiple: false,
autoProcessQueue: false,
accept: function(file, done){
reader = new FileReader();
reader.onload = handleReaderLoad;
reader.readAsDataURL(file);
function handleReaderLoad(evt) {
document.getElementById("id_base64_data")
.setAttribute('value', evt.target.result);
}
document.getElementById("id_base64_name")
.setAttribute('value', file.name);
document.getElementById("id_base64_content_type")
.setAttribute('value', file.type);
form = $('#file-form');
$.pjax( {
method: "POST",
container: "#pjax-container",
timeout: 2000,
url: "/upload/",
data: form.serialize(),
});
done();
},
});
});
Run Code Online (Sandbox Code Playgroud)
形成:
<form class="form-horizontal dropzone dz-clickable" id="file-form" action="/upload/" method="post" enctype="multipart/form-data" name="file-form">
<input id="id_base64_data" name="base64_data" type="hidden">
<input id="id_base64_name" name="base64_name" …
Run Code Online (Sandbox Code Playgroud) 我知道我可以通过点击在一个文件中跳转书签F2.是否可以在项目级别(在文件之间)执行此操作?
插件怎么样?Sublime Text 3?
我有 2 个独立的模型,发布和评论。我使用 DetailView 来显示 Post 内容,我想使用 CreateView 在同一页面上显示评论创建表单。最干净的方法是什么?
唯一想到的是使用自定义视图,它既获取对象又处理评论表单,但这看起来太脏了:
def post_detail(request, slug):
post = get_object_or_404(Post, slug=slug)
if request.POST:
form = CommentForm(request.POST)
# do comment form processing here
return render(request, "post/post_detail.html", {
"object": post, "comment_form": form})
Run Code Online (Sandbox Code Playgroud)
使用基于类的视图有什么干净的方法可以做到这一点吗?或者只是将帖子显示代码与评论处理代码分离的某种方法?
假设我有2D列表,我想检查上一个/下一个元素是否等于某个东西.什么是确保我不会进入最好的方式list[-1][-1]
还是list[len + 1][len + 1]
?
这是我正在尝试做的一个例子:
if list[y + 1][x] == value and list[y - 1][x] == value:
do something
elif list[y][x + 1] == value and list[y][x - 1] == value:
do something else
... # end so on
Run Code Online (Sandbox Code Playgroud)
除了做以下事情,我看不到任何其他选项:
if y - 1 > 0 and y + 1 < len(list) and x - 1 > 0 and x + 1 < len(list[y]):
Run Code Online (Sandbox Code Playgroud)
哪个看起来不对......
我正在尝试与Travis CI建立一个项目.Project也使用了pygame.我有多次尝试设置它 - 但它似乎失败了.
我得到的最接近的是:
.travis.yml
:
language: python
python:
- "2.7"
install:
- pip install -r requirements.txt
before_install:
- sudo apt-get update
- sudo apt-get build-dep python-pygame
- sudo apt-get install mercurial
script:
- nosetests tests/*.py
Run Code Online (Sandbox Code Playgroud)
requirements.txt
:
Twisted==13.2.0
coverage==3.7.1
nose==1.3.0
hg+http://bitbucket.org/pygame/pygame
wsgiref==0.1.2
zope.interface==4.1.0
Run Code Online (Sandbox Code Playgroud)
Travis CI下载pygame包,但安装挂起:
https://travis-ci.org/ruslanosipov/space/builds/19142164#L390
任何提示?
我正在尝试安装mysql-server
和libmysqlclient-dev
清理Ubuntu 12.04.3 LTS,但是我收到一个错误:
131031 13:31:15 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing mysql-server-5.5 (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.5; however:
Package mysql-server-5.5 is not configured yet.
dpkg: error processing …
Run Code Online (Sandbox Code Playgroud) 今天,我想Django的结合LiveServerTestCase
与splinter
和phantomjs
的webdriver.
这是我做的(简化版):
class Test(LiveServerTestCase):
def setUp(self):
self.browser = Browser('phantomjs')
def tearDown(self):
self.browser.quit()
def test(self):
self.browser.visit(self.live_server_url)
self.assertIn("Hello world!", self.browser.title)
Run Code Online (Sandbox Code Playgroud)
有时测试运行正常 - 即使每个测试方法执行第二次.但有时它可以随机地花费约100秒来执行单个测试方法,或者它只是冻结,直到我没有耐心等待它完成.
我django_nose
用作测试运行器,并且我将--liveserver=localhost:8081-8181
一系列端口传递给./manage.py test
命令.
有没有办法加快速度?是否有其他网络测试跑步者哪个更快?
默认的Web驱动程序似乎在速度方面更可靠(每个测试方法1-3秒),但它仍然很慢.我也更喜欢无头浏览器进行测试.
python ×5
django ×2
pygame ×2
algorithm ×1
animation ×1
big-theta ×1
dropzone.js ×1
forms ×1
javascript ×1
math ×1
mysql ×1
pep8 ×1
phantomjs ×1
pip ×1
recurrence ×1
selenium ×1
splinter ×1
sprite ×1
sublimetext2 ×1
sublimetext3 ×1
travis-ci ×1
ubuntu ×1
virtualenv ×1