3
votes

I am planning to write a card game in python, and now looking for a GUI (I'm new to Python). I have so far tried out two GUI's :TK(inter) and wxPython.

Neither of them seem to be able , and correct me if I'm wrong, to do this :

dragging a panel with an image of a Card in it

And it's not even about the dragging. This is the situation

  1. I want to place the Card in a container. It should be able to show both front and backside of the card so I want each card to be a panel rather than a bare image.
  2. The image should be able to have transparent areas (card corners are rounded)
  3. The panel (container) should be able to be transparant (So the card can be dragged over different backgroundcolors, the table other cards,....)

TKinter : can't do 3 as I understand it

wxPython : can't do 2 as I understand it.

I can go along and discover GUI after GUI, but this is kind of time-consuming, so my questions are :

  1. Is it so that TKinter and wxPython have these shortcomings?
  2. If so, what GUI to go to?

I've heard of pygame, but it's really not that much I am asking of the GUI. Swing (java) could do it, and that's not gaming centered either.

4
Why not use PyOpenGL for this? - Niklas R
@Niklas : Because I never heard of it, but I might in the end. Care to elaborate in an answer? - Peter

4 Answers

9
votes

As you want to write a game, I would recommend to not use a GUI library. Instead, you should look for Game Libraries like PyGame, PyOpenGl or Kivy (aside others). They should all fit up your needs.

6
votes

wxPython can do transparency, you just need to use Transparent pngs.

png = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
wx.StaticBitmap(self, -1, png, (10, 5), (png.GetWidth(), png.GetHeight()))

Showing a .png image in a window in wxPython

1
votes

You should take a look at the wxPython demo for examples and ask on the wxPython mailing list to see if is anyone who has made something similar. In the demo, there is a DragImage demo that does some of what you're looking for.

Otherwise, one of the Python gaming libraries may suit your needs better. PyGame is probably the most well known. For a while, Pyglet was gaining momentum. See also wxPython or pygame for a simple card game?

1
votes

Tkinter can handle transparent gifs. Your "container" requirements are a bit hard to understand, though. I don't understand what transparency has to do with the ability to drag it over different colored backgrounds.

Certainly you can group objects (images, rounded retangles, ec) together on a canvas, and those objects can have blank spaces between / around them, and you can certainly draw round corners and drag objects.