参考下面这篇博客:
http://www.cnblogs.com/dcb3688/p/4311138.html
你会发现它讲的并没有什么卵用,你需要的是设置布局,就是你点击右键会有布局在那里,你可以进行水平布局或者垂直布局。
参考这篇博客,好像有点用。
http://www.bubuko.com/infodetail-589789.html
palette1.setBrush(self.backgroundRole(), QtGui.QBrush(QtGui.QPixmap(‘../../../Document/images/17_big.jpg‘))) # 设置背景图片
self.setPalette(palette1)
self.setAutoFillBackground(True) # 不设置也可以
把这几句代码加上去就可以了。
QLayout: Attempting to add QLayout “” to QWidget “t2”, which already has a layout
布局出现了以上问题,根据Stack Overflow的回答就是布局重复了。
http://stackoverflow.com/questions/7684975/pyqt4-qt-designer-making-dynamic-guis
然后我做了以下改变。
# -*- coding: utf-8 -*-
import sys
import os
import re
import time
from PyQt4 import QtCore, QtGui
from ui_nao2 import Ui_Form
from file_nao import file_name
# def update_textBrowser(self):
# self.textBrowser.append(self.ActionBox.currentText())
'''
class MyForm(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QStackedWidget.__init__(self, parent)
self.ui = Ui_Form()
self.ui.setupUi(self)
def event_click(self,parent=None):
# self.ui.ConfirmBtn.setCheckable(True)
if slef.ui.ConfirmBtn.isChecked():
self.ui.textBrowser.append(self.ui.ActionBox.currentText())
'''
def Main():
file_num,list_filename,list_filefullname = file_name()
app = QtGui.QApplication(sys.argv)
Form = QtGui.QWidget()
myapp = Ui_Form()
myapp.setupUi(Form)
i = 0
for i in range(file_num):
# myapp.Form.ActionBox.addItem(list_filename[i])
# myapp.ActionBox.addItem(list_filename[i])
#myapp.ui.ActionBox.addItem(list_filename[i])
#myapp.ui.AudioBox.addItem(list_filename[i])
i = i + 1
# print i
if i == file_num:
# myapp.ui.textBrowser.append(u'目前选择的方案为\n') #追加内容
Form.show()#myapp.show()
'''
while True:
time.sleep(1)
if myapp.ui.ConfirmBtn.isChecked():
myapp.ui.textBrowser.append(myapp.ui.ActionBox.currentText())
'''
# print myapp.ui.ActionBox.currentText()
# while 1:
# if myapp.ui.ConfirmBtn.event == True:
# print myapp.ui.ActionBox.currentText()
# myapp.ui.textBrowser.append(u'test1\n')
# myapp.ui.textBrowser.append(myapp.ui.ActionBox.currentText())
# myapp.show()
# if myapp.ui.ConfirmBtn.event == True:
sys.exit(app.exec_()) # Python不仅仅要在那一行和自身对齐,还需要和后面的程序对其
if __name__ == "__main__": # __main__是用来做当这个模块被调用之后就会不执行这个程序了
Main()
# 使用该函数之后关闭界面不会再出现意外
'''
在uipy里面需要增加的东西
def Dance_Update_TextBrowser(self):
self.textBrowser.append(self.ActionBox.currentText())
def Action_Update_TextBrowser(self):
self.textBrowser.append(self.AudioBox.currentText())
QtCore.QObject.connect(self.ConfirmDanceBtn, QtCore.SIGNAL(_fromUtf8("clicked()")), self.Dance_Update_TextBrowser)
QtCore.QObject.connect(self.ConfirmActionBtn, QtCore.SIGNAL(_fromUtf8("clicked()")), self.Action_Update_TextBrowser)
'''
参考这篇博客:
http://blog.csdn.net/joeblackzqq/article/details/35278665