Exemplo n.º 1
0
 def invoke(self):
     '''
     Method for starting the controller
     '''
     
     self.searchThread = SearchThread(self.tweetqueue, self.database)
     self.mover = None
     
     self.root = Tk()
     self.root.resizable(FALSE,FALSE)
     
     self.root.after(5000, self.showNewTweetIfFound, self.root)
     
     seetweets = MainFrame("SeeTweets", self.root) 
     
     self.searchThread.addObserver(seetweets.handleException, events="exception")
     self.searchThread.addObserver(seetweets.statusChanged, events="statusChanged")
     
     #TODO: addObserverToElement ?
     seetweets.addObserverToHashEntry(self.searchThread.setQuery, events="queryChanged")
     
     self.root.protocol("WM_DELETE_WINDOW", self.safelyExitApplication)
     
     self.searchThread.start()
     
     self.root.mainloop()
Exemplo n.º 2
0
    def OnInit(self):

        wx.InitAllImageHandlers()

        F = wx.SplashScreen(wx.Bitmap("../icons/splash.bmp"),
                            wx.SPLASH_TIMEOUT | wx.SPLASH_CENTER_ON_SCREEN,
                            2000, None, -1)

        frame_EcranPrincipal = MainFrame(None,
                                         title=u"Usine à GASE",
                                         droits=1)
        self.SetTopWindow(frame_EcranPrincipal)
        frame_EcranPrincipal.Show()

        try:
            database = SqliteDatabase('usineagase.sqlite', **{})
            tables_base = database.get_tables()
        except:
            msg = u"Erreur de connection à la base de données"
            dlg = wx.MessageDialog(None, msg, "ERREUR",
                                   wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return 0

        tables_obligatoires = [
            u"achats", u"adherents", u"adhesion_types", u"adhesions",
            u"cotisations", u"categories", u"credits", u"commandes",
            u"exercices", u"fournisseurs", u"lignes_achat", u"lignes_commande",
            u"parametres", u"produits", u"referents", u"tvas"
        ]

        if set(tables_obligatoires) - set(tables_base):
            msg = u"Erreur : la base de données n'est pas accessible ou n'est pas conforme."
            dlg = wx.MessageDialog(None, msg, "ERREUR",
                                   wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return 0
        else:
            #query = session.query(model.Exercice).filter(model.Exercice.DateDebut<datetime.today()).filter(model.Exercice.DateFin>datetime.today())
            #Exercice.select().where(date_debut<datetime.today())

            #if query.count() == 1:
            #    EXERCICE_EN_COURS = query.first()

            return 1
Exemplo n.º 3
0
    def __init__(self, master, algo=None):

        Frame.__init__(self, master)

        # Options pour l'ouverture/sauvegarde des fichiers
        self.openfileoptions = dict()
        self.openfileoptions['filetypes'] = [('Fichier Mots croisés', '.mc'),
                                             ('Tout les fichiers', '.*')]
        self.openfileoptions['initialfile'] = 'ma_grille.mc'
        #self.openfileoptions['initialdir'] = GRILLE_PATH
        self.openfileoptions['parent'] = master

        # Queue pour les Threads
        self.thread_queue = Queue()

        self.createMenu()

        self.algo = Algo(algoName="AC3")
        self.algo.setQueue(self.thread_queue)
        self.mainFrame = MainFrame(self, self.algo, self.thread_queue)
        self.mainFrame.pack(fill=BOTH, expand=True)
        self.filename = None
Exemplo n.º 4
0
    def __init__(self, master, algo=None):

        Frame.__init__(self, master)

        # Options pour l'ouverture/sauvegarde des fichiers
        self.openfileoptions = dict()
        self.openfileoptions['filetypes'] = [('Fichier Mots croisés', '.mc'), ('Tout les fichiers', '.*')]
        self.openfileoptions['initialfile'] = 'ma_grille.mc'
        #self.openfileoptions['initialdir'] = GRILLE_PATH
        self.openfileoptions['parent'] = master

        # Queue pour les Threads
        self.thread_queue = Queue()

        self.createMenu()

        self.algo = Algo(algoName="AC3")
        self.algo.setQueue(self.thread_queue)
        self.mainFrame = MainFrame(self, self.algo, self.thread_queue)
        self.mainFrame.pack(fill=BOTH, expand=True)
        self.filename = None
Exemplo n.º 5
0
from gui.MainFrame import MainFrame

MainFrame().start()
Exemplo n.º 6
0
class Gui(Frame):

    def __init__(self, master, algo=None):

        Frame.__init__(self, master)

        # Options pour l'ouverture/sauvegarde des fichiers
        self.openfileoptions = dict()
        self.openfileoptions['filetypes'] = [('Fichier Mots croisés', '.mc'), ('Tout les fichiers', '.*')]
        self.openfileoptions['initialfile'] = 'ma_grille.mc'
        #self.openfileoptions['initialdir'] = GRILLE_PATH
        self.openfileoptions['parent'] = master

        # Queue pour les Threads
        self.thread_queue = Queue()

        self.createMenu()

        self.algo = Algo(algoName="AC3")
        self.algo.setQueue(self.thread_queue)
        self.mainFrame = MainFrame(self, self.algo, self.thread_queue)
        self.mainFrame.pack(fill=BOTH, expand=True)
        self.filename = None



    def update_Algo(self, arg0):
        self.algo.setAlgoName(arg0)
        self.mainFrame.setAlgo()


    def update_Dico(self):
        start = time.time()
        self.dico = Dico(self.dliste[self.radio_dico.get()-1])
        end = time.time() - start
        self.mainFrame.send_To_Trace("Création du dictionnaire "+self.dliste[self.radio_dico.get()-1].split("/")[-1]+" :"+str(end) + "\n", "temps")
        if self.algo.grille:
            self.algo.grille.updateDico(self.dico)

    def file_chooser(self):
        self.filename = None
        self.openfileoptions['initialdir'] = GRILLEVIDE_PATH
        self.filename = askopenfilename(**self.openfileoptions)
        if self.filename:
            self.Ggrille(self.filename)

    def Ggrille(self, file):
        self.algo.setGrille(Grille(filePath=file))
        self.algo.grille.updateDico(self.dico)
        self.setGrille()

    def genere_Grille(self):
        Up = Toplevel()
        Up.title("Générer Grille")

        li = IntVar()
        li.set(10)
        Label(Up, text ="Nombre de ligne :").grid(row=1, column=0, sticky="w")
        w = Scale(Up, from_=5, to=20, orient=HORIZONTAL, var=li)
        w.grid(row=1, column=1, sticky="w")

        col = IntVar()
        col.set(10)
        Label(Up, text ="Nombre de colonne :").grid(row=2, column=0, sticky="w")
        w = Scale(Up, from_=5, to=20, orient=HORIZONTAL, var=col)
        w.grid(row=2, column=1, sticky="w")

        nbN = IntVar()
        nbN.set(30)
        Label(Up, text ="% de case noir :").grid(row=3, column=0, sticky="w")
        w = Scale(Up, from_=10, to=50, orient=HORIZONTAL, var=nbN)
        w.grid(row=3, column=1, sticky="w")


        button = Button(Up, text ="Créer la Grille", command = Up.destroy).grid(row =5,columnspan=2, sticky=N+S+E+W)

        Up.wait_window()
        self.algo.setGrille(Grille(taille=(li.get(),col.get()),alea=True, percent=nbN.get()))
        self.algo.grille.updateDico(self.dico)
        self.setGrille()

    def file_saver(self):
        self.openfileoptions['initialdir'] = GRILLEPLEIN_PATH
        if self.algo.grille:
            self.openfileoptions['initialfile'] = str(self.algo.grille.nomGrille)+"_"+str(self.algo.algoName)
        filename = asksaveasfilename(**self.openfileoptions)
        if filename and self.algo.grille:
            self.algo.grille.sauvegarder_grille(filename)

    def setGrille(self):
        self.mainFrame.open_grille()

    def createMenu(self):
        menubar = Menu(self.master)

        filemenu = Menu(menubar, tearoff=0)
        algomenu = Menu(menubar, tearoff=0)
        dicomenu = Menu(menubar, tearoff=0)

        newGrilleMenu = Menu(menubar, tearoff=0)
        newGrilleMenu.add_command(label="Ouvrir Grille", command=self.file_chooser)

        newGrilleMenu.add_command(label="Générer Grille", command=self.genere_Grille)

        filemenu.add_cascade(label="Nouvelle grille", menu=newGrilleMenu)
        filemenu.add_cascade(label="Sauver Grille", command=self.file_saver)
        filemenu.add_separator()
        filemenu.add_command(label="Quitter", command=self.master.quit)

        self.radio_algo = StringVar()
        algomenu.add_radiobutton(label="Arc-Consistance 3", variable=self.radio_algo, value=1,
                                 command=lambda arg0="AC3": self.update_Algo(arg0))
        algomenu.add_radiobutton(label="Forward Checking", variable=self.radio_algo, value=2,
                                 command=lambda arg0="FC": self.update_Algo(arg0))
        algomenu.add_radiobutton(label="Forward Checking avec AC3", variable=self.radio_algo, value=3,
                                 command=lambda arg0="FC_AC3": self.update_Algo(arg0))

        algomenu.add_radiobutton(label="Conflict BackJumping avec AC3", variable=self.radio_algo, value=4,
                                 command=lambda arg0="CBJ_AC3": self.update_Algo(arg0))
        algomenu.add_radiobutton(label="Conflict BackJumping", variable=self.radio_algo, value=5,
                                 command=lambda arg0="CBJ": self.update_Algo(arg0))
        algomenu.add_radiobutton(label="Branch & Bound Valué", variable=self.radio_algo, value=6,
                                 command=lambda arg0="VAL": self.update_Algo(arg0))

        self.radio_algo.set(1)

        self.radio_dico = IntVar()
        self.listDico = []
        self.dliste = []
        for dirname, dirnames, filenames in os.walk(DICO_PATH):
            for filename in filenames:
                self.dliste += ["".join([DICO_PATH, filename])]
                self.listDico += [filename[:-4]]

        i = 1
        for l in self.listDico:
            dicomenu.add_radiobutton(label=l, variable=self.radio_dico, value=i, command=self.update_Dico)
            i += 1

        self.radio_dico.set(5)
        menubar.add_cascade(label="Fichier", menu=filemenu)
        menubar.add_cascade(label="Algorithme", menu=algomenu)
        menubar.add_cascade(label="Dictionnaire", menu=dicomenu)

        self.dico = Dico(self.dliste[self.radio_dico.get()-1])

        self.master.config(menu=menubar)
Exemplo n.º 7
0
class Gui(Frame):
    def __init__(self, master, algo=None):

        Frame.__init__(self, master)

        # Options pour l'ouverture/sauvegarde des fichiers
        self.openfileoptions = dict()
        self.openfileoptions['filetypes'] = [('Fichier Mots croisés', '.mc'),
                                             ('Tout les fichiers', '.*')]
        self.openfileoptions['initialfile'] = 'ma_grille.mc'
        #self.openfileoptions['initialdir'] = GRILLE_PATH
        self.openfileoptions['parent'] = master

        # Queue pour les Threads
        self.thread_queue = Queue()

        self.createMenu()

        self.algo = Algo(algoName="AC3")
        self.algo.setQueue(self.thread_queue)
        self.mainFrame = MainFrame(self, self.algo, self.thread_queue)
        self.mainFrame.pack(fill=BOTH, expand=True)
        self.filename = None

    def update_Algo(self, arg0):
        self.algo.setAlgoName(arg0)
        self.mainFrame.setAlgo()

    def update_Dico(self):
        start = time.time()
        self.dico = Dico(self.dliste[self.radio_dico.get() - 1])
        end = time.time() - start
        self.mainFrame.send_To_Trace(
            "Création du dictionnaire " +
            self.dliste[self.radio_dico.get() - 1].split("/")[-1] + " :" +
            str(end) + "\n", "temps")
        if self.algo.grille:
            self.algo.grille.updateDico(self.dico)

    def file_chooser(self):
        self.filename = None
        self.openfileoptions['initialdir'] = GRILLEVIDE_PATH
        self.filename = askopenfilename(**self.openfileoptions)
        if self.filename:
            self.Ggrille(self.filename)

    def Ggrille(self, file):
        self.algo.setGrille(Grille(filePath=file))
        self.algo.grille.updateDico(self.dico)
        self.setGrille()

    def genere_Grille(self):
        Up = Toplevel()
        Up.title("Générer Grille")

        li = IntVar()
        li.set(10)
        Label(Up, text="Nombre de ligne :").grid(row=1, column=0, sticky="w")
        w = Scale(Up, from_=5, to=20, orient=HORIZONTAL, var=li)
        w.grid(row=1, column=1, sticky="w")

        col = IntVar()
        col.set(10)
        Label(Up, text="Nombre de colonne :").grid(row=2, column=0, sticky="w")
        w = Scale(Up, from_=5, to=20, orient=HORIZONTAL, var=col)
        w.grid(row=2, column=1, sticky="w")

        nbN = IntVar()
        nbN.set(30)
        Label(Up, text="% de case noir :").grid(row=3, column=0, sticky="w")
        w = Scale(Up, from_=10, to=50, orient=HORIZONTAL, var=nbN)
        w.grid(row=3, column=1, sticky="w")

        button = Button(Up, text="Créer la Grille",
                        command=Up.destroy).grid(row=5,
                                                 columnspan=2,
                                                 sticky=N + S + E + W)

        Up.wait_window()
        self.algo.setGrille(
            Grille(taille=(li.get(), col.get()), alea=True, percent=nbN.get()))
        self.algo.grille.updateDico(self.dico)
        self.setGrille()

    def file_saver(self):
        self.openfileoptions['initialdir'] = GRILLEPLEIN_PATH
        if self.algo.grille:
            self.openfileoptions['initialfile'] = str(
                self.algo.grille.nomGrille) + "_" + str(self.algo.algoName)
        filename = asksaveasfilename(**self.openfileoptions)
        if filename and self.algo.grille:
            self.algo.grille.sauvegarder_grille(filename)

    def setGrille(self):
        self.mainFrame.open_grille()

    def createMenu(self):
        menubar = Menu(self.master)

        filemenu = Menu(menubar, tearoff=0)
        algomenu = Menu(menubar, tearoff=0)
        dicomenu = Menu(menubar, tearoff=0)

        newGrilleMenu = Menu(menubar, tearoff=0)
        newGrilleMenu.add_command(label="Ouvrir Grille",
                                  command=self.file_chooser)

        newGrilleMenu.add_command(label="Générer Grille",
                                  command=self.genere_Grille)

        filemenu.add_cascade(label="Nouvelle grille", menu=newGrilleMenu)
        filemenu.add_cascade(label="Sauver Grille", command=self.file_saver)
        filemenu.add_separator()
        filemenu.add_command(label="Quitter", command=self.master.quit)

        self.radio_algo = StringVar()
        algomenu.add_radiobutton(
            label="Arc-Consistance 3",
            variable=self.radio_algo,
            value=1,
            command=lambda arg0="AC3": self.update_Algo(arg0))
        algomenu.add_radiobutton(
            label="Forward Checking",
            variable=self.radio_algo,
            value=2,
            command=lambda arg0="FC": self.update_Algo(arg0))
        algomenu.add_radiobutton(
            label="Forward Checking avec AC3",
            variable=self.radio_algo,
            value=3,
            command=lambda arg0="FC_AC3": self.update_Algo(arg0))

        algomenu.add_radiobutton(
            label="Conflict BackJumping avec AC3",
            variable=self.radio_algo,
            value=4,
            command=lambda arg0="CBJ_AC3": self.update_Algo(arg0))
        algomenu.add_radiobutton(
            label="Conflict BackJumping",
            variable=self.radio_algo,
            value=5,
            command=lambda arg0="CBJ": self.update_Algo(arg0))
        algomenu.add_radiobutton(
            label="Branch & Bound Valué",
            variable=self.radio_algo,
            value=6,
            command=lambda arg0="VAL": self.update_Algo(arg0))

        self.radio_algo.set(1)

        self.radio_dico = IntVar()
        self.listDico = []
        self.dliste = []
        for dirname, dirnames, filenames in os.walk(DICO_PATH):
            for filename in filenames:
                self.dliste += ["".join([DICO_PATH, filename])]
                self.listDico += [filename[:-4]]

        i = 1
        for l in self.listDico:
            dicomenu.add_radiobutton(label=l,
                                     variable=self.radio_dico,
                                     value=i,
                                     command=self.update_Dico)
            i += 1

        self.radio_dico.set(5)
        menubar.add_cascade(label="Fichier", menu=filemenu)
        menubar.add_cascade(label="Algorithme", menu=algomenu)
        menubar.add_cascade(label="Dictionnaire", menu=dicomenu)

        self.dico = Dico(self.dliste[self.radio_dico.get() - 1])

        self.master.config(menu=menubar)