最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

PyQt5 控件字體樣式等設(shè)置的實(shí)現(xiàn)

 更新時間:2020年05月13日 10:30:28   作者:c_G-17  
這篇文章主要介紹了PyQt5 控件字體樣式等設(shè)置的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

一、API接口設(shè)置

比如我這段代碼中的一些設(shè)置,設(shè)置文字、居中、禁止復(fù)制、LineEdit輸入為password等等

import sys

from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QFrame
from PyQt5.QtWidgets import QLabel
from PyQt5.QtWidgets import QWidget
from PyQt5.QtWidgets import QLineEdit
from PyQt5.QtWidgets import QTextEdit
from PyQt5.QtWidgets import QSizePolicy
from PyQt5.QtWidgets import QMainWindow
from PyQt5.QtWidgets import QPushButton
from PyQt5.QtWidgets import QGridLayout
from PyQt5.QtWidgets import QApplication




from View import interface

class MainWindow(QMainWindow):

  def __init__(self):
    super(MainWindow,self).__init__(None)
    self.setWindowTitle("對金屬腐蝕性試驗(yàn)儀")
    self.initUI()

  def initUI(self):
    layout = QGridLayout()
    layout.setSpacing(10)
    self.loginLabel = QLabel("用戶名:")
    self.loginLabel.setAlignment(Qt.AlignRight)
    self.loginLabel.setStyleSheet("color:rgb(20,20,20,255);font-size:16px;font-weight:bold:text")
    self.loginTxt = QLineEdit()
    self.loginTxt.setText("admin")
    self.loginTxt.setPlaceholderText("User Name")
    self.loginTxt.setClearButtonEnabled(True)
    self.pwdLabel = QLabel("密碼:")
    self.pwdLabel.setAlignment(Qt.AlignRight)
    self.pwdTxt = QLineEdit()
    self.pwdTxt.setContextMenuPolicy(Qt.NoContextMenu) #禁止復(fù)制粘貼
    self.pwdTxt.setPlaceholderText("Password")
    self.pwdTxt.setText("admin")
    self.pwdTxt.setEchoMode(QLineEdit.Password)
    self.pwdTxt.setClearButtonEnabled(True)
    self.registeredBtn = QPushButton("注冊")
    self.loginBtn = QPushButton("登陸")

    self.headLabel = QLabel("用戶登陸")
    self.headLabel.resize(300,30)
    self.headLabel.setAlignment(Qt.AlignCenter)
    self.headLabel.setStyleSheet("color:rgb(10,10,10,255);font-size:25px;font-weight:bold;font-family:Roman times;")

    self.headLabel.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding)
    layout.addWidget(self.headLabel,0,0,1,2)
    policy = self.headLabel.sizePolicy()
    print(policy.verticalPolicy())
    policy.setVerticalPolicy(1)
    print(policy.verticalPolicy())
    # policy.setVerticalPolicy(1)
    layout.addWidget(self.loginLabel,1,0)
    layout.addWidget(self.loginTxt,1,1)
    layout.addWidget(self.pwdLabel,2,0)
    layout.addWidget(self.pwdTxt,2,1)
    layout.addWidget(self.registeredBtn,3,0)
    layout.addWidget(self.loginBtn,3,1)

    frame = QFrame(self)
    frame.setLayout(layout)
    self.setCentralWidget(frame)
    self.resize(300,150)

if __name__ == '__main__':
  app = QApplication(sys.argv)
  mainWindow = MainWindow()
  mainWindow.show()
  mainWindow.activateWindow()
  mainWindow.raise_()
  app.exec_()
  del mainWindow
  del app

1.1.0 QLineEdit一些屬性

inputMask設(shè)置掩碼
text 設(shè)置文本
maxLength文本框輸入的最大字符數(shù)
frame 設(shè)置邊框
echoMode 設(shè)置文本框顯示格式
Normal正常顯示所輸入的字符,此為默認(rèn)選項(xiàng)
NoEcho不顯示任何輸入的字符,常用于密碼類型的輸入,且長度保密
Password顯示與平臺相關(guān)的密碼掩飾字符,而不是實(shí)際輸入的字符
PasswordEchoOnEdit在編輯時顯示字符,負(fù)責(zé)顯示密碼類型的輸入
cursorPosition光標(biāo)位置
alignment文本對齊方式
AlignLeft左對齊
AlignRight右對齊
AlignCenter水平居中對齊
AlignJustify水平方向調(diào)整間距兩端對齊
AlignTop垂直上對齊
AlignBottom垂直方下對齊
AlignVCenter垂直方向居中對齊
dragEnabled設(shè)置文本框是否接受拖動
readOnly設(shè)置文本為只讀
placeholderText設(shè)置文本框提示文字
cursorMoveStyle光標(biāo)移動風(fēng)格
LogicalMoveStyle邏輯風(fēng)格
VisualMoveStyle視覺風(fēng)格
clearButtonEnabled快速刪除按鈕

參考文章,QLineEdit屬性、信號、方法等

1.1 常用的一些設(shè)置

參數(shù) 作用
AlignAbsolute=16
AlignBaseline=256
AlignBottom=64 底端對齊
AlignCenter=132 完全居中
AlignHCenter=4 水平居中
AlignHorizontal_Mask=31
AlignJustify=8 可用空間對齊
AlignLeading=1 領(lǐng)頭對齊(理解為左對齊吧)
AlignLeft=1 左對齊
AlignRight=2 右對齊
AlignTop=32 上對齊
AlignTrailing=2 尾對齊(右對齊
AlignVCenter=128 垂直居中

setClearButtonEnabled(self, bool): 是否有清除文本按鈕(如我第一段程序文本框后的 小黑X)

setCompleter(self, QCompleter):設(shè)置自動補(bǔ)全QLineEdit自動補(bǔ)全

setCursorMoveStyle(self, Qt_CursorMoveStyle):
setCursorPosition(self, p_int):
setDragEnabled(self, bool):
setEchoMode(self, QLineEdit_EchoMode):
setFrame(self, bool):
setInputMask(self, p_str):
setMaxLength(self, p_int):
setModified(self, bool):
setPlaceholderText(self, p_str):
setReadOnly(self, bool):
setSelection(self, p_int, p_int_1):
setText(self, p_str):
setTextMargins(self, *__args):
setValidator(self, QValidator):

到此這篇關(guān)于PyQt5 控件字體樣式等設(shè)置的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)PyQt5 控件字體樣式內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Python使用爬蟲爬取貴陽房價的方法詳解

    Python使用爬蟲爬取貴陽房價的方法詳解

    這篇文章主要為大家詳細(xì)介紹了Python爬蟲爬取貴陽房價的方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助
    2022-02-02
  • python中對列表的刪除和添加方法詳解

    python中對列表的刪除和添加方法詳解

    這篇文章主要為大家詳細(xì)介紹了python中對列表的刪除和添加方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助
    2022-02-02
  • Python shutil模塊文件和目錄操作示例詳解

    Python shutil模塊文件和目錄操作示例詳解

    本文將會學(xué)習(xí)到?shutil?模塊,包括其主要功能和示例代碼,以幫助你更好地理解如何使用它來處理文件和目錄
    2023-11-11
  • Python3+Flask安裝使用教程詳解

    Python3+Flask安裝使用教程詳解

    這篇文章主要介紹了Python3+Flask安裝使用教程詳解,需要的朋友可以參考下
    2021-02-02
  • python列表字典排序的實(shí)現(xiàn)示例

    python列表字典排序的實(shí)現(xiàn)示例

    在Python中,對列表字典進(jìn)行排序是一項(xiàng)常見的任務(wù),本文主要介紹了python列表字典排序的實(shí)現(xiàn)示例,具有一定的參考價值,感興趣的可以了解一下
    2023-09-09
  • pytorch簡介

    pytorch簡介

    Pytorch是torch的python版本,是由Facebook開源的神經(jīng)網(wǎng)絡(luò)框架,專門針對 GPU 加速的深度神經(jīng)網(wǎng)絡(luò)(DNN)編程。這篇文章給大家介紹pytorch的相關(guān)知識,感興趣的朋友一起看看吧
    2020-11-11
  • python twilio模塊實(shí)現(xiàn)發(fā)送手機(jī)短信功能

    python twilio模塊實(shí)現(xiàn)發(fā)送手機(jī)短信功能

    這篇文章主要介紹了python twilio模塊實(shí)現(xiàn)發(fā)送手機(jī)短信的功能,本文圖文并茂給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-08-08
  • python dlib人臉識別代碼實(shí)例

    python dlib人臉識別代碼實(shí)例

    這篇文章主要介紹了python dlib人臉識別,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • Python3實(shí)現(xiàn)打印任意寬度的菱形代碼

    Python3實(shí)現(xiàn)打印任意寬度的菱形代碼

    這篇文章主要介紹了Python3實(shí)現(xiàn)打印任意寬度的菱形代碼,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-04-04
  • tensorflow1.0學(xué)習(xí)之模型的保存與恢復(fù)(Saver)

    tensorflow1.0學(xué)習(xí)之模型的保存與恢復(fù)(Saver)

    這篇文章主要介紹了tensorflow1.0學(xué)習(xí)之模型的保存與恢復(fù)(Saver) ,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-04-04

最新評論

利津县| 义乌市| 绩溪县| 惠州市| 渝北区| 澄江县| 台前县| 怀来县| 富宁县| 古丈县| 汤原县| 宜城市| 陕西省| 卓资县| 彰武县| 余江县| 墨竹工卡县| 莒南县| 上虞市| 嘉兴市| 香格里拉县| 宁津县| 云霄县| 肇庆市| 会泽县| 岗巴县| 卢湾区| 连江县| 五大连池市| 四平市| 岑巩县| 蓝山县| 九江市| 黎城县| 民勤县| 潼关县| 宝丰县| 敦化市| 南宫市| 鹤山市| 武夷山市|