As a beginner, I looked at the documentation on timers but could not understand the code. Could you provide an example of the code that would set a timer on self.ui.SaveBtn for 2 seconds? thanks
Another alternative:
At the end of the "save" function that is connected to a button labeled "Save" talked about above, I call this function:
def showgreensaved(self):
timer.start(0)
while timer < 3000:
self.ui.SaveBtn.setText('SAVED')
self.ui.SaveBtn.setStyleSheet(
self.ui.SaveBtn.styleSheet() +
'QPushButton:pressed { background-color: #99ff99; border: 2px solid #097547; }')
self.ui.SaveBtn.setText('Save')
self.ui.SaveBtn.setStyleSheet(self.buttonstyle)
def showgreensaved(self):
timer = QtCore.QTimer()
timer.start(0)
while timer < 3000:
self.ui.SaveBtn.setText('SAVED')
self.ui.SaveBtn.setStyleSheet(
self.ui.SaveBtn.styleSheet() +
'QPushButton:pressed { background-color: #99ff99; border: 2px solid #097547; }')
self.ui.SaveBtn.setText('Save')
self.ui.SaveBtn.setStyleSheet(self.buttonstyle)
To copy to clipboard, switch view to plain text mode
What I want to happen (the above code does not work):
When the user presses the Save button, it saves the data, then changes the text/ of the button from "Save" to "Saved" and changes the background color -- for a period of about 3 seconds, then changes the button back to the previous text and color(buttonstyle).
Does anyone know how to make the "timer" portion of the code work? or, is there a better way to do what I want?
Bookmarks