使用Pycharm+PyQt5彈出子窗口的程序代碼
用pycharm和pyqt5,想寫一個彈出窗口的程序,如下:
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_())
如果測試時發(fā)現(xiàn)閃退,可以試著修改一下調(diào)用子窗口的程序:
把‘show'去掉:
def time1(self):
print('rec start')
self.nw=newin()
#self.nw.show()
self.nw.exex_()
到此這篇關(guān)于使用Pycharm+PyQt5彈出子窗口的解決方法的文章就介紹到這了,更多相關(guān)Pycharm PyQt5彈出子窗口內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
python matplotlib 繪圖 和 dpi對應(yīng)關(guān)系詳解
這篇文章主要介紹了python matplotlib 繪圖 和 dpi對應(yīng)關(guān)系詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-03-03
Pytorch 如何實現(xiàn)LSTM時間序列預(yù)測
本文主要基于Pytorch深度學(xué)習(xí)框架,實現(xiàn)LSTM神經(jīng)網(wǎng)絡(luò)模型,用于時間序列的預(yù)測2021-05-05
python按比例隨機(jī)切分?jǐn)?shù)據(jù)的實現(xiàn)
這篇文章主要介紹了python按比例隨機(jī)切分?jǐn)?shù)據(jù)的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07
python 實現(xiàn)將txt文件多行合并為一行并將中間的空格去掉方法
今天小編就為大家分享一篇python 實現(xiàn)將txt文件多行合并為一行并將中間的空格去掉方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-12-12
Python?中設(shè)置請求的最大重試次數(shù)示例代碼
本篇文章介紹了為什么我們會收到錯誤消息,指出超出了最大重試次數(shù),以及我們?nèi)绾卧?Python?中為請求設(shè)置?max_retries,本文通過示例代碼給大家介紹的非常詳細(xì),需要的朋友參考下吧2023-06-06

