新聞中心
PyQt 邊框式樣主要包括以下幾種:

成都創(chuàng)新互聯(lián)公司堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站建設(shè)、成都做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的新密網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
1、QFrame.Sunken:凹陷式邊框,邊框在內(nèi)容區(qū)域之外。
2、QFrame.Raised:凸起式邊框,邊框在內(nèi)容區(qū)域之上。
3、QFrame.Box:默認(rèn)邊框樣式,邊框在內(nèi)容區(qū)域之內(nèi)。
4、QFrame.Panel:面板式邊框,邊框在內(nèi)容區(qū)域之外,但比凹陷式邊框更窄。
5、QFrame.StyledPanel:帶有陰影的面板式邊框。
6、QFrame.WinPanel:Windows風(fēng)格的面板式邊框。
7、QFrame.HLine:水平線邊框。
8、QFrame.VLine:垂直線邊框。
9、QFrame.StyledFrame:帶有圓角和陰影的邊框。
10、QFrame.NoFrame:無(wú)邊框樣式。
以下是一個(gè)簡(jiǎn)單的 PyQt 邊框式樣示例:
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QPushButton, QFrame
from PyQt5.QtCore import Qt
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
vbox = QVBoxLayout()
# 創(chuàng)建不同樣式的邊框
frame1 = QFrame(self)
frame1.setFrameShape(QFrame.Sunken)
frame1.setLineWidth(2)
frame1.setMidLineWidth(1)
frame1.setStyleSheet("bordercolor: red;")
frame2 = QFrame(self)
frame2.setFrameShape(QFrame.Raised)
frame2.setLineWidth(2)
frame2.setMidLineWidth(1)
frame2.setStyleSheet("bordercolor: blue;")
frame3 = QFrame(self)
frame3.setFrameShape(QFrame.Box)
frame3.setLineWidth(2)
frame3.setMidLineWidth(1)
frame3.setStyleSheet("bordercolor: green;")
frame4 = QFrame(self)
frame4.setFrameShape(QFrame.Panel)
frame4.setLineWidth(2)
frame4.setMidLineWidth(1)
frame4.setStyleSheet("bordercolor: purple;")
# 將按鈕添加到不同的邊框中
button1 = QPushButton("按鈕1", self)
button1.setGeometry(50, 50, 100, 30)
frame1.addWidget(button1)
button2 = QPushButton("按鈕2", self)
button2.setGeometry(50, 90, 100, 30)
frame2.addWidget(button2)
button3 = QPushButton("按鈕3", self)
button3.setGeometry(50, 130, 100, 30)
frame3.addWidget(button3)
button4 = QPushButton("按鈕4", self)
button4.setGeometry(50, 170, 100, 30)
frame4.addWidget(button4)
vbox.addWidget(frame1)
vbox.addWidget(frame2)
vbox.addWidget(frame3)
vbox.addWidget(frame4)
self.setLayout(vbox)
self.setWindowTitle('PyQt 邊框式樣')
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
在這個(gè)示例中,我們創(chuàng)建了四個(gè)不同樣式的邊框(凹陷式、凸起式、默認(rèn)樣式和面板式),并將四個(gè)按鈕添加到這些邊框中,通過(guò)運(yùn)行這個(gè)程序,你可以看到不同樣式的邊框效果。
當(dāng)前名稱:PyQt邊框式樣
網(wǎng)頁(yè)URL:http://www.5511xx.com/article/djpshds.html


咨詢
建站咨詢
