Python Forum
Help - GTK3 + Pango: Printing data as table format
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help - GTK3 + Pango: Printing data as table format
Hi, i'm beginner in Python, i'm writing my first program.
I want to print some data in table format.

I found this link but i can't make it's work.

This is my code:
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import Pango
gi.require_version('PangoCairo', '1.0')
from gi.repository import PangoCairo

class Print():

	def __init__(self, content):
		self.content = content
		paper_size = Gtk.PaperSize.new_custom("cc", "cc", 210, 297, Gtk.Unit.MM)
		page_setup = Gtk.PageSetup()
		page_setup.set_bottom_margin(10, Gtk.Unit.MM)
		page_setup.set_left_margin(10, Gtk.Unit.MM)
		page_setup.set_right_margin(10, Gtk.Unit.MM)
		page_setup.set_top_margin(10, Gtk.Unit.MM)
		self.print_operation = Gtk.PrintOperation()
		self.print_operation.connect("draw_page", self.draw_page)

	def draw_page(self, operation, context, page_number):
		pango_layout = context.create_pango_layout()
		pango_layout.set_markup(self.content, -1)
		cairo_context = context.get_cairo_context()
		PangoCairo.show_layout(cairo_context, pango_layout)

	def do_print(self):, None)

test = Print('''|| top left cell || top right cell ||
|| bottom left cell || bottom right cell ||''')
But i want something like this:
<td>Column 1</td><td>Column 2</td><td>Column 3</td>
<td>Column 1</td><td>Column 2</td><td>Column 3</td>

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] modify the html table to include data from tkinter labels rwahdan 0 130 Jun-20-2021, 10:33 AM
Last Post: rwahdan
  [GI] Error when I close the interface Glade/GTK3/ Charles25 2 739 Jun-16-2020, 07:02 PM
Last Post: Charles25
  Problem with Gtk3 and GLArea gsohler 0 1,003 Aug-12-2019, 07:33 AM
Last Post: gsohler
  [PyQt] How to display multiple data(from 2 different related table) in one cell of QTableWid yangjae 4 2,072 Oct-17-2018, 07:54 AM
Last Post: Larz60+
  [Tkinter] insert table columns data in different textboxes dimvord 4 2,732 Jun-15-2018, 07:40 AM
Last Post: dimvord
  python3 + gtk3 image sequence changos 0 2,100 Apr-24-2017, 04:10 PM
Last Post: changos
  Python minesweeper game gtk3 get label value after click lukassz 0 2,008 Mar-25-2017, 08:14 PM
Last Post: lukassz

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020