File: sampleapp.py

package info (click to toggle)
rednotebook 2.29.3%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,704 kB
  • sloc: python: 9,377; javascript: 4,103; xml: 155; sh: 68; makefile: 11
file content (51 lines) | stat: -rwxr-xr-x 1,302 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import gi

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

print("Gtk import works")

from gi.repository import GObject

print("GObject import works")

try:
    gi.require_version("GtkSource", "4")
    print("Using GtkSourceView 4")
except ValueError:
    gi.require_version("GtkSource", "3.0")
    print("Using GtkSourceView 3.0")
from gi.repository import GtkSource

print("GtkSource import works")


# Copied from ctypes module.
def find_library(name):
    import os

    print("PATH:", os.environ["PATH"])
    for directory in os.environ["PATH"].split(os.pathsep):
        fname = os.path.join(directory, name)
        print("Check directory", directory)
        print("Check filename", fname, os.path.isfile(fname))
        if os.path.isfile(fname):
            return fname
        if fname.lower().endswith(".dll"):
            continue
        fname = fname + ".dll"
        print("Check filename", fname, os.path.isfile(fname))
        if os.path.isfile(fname):
            return fname
    return None


find_library("libenchant")

import enchant

print("Languages:", enchant.list_languages())
print("Dictionaries:", enchant.list_dicts())
print("Enchant import works")
assert enchant.list_languages() and enchant.list_dicts()
print("Enchant finds languages and dictionaries")