renamediaolog.py
Go to the documentation of this file.
1 '''
2  Copyright (C) 1997-2017 JDERobot Developers Team
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU Library General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, see <http://www.gnu.org/licenses/>.
16 
17  Authors : Okan Asik (asik.okan@gmail.com)
18 
19  '''
20 import sys
21 from PyQt5.QtWidgets import QDialog, QLineEdit, QPushButton, QVBoxLayout, QWidget, QHBoxLayout, QApplication
22 from PyQt5.QtCore import pyqtSignal
23 
24 class RenameDialog(QDialog):
25  nameChanged = pyqtSignal('QString')
26 
27  def __init__(self, name, currentValue):
28  super(QDialog, self).__init__()
29  self.setWindowTitle(name)
30  self.nameEdit = QLineEdit()
31  self.nameEdit.setText(currentValue)
32  self.cancelButton = QPushButton('Cancel')
33  self.cancelButton.clicked.connect(self.cancel)
34  self.acceptButton = QPushButton('Accept')
35  self.acceptButton.clicked.connect(self.accept)
36 
37  verticalLayout = QVBoxLayout()
38  verticalLayout.addWidget(self.nameEdit)
39 
40  container = QWidget()
41  hLayout =QHBoxLayout()
42  hLayout.addWidget(self.cancelButton)
43  hLayout.addWidget(self.acceptButton)
44  container.setLayout(hLayout)
45 
46  verticalLayout.addWidget(container)
47  self.setLayout(verticalLayout)
48 
49  def cancel(self):
50  self.close()
51 
52  def accept(self):
53  self.nameChanged.emit(self.nameEdit.text())
54  self.close()
55 
56 if __name__ == '__main__':
57  app = QApplication(sys.argv)
58  dialog = RenameDialog('Rename', 'Hello World')
59  dialog.exec_()


visualstates
Author(s):
autogenerated on Thu Apr 1 2021 02:42:20