importing Gtk 3+ on mac for python 3

559 Views Asked by At

I am currently trying to develop a simple instant messenger with a GUI based in Gtk+3. I am using PyCharm on OS X. I read this post, but I already have gtk+3 and pygobject3 installed (I attempted to [again] install them with Homebrew but I got the messages: "gtk+3 3.22.19 is already installed" and "pygobject3 3.24.1_1 is already installed"). My code thus far:

import threading
import re

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

import gobject
import socket
import time
import datetime

gobject.threads_init()

class MainWindow(Gtk.Window):

My specific concerns are that in PyCharm, require_version is highlighted, saying "Cannot find reference 'require_version' in __init__.py, repository is highlighted saying "Cannot find reference 'repository' in __init__.py, and Gtk is underlined saying "Unresolved refernce 'Gtk'. I am unsure as to why, however, there is no protest when I type Gtk.Window or Gtk.Entry() [snipped]. My final concern is that threads_init() is highlighted, again saying "Cannot find reference 'threads_init()' in __init__.py. Could someone offer some insight as to what is wrong? I have done a good amount of research, but I have found very little that fits my particular situation: Mac, python3, and the two modules already installed.

Secondary question: The guide I am using to write this code is written in python2, and I will be writing in python3, so does anyone know of a good source that would indicate the differences in Gtk between python2 and python3 (what is new, maybe) so I might be able to write the correct python3 version of the gtk code?

0

There are 0 best solutions below