1 # -*- coding: utf-8 -*-
2 #Author: Pierre Ratinaud
3 #Copyright (c) 2008-2020 Pierre Ratinaud
4 #modification pour python 3 : Laurent Mérat, 6x7 - mai 2020
7 #------------------------------------
8 # import des modules python
9 #------------------------------------
12 from time import sleep
14 #------------------------------------
15 # import des modules wx
16 #------------------------------------
19 #------------------------------------
20 # import des fichiers du projet
21 #------------------------------------
22 from chemins import ffr, ConstructAfcmPath, ConstructPathOut
23 from functions import exec_rcode, check_Rresult
24 from ProfList import *
25 from dialog import PrefQuestAlc
30 def __init__(self, parent, LISTNUMACTIVE, LISTVARSUP):
34 self.tempgraph = tempfile.mktemp(dir=parent.TEMPDIR)
35 #if parent.g_id: rownames = '1'
36 #else : rownames = 'NULL'
37 #if parent.g_header : header = 'TRUE'
38 #else : header = 'FALSE'
40 datadm <- read.table("%s", header = TRUE, sep = ';', quote='"', encoding="%s",row.names=1)
41 """ % (ffr(parent.tableau.parametre['csvfile']), parent.tableau.parametre['encodage'])
42 if len(LISTVARSUP) == 1 :
43 strlistsup = str(tuple(LISTVARSUP)).replace(',', '')
45 strlistsup = str(tuple(LISTVARSUP))
46 if len(LISTNUMACTIVE) == 1:
47 strlistact = str(tuple(LISTNUMACTIVE)).replace(',', '')
49 strlistact = str(tuple(LISTNUMACTIVE))
52 """ % self.parent.RscriptsPath['Rgraph']
61 """ % ffr(self.tempgraph)
62 #FIXME : faire une fonction pour le graph
65 dataact<-datadm[,lact]
66 act <- mca(dataact, abbrev = TRUE)
67 datasup<-datadm[,lsup]
68 sup <- predict(act, datasup, type="factor")
69 ftab<-cbind(dataact,datasup)
72 #debs<-ncol(dataact)+1
73 #fins<-ncol(dataact)+ncol(datasup)
74 #ftab.mjca<-mjca(ftab,supcol=c(debs:fins),nd=3)
75 open_file_graph(filename, width = 800, height = 800)
81 tmpfile = tempfile.mktemp(dir=parent.TEMPDIR)
82 tmpscript = open(tmpfile, 'w')
85 pid = exec_rcode(self.parent.RPath, tmpfile, wait = False)
86 while pid.poll() == None :
88 check_Rresult(self.parent, pid)
92 txt = '<img src="%s" />' % self.tempgraph
95 # def OnRGL(self, event):
96 # self.parent.text_ctrl_1.write('runrgl\n')
97 # RAFC3DRGL = os.path.join(self.PathFile, self.RAFC3DRGL)
103 def __init__(self, parent):
104 dlg = PrefQuestAlc(parent, sim = True)
105 #dlg = CHDDialog(parent, -1, u"AFCM", size=(350, 400), style=wx.DEFAULT_DIALOG_STYLE)
107 self.val = dlg.ShowModal()
108 if self.val == wx.ID_OK:
109 LISTNUMACTIVE = dlg.nactives
110 LISTVARSUP = dlg.varsup
113 afcm = AFCMQ(parent, LISTNUMACTIVE, LISTVARSUP)
114 txtgraph = afcm.DoLayout()
115 parent.newtab = wx.html.HtmlWindow(parent.nb, -1)
116 if "gtk2" in wx.PlatformInfo:
117 parent.newtab.SetStandardFonts()
118 parent.newtab.SetPage(txtgraph)
119 parent.nb.AddPage(parent.newtab, "AFCM")
120 parent.nb.SetSelection(parent.nb.GetPageCount() - 1)
121 parent.ShowTab(wx.EVT_BUTTON)