Beispiel #1
0
import time
import os
import sys
import wx

import wx.lib.filebrowsebutton as filebrowse

from pyshortcuts import (make_shortcut, platform, get_folders, get_cwd,
                         fix_filename)

USERFOLDERS = get_folders()
DESKTOP = USERFOLDERS.desktop

PY_FILES = "Python scripts (*.py)|*.py"
ALL_FILES = "All files (*.*)|*.*"
ICO_FILES = "Icon files (*.ico)|*.ico"
ICNS_FILES = "Mac Icon files (*.icns)|*.icns"

CEN = wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL
LEFT = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL
RIGHT = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL
ALL_CEN = wx.ALL | CEN
ALL_LEFT = wx.ALL | LEFT
ALL_RIGHT = wx.ALL | RIGHT

FONTSIZE = 11
if platform == 'linux':
    FONTSIZE = 10


class ShortcutFrame(wx.Frame):
#!/usr/bin/env python
'''Normal test run:
     python -m pytests

   Run and see manual debug print()s:
     python test_pyshortcuts.py
'''
import os
import pytest
from pyshortcuts import make_shortcut, platform, Shortcut, get_folders

folders = get_folders()
root = os.path.abspath(os.path.join(__file__, '..', '..'))

def test_shortcut():
    '''Create a shortcut from examples dir'''
    print('---test_shortcut()')
    print("folders:\n Home: {}\n Desktop: {}\n StartMenu: {}\n".format(
        folders.home, folders.desktop, folders.startmenu))

    script = os.path.join(root, 'examples', 'console_scripts', 'timer.py') + ' -u 0.25 -t 10'
    icon  = os.path.join(root, 'examples', 'icons', 'stopwatch')

    iext = 'ico'
    if platform.startswith('darwin'):
        iext = 'icns'

    icon = "%s.%s" % (icon, iext)
    scut = make_shortcut(script, name='Timer', icon=icon, folder=folders.desktop)
    assert isinstance(scut, Shortcut), 'it returns a shortcut instance'