用pycharm和pyqt5,想写一个弹出窗口的程序,如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
class video_record(QWidget):
def __init__( self ):
super ().__init__()
self .initUI()
def initUI( self ):
self .startbtn = QPushButton( 'begin' , self )
self .startbtn.setGeometry( 40 , 20 , 100 , 20 )
self .startbtn.clicked.connect( self .time1)
self .timeshow = QLineEdit('', self )
self .timeshow.setGeometry( 200 , 200 , 100 , 20 )
self .setGeometry( 100 , 100 , 640 , 480 )
self .setWindowTitle( 'rec' )
self .show()
def time1( self ):
print ( 'rec start' )
self .nw = newin()
self .nw.show()
self .nw.exex_()
class newin(QDialog):
def __init__( self ):
super ().__init__()
self .initUI()
def initUI( self ):
self .lblx = QLabel( 'hh' , self )
self .lblx.setGeometry( 100 , 100 , 100 , 20 )
self .lblx.setAutoFillBackground( True )
self .pale = QPalette()
self .pale.setColor(QPalette.Window,Qt.blue)
self .lblx.setPalette( self .pale)
self .setGeometry( 100 , 100 , 300 , 300 )
self .setWindowTitle( 'newin' )
self .show()
if __name__ = = '__main__' :
app = QApplication(sys.argv)
ex = video_record()
ex.show()
sys.exit(app.exec_())
|
如果测试时发现闪退,可以试着修改一下调用子窗口的程序:
把‘show'去掉:
1
2
3
4
5
|
def time1( self ):
print ( 'rec start' )
self .nw = newin()
#self.nw.show()
self .nw.exex_()
|
到此这篇关于使用Pycharm+PyQt5弹出子窗口的解决方法的文章就介绍到这了,更多相关Pycharm PyQt5弹出子窗口内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!
原文链接:https://blog.csdn.net/normer123456/article/details/120727896