Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.48 KB | None | 0 0
  1. main.py
  2.  
  3. import sys
  4. from PyQt5.QtWidgets import (QLineEdit, QVBoxLayout, QMainWindow,
  5.     QWidget, QDesktopWidget, QApplication, QPushButton, QLabel,
  6.     QComboBox, QFileDialog, QRadioButton)
  7. from PyQt5.QtCore import pyqtSlot, QByteArray
  8. from alert import Window2
  9. from test import test
  10.  
  11. class SG(QWidget):
  12.     def __init__(self):
  13.         super().__init__()
  14.         self.initUI()
  15.  
  16.     def initUI(self):
  17.         self.resize(300, 150)
  18.         self.setWindowTitle('TEST')
  19.  
  20.         self.resultsGen = QPushButton('TEST', self)
  21.         self.resultsGen.clicked.connect(lambda: self.on_click())
  22.  
  23.         self.show()
  24.  
  25.     @pyqtSlot()
  26.     def on_click(self):
  27.         test(self)
  28.  
  29. if __name__ == '__main__':
  30.     app = QApplication(sys.argv)
  31.     sg = SG()
  32.  
  33.     sys.exit(app.exec_())
  34. ======================================================================================================
  35. alert.py
  36.  
  37. from PyQt5.QtWidgets import (QLineEdit, QVBoxLayout, QMainWindow,
  38.     QWidget, QDesktopWidget, QApplication, QPushButton, QLabel,
  39.     QComboBox, QFileDialog, QRadioButton)
  40. from PyQt5.QtCore import pyqtSlot, QByteArray
  41. from PyQt5.QtGui import QPixmap
  42.  
  43. from PyQt5 import QtGui, QtCore
  44.  
  45. class Window2(QMainWindow):
  46.     def __init__(self):
  47.         super().__init__()
  48.         self.initPopup()
  49.  
  50.     def initPopup(self):
  51.         self.resize(500, 500)
  52.         self.setWindowTitle("Window22222")
  53.         self.central_widget = QWidget()
  54.         self.setCentralWidget(self.central_widget)
  55.         lay = QVBoxLayout(self.central_widget)
  56.  
  57.         label = QLabel(self)
  58.         pixmap = QPixmap('cropped/8.png')
  59.         label.setPixmap(pixmap)
  60.         self.resize(pixmap.width(), pixmap.height())
  61.  
  62.         lay.addWidget(label)
  63.  
  64.         self.textbox = QLineEdit(self)
  65.         self.textbox.move(20, 20)
  66.         self.textbox.resize(280, 40)
  67.  
  68.         # Create a button in the window
  69.         self.button = QPushButton('Show text', self)
  70.         self.button.move(20, 80)
  71.         # connect button to function on_click
  72.         self.button.clicked.connect(lambda: self.on_clickX())
  73.         self.show()
  74.  
  75.     @pyqtSlot()
  76.     def on_clickX(self):
  77.         textboxValue = self.textbox.text()
  78.         print(textboxValue)
  79.         self.textbox.setText("")
  80.         self.hide()
  81.  
  82. ======================================================================================================
  83. test.py
  84.  
  85. from alert import Window2
  86.  
  87. def test(self):
  88.     for i in range(2):
  89.         for x in range(6):
  90.             w = Window2()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement