SFML community forums
Bindings - other languages => Python => Topic started by: fragged on May 04, 2009, 09:21:14 pm
-
hey guys, I'm having trouble interfacing with events, or finding any tutorial-like documentation to understand (Unfortunately, help(Event) hasn't been very helpful :()
Would anybody be kind enough to show me there code that prints /all/ events to the screen, along with the data related to it. With the code provided below I was able to see a keypress, or mouse movement, but unable to figure out how to probe for any more information..
while App.GetEvent(Event):
print Event.Type
#help(Event)
I'm happy to write my own handler, but I just cant figure out how to pull anymore data :(
Cheers,
Fragged
I've jumped to SFML from PyGame and I'm loving it; bar the installation trouble it seems to be a hell of a lot faster, with the same simple library :)
-
It's the same in c++, so you can have a look at the c++ tutorial : http://www.sfml-dev.org/tutorials/1.4/window-events.php
Just adapt it to the python syntax. For example
while (App.IsOpened())
{
sf::Event Event;
while (App.GetEvent(Event))
{
// Window closed
if (Event.Type == sf::Event::Closed)
App.Close();
// Escape key pressed
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
App.Close();
}
}
becomes
while App.IsOpened():
Event = sf.Event()
while App.GetEvent(Event):
// Window closed
if Event.Type == sf.Event.Closed:
App.Close()
// Escape key pressed
if (Event.Type == sf.Event.KeyPressed) and (Event.Key.Code == sf.Key.Escape):
App.Close()