这个UI是用Qt designer生成的,自己没有系统的学习过Python,有好多东西都走了弯路了!

这里记录一下,感谢google,感谢stackoverflow

只是有一样不爽,现在google.com.hk搜索出来的东西不能直接打开了,只能挂代理上....

代码:

# -*- coding: utf-8 -*-
# Created: Mon Oct 22 16:57:35 2012
#      by: PyQt4 UI code generator 4.9.5
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui ,Qt

try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    _fromUtf8 = lambda s: s

class Ui_myPopForm(object):
    def setupUi(self, myPopForm):
        myPopForm.setObjectName(_fromUtf8("myPopForm"))
        myPopForm.setWindowModality(QtCore.Qt.NonModal)
        myPopForm.resize(780, 600)
        myPopForm.setStyleSheet(_fromUtf8("border:3px solid rgb(0, 0, 0);n"
"background-color: rgb(255, 255, 255);"))
        self.centralWidget = QtGui.QWidget(myPopForm)
        self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
        self.modelTopbar = QtGui.QLabel(self.centralWidget)
        self.modelTopbar.setGeometry(QtCore.QRect(3, 3, 774, 40))
        self.modelTopbar.setStyleSheet(_fromUtf8("background-color:#dddddd;border:0;border-bottom:1px solid #cccccc"))
        self.modelTopbar.setText(_fromUtf8(""))
        self.modelTopbar.setObjectName(_fromUtf8("modelTopbar"))
        self.closeBtn = QtGui.QPushButton(self.centralWidget)
        self.closeBtn.setGeometry(QtCore.QRect(753, 15, 15, 15))
        self.closeBtn.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.closeBtn.setStyleSheet(_fromUtf8("border:0;background-image:url(images/top_close.png);"))
        self.closeBtn.setText(_fromUtf8(""))
        self.closeBtn.setObjectName(_fromUtf8("closeBtn"))
        self.topTitle = QtGui.QLabel(self.centralWidget)
        self.topTitle.setGeometry(QtCore.QRect(15, 15, 661, 16))
        self.topTitle.setStyleSheet(_fromUtf8("border:none;background-color:none;n"
"font: 12pt "微软雅黑";"))
        self.topTitle.setObjectName(_fromUtf8("topTitle"))
        myPopForm.setCentralWidget(self.centralWidget)

        self.retranslateUi(myPopForm)
        QtCore.QObject.connect(self.closeBtn, QtCore.SIGNAL(_fromUtf8("clicked()")), myPopForm.close)
        QtCore.QMetaObject.connectSlotsByName(myPopForm)
        #无边框
        myPopForm.setWindowFlags(Qt.Qt.FramelessWindowHint)

    def retranslateUi(self, myPopForm):
        myPopForm.setWindowTitle(u'小米粥(xiaomizhou.net)')
        self.topTitle.setText(u'小米粥(xiaomizhou.net)')

class renderApp(QtGui.QMainWindow):
    def __init__(self, parent=None):
        super(renderApp, self).__init__(parent)
        self.ui = Ui_myPopForm()
        self.ui.setupUi(self)
        
    def mousePressEvent(self,event):
       #鼠标点击事件
       if event.button() == QtCore.Qt.LeftButton:
           self.dragPosition = event.globalPos() - self.frameGeometry().topLeft()
           event.accept()
    def mouseMoveEvent(self,event):
       #鼠标移动事件
        if event.buttons() ==QtCore.Qt.LeftButton:
            self.move(event.globalPos() - self.dragPosition)
            event.accept()   

if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    render = renderApp()
    render.show()
    sys.exit(app.exec_())