python怎么使用qtdesigner_使用QTDesigner与PyQT和Python 2.6

我开始写我的第一个PyQT应用程序(PyQT只用于处理GUI),似乎好的工具链是:QtDesigner来生成.ui和处理资源和一些IDE,可以设置QtDesigner来编辑它们。我使用Eclipse,因为它是高度可定制的。

您可以通过在应用程序启动,安装或任何其他时间按照这样做在需求情况下编译.qrc和.ui:

os.system("pyrcc4.exe -o ui/images_rc.py ui/images/images.qrc")

uic.compileUiDir(appDir + '/ui', True)

然后以这种方式使用生成的类:

class MyMainWindow(QtGui.QMainWindow):

def __init__(self, owner):

QtGui.QMainWindow.__init__(self)

# 'Ui_MyMainWindow' is the class, that was generated by uic,

# naming convention is: 'Ui_' plus the name of root widget in designer

self.ui = Ui_MyMainWindow()

self.ui.setupUi(self)

或者您可以在容器中直接加载.ui:

QtGui.QMainWindow.__init__(self)

self.ui = None

uic.loadUi('MyMainWindowUI.ui', self.ui)

#now you have the instance of Ui_MyMainWindow in s

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值