Set coordinates of grid using obtained coordinates in wxPython Topic is solved
Set coordinates of grid using obtained coordinates in wxPython
I have a program which obtaines a set of coordinates from the user and try to display it on a grid in wxPython. How to do this in Python?
Re: Set coordinates of grid using obtained coordinates in wxPython
That's a little vague, what exactly is the problem?
In the simplest form, you just call wxGrid::CreateGrid(numRows, numCols) so that it's big enough to fit all your data.
Then call wxGrid::SetCellValue ( row, col, string ) to fill the cells.
In the simplest form, you just call wxGrid::CreateGrid(numRows, numCols) so that it's big enough to fit all your data.
Then call wxGrid::SetCellValue ( row, col, string ) to fill the cells.
Use the source, Luke!
Re: Set coordinates of grid using obtained coordinates in wxPython
I have a grid of dimension x X y. I want to highlight the cell whose coordinates I obtain from the user.
Re: Set coordinates of grid using obtained coordinates in wxPython
Sorry, i still don't understand. What do you mean with "highlight"? And how do you get the coordinates from the user?
Use the source, Luke!
Re: Set coordinates of grid using obtained coordinates in wxPython
As shown in the figure, some cells are coloured red. These are the highlighted cells. I want to do a program where I have a grid and user gives me the x and y coordinates of some cells in this grid. I have to map these coordinates to corresponding cells in the grid and colour them red.
Re: Set coordinates of grid using obtained coordinates in wxPython
If I understand you correctly, you need map pixel coordinates to cell coordinates? If so, at least in C++, wxGrid provides a group of methods for that (such as XYToCell): see Cell and Device Coordinate Translation in http://docs.wxwidgets.org/3.1/classwx_grid.html
If you meant that user gives you cell coordinates matching your grid ones, why just don't call SetCellBackgroundColour (int row, int col, const wxColour &colour)?
If you meant that user gives you cell coordinates matching your grid ones, why just don't call SetCellBackgroundColour (int row, int col, const wxColour &colour)?