(Create simple GUI Applications with Python and Qt学习)pyqt的widget

基本是照着视频打的

只是把各种widget分开设置然后整合到一起

这也导致视频中获取centralwidget相关的部分不知道怎么实现,这个layout,widget层次细节不了解。。

程序如下:

from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *

import sys

class MainWindow(QMainWindow):

    def __init__(self, *args ,**kwargs):
        super(MainWindow,self).__init__(*args,**kwargs)
        self.setWindowTitle("Widget")
        layout = QVBoxLayout()

        '''
        widgets = [
                  QCheckBox,
                  QDateEdit,
                  QDateTimeEdit,
                  QDial,
                  QDoubleSpinBox,
                  QFontComboBox,
                  QLCDNumber,
                  QLabel,
                  QLineEdit,
                  QProgressBar,
                  QPushButton,
                  QRadioButton,
                  QSlider,
                  QSpinBox,
                  QTimeEdit
                ]
        for w in widgets:
                layout.addWidget(w())
        '''


#label
        label = QLabel("hello label!")
        font =  label.font()
        font.setPointSize(30)
        label.setFont(font)
        label.setPixmap(QPixmap("dog.jpg"))
        label.setScaledContents(True)     #文字不可用
        label.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter )
        layout.addWidget(label)

#checkbox
        checkbox = QCheckBox()
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
2016出版新书,2016.2.27重新上传,此pdf比我之前(2016.01.05)上传的那个版本更好。 Paperback: 304 pages Publisher: Packt Publishing - ebooks Account (January 6, 2016) Language: English ISBN-10: 1785287737 ISBN-13: 978-1785287732 Key Features This book empowers you to create rich cross-platform graphical user interfaces using Python It helps you develop applications that can be deployed on Windows, OSX, and Linux The recipes in the book involve real-world applications, giving you a first-hand experience of the practical scenarios Book Description wxPython is a GUI toolkit for the Python programming language built on top of the cross-platform wxWidgets GUI libraries. wxPython provides a powerful set of tools that allow you to quickly and efficiently building applications that can run on a variety of different platforms. Since wxWidgets provides a wrapper around each platform's native GUI toolkit, the applications built with wxPython will have a native look and feel wherever they are deployed. This book will provide you with the skills to build highly functional and native looking user interfaces for Python applications on multiple operating system environments. By working through the recipes, you will gain insights into and exposure to creating applications using wxPython. With a wide range of topics covered in the book, there are recipes to get the most basic of beginners started in GUI programming as well as tips to help experienced users get more out of their applications. The recipes will take you from the most basic application constructs all the way through to the deployment of complete applications. What you will learn Create full featured user interfaces Design and develop custom controls Deploy and distribute wxPython applications to Windows, Macintosh OS X, Linux, and other UNIX-like environments Handle and respond to application events Manage and display data using grids Interact with web services from your GUI Use Paint events to draw custom displays Support the display of user interfaces in multiple languages
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值