이는 .. extreeemely 막연한 질문이다 그러나 여기서 우리는 ... 나는 전통적인 모듈의 대부분을 건너 뛸 것 (예 : TK에 또는 wxPython을 등을하지만 그들은 당신을 위해 일할 수있는) 이동합니다.
나는 보통 여기
짧은 드래그 앤 드롭 예입니다 .. GUI 개발이나 현명한 그래픽 것도 흥미로운 사람에게 Pyglet 옵션을 제공 : 여기
#!/usr/bin/python
import pyglet
from time import time, sleep
class Window(pyglet.window.Window):
def __init__(self, refreshrate):
super(Window, self).__init__(vsync = False)
self.frames = 0
self.framerate = pyglet.text.Label(text='Unknown', font_name='Verdana', font_size=8, x=10, y=10, color=(255,255,255,255))
self.last = time()
self.alive = 1
self.refreshrate = refreshrate
self.click = None
self.drag = False
def on_draw(self):
self.render()
def on_mouse_press(self, x, y, button, modifiers):
self.click = x,y
def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers):
if self.click:
self.drag = True
print 'Drag offset:',(dx,dy)
def on_mouse_release(self, x, y, button, modifiers):
if not self.drag and self.click:
print 'You clicked here', self.click, 'Relese point:',(x,y)
else:
print 'You draged from', self.click, 'to:',(x,y)
self.click = None
self.drag = False
def render(self):
self.clear()
if time() - self.last >= 1:
self.framerate.text = str(self.frames)
self.frames = 0
self.last = time()
else:
self.frames += 1
self.framerate.draw()
self.flip()
def on_close(self):
self.alive = 0
def run(self):
while self.alive:
self.render()
# ----> Note: <----
# Without self.dispatc_events() the screen will freeze
# due to the fact that i don't call pyglet.app.run(),
# because i like to have the control when and what locks
# the application, since pyglet.app.run() is a locking call.
event = self.dispatch_events()
sleep(1.0/self.refreshrate)
win = Window(23) # set the fps
win.run()
당신이 만들어야 할 것이다 자신의 개체 (텍스트 상자, 슬라이더 .. 등)하지만 전체 제어 할 수 있습니다.
몇 가지 (8-13) 개의 대규모 GUI 응용 프로그램을 만들었으며 벽돌 모양 버튼과 일반 색상 표를 사용하지 않으려는 경우 가장 깨끗한 방법입니다. 또한
, GUI 토론에이 스레드와 더 많은 참조 최고의 모듈 등 무엇 : http://wiki.python.org/moin/GuiProgramming
Game Development in Python, ruby or LUA?
Curses alternative for windows
그리고 Pyglet에 대한
: