I sub classed wx.Button as to see how to trigger the game’s logic from the GUI. I would later replace it with some other colored control (window) such as those blocks shown in the game I am trying to implement.
This project has been stale like this for two months. I don’t seem to be able to figure it out and don’t know what else to do… I tested other examples, all of them worked as expediente.
You can use a grid sizer with hgap/vgap, e.g. wx.GridSizer(3, 3, 2, 2) for a 3x3 grid with 2 pixels gap.
See attachment and screenshot.
I doubt that this will create a really nice result, though. You’re probably better off painting the board yourself. For games, there might be more suitable libraries, maybe pygame or something similar.
First things first, Sizers are for the layout of a collection of widgets. They don’t actually draw anything. If you need that, the best thing to do is create a EVT_PAINT event handler and draw things there.
@DietmarSchwertberger’s example works by setting the background color of the parent window, and then leaving enough space between the tile widgets that the color can be seen between them. That’s okay if it works for you, but I expect that it won’t scale well and could end up with some flicker in some situations.
Because you never called SetSizer, so the layout algorithm is never run, so the tile widgets are never moved from their default position.
The row, col indexes are zero-based. If you want to display a one-based range, then add one to the values you get.
I labeled the buttons with their positions for debugging this issue.
About that, I wasn’t going to do the aesthetic work and coding until I didn’t fix my issue. Now, I have to get the logic to work.Then, I’ll implement the aesthetics. That’s why I made the wxBlock class, so I can code in one place the look and feel of every cell according to their value.
Thanks a lot @Robin. I don’t think I would have solved it without your comment. Lesson learned|