Pygame Function Book
Project description
Pygame Function Book
pygame be used easier
1.下载 download
pip install pgbook
2.简单的程序 easiest program
1.esay
from pgbook.screen.window import Window
mywindow = Window()
#窗口对象
mywindow.show()
#展示
'''
这段代码生成了一个空白窗口
'''
2.window
from pgbook.screen.window import Window
mywindow = Window()
#窗口对象
mywindow.set_name('Hello World')
#set_name:用于修改名称
mywindow.set_ico('logo.ico')
#set_ico:用于设置图标
mywindow.set_rect(0.4,0.4)
#set_rect:(w,h):
# w,h<=1 大小为屏幕大小的w,h倍
# w,h>1 大小为w,h
mywindow.show()
#展示
'''
这段代码展示了Window类的使用
'''
3.事件系统
from pgbook.eventlist.thinglist import Thing,ThingList
t=Thing()
#单个事件对象
# 设置事件 方式1
def k(get1,get2):
print(str(get1)+' and '+str(get2))
t.connect(k)
# 设置事件 方式2
@t.connect()
def k(get1,get2):
print(str(get1)+' and '+str(get2))
t.set_name('PrintA')
#设置对象名称,用于寻找
t.did(256,None)
#输出:256 and None
#did:执行,传入参数
t.did_n(1024,False)
#输出:256 and False
#did:如果名称符合则执行,传入参数
t.lock(True)# 上锁did did_n不执行(也不报错)
t.lock(False)# 开锁 默认
t.lock()# 更改锁的方向
tl=ThingList()
# 事件列表,可叠多层
tl.set_name('PrintList')#检索名称
tl.lock(True)#锁功能同上,不执行本列表,但子对象不上锁
#添加事件 方式1
tl.connect(t)#Thing或ThingList均可,但不可传入自身,以防锁死
#添加事件 方式2
@tl.connect(name='PrintA')
def k(get1,get2):#注意保持参数统一
print(str(get1)+' and '+str(get2))
#自动创建一个Thing对象,name为'PrintA'
tl.did('pan',64)#所有对象执行,同时受本身和子对象的锁影响
tl.did_n('apple',64)#名称正确对象执行
tl.lock_n('PrintA')
#给所有name='PrintA'的对象上锁
#不受tl.lock(True)的影响
tl.find_n('PrintA')
#返回第一个name='PrintA'的对象
#不受tl.lock(True)的影响
tl.find_n('PrintA').did()
'''
这段代码展示了事件系统的使用
'''
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pgbook-0.1.16.tar.gz
(6.0 MB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pgbook-0.1.16.tar.gz.
File metadata
- Download URL: pgbook-0.1.16.tar.gz
- Upload date:
- Size: 6.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.8.10 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
367756cf16fb0dd460ec2224232cafe3b904b5abadbda840a3345aeea28b30bb
|
|
| MD5 |
4d37541c6ac4dc9b8c5b0bb208d65977
|
|
| BLAKE2b-256 |
34ac55bee3f9111d286551058c4fea87966bbc124d866b96f33a20435e72a294
|
File details
Details for the file pgbook-0.1.16-py3-none-any.whl.
File metadata
- Download URL: pgbook-0.1.16-py3-none-any.whl
- Upload date:
- Size: 6.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.8.10 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f5603458bae01619a62f637b5a2254e510c366f87b730009449342750742a05
|
|
| MD5 |
59e48df34a235ee6333f8fe0ca11c268
|
|
| BLAKE2b-256 |
3cae4f384bb3eddf8ed2ff6be92675948a878b54388280e036aa9cc8a39a045d
|