#MyOperation button clicked
@pyqtSignature("")
def on_button_MyOperation_clicked(self):
#pass to the operation handler
self.utilityButtonClicked('MyOperation')
def utilityButtonClicked(self, operation):
#get selected items
selectedItems = self.treeWidget_Files.selectedItems()
if len(selectedItems) > 0:
#progressViewer is a dialog that contains a QTextEdit widget
window = progressViewer.progressViewer(self)
window.setVisible(True)
window.show()
utilityThread = None
#create the thread to do the utility operation
utilityThread = threading.Thread( None, self.DoUtilityOperation, None, ( operation, selectedItems, window ) )
utilityThread.start()
self.threads.append( utilityThread ) #store the thread
def DoUtilityOperation( self, operation, selectedItems, window ):
for item in selectedItems: #run the operation on each item
self.DoUtilityOperationOnItem( operation, item, window )
def DoUtilityOperationOnItem( self, operation, item, window ):
#do some stuff
#output text using this code several times
window.textEdit_ProgressDisplay.append( 'some text' )
window.
textEdit_ProgressDisplay.
moveCursor( QTextCursor.
End )
#do some other stuff
#MyOperation button clicked
@pyqtSignature("")
def on_button_MyOperation_clicked(self):
#pass to the operation handler
self.utilityButtonClicked('MyOperation')
def utilityButtonClicked(self, operation):
#get selected items
selectedItems = self.treeWidget_Files.selectedItems()
if len(selectedItems) > 0:
#progressViewer is a dialog that contains a QTextEdit widget
window = progressViewer.progressViewer(self)
window.setVisible(True)
window.show()
utilityThread = None
#create the thread to do the utility operation
utilityThread = threading.Thread( None, self.DoUtilityOperation, None, ( operation, selectedItems, window ) )
utilityThread.start()
self.threads.append( utilityThread ) #store the thread
def DoUtilityOperation( self, operation, selectedItems, window ):
for item in selectedItems: #run the operation on each item
self.DoUtilityOperationOnItem( operation, item, window )
def DoUtilityOperationOnItem( self, operation, item, window ):
#do some stuff
#output text using this code several times
window.textEdit_ProgressDisplay.append( 'some text' )
window.textEdit_ProgressDisplay.moveCursor( QTextCursor.End )
#do some other stuff
To copy to clipboard, switch view to plain text mode
Bookmarks