本文整理汇总了Python中Tc2Config.msgWarning方法的典型用法代码示例。如果您正苦于以下问题:Python Tc2Config.msgWarning方法的具体用法?Python Tc2Config.msgWarning怎么用?Python Tc2Config.msgWarning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tc2Config
的用法示例。
在下文中一共展示了Tc2Config.msgWarning方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onButtonBackupClicked
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import msgWarning [as 别名]
def onButtonBackupClicked(self, checked):
dlg = QtGui.QFileDialog(self)
dlg.setWindowTitle('Backup tableCrab To Config File..')
dlg.setFileMode(dlg.AnyFile)
dlg.setAcceptMode(dlg.AcceptSave)
dlg.setConfirmOverwrite(True)
filters = QtCore.QStringList()
filters << 'Config Files (*.ini *.cfg)'
filters << 'All Files (*)'
dlg.setNameFilters(filters)
dlg.restoreState( Tc2Config.settingsValue(self.SettingsKeyDialogBackupState, QtCore.QByteArray()).toByteArray() )
result = dlg.exec_()
Tc2Config.settingsSetValue(self.SettingsKeyDialogBackupState, dlg.saveState() )
if result != dlg.Accepted:
return
fileName = dlg.selectedFiles()[0]
fileInfo = QtCore.QFileInfo(fileName)
format = fileInfo.suffix().toLower()
# default save format to to ".ini"
if not format:
fileName = fileName + '.ini'
#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
示例2: onEditCardsReturnPressed
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import msgWarning [as 别名]
def onEditCardsReturnPressed(self):
text = self.editCards.text().toUtf8()
text = unicode(text, 'utf-8')
cards = [i.strip() for i in text.split(',')]
try:
cards = [PokerTools.Card(i) for i in cards]
except ValueError:
Tc2Config.msgWarning(self, 'Invalid cards')
return
#NOTE: we don't care about duplicate cards here. ok?
self.setCards(cards)
示例3: onOpen
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import msgWarning [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)
示例4: onButtonSaveImageClicked
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import msgWarning [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')
示例5: onButtonBackgroundImageClicked
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import msgWarning [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)
示例6: onActionOpenTriggered
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import msgWarning [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)
示例7: onSave
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import msgWarning [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)
示例8: onActionSaveTriggered
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import msgWarning [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)
示例9: onActionSaveSettingsTriggered
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import msgWarning [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
示例10: onActionOpenImageTriggered
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import msgWarning [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)
示例11: onActionSaveImageTriggered
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import msgWarning [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')
示例12: setCards
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import msgWarning [as 别名]
def setCards(self, cards):
self.editCards.setText(', '.join([card.name() for card in cards]))
directory = self.directory()
#NOTE: we draw cards directly if no cards are specified to avoid
# the nasty error messages below on startup
if not directory or not cards:
self.boardWidget.setCards(cards)
return
if not os.path.isdir(directory):
Tc2Config.msgWarning(self, 'Invalid directory')
return
fmts = ('.png', '.jpg', '.svg', '.bmp')
pixmaps = [[i, None] for i in cards]
for name in os.listdir(directory):
myName, ext = os.path.splitext(name.lower())
if ext not in fmts: continue
if len(myName) != 2: continue
myName = myName[0].upper() + myName[1].lower()
try: card = PokerTools.Card(myName)
except ValueError: continue
try: i = cards.index(card)
except ValueError: continue
# load pixmap
fileName = os.path.normpath(os.path.join(directory, name))
px = QtGui.QPixmap()
if px.load(fileName):
pixmaps[i][1] = px
# errcheck
for card, px in pixmaps:
if px is None:
Tc2Config.msgWarning(self, 'Could not load card: %s' % card.name())
return
self.boardWidget.setPixmaps(pixmaps)
示例13: onSave
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import msgWarning [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)
示例14: open
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import msgWarning [as 别名]
if not format:
fileName = fileName + '.ini'
#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
finally:
if fp is not None: fp.close()
newSettings = QtCore.QSettings(fileName, QtCore.QSettings.IniFormat)
if not newSettings.isWritable():
Tc2Config.msgWarning(self, 'Config File Is Not Writable')
return
settings = Tc2Config.settings()
for key in settings.allKeys():
newSettings.setValue(key, settings.value(key) )
def onHelp(self, *args):
Tc2GuiHelp.dialogHelp('settingsGlobal', parent=self)
def guiStyle(self):
return self.groupGuiStyle.value()
def setGuiStyle(self, value):
style = QtGui.QStyleFactory.create(value)
#TODO: we currently set no palette. QStyle docs say palette should not be set
# for styles that use system defaults, but there seems to be no way to find out