From c0084794c30658ff5b285f916927c4463aaef689 Mon Sep 17 00:00:00 2001 From: Philippe Roy <2550090-phroy@users.noreply.gitlab.com> Date: Mon, 30 Jan 2023 06:36:11 +0000 Subject: [PATCH] Qt6 pour GNU/Linux et wxPython pour Windows --- twin.py | 8 ++++++-- twin_daq.py | 15 +++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/twin.py b/twin.py index fd9f1e0..db6cf51 100644 --- a/twin.py +++ b/twin.py @@ -453,7 +453,7 @@ def manip(cont): # Zoom ## -def manip_wheel(cont): +def manip_wheel(cont): obj = cont.owner sensibilite_wheel = 20 if cont.sensors['WheelUp'].positive: @@ -473,7 +473,11 @@ def file_open(): scene.objects['System']['file_proc'].terminate() # Démarrer le processus file - scene.objects['System']['file_proc'] = subprocess.Popen([sys.executable, os.path.join(os.getcwd(), "twin_file_qt.py")], stdout=subprocess.PIPE, encoding = 'utf8') + if sys.platform=="linux": # wxPython ne s'installe pas bien sur GNU/linux -> Qt6 + scene.objects['System']['file_proc'] = subprocess.Popen([sys.executable, os.path.join(os.getcwd(), "twin_file_qt.py")], stdout=subprocess.PIPE, encoding = 'utf8') + else: # Qt6 ne s'installe pas bien sur Windows -> wxPython + scene.objects['System']['file_proc'] = subprocess.Popen([sys.executable, os.path.join(os.getcwd(), "twin_file_wx.py")], stdout=subprocess.PIPE, encoding = 'utf8') + stout = scene.objects['System']['file_proc'].communicate() if stout[0][:-1] != 'None': scene.objects['System']['script'] = stout[0][:-1] diff --git a/twin_daq.py b/twin_daq.py index a00ce97..167810c 100644 --- a/twin_daq.py +++ b/twin_daq.py @@ -86,7 +86,7 @@ def localize_floats(row): # Génération du fichier ## -def csv_generate(): +def csv_generate(): scene.objects['System']['daq']=False fichier_csv=os.path.join(os.path.split((scene.objects['System']['script']))[0], scene.objects['System']['system']+'.csv') scene.objects['Cmd-text']['modal']= True @@ -105,7 +105,7 @@ def csv_generate(): # Création du fichier twin_plot.xml (configuration du graphique) ## -def plot_config_generate(data_groups): +def plot_config_generate(data_groups): # Création du XML daq_config_list=list(daq_config) @@ -150,7 +150,7 @@ def plot_config_generate(data_groups): # Activation du mode Plot ## -def plot(data_groups): +def plot(data_groups): plot_config_generate(data_groups) scene.objects['System']['plot']=True @@ -159,11 +159,14 @@ def plot(data_groups): # Threading -> reste actif après le Stop ## -def plot_generate_thread(csv_file): - command = sys.executable + " " + os.path.join(sys.executable, os.getcwd(), "twin_plot_qt.py") + " "+ csv_file +def plot_generate_thread(csv_file): + if sys.platform=="linux": # wxPython ne s'installe pas bien sur GNU/linux -> Qt6 + command = sys.executable + " " + os.path.join(sys.executable, os.getcwd(), "twin_plot_qt.py") + " "+ csv_file + else: # Qt6 ne s'installe pas bien sur Windows -> wxPython + command = sys.executable + " " + os.path.join(sys.executable, os.getcwd(), "twin_plot_wx.py") + " "+ csv_file os.system(command) -def plot_generate(threads): +def plot_generate(threads): csv_file=os.path.join(os.path.split((scene.objects['System']['script']))[0], scene.objects['System']['system']+'.csv') threads.append(threading.Thread(target=plot_generate_thread, args=(csv_file,))) threads[len(threads)-1].start()