本文整理汇总了Python中Tc2Config.dlgOpenSaveFile方法的典型用法代码示例。如果您正苦于以下问题:Python Tc2Config.dlgOpenSaveFile方法的具体用法?Python Tc2Config.dlgOpenSaveFile怎么用?Python Tc2Config.dlgOpenSaveFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tc2Config
的用法示例。
在下文中一共展示了Tc2Config.dlgOpenSaveFile方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onActionOpenSettingsTriggered
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import dlgOpenSaveFile [as 别名]
def onActionOpenSettingsTriggered(self):
fileName = Tc2Config.dlgOpenSaveFile(
parent=self,
openFile=True,
title='Open Settings..',
fileFilters=('ConfigFiles (*.cfg *.ini)', 'All Files (*)'),
defaultSuffix='cfg',
settingsKey=self.SettingsKeyDialogSettingsOpenState,
)
if fileName is None:
return
#TODO: we hapily assume we can read settings. how to handle errors?
qSettings = QtCore.QSettings(fileName, QtCore.QSettings.IniFormat)
params = self.gocrParamsFromQSettings(qSettings)
self.setGocrParams(params)
示例2: onOpen
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import dlgOpenSaveFile [as 别名]
def onOpen(self, checked):
fileName = Tc2Config.dlgOpenSaveFile(
parent=self,
openFile=True,
title='Open Style Sheet..',
fileFilters=('Style sheets (*.css)', 'All Files (*)'),
#TODO: rename to HandViewerStyleSheet
settingsKey=self.SettingsKeyDialogOpenState,
)
if fileName is None:
return
fp = None
try:
fp = open(fileName, 'r')
except Exception, d:
Tc2Config.msgWarning(self, 'Could Not Open Style sheet\n\n%s' % d)
示例3: onButtonSaveImageClicked
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import dlgOpenSaveFile [as 别名]
def onButtonSaveImageClicked(self):
imageFormats = imageFormats = Tc2Config.readWriteImageFormats()
fileName = Tc2Config.dlgOpenSaveFile(
parent=self,
openFile=False,
title='Save Screenshot..',
fileFilters=('Images (%s)' % ' '.join(['*.%s' % i for i in imageFormats]), 'All Files (*)'),
defaultSuffix='png',
settingsKey=self.SettingsKeyDialogSaveImageState,
)
if fileName is None:
return
fileInfo = QtCore.QFileInfo(fileName)
format = fileInfo.suffix().toLower()
if not self.labelPixmap.pixmap().save(fileName, format):
Tc2Config.msgWarning(self, 'Could Not Save Image')
示例4: onButtonBackgroundImageClicked
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import dlgOpenSaveFile [as 别名]
def onButtonBackgroundImageClicked(self):
imageFormats = Tc2Config.readWriteImageFormats()
fileName = Tc2Config.dlgOpenSaveFile(
parent=self,
openFile=True,
title='Open Background Image..',
fileFilters=('Images (%s)' % ' '.join(['*.%s' % i for i in imageFormats]), 'All Files (*)'),
settingsKey=self.SettingsKeyDialogOpenImageState,
)
if fileName is None:
return
imageName, pixmap = self.imageFromFileName(fileName)
if imageName is None:
Tc2Config.msgWarning(self, 'Could not open background image')
return
self.setBackgroundImage(imageName, pixmap)
示例5: onActionOpenTriggered
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import dlgOpenSaveFile [as 别名]
def onActionOpenTriggered(self):
fileName = Tc2Config.dlgOpenSaveFile(
parent=self,
openFile=True,
title='Open Hand..',
fileFilters=('HandHistories (*.txt)', 'All Files (*)'),
settingsKey=self.SettingsKeyDialogOpenState,
)
if fileName is None:
return
#TODO: make failsave
fileName = fileName.toUtf8()
fileName = unicode(fileName, 'utf-8')
try:
self.handHistoryFile = Tc2SitePokerStarsHandGrabber.HandHistoryFile(fileName)
except Exception, d:
Tc2Config.msgWarning(self, 'Could Not Open Hand history\n\n%s' % d)
示例6: onSave
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import dlgOpenSaveFile [as 别名]
def onSave(self, checked):
fileName = Tc2Config.dlgOpenSaveFile(
parent=self,
openFile=False,
title='Save Style Sheet..',
fileFilters=('Stylesheets (*.css)', 'All Files (*)'),
#TODO: rename to HandViewerStyleSheet
settingsKey=self.SettingsKeyDialogSaveState,
defaultSuffix='css',
)
if fileName is None:
return
fp = None
try:
fp = open(fileName, 'w')
fp.write(self.edit.toPlainText() )
except Exception, d:
Tc2Config.msgWarning(self, 'Could Not Save Style sheet\n\n%s' % d)
示例7: onActionSaveTriggered
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import dlgOpenSaveFile [as 别名]
def onActionSaveTriggered(self):
fileName = Tc2Config.dlgOpenSaveFile(
parent=self,
openFile=False,
title='Save Hand..',
fileFilters=('HtmlFiles (*.html *.htm)', 'All Files (*)'),
#TODO: rename to Gui/HandViewer/DialogSave/State
settingsKey=self.SettingsKeyDialogSaveState,
defaultSuffix='html',
)
if fileName is None:
return
fileName = unicode(fileName.toUtf8(), 'utf-8')
fp = None
try:
fp = codecs.open(fileName, 'w', encoding='utf-8')
except Exception, d:
Tc2Config.msgWarning(self, 'Could Not Save Hand\n\n%s' % d)
示例8: onActionSaveSettingsTriggered
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import dlgOpenSaveFile [as 别名]
def onActionSaveSettingsTriggered(self):
fileName = Tc2Config.dlgOpenSaveFile(
parent=self,
openFile=False,
title='Save Settings..',
fileFilters=('ConfigFiles (*.cfg *.ini)', 'All Files (*)'),
defaultSuffix='cfg',
settingsKey=self.SettingsKeyDialogSettingsSaveState,
)
if fileName is None:
return
#NOTE: looks like Qt is only checking for write protect anything else may or may not pass ..and we don't get any IO errors
# so we try in advance. obv there are still loopholes
fp = None
try: fp = open(fileName, 'w').close()
except Exception, d:
Tc2Config.msgWarning(self, 'Could Not Open Config File\n\n%s' % d)
return
示例9: onActionOpenImageTriggered
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import dlgOpenSaveFile [as 别名]
def onActionOpenImageTriggered(self):
imageFormats = Tc2Config.readWriteImageFormats()
fileName = Tc2Config.dlgOpenSaveFile(
parent=self,
openFile=True,
title='Open Image..',
fileFilters=('Images (%s)' % ' '.join(['*.%s' % i for i in imageFormats]), 'All Files (*)'),
settingsKey=self.SettingsKeyDialogImageOpenState,
)
if fileName is None:
return
pixmap = QtGui.QPixmap()
if not pixmap.load(fileName):
Tc2Config.msgWarning(self, 'Could not open image')
return
fileInfo = QtCore.QFileInfo(fileName)
screenshotName = fileInfo.baseName()
self.setPixmap(pixmap=pixmap)
示例10: onActionSaveImageTriggered
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import dlgOpenSaveFile [as 别名]
def onActionSaveImageTriggered(self):
if self.labelInputImage.pixmap() is None:
self.actionSaveImage.setEnabled(False)
return
imageFormats = imageFormats = Tc2Config.readWriteImageFormats()
fileName = Tc2Config.dlgOpenSaveFile(
parent=self,
openFile=False,
title='Save Image..',
fileFilters=('Images (%s)' % ' '.join(['*.%s' % i for i in imageFormats]), 'All Files (*)'),
defaultSuffix='png',
settingsKey=self.SettingsKeyDialogImageSaveState,
)
if fileName is None:
return
fileInfo = QtCore.QFileInfo(fileName)
format = fileInfo.suffix().toLower()
if not self.labelInputImage.pixmap().save(fileName, format):
Tc2Config.msgWarning(self, 'Could Not Save Image')
示例11: onSave
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import dlgOpenSaveFile [as 别名]
def onSave(self, *args):
fileName = Tc2Config.dlgOpenSaveFile(
parent=self,
openFile=False,
title='Save Screenshot Info..',
fileFilters=('TextFiles (*.txt)', 'All Files (*)'),
settingsKey='Gui/Screenshot/DialogScreenshotInfo/DialogSave/State',
)
if fileName is None:
return
# default to '.txt'
fileInfo = QtCore.QFileInfo(fileName)
format = fileInfo.suffix().toLower()
if not format:
fileName = fileName + '.txt'
fp = None
try:
fp = open(fileName, 'w')
fp.write(self.edit.toPlainText() )
except Exception, d:
Tc2Config.msgWarning(self, 'Could Not Save Screenshot Info\n\n%s' % d)
示例12: onActionOpenTriggered
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import dlgOpenSaveFile [as 别名]
def onActionOpenTriggered(self):
fileName = Tc2Config.dlgOpenSaveFile(
parent=self,
openFile=True,
title='Open Hand..',
fileFilters=('HtmlFiles (*.html *.htm)', 'All Files (*)'),
#TODO: rename to Gui/HandViewer/DialogOpen/State
settingsKey=self.SettingsKeyDialogOpenState,
)
if fileName is None:
return
#TODO: maybe limit max size of file before we read unconditionally
fileName = fileName.toUtf8()
fileName = unicode(fileName, 'utf-8')
fp = codecs.open(fileName, 'r', encoding='utf-8')
try:
raw = fp.read()
except UnicodeDecodeError:
self._browser.setHtml('<h3>Could not open hand: invalid</h3>')
return
try:
data = QtCore.QString(raw).toUtf8()
finally:
fp.close()
hand = None
for siteHandler in Tc2Config.globalObject.siteManager:
hand = siteHandler.handFromHtml(raw)
if hand:
break
if hand is None:
pass
elif not hand:
self._browser.setHtml('<h3>Could not open hand: invalid</h3>')
else:
self.setHand(data, fileName=fileName)
self.sideBarContainer.handleHandSet(hand)