tags:

views:

140

answers:

2

I know python and I'm a newibe with wx python but I would like to make a card game. However I have no idea how to make a image follow the mouse and put it in the middle of the screen in the

when the program running. It will be nice if you guys can help me out.

Thank you

+1  A: 

Check the DC class like

http://docs.wxwidgets.org/trunk/classwx%5Fpaint%5Fd%5Fc.html

there you have full freedom. just select a brush, a color and paint copy, stamp store loaded images, what you like. With an Eventhandler like

EVT_LEFT_UP( widget, callback );

you can intercept clicks or with EVT_MOTION the movement with mouse and in the callback the second parameter is the eventobject from where you get coordinates.

just have a look here:

http://docs.wxwidgets.org/2.8.9/wx%5Fclassref.html#classref

because you need to understand some concepts before you can solve such complex task in Wx. Maybe start with the surrounding Wx::Frame, add an Wx::StatusBar a Wx::Menu, put it into the Wx::MenuBar and connect one Menu as Conetxtmenu (also Wx::Menu poped out on mouse click) and so on. You maybe load a little bitmap into menuitem icon before you manipulate it (as Wx::Image, with Wx::Bitmap you can't do a lot). So take your time and enjoy. :)

sir_lichtkind
+2  A: 

Going through the wxPython demo and looking at all the examples would be a good start. You'll likely find page Using Images | DragImage to be useful, since you'll probably want cards that you can drag.

Generally, the demo can help you do most things in wxPython, and also show you what wxPython can do, and it's worth the time to see every demo. This approach works for everything except the very first step of getting an app running and putting a frame in it (since the demo itself is an app, but not a simple one). Any of the basic tutorials can help you get started with an app and frame in just a very lines of code.

tom10
The wxPython demo app code is also viewable in the demo under the root "wxPython Overview", then the "Demo Code" tab. It's a good second place to look for a more meaty app framework, especially if you went through some of the horribly watered-down tutorials.
Nick T