本文整理汇总了Python中javax.swing.JFileChooser.getCurrentDirectory方法的典型用法代码示例。如果您正苦于以下问题:Python JFileChooser.getCurrentDirectory方法的具体用法?Python JFileChooser.getCurrentDirectory怎么用?Python JFileChooser.getCurrentDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JFileChooser
的用法示例。
在下文中一共展示了JFileChooser.getCurrentDirectory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: menuItemClicked
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import getCurrentDirectory [as 别名]
def menuItemClicked(self, menuItemCaption, messageInfo):
if menuItemCaption == 'Save PoC':
if self.dir:
fc = JFileChooser(self.dir)
else:
fc = JFileChooser()
returnVal = fc.showSaveDialog(None)
if returnVal == JFileChooser.APPROVE_OPTION:
file = fc.getSelectedFile()
try:
mode = 'w'
if file.exists():
res = JOptionPane.showConfirmDialog(None,
"File exists. Append?")
mode = {
JOptionPane.YES_OPTION : 'a',
JOptionPane.NO_OPTION : 'w',
JOptionPane.CANCEL_OPTION : None,
}[res]
if not mode:
return
fp = open(str(file.getAbsolutePath()), mode)
for req_resp in messageInfo:
req = req_resp.getRequest()
resp = req_resp.getResponse()
fp.write(req.tostring())
fp.write('\r\n\r\n')
fp.write(resp.tostring())
fp.write('\r\n\r\n')
fp.close()
except Exception, e:
JOptionPane.showMessageDialog(None,
"Error during save: " + str(e), "Error",
JOptionPane.ERROR_MESSAGE)
raise
JOptionPane.showMessageDialog(None,
"File was successfully saved", "Ok",
JOptionPane.INFORMATION_MESSAGE)
self.dir = fc.getCurrentDirectory()