hello,
i have completed making the wx python csheet and now i need to enter data in it and save it and than print it as well.but i am not sure how to do that:(
any help or example regarding this problem will b highly appreciated.
Thank you
Regards
punter

Dani AI

Generated

Brief followup for building on 's point: wx printing is fiddly, so split the task into three simple steps — extract the sheet data, persist it in a portable format, then print that file. If your csheet is a wx.grid.Grid subclass, you can reliably read every cell and write to CSV (or Excel/HTML) and use the OS/browser or a WebView to print.

Example: read grid values and write CSV.

import csv

rows = grid.GetNumberRows()
cols = grid.GetNumberCols()

with open('sheet_export.csv', 'w', newline='') as f:
    writer = csv.writer(f)
    for r in range(rows):
        writer.writerow([grid.GetCellValue(r, c) for c in range(cols)])

Printing approaches (pick one depending on how much control you need):

  • Quick and cross-platform: export to CSV or HTML and open in the default application or browser; users can print from there.
  • In-app: render the exported HTML in wx.html2.WebView and call its print facility to show the print dialog. See the WebView docs for method details.
  • Full control: implement a wx.Printout subclass and draw the sheet to the device context for accurate pagination and scaling; this is more work but gives precise layout.

Notes and tips:

  • GetCellValue returns strings; convert types as needed before saving.
  • If csheet is a custom control (not wx.grid.Grid), inspect its API or underlying data model and pull values directly — that is usually simpler and safer than scraping rendered cells.
  • Watch encoding and large-sheet performance: stream rows to disk rather than building giant strings in memory.

References: wx grid and WebView docs, and Python csv docs, are useful starting points for the methods above.

Recommended Answers

All 3 Replies

the only nightmare of wxPython is complexity in printing framework. Many geeks haven't got past there. Thanks to for their PDF toolkit. you can maneuver it to print on fly

the only nightmare of wxPython is complexity in printing framework. Many geeks haven't got past there. Thanks to for their PDF toolkit. you can maneuver it to print on fly

can you refer me any website or any place where i can see some coding examples which can help to solve my problem of getting the data from csheet???
if you can do that.it would b great.
thanks in advance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.