Skip to content

Commit

Permalink
GUI: fix for Python3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
petrasovaa committed Nov 5, 2024
1 parent 039183d commit d1d88cf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
34 changes: 20 additions & 14 deletions gui/wxpython/core/gconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ def SetId(self, id):
def run(self):
os.environ["GRASS_MESSAGE_FORMAT"] = "gui"
while True:
variables = {
"callable": None,
"onDone": None,
"onPrepare": None,
"userData": None,
"addLayer": None,
"notification": None,
}
requestId, args, kwds = self.requestQ.get()
for key in (
"callable",
Expand All @@ -130,13 +138,11 @@ def run(self):
"notification",
):
if key in kwds:
vars()[key] = kwds[key]
variables[key] = kwds[key]
del kwds[key]
else:
vars()[key] = None

if not vars()["callable"]:
vars()["callable"] = GrassCmd
if not variables["callable"]:
variables["callable"] = GrassCmd

requestTime = time.time()

Expand All @@ -146,21 +152,21 @@ def run(self):
cmd=args[0],
time=requestTime,
pid=requestId,
onPrepare=vars()["onPrepare"],
userData=vars()["userData"],
onPrepare=variables["onPrepare"],
userData=variables["userData"],
)

wx.PostEvent(self.receiver, event)

# run command
event = wxCmdRun(
cmd=args[0], pid=requestId, notification=vars()["notification"]
cmd=args[0], pid=requestId, notification=variables["notification"]
)

wx.PostEvent(self.receiver, event)

time.sleep(0.1)
self.requestCmd = vars()["callable"](*args, **kwds)
self.requestCmd = variables["callable"](*args, **kwds)
if self._want_abort_all and self.requestCmd is not None:
self.requestCmd.abort()
if self.requestQ.empty():
Expand Down Expand Up @@ -211,7 +217,7 @@ def run(self):
"map=%s" % mapName,
"color=%s" % colorTable,
]
self.requestCmdColor = vars()["callable"](*argsColor, **kwds)
self.requestCmdColor = variables["callable"](*argsColor, **kwds)
self.resultQ.put((requestId, self.requestCmdColor.run()))

if self.receiver:
Expand All @@ -221,10 +227,10 @@ def run(self):
returncode=returncode,
time=requestTime,
pid=requestId,
onDone=vars()["onDone"],
userData=vars()["userData"],
addLayer=vars()["addLayer"],
notification=vars()["notification"],
onDone=variables["onDone"],
userData=variables["userData"],
addLayer=variables["addLayer"],
notification=variables["notification"],
)

# send event
Expand Down
18 changes: 11 additions & 7 deletions gui/wxpython/core/gthread.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,25 @@ def SetId(self, id):
gThread.requestId = id

def run(self):
variables = {
"callable": None,
"ondone": None,
"userdata": None,
"onterminate": None,
}
while True:
requestId, args, kwds = self.requestQ.get()
for key in ("callable", "ondone", "userdata", "onterminate"):
if key in kwds:
vars()[key] = kwds[key]
variables[key] = kwds[key]
del kwds[key]
else:
vars()[key] = None

ret = None
exception = None
time.sleep(0.01)

self._terminate_evt = wxThdTerminate(
onterminate=vars()["onterminate"],
onterminate=variables["onterminate"],
kwds=kwds,
args=args,
pid=requestId,
Expand All @@ -109,7 +113,7 @@ def run(self):
if self.terminate:
return

ret = vars()["callable"](*args, **kwds)
ret = variables["callable"](*args, **kwds)

if self.terminate:
return
Expand All @@ -119,12 +123,12 @@ def run(self):
self.resultQ.put((requestId, ret))

event = wxCmdDone(
ondone=vars()["ondone"],
ondone=variables["ondone"],
kwds=kwds,
args=args, # TODO expand args to kwds
ret=ret,
exception=exception,
userdata=vars()["userdata"],
userdata=variables["userdata"],
pid=requestId,
)

Expand Down

0 comments on commit d1d88cf

Please sign in to comment.