Chinaunix首页 | 论坛 | 博客
  • 博客访问: 43432
  • 博文数量: 6
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 60
  • 用 户 组: 普通用户
  • 注册时间: 2015-03-07 12:16
文章分类
文章存档

2015年(6)

我的朋友

分类: Python/Ruby

2015-03-07 17:07:58



#python 3.4.3
#PySide 1.2.2


点击(此处)折叠或打开

  1. #!/usr/bin/env python
  2.      
  3.     import sys
  4.     from PySide import QtCore, QtGui
  5.      
  6.     # define a function that will be used as a slot
  7.     def sayHello():
  8.         print 'Hello world!'
  9.      
  10.     app = QtGui.QApplication(sys.argv)
  11.      
  12.     button = QtGui.QPushButton('Say hello!')
  13.      
  14.     # connect the clicked signal to the sayHello slot
  15.     button.clicked.connect(sayHello)
  16.     button.show()
  17.      
  18.     sys.exit(app.exec_())


点击(此处)折叠或打开

  1. #!/usr/bin/env python
  2.      
  3.     import sys
  4.     from PySide import QtCore
  5.      
  6.     # define a new slot that receives a C 'int' or a 'str'
  7.     # and has 'saySomething' as its name
  8.     @QtCore.Slot(int)
  9.     @QtCore.Slot(str)
  10.     def saySomething(stuff):
  11.         print stuff
  12.      
  13.     class Communicate(QtCore.QObject):
  14.         # create two new signals on the fly: one will handle
  15.         # int type, the other will handle strings
  16.         speakNumber = QtCore.Signal(int)
  17.         speakWord = QtCore.Signal(str)
  18.      
  19.     someone = Communicate()
  20.     # connect signal and slot properly
  21.     someone.speakNumber.connect(saySomething)
  22.     someone.speakWord.connect(saySomething)
  23.     # emit each 'speak' signal
  24.     someone.speakNumber.emit(10)
  25.     someone.speakWord.emit("Hello everybody!")

阅读(1256) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:PyQt5 label文字设置颜色

给主人留下些什么吧!~~