File: sampleapp.py

package info (click to toggle)
rednotebook 2.39%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 5,956 kB
  • sloc: python: 9,570; javascript: 4,103; xml: 128; sh: 58; makefile: 11
file content (56 lines) | stat: -rwxr-xr-x 1,349 bytes parent folder | download | duplicates (2)
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
52
53
54
55
56
import gi


gi.require_version("Gtk", "3.0")
from gi.repository import Gtk  # noqa: F401


print("Gtk import works")

from gi.repository import GObject  # noqa: F401


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  # noqa: F401


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 = f"{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")