Esempio n. 1
0
    def __init__(self,
                 parent,
                 id,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.NO_BORDER | wx.TAB_TRAVERSAL):
        eclib.ControlBox.__init__(self, parent, id, pos, size, style)

        # Attributes
        self._mw = parent
        filters = u"".join(syntax.syntax.GenFileFilters())
        self._menbar = BrowserMenuBar(self)
        self._browser = FileBrowser(self,
                                    ID_FILEBROWSE,
                                    dir=wx.GetHomeDir(),
                                    style=wx.DIRCTRL_SHOW_FILTERS
                                    | wx.DIRCTRL_EDIT_LABELS
                                    | wx.BORDER_SUNKEN,
                                    filter=filters)
        self._browser.SetMainWindow(self._mw)
        self._config = PathMarkConfig(ed_glob.CONFIG['CACHE_DIR'])
        for item in self._config.GetItemLabels():
            self._menbar.AddItem(item)

        # Setup hidden files checkbox
        bbar = eclib.ControlBar(self, style=eclib.CTRLBAR_STYLE_GRADIENT)
        if wx.Platform == '__WXGTK__':
            bbar.SetWindowStyle(eclib.CTRLBAR_STYLE_DEFAULT)

        self._showh_cb = wx.CheckBox(bbar, self.ID_SHOW_HIDDEN,
                                     _("Show Hidden Files"))
        self._showh_cb.SetValue(False)
        bbar.AddControl(self._showh_cb, wx.ALIGN_LEFT)

        # Layout
        self.SetWindow(self._browser)
        self.SetControlBar(self._menbar, wx.TOP)
        self.SetControlBar(bbar, wx.BOTTOM)
        if wx.Platform == '__WXMSW__':
            bbar.Hide()
        self.Layout()

        #---- Add Menu Items ----#
        viewm = self._mw.GetMenuBar().GetMenuByName("view")
        self._mi = viewm.InsertAlpha(ID_FILEBROWSE,
                                     _("File Browser"),
                                     _("Open File Browser Sidepanel"),
                                     wx.ITEM_CHECK,
                                     after=ed_glob.ID_PRE_MARK)

        # Event Handlers
        self.Bind(wx.EVT_CHECKBOX, self.OnCheck)
        self.Bind(wx.EVT_MENU, self.OnMenu)

        # Messages
        ed_msg.Subscribe(self.OnUpdateFont, ed_msg.EDMSG_DSP_FONT)
Esempio n. 2
0
def MakeConfigDir(name):
    """Makes a user config directory
    @param name: name of config directory to make in user config dir

    """
    config_dir = wx.GetHomeDir() + os.sep + u"." + ed_glob.PROG_NAME
    try:
        os.mkdir(config_dir + os.sep + name)
    except (OSError, IOError):
        pass
Esempio n. 3
0
def GetLoader():
    """Finds the loader to use
    @return: path to profile loader
    @note: path may not exist, only returns the path to where the loader
           should be.

    """
    loader = os.path.join(wx.GetHomeDir(), u"." + PROG_NAME,
                          u"profiles", u".loader2")
    return loader
Esempio n. 4
0
    def FillContent(self):
        self.nameCtrl = wx.xrc.XRCCTRL(self, "name")
        self.dirCtrl = wx.xrc.XRCCTRL(self, "directory")
        self.progress = wx.xrc.XRCCTRL(self, "progress")

        config = wx.FileConfig.Get()
        lastName = config.Read("/ExportDialog/name", "untitled")
        self.lastDir = config.Read("/ExportDialog/dir", wx.GetHomeDir())
        self.nameCtrl.SetValue(lastName)
        self.dirCtrl.SetValue(self.lastDir)
Esempio n. 5
0
    def __init__(self,
                 parent,
                 id,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.NO_BORDER):
        wx.Panel.__init__(self, parent, id, pos, size, style)

        # Attributes
        self._mw = parent
        self._sizer = wx.BoxSizer(wx.VERTICAL)
        filters = "".join(syntax.syntax.GenFileFilters())
        self._menbar = BrowserMenuBar(self)
        self._browser = FileBrowser(self,
                                    ID_FILEBROWSE,
                                    dir=wx.GetHomeDir(),
                                    size=(200, -1),
                                    style=wx.DIRCTRL_SHOW_FILTERS
                                    | wx.DIRCTRL_EDIT_LABELS
                                    | wx.BORDER_SUNKEN,
                                    filter=filters)
        self._config = PathMarkConfig(ed_glob.CONFIG['CACHE_DIR'])
        for item in self._config.GetItemLabels():
            self._menbar.AddItem(item)
        self._showh_cb = wx.CheckBox(self, self.ID_SHOW_HIDDEN,
                                     _("Show Hidden Files"))
        self._showh_cb.SetValue(False)
        if wx.Platform == '__WXMAC__':
            self._showh_cb.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)

        #---- Add Menu Items ----#
        viewm = self._mw.GetMenuBar().GetMenuByName("view")
        self._mi = viewm.InsertAlpha(ID_FILEBROWSE,
                                     _("File Browser"),
                                     _("Open File Browser Sidepanel"),
                                     wx.ITEM_CHECK,
                                     after=ed_glob.ID_PRE_MARK)

        # Layout Pane
        self._sizer.AddMany([(self._menbar, 0, wx.EXPAND),
                             (self._browser, 1, wx.EXPAND), ((2, 2))])
        cb_sz = wx.BoxSizer(wx.HORIZONTAL)
        cb_sz.Add((4, 4))
        cb_sz.Add(self._showh_cb, 0, wx.ALIGN_LEFT)
        self._sizer.Add(cb_sz, 0, wx.ALIGN_LEFT)
        self._sizer.Add((3, 3))
        self.SetSizer(self._sizer)

        # Event Handlers
        self.Bind(wx.EVT_CHECKBOX, self.OnCheck)
        self.Bind(wx.EVT_MENU, self.OnMenu)
        self.Bind(wx.EVT_PAINT, self.OnPaint)

        # Messages
        ed_msg.Subscribe(self.OnUpdateFont, ed_msg.EDMSG_DSP_FONT)
Esempio n. 6
0
    def OnAddFolder(self, event):  # wxGlade: mainFrame.<event_handler>
        dirHome = wx.GetHomeDir()
        d = wx.DirDialog(self, "Choose an mp3 folder")

        if d.ShowModal() == wx.ID_OK:
            self.cancelProcessing = False
            self.EnableStuff(False)
            os.path.walk(d.GetPath(), self.AddFolder, None)
            self.EnableStuff(True)

        self.mainStatusbar.SetStatusText("")
Esempio n. 7
0
    def GetNextDir(self):
        """Get the next directory path from the current cmd path
        @note: used for tab completion of cd, completion is based off cwd
        @todo: finish working on this by starting over
        @note: not currently used

        """
        cmd = self.GetValue()
        if not cmd.startswith('cd '):
            return

        cmd = cmd.replace('cd ', u'', 1).strip()
        if not os.path.exists(self._curdir):
            self._curdir = wx.GetHomeDir()

        if len(cmd) and (cmd[0].isalnum() or cmd.startswith('.')):
            path = self._curdir
            cmd = os.path.join(path, cmd)
        else:
            path = os.path.abspath(cmd)
            if (len(cmd) and cmd[-1] == os.sep) or not len(cmd):
                path = path + os.sep

        if not os.path.exists(path):
            path = self._curdir

        # Filter Directories
        if path[-1] != os.sep:
            path = os.path.join(*os.path.split(path)[:-1]) + os.sep
            if not path.startswith(os.sep):
                path = os.sep + path
        dirs = [ os.path.join(path, x) \
                 for x in os.listdir(path) \
                 if os.path.isdir(os.path.join(path, x)) ]
        dirs.sort()
        if not len(dirs):
            return

        if len(cmd):
            npath = None
            for next in dirs:
                if next.startswith(cmd):
                    if cmd[-1] != os.path.sep and next == cmd:
                        idx = dirs.index(next) + 1
                    else:
                        idx = dirs.index(next)
                    
                    if idx < len(dirs):
                        npath = dirs[idx] #.replace(path, u'', 1)
                    break
            if npath:
                return npath
        else:
            return dirs[0]
Esempio n. 8
0
    def GetDownloadLocation(self):
        """Returns the path that the file will be downloaded to.
        Currently will either return the users Desktop path or the
        users home directory in the case that there is no deskop directory
        @return: path to download file

        """
        dl_loc = wx.GetHomeDir() + os.sep
        if os.path.exists(dl_loc + u"Desktop"):
            dl_loc = dl_loc + u"Desktop" + os.sep
        return dl_loc
Esempio n. 9
0
def HasConfigDir(loc=u""):
    """ Checks if the user has a config directory and returns True
    if the config directory exists or False if it does not.
    @return: whether config dir in question exists on an expected path

    """
    if os.path.exists(u"%s%s.%s%s%s" % (wx.GetHomeDir(), os.sep,
                                        ed_glob.PROG_NAME, os.sep, loc)):
        return True
    else:
        return False
Esempio n. 10
0
def GetLoader():
    """Finds the loader to use"""
    user_home = wx.GetHomeDir() + util.GetPathChar()
    rel_prof_path = ("." + PROG_NAME + util.GetPathChar() + 
                     "profiles" + util.GetPathChar() + ".loader2")

    if os.path.exists(user_home + rel_prof_path):
        loader = user_home + rel_prof_path
    else:
        loader = CONFIG['PROFILE_DIR'] + ".loader2"

    return loader
Esempio n. 11
0
 def OnFirst(self, event):
     dlg = wx.DirDialog(self,
                        message="Select 1st folder",
                        defaultPath=wx.GetHomeDir(),
                        style=wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST)
     if dlg.ShowModal() == wx.ID_OK:
         firstFolder = dlg.GetPath()
         if self.firstFolder != firstFolder:
             self.firstFolder = firstFolder
             self.ResetDoButton()
         self.txt1.SetValue(self.firstFolder)
     dlg.Destroy()
Esempio n. 12
0
    def __init__(self,
                 parent,
                 id,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.NO_BORDER):
        wx.Panel.__init__(self, parent, id, pos, size, style)

        # Attributes
        self._mw = parent
        self._sizer = wx.BoxSizer(wx.VERTICAL)
        ff = "".join(syntax.syntax.GenFileFilters())
        self._menbar = BrowserMenuBar(self, self.ID_BROWSE_MENU)
        self._browser = FileBrowser(self,
                                    ID_FILEBROWSE,
                                    dir=wx.GetHomeDir(),
                                    size=(200, -1),
                                    style=wx.DIRCTRL_SHOW_FILTERS
                                    | wx.BORDER_SUNKEN,
                                    filter=ff)
        self._config = PathMarkConfig(ed_glob.CONFIG['CACHE_DIR'])
        for item in self._config.GetItemLabels():
            self._menbar.AddItem(item)
        self._showh_cb = wx.CheckBox(self, self.ID_SHOW_HIDDEN,
                                     _("Show Hidden Files"))
        self._showh_cb.SetValue(False)

        #---- Add Menu Items ----#
        mb = self._mw.GetMenuBar()
        vm = mb.GetMenuByName("view")
        self._mi = vm.InsertAlpha(ID_FILEBROWSE,
                                  _("File Browser"),
                                  _("Open File Browser sidepanel"),
                                  wx.ITEM_CHECK,
                                  after=ed_glob.ID_PRE_MARK)

        # Layout Pane
        self._sizer.Add(self._menbar, 0, wx.EXPAND)
        self._sizer.Add(self._browser, 1, wx.EXPAND)
        self._sizer.Add((2, 2))
        cb_sz = wx.BoxSizer(wx.HORIZONTAL)
        cb_sz.Add((4, 4))
        cb_sz.Add(self._showh_cb, 0, wx.ALIGN_LEFT)
        self._sizer.Add(cb_sz, 0, wx.ALIGN_LEFT)
        self._sizer.Add((3, 3))
        self.SetSizer(self._sizer)

        # Event Handlers
        self.Bind(wx.EVT_CHECKBOX, self.OnCheck)
        self.Bind(wx.EVT_MENU, self.OnMenu)
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        vm.Bind(wx.EVT_MENU_OPEN, self.UpdateMenuItem)
Esempio n. 13
0
    def GetItemPath(self, itemId):
        """Get and return the path of the given item id
        @param itemId: TreeItemId
        @return: string

        """
        root = self._tree.GetRootItem()
        start = itemId
        atoms = [itemId]
        while self._tree.GetItemParent(start) != root:
            atoms.append(self._tree.GetItemParent(start))
            start = atoms[-1]

        atoms.reverse()
        path = list()
        for atom in atoms:
            path.append(self._tree.GetItemText(atom))

        if wx.Platform == '__WXMSW__':
            r_txt = u''
        else:
            if wx.Platform == '__WXGTK__':
                if path[0].lower() == 'home directory':
                    path[0] = wx.GetHomeDir()
                elif path[0].lower() == 'desktop':
                    path.insert(0, wx.GetHomeDir())
                else:
                    pass

            if wx.Platform == '__WXMAC__':
                if path[0] != "/":
                    if path == 'Macintosh HD':
                        path.pop(0)
                    else:
                        path.insert(0, 'Volumes')

            r_txt = os.path.sep
        return r_txt + os.sep.join(path)
Esempio n. 14
0
 def GetRoots():
     roots = []
     home_dir = wx.GetHomeDir()
     folder_bmp = wx.ArtProvider.GetBitmap(wx.ART_FOLDER_OPEN,
                                           wx.ART_CMN_DIALOG, (16, 16))
     roots.append([_("Home directory"), folder_bmp, home_dir])
     desktop_dir = home_dir + "/Desktop"
     roots.append([_("Desktop"), folder_bmp, desktop_dir])
     roots.append([
         "/",
         wx.ArtProvider.GetBitmap(wx.ART_HARDDISK, wx.ART_CMN_DIALOG,
                                  (16, 16)), "/"
     ])
     return roots
Esempio n. 15
0
def UpgradeOldInstall():
    """Upgrade an old installation and transfer all files if they exist
    @note: FOR INTERNAL USE ONLY
    @return: bool (True if success, False if failure)

    """
    old_cdir = u"%s%s.%s%s" % (wx.GetHomeDir(), os.sep, ed_glob.PROG_NAME,
                               os.sep)
    base = ed_glob.CONFIG['CONFIG_BASE']
    if base is None:
        base = wx.StandardPaths.Get().GetUserDataDir() + os.sep

    err = 0
    if os.path.exists(old_cdir) and \
       base.lower().rstrip(os.sep) != old_cdir.lower().rstrip(os.sep):
        for item in os.listdir(old_cdir):
            print item
            try:
                dest = os.path.join(base, item)
                item = os.path.join(old_cdir, item)
                if os.path.exists(dest):
                    if os.path.isdir(dest):
                        shutil.rmtree(dest, True)
                    else:
                        os.remove(dest)

                shutil.move(item, dest)
            except Exception, msg:
                util.Log("[Upgrade][err] %s" % msg)
                err += 1
                continue

        os.rmdir(old_cdir)

        # Load the copied over profile
        pstr = profiler.GetProfileStr()
        prof = os.path.basename(pstr)
        pstr = os.path.join(base, u"profiles", prof)
        if os.path.exists(pstr):
            profiler.Profile().Load(pstr)
            profiler.Profile().Update()
            profiler.UpdateProfileLoader()

        if not err:
            wx.MessageBox(_("Your profile has been updated to the latest "
                "version") + u"\n" + \
              _("Please check the preferences dialog to check "
                "your preferences"),
              _("Profile Updated"))
Esempio n. 16
0
    def __init__(self, parent):
        super(MyPanel, self).__init__(parent)

        # Attributes
        self.browser = FileBrowser(self, wx.GetHomeDir())

        # Setup

        # Layout
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.browser, 1, wx.EXPAND)
        self.SetSizer(sizer)

        # Event Handlers
        self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnItemActivated)
Esempio n. 17
0
def MakeConfigDir(name):
    """Makes a user config directory
    @param name: name of config directory to make in user config dir

    """
    cbase = ed_glob.CONFIG['CONFIG_BASE']
    if cbase is None:
        config_dir = wx.GetHomeDir() + os.sep + u"." + ed_glob.PROG_NAME
    else:
        config_dir = cbase

    try:
        os.mkdir(config_dir + os.sep + name)
    except (OSError, IOError):
        pass
Esempio n. 18
0
def GetLoader():
    """Finds the loader to use
    @return: path to profile loader
    @note: path may not exist, only returns the path to where the loader
           should be.

    """
    cbase = CONFIG['CONFIG_BASE']
    if cbase is None:
        loader = os.path.join(wx.GetHomeDir(), u"." + PROG_NAME, u"profiles",
                              u".loader2")
    else:
        loader = os.path.join(cbase, u"profiles", u".loader2")

    return loader
Esempio n. 19
0
    def __init__(self, parent, *args, **kw):
        wx.Panel.__init__(self,
                          parent,
                          -1,
                          style=wx.WANTS_CHARS | wx.BORDER_NONE)
        self.parent = parent
        vBox = wx.BoxSizer(wx.VERTICAL)

        ####################################################################

        vBox1 = wx.BoxSizer(wx.VERTICAL)
        import wx.lib.rcsizer as rcs
        sizer = rcs.RowColSizer()

        fbbLabel = wx.StaticText(self, -1, "Database File")

        os.chdir(wx.GetHomeDir())
        self.fbb = filebrowse.FileBrowseButton(
            self,
            -1,
            size=(350, -1),
            labelText="",
            fileMask=
            'sqlite (*.sqlite)|*.sqlite|Database (*.db)|*.db*|All Files|*.*',
            changeCallback=self.fbbCallback)

        connectionNameLabel = wx.StaticText(self, -1, "Connection Name    ")
        self.connectionNameText = wx.TextCtrl(self,
                                              -1,
                                              "",
                                              style=wx.TE_PROCESS_ENTER,
                                              size=(250, -1))
        self.Bind(wx.EVT_TEXT, self.onChangeConnectionName,
                  self.connectionNameText)

        sizer.Add(fbbLabel, flag=wx.EXPAND, row=1, col=1)
        sizer.Add(self.fbb, flag=wx.EXPAND, row=1, col=2)
        sizer.Add(connectionNameLabel, flag=wx.EXPAND, row=2, col=1)
        sizer.Add(self.connectionNameText, row=2, col=2)

        vBox1.Add(sizer)
        vBox.Add(vBox1, 0, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL)
        ####################################################################
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(vBox, 1, wx.EXPAND, 0)
        self.SetSizer(sizer)
        self.SetAutoLayout(True)
Esempio n. 20
0
def HasConfigDir(loc=u""):
    """ Checks if the user has a config directory and returns True
    if the config directory exists or False if it does not.
    @return: whether config dir in question exists on an expected path

    """
    cbase = ed_glob.CONFIG['CONFIG_BASE']
    if cbase is None:
        to_check = u"%s%s.%s%s%s" % (wx.GetHomeDir(), os.sep,
                                     ed_glob.PROG_NAME, os.sep, loc)
    else:
        to_check = cbase + os.sep + loc

    if os.path.exists(to_check):
        return True
    else:
        return False
Esempio n. 21
0
    def __init__(self, parent, id_, size=wx.DefaultSize):
        """Initializes the CommandExecuter"""
        wx.SearchCtrl.__init__(self,
                               parent,
                               id_,
                               size=size,
                               style=wx.TE_PROCESS_ENTER | wx.WANTS_CHARS)

        # Attributes
        self._history = dict(cmds=[''], index=-1, lastval='')
        if not hasattr(sys, 'frozen'):
            self._curdir = os.path.abspath(os.curdir) + os.sep
        else:
            self._curdir = wx.GetHomeDir() + os.sep

        if wx.Platform == '__WXMAC__':
            self._popup = PopupList(self)
            self.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus)
            self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus)
        else:
            self._popup = PopupWinList(self)

        # Hide the search button and text
        self.ShowSearchButton(False)
        self.ShowCancelButton(False)
        self.SetDescriptiveText(wx.EmptyString)

        # Event Handlers
        # HACK, needed on Windows to get any key events and for
        # GTK to get key down events
        if wx.Platform in ['__WXGTK__', '__WXMSW__']:
            for child in self.GetChildren():
                if isinstance(child, wx.TextCtrl):
                    child.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
                    child.Bind(wx.EVT_KEY_UP, self.OnKeyUp)
                    break
        else:
            self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
            self.Bind(wx.EVT_KEY_UP, self.OnKeyUp)

        self.Bind(wx.EVT_TEXT_ENTER, self.OnEnter)
        self.Bind(ed_event.EVT_NOTIFY, self.OnPopupNotify)
        ed_msg.Subscribe(self._UpdateCwd, ed_msg.EDMSG_UI_NB_CHANGED)
        ed_msg.Subscribe(self._UpdateCwd, ed_msg.EDMSG_FILE_SAVED)
Esempio n. 22
0
    def getHomeDirectory(self):
        """ Returns the user's home directory, if we can figure that
        out. """

        if env != ENV_GP2X:
            # First attempt: ask wx, if it's available.
            try:
                import wx
                return wx.GetHomeDir()
            except:
                pass

            # Second attempt: look in $HOME
            home = os.getenv('HOME')
            if home:
                return home

        # Give up and return the current directory.
        return '.'
Esempio n. 23
0
    def GetUpdateFiles(self, dl_to=wx.GetHomeDir()):
        """Gets the requested version of the program from the website
        if possible. It will download the current files for the host system to
        location (dl_to). On success it returns True, otherwise it returns
        false.
        @keyword dl_to: where to download the file to

        """
        # Check version to see if update is needed
        # Dont allow update if files are current
        verpat = re.compile('[0-9]+\.[0-9]+\.[0-9]+')
        current = self.GetCurrentVersionStr()
        if not re.match(verpat, current):
            return False

        if CalcVersionValue(ed_glob.VERSION) < CalcVersionValue(current):
            dl_path = self.GetCurrFileURL()
            dl_file = dl_path.split('/')[-1]
            dl_to = ebmlib.GetUniqueName(dl_to, dl_file)
            blk_sz = 4096
            read = 0
            try:
                # Download the file in chunks so it can be aborted if need be
                # inbetween reads.
                webfile = self.__GetUrlHandle(dl_path)
                fsize = int(webfile.info()['Content-Length'])
                locfile = open(dl_to, 'wb')
                while read < fsize and not self._abort:
                    locfile.write(webfile.read(blk_sz))
                    read += blk_sz
                    self.UpdaterHook(int(read / blk_sz), blk_sz, fsize)

                locfile.close()
                webfile.close()
            finally:
                self._abort = False
                if os.path.exists(dl_to) and \
                   os.stat(dl_to)[stat.ST_SIZE] == fsize:
                    return True
                else:
                    return False
        else:
            return False
Esempio n. 24
0
    def ChangeDir(self, cmd):
        """Change to a directory based on cd command
        @param cmd: cd path

        """
        path = cmd.replace('cd', '', 1).strip()
        if not os.path.isabs(path):
            if path.startswith('..'):
                path = os.path.abspath(path)
            elif path.startswith('~'):
                path = path.replace('~', wx.GetHomeDir(), 1)
            else:
                path = os.path.join(self._curdir, path)

        if os.path.exists(path) and os.path.isdir(path):
            os.chdir(path)
            self._curdir = os.path.abspath(os.path.curdir) + os.sep
        else:
            self.Clear()
            wx.Bell()
Esempio n. 25
0
 def DownloadUpdates(self, dl_loc=wx.EmptyString):
     """Downloads available updates and configures the bar.
     Returns True if the update was successfull or False if
     it was not. The updates will be downloaded to the 
     specified location or to the Users Desktop or Home
     Folder if no location is specified.
     @keyword dl_loc: location to download file to
     
     """
     self.LOG("[updateprog][evt] Attempting to download updates...")
     if dl_loc == wx.EmptyString:
         dl_loc = wx.GetHomeDir() + util.GetPathChar()
         if os.path.exists(dl_loc + u"Desktop"):
             dl_loc = dl_loc + u"Desktop" + util.GetPathChar()
     self._mode = self.ID_DOWNLOADING
     self.SetValue(0)
     self.Start(50)  #XXX Try this for starters
     self._downloading = True  # Mark the work status as busy
     delayedresult.startWorker(self._ResultNotifier,
                               self._DownloadThread,
                               wargs=dl_loc,
                               jobID=self.ID_DOWNLOADING)
Esempio n. 26
0
    def __init__(self, parent, title):
        wx.Dialog.__init__(self,
                           parent,
                           name="DlgNewProject",
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
                           title=title)

        self._InitCtrls()
        self._InitSizers()

        self.pnlHdr.SetTitle(title)
        self.pnlHdr.SetBitmap(
            wx.ArtProvider.GetBitmap('PFS_ICON', size=(32, 32)))

        self.choiceAspect.Append(Aspect.ASPECT_16_9)
        self.choiceAspect.Append(Aspect.ASPECT_16_10)
        self.choiceAspect.Append(Aspect.ASPECT_4_3)
        self.choiceAspect.Append(Aspect.ASPECT_3_2)
        self.choiceAspect.Select(0)

        self.tcProject.SetMinSize(wx.Size(300, -1))
        self.tcFolder.SetMinSize(wx.Size(300, -1))
        self.choiceAspect.SetMinSize(wx.Size(300, -1))

        self.tcProject.SetValue(_("Unnamed project"))
        self.tcProject.SelectAll()
        self.tcProject.SetFocus()

        projPath = Settings().GetProjectPath()
        if not projPath:
            projPath = os.path.join(wx.GetHomeDir(), _("My PhotoFilmStrips"))
            Settings().SetProjectPath(projPath)
        self.tcFolder.SetValue(projPath)

        self.SetInitialSize(self.GetEffectiveMinSize())
        self.Fit()
        self.CenterOnParent()
        self.SetFocus()
Esempio n. 27
0
    def OnPageChange(self, msg):
        """Syncronize selection with the notebook page changes
        @param msg: MessageObject
        @todo: check if message is from a page closing and avoid updates

        """

        nbdata = msg.GetData()
        page = nbdata[0].GetPage(nbdata[1])
        path = page.GetFileName()
        if len(path) and os.path.exists(path):
            if wx.Platform == '__WXMAC__' and \
               path.startswith('/Volumes/Macintosh HD'):
                path = path.replace('/Volumes/Macintosh HD', '', 1)
            elif wx.Platform == '__WXGTK__':
                home = wx.GetHomeDir()
                desk = home + _("Desktop")
                if path.startswith(desk):
                    path = path.replace(desk, '', 1)
                elif path.startswith(home):
                    path = path.replace(home, '', 1)

            self.GotoPath(path)
Esempio n. 28
0
    def __LayoutPanel(self, panel, label, exstyle=False):
        """Puts a set of controls in the panel
        @param panel: panel to layout
        @param label: panels title
        @param exstyle: Set the PB_STYLE_NOBG or not

        """
        # Bitmaps (32x32) and (16x16)
        devil = Devil.GetBitmap() # 32x32
        monkey = Monkey.GetBitmap() # 32x32
        address = Address.GetBitmap() # 16x16
        folder = Home.GetBitmap()
        bookmark = Book.GetBitmap() # 16x16

        vsizer = wx.BoxSizer(wx.VERTICAL)
        hsizer1 = wx.BoxSizer(wx.HORIZONTAL)
        hsizer1.Add((15, 15))
        hsizer2 = wx.BoxSizer(wx.HORIZONTAL)
        hsizer2.Add((15, 15))
        hsizer3 = wx.BoxSizer(wx.HORIZONTAL)
        hsizer3.Add((15, 15))
        hsizer4 = wx.BoxSizer(wx.HORIZONTAL)
        hsizer4.Add((15, 15))

        # Button Styles
        default = platebtn.PB_STYLE_DEFAULT
        square  = platebtn.PB_STYLE_SQUARE
        sqgrad  = platebtn.PB_STYLE_SQUARE | platebtn.PB_STYLE_GRADIENT
        gradient = platebtn.PB_STYLE_GRADIENT
        droparrow = platebtn.PB_STYLE_DROPARROW
        toggle = default | platebtn.PB_STYLE_TOGGLE

        # Create a number of different PlateButtons
        # Each button is created in the below loop by using the data set in this
        # lists tuple
        #        (bmp,   label,                Style,   Variant, Menu, Color, Enable)
        btype = [(None,  "Normal PlateButton", default, None,    None, None,  True),
                 (devil, "Normal w/Bitmap",    default, None,    None, None,  True),
                 (devil, "Disabled",           default, None,    None, None,  False),
                 (None,  "Normal w/Menu",      default, None,    True, None,  True),
                 (folder, "Home Folder",       default, None,    True, None,  True),
                 # Row 2
                 (None,  "Square PlateButton", square,  None,    None, None,  True),
                 (address, "Square/Bitmap",     square,  None,    None, None,  True),
                 (monkey, "Square/Gradient",   sqgrad,  None,    None, None,   True),
                 (address, "Square/Small",       square,  wx.WINDOW_VARIANT_SMALL, True, None, True),
                 (address, "Small Bitmap",      default, wx.WINDOW_VARIANT_SMALL, None, wx.Colour(33, 33, 33), True),
                 # Row 3
                 (devil, "Custom Color",       default, None,    None, wx.RED, True),
                 (monkey, "Gradient Highlight", gradient, None,  None, None,   True),
                 (monkey, "Custom Gradient",   gradient, None,   None, wx.Colour(245, 55, 245), True),
                 (None,  "Drop Arrow",                  droparrow, None,    None, None,   True),
                 (devil,  "",                  default, None,    None, None,   True),
                 (bookmark,  "",               default, None,    True, None,   True),
                 (monkey,  "",                 square,  None,    None, None,   True),
                 # Row 4
                 (None,  "Toggle PlateButton", toggle, None,    None, None,  True),
                 (devil, "Toggle w/Bitmap",    toggle, None,    None, None,  True),
                 (None,  "Toggle w/Menu",      toggle, None,    True, None,  True),
                 ]

        # Make and layout three rows of buttons in the panel
        for btn in btype:
            if exstyle:
                # With this style flag set the button can appear transparent on
                # on top of a background that is not solid in color, such as the
                # gradient panel in this demo.
                #
                # Note: This flag only has affect on wxMSW and should only be
                #       set when the background is not a solid color. On wxMac
                #       it is a no-op as this type of transparency is achieved
                #       without any help needed. On wxGtk it doesn't hurt to
                #       set but also unfortunatly doesn't help at all.
                bstyle = btn[2] | platebtn.PB_STYLE_NOBG
            else:
                bstyle = btn[2]

            if btype.index(btn) < 5:
                tsizer = hsizer1
            elif btype.index(btn) < 10:
                tsizer = hsizer2
            elif btype.index(btn) < 17:
                tsizer = hsizer3
            else:
                tsizer = hsizer4

            tbtn = platebtn.PlateButton(panel, wx.ID_ANY, btn[1], btn[0], style=bstyle)

            # Set a custom window size variant?
            if btn[3] is not None:
                tbtn.SetWindowVariant(btn[3])

            # Make a menu for the button?
            if btn[4] is not None:
                menu = wx.Menu()
                if btn[0] is not None and btn[0] == folder:
                    for fname in os.listdir(wx.GetHomeDir()):
                        if not fname.startswith('.'):
                            menu.Append(wx.NewId(), fname)
                elif btn[0] is not None and btn[0] == bookmark:
                    for url in ['http://wxpython.org', 'http://slashdot.org',
                                'http://editra.org', 'http://xkcd.com']:
                        menu.Append(wx.NewId(), url, "Open %s in your browser" % url)
                else:
                    menu.Append(wx.NewId(), "Menu Item 1")
                    menu.Append(wx.NewId(), "Menu Item 2")
                    menu.Append(wx.NewId(), "Menu Item 3")
                tbtn.SetMenu(menu)

            # Set a custom colour?
            if btn[5] is not None:
                tbtn.SetPressColor(btn[5])
                
            if btn[2] == droparrow:
                
                tbtn.Bind(platebtn.EVT_PLATEBTN_DROPARROW_PRESSED, self.OnDropArrowPressed)

            # Enable/Disable button state
            tbtn.Enable(btn[6])

            tsizer.AddMany([(tbtn, 0, wx.ALIGN_CENTER), ((10, 10))])

        txt_sz = wx.BoxSizer(wx.HORIZONTAL)
        txt_sz.AddMany([((5, 5)), (wx.StaticText(panel, label=label), 0, wx.ALIGN_LEFT)])
        vsizer.AddMany([((10, 10)),
                        (txt_sz, 0, wx.ALIGN_LEFT),
                        ((10, 10)), (hsizer1, 0, wx.EXPAND), ((10, 10)), 
                        (hsizer2, 0, wx.EXPAND), ((10, 10)), 
                        (hsizer3, 0, wx.EXPAND), ((10, 10)),
                        (hsizer4, 0, wx.EXPAND), ((10, 10))])
        panel.SetSizer(vsizer)
Esempio n. 29
0
 def __init__(self, path=None):
     super().__init__(redirect=0, useBestVisual=True)
     self.path = path or os.path.join(wx.GetHomeDir(), ".labpype")
Esempio n. 30
0
def ResolvConfigDir(config_dir, sys_only=False):
    """Checks for a user config directory and if it is not
    found it then resolves the absolute path of the executables
    directory from the relative execution path. This is then used
    to find the location of the specified directory as it relates
    to the executable directory, and returns that path as a
    string.
    @param config_dir: name of config directory to resolve
    @keyword sys_only: only get paths of system config directory or user one
    @note: This method is probably much more complex than it needs to be but
           the code has proven itself.

    """
    if not sys_only:
        # Try to look for a user dir
        user_config = u"%s%s.%s%s%s" % (wx.GetHomeDir(), os.sep,
                                        ed_glob.PROG_NAME, os.sep, config_dir)
        if os.path.exists(user_config):
            return user_config + os.sep

    # The following lines are used only when Editra is being run as a
    # source package. If the found path does not exist then Editra is
    # running as as a built package.
    path = __file__
    path = os.sep.join(path.split(os.sep)[:-2])
    path = path + os.sep + config_dir + os.sep
    if os.path.exists(path):
        return path

    # If we get here we need to do some platform dependant lookup
    # to find everything.
    path = sys.argv[0]

    # If it is a link get the real path
    if os.path.islink(path):
        path = os.path.realpath(path)

    # Tokenize path
    pieces = path.split(os.sep)

    if os.sys.platform == 'win32':
        # On Windows the exe is in same dir as config directories
        pro_path = os.sep.join(pieces[:-1])

        if os.path.isabs(pro_path):
            pass
        elif pro_path == "":
            pro_path = os.getcwd()
            pieces = pro_path.split(os.sep)
            pro_path = os.sep.join(pieces[:-1])
        else:
            pro_path = ResolvAbsPath(pro_path)
    else:
        pro_path = os.sep.join(pieces[:-2])

        if pro_path.startswith(os.sep):
            pass
        elif pro_path == "":
            pro_path = os.getcwd()
            pieces = pro_path.split(os.sep)
            if pieces[-1] not in [
                    ed_glob.PROG_NAME.lower(), ed_glob.PROG_NAME
            ]:
                pro_path = os.sep.join(pieces[:-1])
        else:
            pro_path = ResolvAbsPath(pro_path)

    if os.sys.platform == "darwin":
        # On OS X the config directories are in the applet under Resources
        pro_path = u"%s%sResources%s%s%s" % (pro_path, os.sep, os.sep,
                                             config_dir, os.sep)
    else:
        pro_path = pro_path + os.sep + config_dir + os.sep

    return os.path.normpath(pro_path) + os.sep