From 716a8f9cb7953e37d276908a033d5b627b550a42 Mon Sep 17 00:00:00 2001 From: "Silas S. Brown" <ssb22@cam.ac.uk> Date: Fri, 2 Oct 2020 10:52:02 +0100 Subject: [PATCH] tweaks for Lubuntu 20.04 / LXQt --- gradint-build/Makefile | 2 +- gradint-build/src/booktime.py | 2 +- gradint-build/src/filescan.py | 2 +- gradint-build/src/frontend.py | 10 ++++++---- gradint-build/src/lessonplan.py | 2 +- gradint-build/src/loop.py | 2 +- gradint-build/src/makeevent.py | 2 +- gradint-build/src/play.py | 15 +++++++++++---- gradint-build/src/recording.py | 10 ++++++---- gradint-build/src/sequence.py | 2 +- gradint-build/src/synth.py | 2 +- gradint-build/src/system.py | 2 +- gradint-build/src/top.py | 2 +- gradint-build/src/users.py | 2 +- gradint-build/thindown.py | 2 +- 15 files changed, 35 insertions(+), 24 deletions(-) diff --git a/gradint-build/Makefile b/gradint-build/Makefile index 616d49e..0bbe023 100644 --- a/gradint-build/Makefile +++ b/gradint-build/Makefile @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v3.04 (c) 2002-20 Silas S. Brown. GPL v3+. +# gradint v3.05 (c) 2002-20 Silas S. Brown. GPL v3+. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or diff --git a/gradint-build/src/booktime.py b/gradint-build/src/booktime.py index a245781..f0907d7 100644 --- a/gradint-build/src/booktime.py +++ b/gradint-build/src/booktime.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v3.04 (c) 2002-20 Silas S. Brown. GPL v3+. +# gradint v3.05 (c) 2002-20 Silas S. Brown. GPL v3+. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or diff --git a/gradint-build/src/filescan.py b/gradint-build/src/filescan.py index 87f8a0a..1923d49 100644 --- a/gradint-build/src/filescan.py +++ b/gradint-build/src/filescan.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v3.04 (c) 2002-20 Silas S. Brown. GPL v3+. +# gradint v3.05 (c) 2002-20 Silas S. Brown. GPL v3+. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or diff --git a/gradint-build/src/frontend.py b/gradint-build/src/frontend.py index db881ac..ce7a25a 100644 --- a/gradint-build/src/frontend.py +++ b/gradint-build/src/frontend.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v3.04 (c) 2002-20 Silas S. Brown. GPL v3+. +# gradint v3.05 (c) 2002-20 Silas S. Brown. GPL v3+. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or @@ -378,6 +378,8 @@ def setupScrollbar(parent,rowNo): onLeft = winCEsound or olpc s = Tkinter.Scrollbar(parent,takefocus=0) s.grid(row=rowNo,column=cond(onLeft,0,1),sticky="ns"+cond(onLeft,"w","e")) + try: parent.rowconfigure(rowNo,weight=1) + except: pass c=Tkinter.Canvas(parent,bd=0,width=200,height=100,yscrollcommand=s.set) c.grid(row=rowNo,column=cond(onLeft,1,0),sticky="nsw") s.config(command=c.yview) @@ -501,7 +503,7 @@ def startTk(): self.extra_button_callables = [] self.pack(fill=Tkinter.BOTH,expand=1) self.leftPanel = Tkinter.Frame(self) - self.leftPanel.pack(side="left",fill=Tkinter.X,expand=1) # "fill" needed so listbox can fill later + self.leftPanel.pack(side="left",fill=Tkinter.BOTH,expand=1) self.rightPanel = None # for now self.cancelling = 0 # guard against multiple presses of Cancel self.Label = Tkinter.Label(self.leftPanel,text="Please wait a moment") @@ -1230,7 +1232,7 @@ if useTK: if sys.version.startswith("2.3.5") and "DISPLAY" in os.environ: explorerCommand = None # 'open' doesn't seem to work when running from within Python in X11 on 10.4 else: explorerCommand="open" elif unix: - if "KDE_FULL_SESSION" is os.environ and got_program("kfmclient"): + if "KDE_FULL_SESSION" in os.environ and got_program("kfmclient"): # looks like we're in a KDE session and can use the kfmclient command textEditorCommand=explorerCommand="kfmclient exec" elif not olpc and got_program("gnome-open"): @@ -1242,7 +1244,7 @@ if useTK: # (TODO if both rox and gnome are available, can we tell which one the user prefers?) explorerCommand="rox" # anyway, see if we can find a nice editor - for editor in ["leafpad","gedit","nedit","kedit","xedit"]: + for editor in ["leafpad","featherpad","gedit","nedit","kedit","xedit"]: if got_program(editor): textEditorName=textEditorCommand=editor textEditorWaits = 1 diff --git a/gradint-build/src/lessonplan.py b/gradint-build/src/lessonplan.py index 188765d..4570320 100644 --- a/gradint-build/src/lessonplan.py +++ b/gradint-build/src/lessonplan.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v3.04 (c) 2002-20 Silas S. Brown. GPL v3+. +# gradint v3.05 (c) 2002-20 Silas S. Brown. GPL v3+. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or diff --git a/gradint-build/src/loop.py b/gradint-build/src/loop.py index 7205c3b..8d6d01f 100644 --- a/gradint-build/src/loop.py +++ b/gradint-build/src/loop.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v3.04 (c) 2002-20 Silas S. Brown. GPL v3+. +# gradint v3.05 (c) 2002-20 Silas S. Brown. GPL v3+. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or diff --git a/gradint-build/src/makeevent.py b/gradint-build/src/makeevent.py index b814afe..fa9fa20 100644 --- a/gradint-build/src/makeevent.py +++ b/gradint-build/src/makeevent.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v3.04 (c) 2002-20 Silas S. Brown. GPL v3+. +# gradint v3.05 (c) 2002-20 Silas S. Brown. GPL v3+. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or diff --git a/gradint-build/src/play.py b/gradint-build/src/play.py index 6c3e565..2d5c4f8 100644 --- a/gradint-build/src/play.py +++ b/gradint-build/src/play.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v3.04 (c) 2002-20 Silas S. Brown. GPL v3+. +# gradint v3.05 (c) 2002-20 Silas S. Brown. GPL v3+. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or @@ -156,14 +156,18 @@ if winsound or mingw32: # TODO now that we (usually) have tkSnack bundled with the Windows version, can we try that also (with file=) before sndrec32? if not wavPlayer and fileExists(os.environ.get("windir","C:\\Windows")+"\\system32\\sndrec32.exe"): wavPlayer = "start /min sndrec32 /play /close" # TODO could also use ShellExecute or some other utility to make it completely hidden elif unix and not macsound: - sox_type = "-t ossdsp -s "+sox_16bit # (we will check that sox can do ossdsp below) (always specify 16-bit because if we're adjusting the volume of 8-bit wav's then we could lose too many bits in the adjustment unless we first convert to 16-bit) + sox_type = "-t ossdsp "+sox_signed+" "+sox_16bit # (we will check that sox can do ossdsp below) (always specify 16-bit because if we're adjusting the volume of 8-bit wav's then we could lose too many bits in the adjustment unless we first convert to 16-bit) if not soundVolume==1: sox_effect=" vol "+str(soundVolume) if sox_effect and not gotSox: show_warning("Warning: trying to adjust soundVolume when 'sox' is not on the system might not work") # (need a warning here, because if using 'aplay' then sox o/p is 2>/dev/null (see below) so a missing sox won't be obvious) + if sox_formats.find("alsa")>=0 and isDirectory("/dev/snd"): + sox_type=sox_type.replace("ossdsp","alsa") + oss_sound_device = "hw:0,0" if not oss_sound_device: dsps_to_check = [] - if sox_formats.find("ossdsp")>=0: dsps_to_check += ["/dev/sound/dsp","/dev/dsp"] + if sox_formats.find("ossdsp")>=0: + dsps_to_check += ["/dev/sound/dsp","/dev/dsp"] if sox_formats.find("sunau")>=0: dsps_to_check += ["/dev/audio"] for dsp in dsps_to_check: if fileExists_stat(dsp): @@ -421,7 +425,10 @@ def lengthOfSound(file): def pcmlen(file): header = sndhdr.what(file) - if not header: raise IOError("Problem opening file '%s'" % (file,)) + if not header: + # some Python 3 installations seem less able to run sndhdr + if gotSox: return len(readB(os.popen("sox \""+file+"\" -t raw "+sox_8bit+" "+sox_signed+" -c 1 -r 8000 - ",popenRB)))/8000.0 + else: raise IOError("sndhdr can't analyse file '%s'" % (file,)) (wtype,wrate,wchannels,wframes,wbits) = header if android: if wrate==6144: # might be a .3gp from android_recordFile diff --git a/gradint-build/src/recording.py b/gradint-build/src/recording.py index b2f01e1..19f42f6 100644 --- a/gradint-build/src/recording.py +++ b/gradint-build/src/recording.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v3.04 (c) 2002-20 Silas S. Brown. GPL v3+. +# gradint v3.05 (c) 2002-20 Silas S. Brown. GPL v3+. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or @@ -51,7 +51,7 @@ class PlayerInput(InputSource): # play to speakers while recording to various de global paranoid_file_management if use_unicode_filenames: fileToPlay=ensure_unicode(fileToPlay) else: - assert not type(fileToPlay)==type(u"") + assert type(fileToPlay)==type("") if not paranoid_file_management and filter(lambda x:ord(x)>=128,list(fileToPlay)): paranoid_file_management = True # hack to try to work around a Tkinter fault on Linux with utf-8 filenames if paranoid_file_management: # try to ensure it's ready for reading if filelen(fileToPlay)<1048576: @@ -86,7 +86,8 @@ class PlayerInput(InputSource): # play to speakers while recording to various de elapsedTime = self.elapsedTime() if elapsedTime>=self.length-self.startSample*1.0/self.sampleRate: self.close() else: - import thread + try: import thread + except ImportError: import _thread as thread def stopMe(self,thread_id,elapsedTime): time.sleep(max(0.5,self.length-self.startSample*1.0/self.sampleRate-elapsedTime)) self.autostop(thread_id) @@ -678,7 +679,8 @@ class RecorderControls(ButtonScrollingMixin): app.scanrow.set("0") self.reconfigure_scrollbar() if tkSnack: theISM.setInputSource(MicInput()) - self.frame=Tkinter.Frame(app.leftPanel) ; self.frame.pack() + self.frame=Tkinter.Frame(app.leftPanel) + self.frame.pack(fill=Tkinter.Y,expand=1) self.need_reRecord_enabler = 0 # no previously-existing words yet (when we get existing words we 'lock' them and have to unlock by pressing a global 'rerecord' button 1st, just in case) diff --git a/gradint-build/src/sequence.py b/gradint-build/src/sequence.py index 3c9f991..e58f5c1 100644 --- a/gradint-build/src/sequence.py +++ b/gradint-build/src/sequence.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v3.04 (c) 2002-20 Silas S. Brown. GPL v3+. +# gradint v3.05 (c) 2002-20 Silas S. Brown. GPL v3+. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or diff --git a/gradint-build/src/synth.py b/gradint-build/src/synth.py index a12cc7f..98b0654 100644 --- a/gradint-build/src/synth.py +++ b/gradint-build/src/synth.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v3.04 (c) 2002-20 Silas S. Brown. GPL v3+. +# gradint v3.05 (c) 2002-20 Silas S. Brown. GPL v3+. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or diff --git a/gradint-build/src/system.py b/gradint-build/src/system.py index 8276d6d..f9ad43a 100644 --- a/gradint-build/src/system.py +++ b/gradint-build/src/system.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v3.04 (c) 2002-20 Silas S. Brown. GPL v3+. +# gradint v3.05 (c) 2002-20 Silas S. Brown. GPL v3+. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or diff --git a/gradint-build/src/top.py b/gradint-build/src/top.py index 44b70b0..5eb5f8c 100644 --- a/gradint-build/src/top.py +++ b/gradint-build/src/top.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # (Python 2 or Python 3, but more fully tested on 2) -program_name = "gradint v3.04 (c) 2002-20 Silas S. Brown. GPL v3+." +program_name = "gradint v3.05 (c) 2002-20 Silas S. Brown. GPL v3+." # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gradint-build/src/users.py b/gradint-build/src/users.py index 44d82ff..1539079 100644 --- a/gradint-build/src/users.py +++ b/gradint-build/src/users.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v3.04 (c) 2002-20 Silas S. Brown. GPL v3+. +# gradint v3.05 (c) 2002-20 Silas S. Brown. GPL v3+. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or diff --git a/gradint-build/thindown.py b/gradint-build/thindown.py index 4872d0d..b12eb56 100644 --- a/gradint-build/thindown.py +++ b/gradint-build/thindown.py @@ -1,5 +1,5 @@ # This file is part of the source code of -# gradint v3.04 (c) 2002-20 Silas S. Brown. GPL v3+. +# gradint v3.05 (c) 2002-20 Silas S. Brown. GPL v3+. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or -- GitLab