eric7/Debugger/CallStackViewer.py

branch
eric7
changeset 8356
68ec9c3d4de5
parent 8322
b422b4e77d19
child 8358
144a6b854f70
equal deleted inserted replaced
8355:8a7677a63c8d 8356:68ec9c3d4de5
10 from PyQt6.QtCore import pyqtSignal, Qt, QFileInfo 10 from PyQt6.QtCore import pyqtSignal, Qt, QFileInfo
11 from PyQt6.QtWidgets import ( 11 from PyQt6.QtWidgets import (
12 QTreeWidget, QTreeWidgetItem, QMenu, QWidget, QVBoxLayout, QLabel 12 QTreeWidget, QTreeWidgetItem, QMenu, QWidget, QVBoxLayout, QLabel
13 ) 13 )
14 14
15 from E5Gui.E5Application import e5App 15 from E5Gui.EricApplication import ericApp
16 from E5Gui import E5FileDialog, E5MessageBox 16 from E5Gui import EricFileDialog, EricMessageBox
17 17
18 import Utilities 18 import Utilities
19 19
20 20
21 class CallStackViewer(QWidget): 21 class CallStackViewer(QWidget):
99 @param enabled flag indicating to enable the project mode 99 @param enabled flag indicating to enable the project mode
100 @type bool 100 @type bool
101 """ 101 """
102 self.__projectMode = enabled 102 self.__projectMode = enabled
103 if enabled and self.__project is None: 103 if enabled and self.__project is None:
104 self.__project = e5App().getObject("Project") 104 self.__project = ericApp().getObject("Project")
105 105
106 def __showContextMenu(self, coord): 106 def __showContextMenu(self, coord):
107 """ 107 """
108 Private slot to show the context menu. 108 Private slot to show the context menu.
109 109
186 def __saveStackTrace(self): 186 def __saveStackTrace(self):
187 """ 187 """
188 Private slot to save the stack trace info to a file. 188 Private slot to save the stack trace info to a file.
189 """ 189 """
190 if self.__callStackList.topLevelItemCount() > 0: 190 if self.__callStackList.topLevelItemCount() > 0:
191 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( 191 fname, selectedFilter = EricFileDialog.getSaveFileNameAndFilter(
192 self, 192 self,
193 self.tr("Save Call Stack Info"), 193 self.tr("Save Call Stack Info"),
194 "", 194 "",
195 self.tr("Text Files (*.txt);;All Files (*)"), 195 self.tr("Text Files (*.txt);;All Files (*)"),
196 None, 196 None,
197 E5FileDialog.DontConfirmOverwrite) 197 EricFileDialog.DontConfirmOverwrite)
198 if fname: 198 if fname:
199 ext = QFileInfo(fname).suffix() 199 ext = QFileInfo(fname).suffix()
200 if not ext: 200 if not ext:
201 ex = selectedFilter.split("(*")[1].split(")")[0] 201 ex = selectedFilter.split("(*")[1].split(")")[0]
202 if ex: 202 if ex:
203 fname += ex 203 fname += ex
204 if QFileInfo(fname).exists(): 204 if QFileInfo(fname).exists():
205 res = E5MessageBox.yesNo( 205 res = EricMessageBox.yesNo(
206 self, 206 self,
207 self.tr("Save Call Stack Info"), 207 self.tr("Save Call Stack Info"),
208 self.tr("<p>The file <b>{0}</b> already exists." 208 self.tr("<p>The file <b>{0}</b> already exists."
209 " Overwrite it?</p>").format(fname), 209 " Overwrite it?</p>").format(fname),
210 icon=E5MessageBox.Warning) 210 icon=EricMessageBox.Warning)
211 if not res: 211 if not res:
212 return 212 return
213 fname = Utilities.toNativeSeparators(fname) 213 fname = Utilities.toNativeSeparators(fname)
214 214
215 try: 215 try:
222 while itm is not None: 222 while itm is not None:
223 f.write("{0}\n".format(itm.text(0))) 223 f.write("{0}\n".format(itm.text(0)))
224 f.write("{0}\n".format(78 * "=")) 224 f.write("{0}\n".format(78 * "="))
225 itm = self.__callStackList.itemBelow(itm) 225 itm = self.__callStackList.itemBelow(itm)
226 except OSError as err: 226 except OSError as err:
227 E5MessageBox.critical( 227 EricMessageBox.critical(
228 self, 228 self,
229 self.tr("Error saving Call Stack Info"), 229 self.tr("Error saving Call Stack Info"),
230 self.tr("""<p>The call stack info could not be""" 230 self.tr("""<p>The call stack info could not be"""
231 """ written to <b>{0}</b></p>""" 231 """ written to <b>{0}</b></p>"""
232 """<p>Reason: {1}</p>""") 232 """<p>Reason: {1}</p>""")

eric ide

mercurial