Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9179529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:49:11+00:00 2026-06-17T17:49:11+00:00

The simplest example. We create a window by means of Gtk, we add there

  • 0

The simplest example. We create a window by means of Gtk, we add there area for drawing of Gtk.DrawingArea and on it we draw the text by means of Cairo.

Example:

#!/usr/bin/env python
from gi.repository import Gtk
import cairo

class MyWindow (Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self, title='MyWindow')

        darea = Gtk.DrawingArea()
        darea.connect('draw', self.on_draw)
        self.add(darea)

    def on_draw(self, widget, ctx):
        ctx.set_source_rgb(0, 0, 0)
        ctx.select_font_face("Sans", cairo.FONT_SLANT_NORMAL,
            cairo.FONT_WEIGHT_NORMAL)
        ctx.set_font_size(20)
        ctx.move_to(10, 20)
        ctx.show_text("Text...")

win = MyWindow()
win.connect('delete-event', Gtk.main_quit)
win.show_all()
Gtk.main()

At me everything perfectly works at Python 2.7, but only it is necessary to change Python for Python3 and the text isn’t drawn any more.
In what there can be a problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:49:12+00:00Added an answer on June 17, 2026 at 5:49 pm

    Had the same problem… turns out you’ll get no complaints if you’re missing a few packages.

    try apt-get install python3-gi-cairo and give it another try. Worked for me (including your code).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the simplest example: <textarea id=text_area name=text_area style=width:280px> </textarea> <input id=text_field name=text_field style=width:280px type=text
can any One Give me an example to create simplest navigation based application in
I am looking for the simplest example which shows one window opening another window
The simplest example would be the built in class keyValuePair(of T,U). I would like
The simplest example that I can provide for what I want to do is
can anybody post the simplest possible example for django-ajax-selects ? Just one model with
I'm trying to build simplest Boost.Asio tutorial example "timer1" (it's in timer.cpp) with waf
I am trying my hardest to find the simplest way to create a basic
I've run into this a few times now. I've tried to create the simplest
I have to create translations for the project I work on. The simplest solution

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.