本文整理汇总了Python中PySide.QtGui.QDesktopServices.storageLocation方法的典型用法代码示例。如果您正苦于以下问题:Python QDesktopServices.storageLocation方法的具体用法?Python QDesktopServices.storageLocation怎么用?Python QDesktopServices.storageLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QDesktopServices
的用法示例。
在下文中一共展示了QDesktopServices.storageLocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: askOpenFile
# 需要导入模块: from PySide.QtGui import QDesktopServices [as 别名]
# 或者: from PySide.QtGui.QDesktopServices import storageLocation [as 别名]
def askOpenFile(self):
if not self.askSaveChanges():
return
directory = QDesktopServices.storageLocation(
QDesktopServices.DocumentsLocation)
filename, selected_filter = QFileDialog.getOpenFileName(
self, self.trUtf8(b'Open file'), directory)
if filename:
self.load(filename)
示例2: browseMediapath
# 需要导入模块: from PySide.QtGui import QDesktopServices [as 别名]
# 或者: from PySide.QtGui.QDesktopServices import storageLocation [as 别名]
def browseMediapath(self):
self.loadMediaBrowseSettings()
options = QtGui.QFileDialog.Options()
if (os.path.isdir(self.mediadirectory)):
defaultdirectory = self.mediadirectory
elif (os.path.isdir(QDesktopServices.storageLocation(QDesktopServices.MoviesLocation))):
defaultdirectory = QDesktopServices.storageLocation(QDesktopServices.MoviesLocation)
elif (os.path.isdir(QDesktopServices.storageLocation(QDesktopServices.HomeLocation))):
defaultdirectory = QDesktopServices.storageLocation(QDesktopServices.HomeLocation)
else:
defaultdirectory = ""
browserfilter = "All Files (*)"
fileName, filtr = QtGui.QFileDialog.getOpenFileName(self,"Browse for media files",defaultdirectory,
browserfilter, "", options)
if fileName:
self.mediapathTextbox.setText(fileName)
self.mediadirectory = os.path.dirname(fileName)
self.saveMediaBrowseSettings()
示例3: askSaveFile
# 需要导入模块: from PySide.QtGui import QDesktopServices [as 别名]
# 或者: from PySide.QtGui.QDesktopServices import storageLocation [as 别名]
def askSaveFile(self):
if self.currentFilename:
directory = os.path.dirname(self.currentFilename)
else:
directory = QDesktopServices.storageLocation(
QDesktopServices.DocumentsLocation)
filename, selected_filter = QFileDialog.getSaveFileName(
self, self.trUtf8(b'Save file'), directory)
if not filename:
return False
return self.saveFile()
示例4: __init__
# 需要导入模块: from PySide.QtGui import QDesktopServices [as 别名]
# 或者: from PySide.QtGui.QDesktopServices import storageLocation [as 别名]
def __init__(self, app):
super(MainWindow, self).__init__()
# Window layout - a splitter with the image on the left and controls
# on the right
self._image_widget = ImageLabel(self)
self._controls = Controls(self)
self._splitter = QSplitter()
self._splitter.addWidget(self._image_widget)
self._splitter.addWidget(self._controls)
self._splitter.setSizes([1200, 600])
# Main window layout
self.setCentralWidget(self._splitter)
# Connect controls to handlers
self._controls.ok.clicked.connect(self.ok)
self._controls.cancel.clicked.connect(self.cancel)
self._controls.inbox.choose_directory.clicked.connect(self.choose_inbox)
self._controls.processed.choose_directory.clicked.connect(self.choose_processed)
# Directories
mydocuments = QDesktopServices.storageLocation(
QDesktopServices.DocumentsLocation)
self._inbox = Path(QSettings().value('inbox',
str(Path(mydocuments) / 'inbox')))
self._processed = Path(QSettings().value('processed',
str(Path(mydocuments) / 'processed')))
self._controls.inbox.set_link(str(self._inbox.as_uri()), self._inbox.name)
self._controls.processed.set_link(str(self._processed.as_uri()), self._processed.name)
# A stack of Path objects to be processed
self._pending_files = []
# The Path currently shown in the UI
self._under_review = None
# Watch the inbox directory, if it exists
self.new_pending_files.connect(self.process_next_pending,
QtCore.Qt.QueuedConnection)
if self._inbox.is_dir():
self._watcher = NewFileWatcher(self._inbox, IMAGE_SUFFIXES_RE)
self._watcher.new_file.connect(self.new_image_file)
else:
self._watcher = None
self.empty_controls()
# Setup drag-drop handling
self.setAcceptDrops(True)
self._controls.installEventFilter(self)
self._splitter.installEventFilter(self)
示例5: appdata
# 需要导入模块: from PySide.QtGui import QDesktopServices [as 别名]
# 或者: from PySide.QtGui.QDesktopServices import storageLocation [as 别名]
def appdata():
"""
Return the path that application data should be stored in. This acts a bit
special on Windows machines as Qt doesn't return the right path itself.
"""
if os.name == "nt":
path = os.getenv("APPDATA")
app = QCoreApplication.instance()
if app:
if app.organizationName():
path = os.path.join(path, app.organizationName())
if app.applicationName():
path = os.path.join(path, app.applicationName())
return path
return QDesktopServices.storageLocation(QDesktopServices.DataLocation)
示例6: _on_export
# 需要导入模块: from PySide.QtGui import QDesktopServices [as 别名]
# 或者: from PySide.QtGui.QDesktopServices import storageLocation [as 别名]
def _on_export(self):
if len(self.test.array) == 0:
QMessageBox.warning(self, self.tr("IrregularVerbsTestGenerator"),
self.tr("You need to generate a test first !"))
return
export_file, export_format = QFileDialog.getSaveFileName(
self,
self.tr("Save test"),
QDesktopServices.storageLocation(QDesktopServices.DesktopLocation),
self.tr("Xls file (*.xls)"))
if not export_file:
return
include_solutions = self.mIncludeSolutions.isChecked()
export_file = "{0}.xls".format(os.path.splitext(export_file)[0])
_export_test_to_xls_file(self.test, export_file, include_solutions)
示例7: get_data_path
# 需要导入模块: from PySide.QtGui import QDesktopServices [as 别名]
# 或者: from PySide.QtGui.QDesktopServices import storageLocation [as 别名]
def get_data_path():
"""
Returns the path that application data should be stored in. This acts a bit
special on Windows machines, using the APPDATA environment variable to
ensure things go to AppData\Roaming and not AppData\Local.
"""
if os.name == 'nt':
qapp = QCoreApplication.instance()
path = os.getenv('APPDATA')
if qapp.organizationName():
path = os.path.join(path, qapp.organizationName())
if qapp.applicationName():
path = os.path.join(path, qapp.applicationName())
return path
return QDesktopServices.storageLocation(QDesktopServices.DataLocation)
示例8: ensure_paths
# 需要导入模块: from PySide.QtGui import QDesktopServices [as 别名]
# 或者: from PySide.QtGui.QDesktopServices import storageLocation [as 别名]
def ensure_paths():
""" Ensure cache_path, profile_path, and root_path are set. """
global cache_path
global profile_path
global root_path
if not root_path:
root_path = os.path.abspath(os.path.dirname(sys.argv[0]))
if not profile_path:
# The profile path is a bit trickier than the root path, since it can
# move depending on the portability flag.
if portable:
path = root_path
else:
path = os.path.abspath(get_data_path())
# Add the Profiles/<profile> bit to the profile path, and ensure the
# path actually exists.
path = os.path.join(path, u'Profiles', name)
if not os.path.exists(path):
os.makedirs(path)
profile_path = path
if not cache_path:
# The cache path is like the profile path, in that it varies based on
# the portability flag.
if portable:
path = os.path.join(root_path, u'cache')
else:
path = QDesktopServices.storageLocation(
QDesktopServices.CacheLocation)
# Add the Profiles/<profile> bit to the cache path, and ensure the path
# actually exists.
path = os.path.join(path, u'Profiles', name)
if not os.path.exists(path):
os.makedirs(path)
cache_path = path
示例9: __init__
# 需要导入模块: from PySide.QtGui import QDesktopServices [as 别名]
# 或者: from PySide.QtGui.QDesktopServices import storageLocation [as 别名]
def __init__(self):
dbus_main_loop = dbus.glib.DBusGMainLoop(set_as_default=True)
session_bus = dbus.SessionBus(dbus_main_loop)
bus_name = dbus.service.BusName("com.mikeasoft.statusnet", bus=session_bus)
dbus.service.Object.__init__(self, object_path="/synchronize", bus_name=bus_name)
self.app = QCoreApplication(sys.argv)
signal.signal(signal.SIGINT, signal.SIG_DFL)
self.client = gconf.client_get_default()
self.api_path = self.client.get_string('/apps/ControlPanel/Statusnet/api_path')
self.latest = self.client.get_int('/apps/ControlPanel/Statusnet/latest')
self.eventService = EventFeedService('statusnet', 'StatusNet')
self.eventService.local_name = "com.mikeasoft.statusnet.eventcallback"
self.eventService.DEFAULT_INTF = "com.mikeasoft.statusnet.eventcallback"
if not self.api_path:
return
self.cacheDir = QDesktopServices.storageLocation(QDesktopServices.CacheLocation)
if not os.path.exists(self.cacheDir):
os.mkdir(self.cacheDir)
sys.exit(self.app.exec_())
示例10: __init__
# 需要导入模块: from PySide.QtGui import QDesktopServices [as 别名]
# 或者: from PySide.QtGui.QDesktopServices import storageLocation [as 别名]
def __init__(self, parent=None, flags=Qt.Widget):
super(FileBrowser, self).__init__(parent, flags)
self.gallery = QDocumentGallery(self)
self.fileSystemModel = QFileSystemModel(self)
self.rootPath = QDesktopServices.storageLocation(QDesktopServices.HomeLocation)
self.fileSystemModel.setRootPath(self.rootPath)
self.view = QListView()
self.view.setModel(self.fileSystemModel)
self.view.activated.connect(self.activated)
self.setCentralWidget(self.view)
self.menuBar().addAction(self.tr("Documents"), self.browseDocuments)
self.menuBar().addAction(self.tr("Audio"), self.browseAudio)
self.menuBar().addAction(self.tr("Images"), self.browseImages)
self.menuBar().addAction(self.tr("Videos"), self.browseVideos)
self.browseDocuments()
示例11: __init__
# 需要导入模块: from PySide.QtGui import QDesktopServices [as 别名]
# 或者: from PySide.QtGui.QDesktopServices import storageLocation [as 别名]
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setupUi(self)
self.test = Test()
# Copy the default irv file into app data directory if necessary
data_path = QDesktopServices.storageLocation(QDesktopServices.DataLocation)
if not os.path.exists(data_path):
os.makedirs(data_path)
verbs_file_path = os.path.join(data_path, VERBS_FILE)
if not os.path.exists(verbs_file_path):
shutil.copy(os.path.join(QApplication.applicationDirPath(), VERBS_FILE),
verbs_file_path)
format_file_path = os.path.join(data_path, FORMAT_FILE)
if not os.path.exists(format_file_path):
shutil.copy(os.path.join(QApplication.applicationDirPath(), FORMAT_FILE),
format_file_path)
# Load verbs informations
workbook = xlrd.open_workbook(verbs_file_path)
self.levels_list = []
self.levels_dict = {}
for sheet in workbook.sheets():
verbs = []
for i in range(sheet.nrows):
verb = Verb(sheet.row(i)[0].value, sheet.row(i)[1].value,
sheet.row(i)[2].value, sheet.row(i)[3].value)
verbs.append(verb)
self.levels_list.append(sheet.name)
self.levels_dict[sheet.name] = Level(verbs)
self.mClassList.currentIndexChanged.connect(self._on_level_selected_changed)
for level in self.levels_list:
self.mClassList.addItem(level, level)
self.mGenerate.clicked.connect(self._on_generate)
self.mExport.clicked.connect(self._on_export)
self.mActionExport.triggered.connect(self._on_export)
self.mActionEditVerbsList.triggered.connect(self._on_edit_verbs_list)
self.mActionEditExportStyle.triggered.connect(self._on_edit_export_style)
示例12: addFiles
# 需要导入模块: from PySide.QtGui import QDesktopServices [as 别名]
# 或者: from PySide.QtGui.QDesktopServices import storageLocation [as 别名]
def addFiles(self):
files, _ = QFileDialog.getOpenFileNames(
self, self.tr("Select Music Files"),
QDesktopServices.storageLocation(QDesktopServices.MusicLocation),
self.tr("Media Files (*.mp3 *.mp4 *.aac)")
)
if not files:
return
for mediafile in files:
title = "unknown"
artist, album, year = "", "", ""
try:
tag = EasyID3(mediafile)
title = tag['title'][0]
artist = tag['artist'][0]
album = tag['album'][0]
year = tag['date'][0]
except:
pass
titleItem = QTableWidgetItem(title)
titleItem.setFlags(titleItem.flags() ^ Qt.ItemIsEditable)
artistItem = QTableWidgetItem(artist)
artistItem.setFlags(artistItem.flags() ^ Qt.ItemIsEditable)
albumItem = QTableWidgetItem(album)
albumItem.setFlags(albumItem.flags() ^ Qt.ItemIsEditable)
yearItem = QTableWidgetItem(year)
yearItem.setFlags(yearItem.flags() ^ Qt.ItemIsEditable)
currentRow = self.musicTable.rowCount()
self.musicTable.insertRow(currentRow)
self.musicTable.setItem(currentRow, 0, titleItem)
self.musicTable.setItem(currentRow, 1, artistItem)
self.musicTable.setItem(currentRow, 2, albumItem)
self.musicTable.setItem(currentRow, 3, yearItem)
self.engine.play_list_add(files)
self.play_action()
示例13: _export_test_to_xls_file
# 需要导入模块: from PySide.QtGui import QDesktopServices [as 别名]
# 或者: from PySide.QtGui.QDesktopServices import storageLocation [as 别名]
def _export_test_to_xls_file(test, filepath, include_solutions):
# Open format workbook
format_file_path = os.path.join(
QDesktopServices.storageLocation(QDesktopServices.DataLocation),
FORMAT_FILE)
f_workbook = xlrd.open_workbook(format_file_path, formatting_info=True)
f_sheet = f_workbook.sheet_by_index(0)
# Open destination workbook
wb = xlwt.Workbook(encoding='utf-8')
sheet = wb.add_sheet(u"Test")
# Write header
title_r_format, title_r_font = _get_cell_format_information(f_workbook, f_sheet, 0)
title_w_style = _r_format_to_w_format(title_r_format, title_r_font)
content_r_format, content_r_font = _get_cell_format_information(f_workbook, f_sheet, 1)
content_w_style = _r_format_to_w_format(content_r_format, content_r_font)
solution_r_format, solution_r_font = _get_cell_format_information(f_workbook, f_sheet, 2)
solution_w_style = _r_format_to_w_format(solution_r_format, solution_r_font)
max_cell_height = max(_get_string_width(title_w_style.font, 'w'),
_get_string_width(content_w_style.font, 'w'))
max_cell_width = len(u"Participe passé") * max_cell_height
sheet.write(0, 0, u"Base verbale", title_w_style)
sheet.write(0, 1, u"Preterit", title_w_style)
sheet.write(0, 2, u"Participe passé", title_w_style)
sheet.write(0, 3, u"Traduction", title_w_style)
sheet.write(0, 4, u"Points", title_w_style)
sheet.row(0).height = max_cell_height
# Write test content
for i in range(len(test.array)):
for j in range(5):
if j == test.array[i][0]:
sheet.write(i+1, test.array[i][0], test.array[i][1], content_w_style)
max_cell_width = max(max_cell_width, len(test.array[i][1])*max_cell_height)
else:
sheet.write(i+1, j, '', content_w_style)
sheet.row(i+1).height = max_cell_height
# Resize columns
for i in range(4):
sheet.col(i).width = max_cell_width
# Write solutions
if include_solutions:
solution_lines = []
max_line_width = max_cell_width * 5
for solution in test.solutions:
width = _get_string_width(solution_w_style.font, " / "+solution)
if len(solution_lines) == 0 or (_get_string_width(solution_w_style.font, solution_lines[-1])+width) > max_line_width:
solution_lines.append(solution)
else:
solution_lines[-1] += " / "+solution
current_row = len(test.array)+2
for line in solution_lines:
sheet.write_merge(current_row, current_row, 0, 4, line, solution_w_style)
current_row+=1
wb.save(filepath)
示例14: get_home
# 需要导入模块: from PySide.QtGui import QDesktopServices [as 别名]
# 或者: from PySide.QtGui.QDesktopServices import storageLocation [as 别名]
def get_home():
""" Returns the path to the user's home directory. """
return QDesktopServices.storageLocation(QDesktopServices.HomeLocation)
示例15: _get_hamster_dir
# 需要导入模块: from PySide.QtGui import QDesktopServices [as 别名]
# 或者: from PySide.QtGui.QDesktopServices import storageLocation [as 别名]
def _get_hamster_dir():
hamster_dir = QDesktopServices.storageLocation(QDesktopServices.DataLocation)
if not os.path.exists(hamster_dir):
os.makedirs(hamster_dir)
#TODO catch exception
return hamster_dir