SHARE
TWEET

Untitled

a guest May 19th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class MainWindow(QMainWindow):
  2.     '''
  3.     classdocs
  4.     '''
  5.  
  6.  
  7.     def __init__(self):
  8.         '''
  9.         Constructor
  10.         '''
  11.         super(MainWindow, self).__init__()
  12.        
  13.         self.initButtons()
  14.        
  15.         #self.showMaximized()
  16.        
  17.     def initButtons(self):
  18.         centalWidget = QWidget()
  19.        
  20.         btnFolderDialog = QPushButton("Folder dialog")
  21.         btnFolderDialog.clicked.connect(self.folderButton)
  22.        
  23.         btnFileDialog = QPushButton("File dialog")
  24.         btnFileDialog.clicked.connect(self.fileButton)
  25.        
  26.         btnSaveFile = QPushButton("Save file dialog")
  27.         btnSaveFile.clicked.connect(self.saveFileButton)
  28.        
  29.         btnErrorMessage = QPushButton("Error message")
  30.         btnErrorMessage.clicked.connect(self.errorMessage)
  31.        
  32.         btnQuestionMessage = QPushButton("Question message")
  33.         btnQuestionMessage.clicked.connect(self.questionMessage)
  34.        
  35.         btnTextInput = QPushButton("Text input")
  36.         btnTextInput.clicked.connect(self.textInput)
  37.        
  38.         btnIntInput = QPushButton("Int input")
  39.         btnIntInput.clicked.connect(self.intInput)
  40.        
  41.         btnItemInput = QPushButton("Item input")
  42.         btnItemInput.clicked.connect(self.itemInput)
  43.        
  44.         layout = QVBoxLayout()
  45.        
  46.         layout.addWidget(btnFolderDialog)
  47.         layout.addWidget(btnFileDialog)
  48.         layout.addWidget(btnSaveFile)
  49.         layout.addWidget(btnErrorMessage)
  50.         layout.addWidget(btnQuestionMessage)
  51.         layout.addWidget(btnIntInput)
  52.         layout.addWidget(btnTextInput)
  53.         layout.addWidget(btnItemInput)
  54.        
  55.        
  56.         centalWidget.setLayout(layout)
  57.        
  58.         self.setCentralWidget(centalWidget)        
  59.        
  60.        
  61.    
  62.     def folderButton(self):
  63.         name = QFileDialog.getExistingDirectory(self, "Odaberi folder", "")
  64.         print(name)
  65.        
  66.     def fileButton(self):
  67.         #
  68.         name, filter = QFileDialog.getOpenFileName(self, "Otvori fajl", "", "*.docx")
  69.         print(name)
  70.        
  71.     def saveFileButton(self):
  72.         name, filter = QFileDialog.getSaveFileName(self, u"Sačuvaj fajl", "", "*.docx")
  73.         print(name)
  74.        
  75.     def errorMessage(self):
  76.         QMessageBox.critical(self, u"Greška", u"Dogodila se greška! ")
  77.    
  78.     def questionMessage(self):
  79.         flags = QtGui.QMessageBox.StandardButton.Yes|QtGui.QMessageBox.StandardButton.No
  80.         button = QMessageBox.question(self, u"Pitanje", u"Da li ste sigurni?", flags)
  81.        
  82.         if(button == QMessageBox.Yes):
  83.             QMessageBox.information(self, "Odabrano dugme", "Odabrano je dugme Yes")
  84.         else:
  85.             QMessageBox.information(self, "Odabrano dugme", "Odabrano je dugme No")
  86.        
  87.     def textInput(self):
  88.         retText, okButton = QInputDialog.getText(self, "Naziv", "Unesite naziv")
  89.         if okButton:
  90.             print(retText)
  91.        
  92.     def intInput(self):
  93.         intRet,okButton = QInputDialog.getInt(self, "Celobrojni unos",u"Unesite ceo broj između 1 i 100", 1, 1, 100, 1)
  94.         if okButton:
  95.             print(intRet)
  96.        
  97.     def itemInput(self):
  98.         itemRet, okButton = QInputDialog.getItem(self, "Izbor","Odaberite neku vrednost", ["crno", "belo", "plavo"], 1, False)
  99.         if okButton:
  100.             print(itemRet)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top