Skip to content

Commit 77933d8

Browse files
committed
Fix the issues with pathfinding
1 parent 77723eb commit 77933d8

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

generic/gttk_Init.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ extern void gttk_DestroyGtkApp(void);
1717

1818
static char initScript[] =
1919
"namespace eval gttk { };"
20-
"namespace eval ttk::theme::gttk { variable version "
21-
PACKAGE_VERSION " };"
20+
"namespace eval ttk::theme::gttk { variable version " PACKAGE_VERSION " };"
2221
"tcl_findLibrary gttk $ttk::theme::gttk::version "
23-
"$ttk::theme::gttk::version gttk.tcl GTTK_LIBRARY gttk::library;";
22+
"$ttk::theme::gttk::version [file join [pwd] gttk.tcl] GTTK_LIBRARY gttk::library;";
2423
#ifdef GTTK_LOAD_GTK_DYNAMICALLY
2524
static char libsInitScript[] =
2625
"ttk::theme::gttk::loadLibraries";
@@ -739,7 +738,7 @@ int gttk_SetStyle(ClientData clientData, Tcl_Interp *interp,
739738
}; /* gttk_SetStyle */
740739

741740
extern "C" int DLLEXPORT
742-
gttk_Init(Tcl_Interp *interp)
741+
_Gttk_Init(Tcl_Interp *interp)
743742
{
744743
Ttk_Theme themePtr;
745744
Tk_Window tkwin;
@@ -876,7 +875,7 @@ gttk_Init(Tcl_Interp *interp)
876875
}; /* gttk_Init */
877876

878877
int DLLEXPORT
879-
gttk_Finish(Tcl_Interp *interp)
878+
Gttk_Finish(Tcl_Interp *interp)
880879
{
881880
Tcl_MutexLock(&gttkMutex);
882881
if (gttk_GtkAppCreated < 0) {Tcl_MutexUnlock(&gttkMutex); return 0;}

gttk/__init__.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,20 @@
33
License: GNU GPLv3
44
Copyright (c) 2020 RedFantom
55
"""
6+
import contextlib
67
import os
78
from tkinter import ttk
89

910

11+
@contextlib.contextmanager
12+
def chdir(target):
13+
cwd = os.getcwd()
14+
try:
15+
os.chdir(target)
16+
yield
17+
finally:
18+
os.chdir(cwd)
19+
1020
__orig_ttk_Style_init__ = ttk.Style.__init__
1121

1222

@@ -15,8 +25,9 @@ def __ttk_Style_init__(self, *args, **kwargs):
1525

1626
folder = os.path.dirname(os.path.abspath(__file__))
1727

18-
self.tk.eval("set dir {0}; source {0}/pkgIndex.tcl".format(folder))
19-
self.tk.call("package", "require", "ttk::theme::gttk")
28+
with chdir(folder):
29+
self.tk.eval("set dir {0}; source {0}/pkgIndex.tcl".format(folder))
30+
self.tk.call("package", "require", "ttk::theme::gttk")
2031

2132

2233
ttk.Style.__init__ = __ttk_Style_init__

0 commit comments

Comments
 (0)