Example #1
0
    def OnClick(self, event):

        if event.GetId() == 100:
            dlg = wx.DirDialog(self,
                               "Sélectionner un dossier",
                               style=wx.DD_DEFAULT_STYLE,
                               defaultPath=toSystemEncoding(self.pathref)
                               #| wx.DD_DIR_MUST_EXIST
                               #| wx.DD_CHANGE_DIR
                               )
            if dlg.ShowModal() == wx.ID_OK:
                self.SetPath(dlg.GetPath(), 'd', marquerModifier=True)

            dlg.Destroy()

        else:
            dlg = wx.FileDialog(
                self,
                "Sélectionner un fichier",
                wildcard=self.ext,
                defaultDir=toSystemEncoding(self.pathref),
                #                           defaultPath = globdef.DOSSIER_EXEMPLES,
                style=wx.DD_DEFAULT_STYLE
                #| wx.DD_DIR_MUST_EXIST
                #| wx.DD_CHANGE_DIR
            )

            if dlg.ShowModal() == wx.ID_OK:
                self.SetPath(dlg.GetPath(), 'f', marquerModifier=True)

            dlg.Destroy()

        self.MiseAJour()

        self.SetFocus()
Example #2
0
    def Afficher(self, pathref, fenSeq=None):
        """ Lance l'affichage du contenu du lien
            <pathref> = chemin de l'application pour déterminer le chemin absolu
        """
        t = self.getTexte()
        print("Afficher", self.type, self.path)
        path = self.GetAbsPath(pathref)
        #         print "   ", path
        #         print "   ", path.decode("unicode-escape")
        #         print "   ", path.encode(sys.getfilesystemencoding())

        if self.type == "f":
            if os.path.exists(path):
                try:
                    os.startfile(path)
                except:
                    messageErreur(
                        None, "Ouverture impossible",
                        "Impossible d'ouvrir le fichier\n\n%s\n" %
                        toSystemEncoding(path))
            else:
                messageErreur(
                    None, "Chemin non trouvé",
                    "Le fichiern'a pas été trouvé\n\n%s" %
                    toSystemEncoding(path))

        elif self.type == 'd':
            if os.path.isdir(path):
                openFolder(path)
#                 try:
# #                     subprocess.Popen(["explorer", path])
#
#                 except:
#                     messageErreur(None, u"Ouverture impossible",
#                                   u"Impossible d'acc�der au dossier\n\n%s\n" %toSystemEncoding(path))
            else:
                messageErreur(
                    None, "Chemin non trouvé",
                    "Le dossiern'a pas été trouvé\n\n%s" %
                    toSystemEncoding(path))

        elif self.type == 'u':
            try:
                webbrowser.open(self.path)
            except:
                messageErreur(
                    None, "Ouverture impossible",
                    "Impossible d'ouvrir l'url\n\n%s\n" %
                    toSystemEncoding(self.path))

        elif self.type == 's':
            if os.path.isfile(path):
                #                self.Show(False)
                child = fenSeq.commandeNouveau()
                child.ouvrir(path)
Example #3
0
    def CreateSelector(self, dossier=True, btn_ouvrir=False):
        # Passage momentan� en Anglais (bug de wxpython)
        #         locale2EN()
        #         loc = wx.GetApp().locale.GetSystemLanguage()
        #         wx.GetApp().locale = wx.Locale(wx.LANGUAGE_ENGLISH)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        bsize = (16 * SSCALE, 16 * SSCALE)
        #         print("    ", self.lien.path)
        self.texte = wx.TextCtrl(self,
                                 -1,
                                 toSystemEncoding(self.lien.path),
                                 size=(-1, bsize[1]))

        if dossier:
            #             bt1 =wx.BitmapButton(self, 100, wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, bsize))
            bt1 = wx.BitmapButton(
                self, 100, scaleImage(images.Icone_folder.GetBitmap(), *bsize))
            bt1.SetToolTip("Sélectionner un dossier")
            self.Bind(wx.EVT_BUTTON, self.OnClick, bt1)
            self.bt1 = bt1
            sizer.Add(bt1)
#         bt2 =wx.BitmapButton(self, 101, images.wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, bsize))

        bt2 = wx.BitmapButton(
            self, 101, scaleImage(images.Icone_fichier.GetBitmap(), *bsize))
        bt2.SetToolTip("Sélectionner un fichier")
        self.Bind(wx.EVT_BUTTON, self.OnClick, bt2)
        self.Bind(wx.EVT_TEXT, self.EvtText, self.texte)
        self.bt2 = bt2

        self.cb = wx.CheckBox(self, label='/', pos=(20, 20))
        self.cb.SetToolTip("Cocher pour utiliser un chemin absolu")
        self.cb.Bind(wx.EVT_CHECKBOX, self.OnCbAbs, self.cb)

        sizer.Add(bt2)
        sizer.Add(self.cb, flag=wx.EXPAND)
        sizer.Add(self.texte, 1, flag=wx.EXPAND)

        if btn_ouvrir:
            self.btnlien = wx.BitmapButton(
                self, -1, scaleImage(images.Icone_open.GetBitmap(), *bsize))

            self.btnlien.Show(self.lien.path != "")
            self.Bind(wx.EVT_BUTTON, self.OnClickLien, self.btnlien)
            sizer.Add(self.btnlien)

        # Pour drag&drop direct de fichiers !! (exp�rimental)
        file_drop_target = MyFileDropTarget(self)
        self.SetDropTarget(file_drop_target)

        #         locale2def()
        #         wx.GetApp().locale = wx.Locale(loc)

        return sizer
Example #4
0
    def CreateSelector(self):
        # Passage momentan� en Anglais (bug de wxpython)
#         locale2EN()
#         loc = wx.GetApp().locale.GetSystemLanguage()
#         wx.GetApp().locale = wx.Locale(wx.LANGUAGE_ENGLISH)
        
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        bsize = (16*SSCALE, 16*SSCALE)
        
        self.texte = wx.TextCtrl(self, -1, toSystemEncoding(self.lien.path), size = (-1, bsize[1]))
        
        
        if self.dossier:
#             bt1 =wx.BitmapButton(self, 100, wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, bsize))
            bt1 =wx.BitmapButton(self, 100, scaleImage(images.Icone_folder.GetBitmap(), *bsize))
            bt1.SetToolTip("Sélectionner un dossier")
            self.Bind(wx.EVT_BUTTON, self.OnClick, bt1)
            self.bt1 = bt1
            sizer.Add(bt1)
#         bt2 =wx.BitmapButton(self, 101, images.wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, bsize))
        
        bt2 =wx.BitmapButton(self, 101, scaleImage(images.Icone_fichier.GetBitmap(), *bsize))
        bt2.SetToolTip("Sélectionner un fichier")
        self.Bind(wx.EVT_BUTTON, self.OnClick, bt2)
        self.Bind(wx.EVT_TEXT, self.EvtText, self.texte)
        self.bt2 = bt2
        
        sizer.Add(bt2)
        sizer.Add(self.texte,1,flag = wx.EXPAND)
        
#         self.btnlien = wx.BitmapButton(self, -1, wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, bsize))
        self.btnlien = wx.BitmapButton(self, -1, scaleImage(images.Icone_open.GetBitmap(), *bsize))
        self.btnlien.SetToolTip("Ouvrir le lien externe")
        self.btnlien.Show(self.lien.path != "")
        self.Bind(wx.EVT_BUTTON, self.OnClickLien, self.btnlien)
        sizer.Add(self.btnlien)
         
        
        # Pour drag&drop direct de fichiers !! (exp�rimental)
        file_drop_target = MyFileDropTarget(self)
        self.SetDropTarget(file_drop_target)
        
#         locale2def()
#         wx.GetApp().locale = wx.Locale(loc)
        
        return sizer
Example #5
0
    def SetPath(self, lien = None, typ = None, marquerModifier = False):
        """ lien doit être de type 'String' encodé en SYSTEM_ENCODING
            
        """
        print("SetPath", lien)
#         print "   ", lien, typ
        if lien is not None:
            self.lien.path = lien
            self.lien.EvalLien(lien, self.pathref)
        
        try:
            self.texte.ChangeValue(self.lien.path)
        except: # Ca ne devrait pas arriver ... et pourtant �a arrive !
            self.lien.path = self.lien.path.decode(FILE_ENCODING)
#             self.lien.path = self.lien.path.encode(SYSTEM_ENCODING)
            self.texte.ChangeValue(toSystemEncoding(self.lien.path)) # On le met en SYSTEM_ENCODING
        
        
        self.MiseAJour()
        
        if marquerModifier:
            self.sendEvent()
Example #6
0
 def __repr__(self):
     return self.type + " : " + toSystemEncoding(self.path)
Example #7
0
 def getBranche(self, branche):
     #         branche.set("Lien", toSystemEncoding(os.path.normpath(self.path)))
     branche.set("Lien", toSystemEncoding(self.path))
     branche.set("TypeLien", self.type)
     branche.set("Abs", str(self.abs))