本文整理匯總了Python中PyQt5.QtWidgets.QLineEdit.setFixedHeight方法的典型用法代碼示例。如果您正苦於以下問題:Python QLineEdit.setFixedHeight方法的具體用法?Python QLineEdit.setFixedHeight怎麽用?Python QLineEdit.setFixedHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWidgets.QLineEdit
的用法示例。
在下文中一共展示了QLineEdit.setFixedHeight方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFixedHeight [as 別名]
class Edit:
def __init__(self,label):
height = 24
self.key = label
self.value = ""
self.layout = QHBoxLayout()
self.labl = QLabel(label)
self.labl.setFixedHeight(height)
self.labl.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
self.edit = QLineEdit( )
self.edit.setFixedHeight(height)
self.edit.setText(self.value)
self.edit.setStyleSheet(bgcolor(128,128,128)+fgcolor(255,255,128))
self.edit.textChanged.connect(self.editChanged)
self.layout.addWidget(self.labl)
self.layout.addWidget(self.edit)
def editChanged(self,text):
self.value = text
def onChangedExternally(self,text):
self.value = text
self.edit.setText(text)
def addToLayout(self,l):
l.addLayout(self.layout)
示例2: TopWidget
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFixedHeight [as 別名]
class TopWidget(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.last_music_btn = QPushButton()
self.next_music_btn = QPushButton()
self.play_pause_btn = QPushButton()
self.search_edit = QLineEdit()
self.login_btn = QPushButton("->")
self.login_label = LoginLabel()
self.show_current_list = QPushButton()
self.edit_layout = QHBoxLayout()
self.music_info_container = MusicInfoWidget()
self.top_layout = QHBoxLayout()
self.bottom_layout = QHBoxLayout()
self.layout = QVBoxLayout()
self.setLayout(self.layout)
self.set_widgets_prop()
self.set_layouts_prop()
self.init_widget()
def paintEvent(self, QPaintEvent):
"""
self is derived from QWidget, Stylesheets don't work unless \
paintEvent is reimplemented.y
at the same time, if self is derived from QFrame, this isn't needed.
"""
option = QStyleOption()
option.initFrom(self)
painter = QPainter(self)
style = self.style()
style.drawPrimitive(QStyle.PE_Widget, option, painter, self)
def init_widget(self):
self.login_label.close()
self.music_info_container.love_music_btn.close()
self.music_info_container.play_mv_btn.close()
def set_widgets_prop(self):
self.login_btn.setToolTip(u'登錄')
self.login_label.setFixedSize(30, 30)
self.login_btn.setFixedSize(30, 30)
self.show_current_list.setFixedSize(30, 30)
self.show_current_list.setToolTip(u'顯示當前播放列表')
self.search_edit.setFixedHeight(30)
self.search_edit.setPlaceholderText(u'搜索歌曲')
self.search_edit.setAttribute(Qt.WA_MacShowFocusRect, False)
self.search_edit.setSizePolicy(
QSizePolicy.Minimum, QSizePolicy.Minimum)
self.play_pause_btn.setCheckable(True)
self.play_pause_btn.setChecked(True)
self.music_info_container.setFixedHeight(57)
self.setFixedHeight(57)
self.set_object_name()
def set_object_name(self):
self.play_pause_btn.setObjectName('play_pause')
self.last_music_btn.setObjectName('last')
self.next_music_btn.setObjectName('next')
self.login_btn.setObjectName('login_btn')
self.login_label.setObjectName('login_label')
self.show_current_list.setObjectName('show_current_list')
def set_layouts_prop(self):
self.layout.setContentsMargins(0, 0, 0, 0)
self.layout.setSpacing(0)
self.top_layout.addSpacing(10)
self.top_layout.addWidget(self.last_music_btn)
self.top_layout.addSpacing(10)
self.top_layout.addWidget(self.play_pause_btn)
self.top_layout.addSpacing(10)
self.top_layout.addWidget(self.next_music_btn)
self.top_layout.addSpacing(30) # make table widget
self.top_layout.addWidget(self.music_info_container)
self.top_layout.addSpacing(20) # make table widget
self.top_layout.addWidget(self.search_edit)
self.top_layout.addSpacing(10)
self.top_layout.addWidget(self.show_current_list)
self.top_layout.addSpacing(10)
self.top_layout.addWidget(self.login_btn)
self.top_layout.addSpacing(10)
self.top_layout.addWidget(self.login_label)
self.top_layout.addSpacing(5)
self.layout.addLayout(self.top_layout)
self.layout.addLayout(self.bottom_layout)
self.layout.addSpacing(3)
示例3: AddUI
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFixedHeight [as 別名]
class AddUI(QWidget):
def __init__(self, socman):
super(AddUI, self).__init__()
# create objects;
self.__ob_label_title = QLabel("Заголовок, название:")
self.__ob_label_text = QLabel("Текст, описание:")
self.__ob_vlay_main = QVBoxLayout()
self.__ob_line_title = QLineEdit()
self.__ob_line_text = QTextEdit()
self.__ob_button_add = Button("Назад")
self.__socman = socman
self.buttonClicked = 0
# config;
self.setLayout(self.__ob_vlay_main)
self.setFixedSize(400,250)
self.__ob_vlay_main.addWidget(self.__ob_label_title)
self.__ob_vlay_main.addWidget(self.__ob_line_title)
self.__ob_vlay_main.addWidget(self.__ob_label_text)
self.__ob_vlay_main.addWidget(self.__ob_line_text)
self.__ob_vlay_main.addWidget(self.__ob_button_add)
self.__ob_vlay_main.setContentsMargins(0, 0, 0, 0)
self.__ob_button_add.setFixedHeight(50)
self.__ob_button_add.clicked.connect(self.__onButtonClicked)
self.__ob_line_text.setStyleSheet("background: rgb(200, 200, 200); border: none;")
self.__ob_line_title.setStyleSheet("background: rgb(200, 200, 200); border: none;")
self.__ob_line_title.setFixedHeight(30)
self.__ob_line_title.textChanged.connect(self.__onLinesEdit)
self.__ob_line_text.textChanged.connect(self.__onLinesEdit)
def __onButtonClicked(self):
if(self.__ob_button_add.text() == "<p align='center'>Назад"):
self.buttonClicked()
elif(self.__ob_button_add.text() == "<p align='center'>Добавить"):
if(self.__socman.add(self.__ob_line_title.text(), self.__ob_line_text.toPlainText())):
self.__ob_button_add.setCurrentText("Не добавлено!")
else:
self.__ob_line_text.clear()
self.__ob_line_title.clear()
self.buttonClicked()
def __onLinesEdit(self):
if(len(self.__ob_line_title.text())):
count = 0
for i in self.__socman.getDump():
if(self.__ob_line_title.text().upper() != i.getTitle().upper()):
count += 1
if(count == len(self.__socman.getDump())):
if(len(self.__ob_line_text.toPlainText())):
self.__ob_button_add.setCurrentText("Добавить")
else:
self.__ob_button_add.setCurrentText("Назад")
else:
self.__ob_button_add.setCurrentText("Такая запись уже существует")
else:
self.__ob_button_add.setCurrentText("Назад")
示例4: ControlWidget
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFixedHeight [as 別名]
class ControlWidget(QWidget):
def __init__(self,winParent):
super(ControlWidget, self).__init__()
self.winParent=winParent
self.rgbdwn = RGBMIN
self.rgbup = RGBMAX
self.hsvdwn = HSVMIN
self.hsvup = HSVMAX
self.yuvdwn = YUVMIN
self.yuvup = YUVMAX
self.initUI()
def initUI(self):
#self.setMinimumSize(WIDTH,HEIGTH)
#self.setMaximumSize(WIDTH,HEIGTH)
'''Radio buttons for Original/RGB/HSV/YUV images'''
self.origButton = QRadioButton("Original")
self.rgbButton = QRadioButton("RGB")
self.hsvButton = QRadioButton("HSV")
self.yuvButton = QRadioButton("YUV")
'''Signals for toggled radio buttons'''
self.origButton.toggled.connect(lambda:self.origButtonState())
self.rgbButton.toggled.connect(lambda:self.rgbButtonState())
self.hsvButton.toggled.connect(lambda:self.hsvButtonState())
self.yuvButton.toggled.connect(lambda:self.yuvButtonState())
self.origButton.setChecked(True)
'''Main layout of the widget will contain several vertical layouts'''
self.gLayout = QGridLayout(self)
self.gLayout.setObjectName("gLayout")
''' Vertical Layout for radio buttons '''
self.radioLayout = QVBoxLayout()
self.radioLayout.setObjectName("radioLayout")
self.radioLayout.addWidget(self.origButton)
self.radioLayout.addWidget(self.rgbButton)
self.radioLayout.addWidget(self.hsvButton)
self.radioLayout.addWidget(self.yuvButton)
self.vSpacer = QSpacerItem(30, 20, QSizePolicy.Ignored, QSizePolicy.Ignored);
self.radioLayout.addItem(self.vSpacer)
hmin,smin,vmin = HSVMIN
hmax,smax,vmax = HSVMAX
''' Vertical Layout for HMIN Slider'''
self.hminLayout = QVBoxLayout()
self.hminLayout.setObjectName("hminLayout")
self.hminLabel = QLabel("HMin")
self.hminValue = QLineEdit(str(hmin),self)
self.hminValue.setValidator(QIntValidator(hmin, hmax, self));
self.hminValue.setFixedWidth(40)
self.hminValue.setFixedHeight(27)
self.hminValue.setAlignment(Qt.AlignCenter);
self.hminSlider = QSlider(Qt.Vertical)
self.hminSlider.setMinimum(hmin)
self.hminSlider.setMaximum(hmax)
self.hminSlider.setValue(hmin)
self.hminLayout.addWidget(self.hminLabel, Qt.AlignCenter)
self.hminLayout.addWidget(self.hminValue,Qt.AlignCenter)
self.hminLayout.addWidget(self.hminSlider)
''' Vertical Layout for HMAX Slider'''
self.hmaxLayout = QVBoxLayout()
self.hmaxLayout.setObjectName("hmaxLayout")
self.hmaxLabel = QLabel("HMax")
self.hmaxValue = QLineEdit(str(hmax),self)
self.hmaxValue.setValidator(QIntValidator(hmin, hmax, self));
self.hmaxValue.setFixedWidth(40)
self.hmaxValue.setFixedHeight(27)
self.hmaxValue.setAlignment(Qt.AlignCenter);
self.hmaxSlider = QSlider(Qt.Vertical)
self.hmaxSlider.setMinimum(hmin)
self.hmaxSlider.setMaximum(hmax)
self.hmaxSlider.setValue(hmax)
self.hmaxLayout.addWidget(self.hmaxLabel)
self.hmaxLayout.addWidget(self.hmaxValue)
self.hmaxLayout.addWidget(self.hmaxSlider)
''' Vertical Layout for SMIN Slider'''
self.sminLayout = QVBoxLayout()
self.sminLayout.setObjectName("sminLayout")
self.sminLabel = QLabel("SMin")
self.sminValue = QLineEdit(str(smin),self)
self.sminValue.setValidator(QIntValidator(smin, smax, self));
self.sminValue.setFixedWidth(40)
self.sminValue.setFixedHeight(27)
self.sminValue.setAlignment(Qt.AlignCenter);
self.sminSlider = QSlider(Qt.Vertical)
self.sminSlider.setMinimum(smin)
self.sminSlider.setMaximum(smax)
self.sminSlider.setValue(smin)
self.sminLayout.addWidget(self.sminLabel)
self.sminLayout.addWidget(self.sminValue)
#.........這裏部分代碼省略.........
示例5: ListUI
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFixedHeight [as 別名]
class ListUI(QWidget):
def __init__(self, socman):
super(ListUI, self).__init__()
# create objects;
self.__socman = socman
self.__ob_list_main = QListWidget()
self.__ob_line_search = QLineEdit()
self.__ob_vlay_main = QVBoxLayout()
self.__ob_hlay_main = QHBoxLayout()
self.__ob_button_back = Button("Назад")
self.__ob_button_delete = Button("Удалить", 1)
self.buttonClicked = 0
self.doubleClicked = 0
# config;
self.setLayout(self.__ob_vlay_main)
self.setFixedSize(700, 500)
self.__ob_vlay_main.setSpacing(0)
self.__ob_vlay_main.addWidget(self.__ob_line_search)
self.__ob_vlay_main.addWidget(self.__ob_list_main)
self.__ob_vlay_main.addLayout(self.__ob_hlay_main)
self.__ob_hlay_main.addWidget(self.__ob_button_back, 4)
self.__ob_hlay_main.addWidget(self.__ob_button_delete, 1)
self.__ob_line_search.setStyleSheet("background: rgb(170, 170, 170); border: none;")
self.__ob_line_search.setFixedHeight(50)
self.__ob_line_search.textChanged.connect(self.__onLineEdit)
self.__ob_list_main.setStyleSheet("background: rgb(200, 200, 200); border: none;")
self.__ob_list_main.setMinimumWidth(self.__ob_list_main.sizeHintForColumn(0))
self.__ob_list_main.itemDoubleClicked.connect(self.__onDoubleClicked)
self.__ob_list_main.itemClicked.connect(self.__onItemClicked)
self.__ob_list_main.setSelectionMode(QListWidget.MultiSelection)
self.__ob_button_back.clicked.connect(self.__onButtonClicked)
self.__ob_button_back.setFixedHeight(50)
self.__ob_button_delete.hide()
self.__ob_button_delete.clicked.connect(self.__onButtonDeleteClicked)
def showData(self):
self.loadList()
self.show()
def __onButtonClicked(self):
self.buttonClicked()
def __onLineEdit(self):
self.__ob_button_delete.hide()
if len(self.__ob_line_search.text()):
self.__ob_list_main.clear()
for i in self.__socman.getDump():
if self.__ob_line_search.text().upper() in i.getTitle().upper():
item = QListWidgetItem()
item.setText(i.getTitle())
item.setSizeHint(QSize(10, 30))
self.__ob_list_main.addItem(item)
else:
self.loadList()
def __onDoubleClicked(self, item):
self.__ob_list_main.clearSelection()
for i in self.__socman.getDump():
if item.text() == i.getTitle():
self.doubleClicked(i)
break
def __onItemClicked(self):
if len(self.__ob_list_main.selectedItems()):
self.__ob_button_delete.show()
else:
self.__ob_button_delete.hide()
def __onButtonDeleteClicked(self):
for i in self.__ob_list_main.selectedItems():
for item in self.__socman.getDump():
if i.text() == item.getTitle():
self.__socman.delete(item)
break
self.__ob_button_delete.hide()
self.loadList()
def loadList(self):
self.__ob_list_main.clear()
self.__ob_line_search.clear()
for i in self.__socman.getDump():
item = QListWidgetItem()
item.setText(i.getTitle())
item.setSizeHint(QSize(10, 30))
self.__ob_list_main.addItem(item)
示例6: MainWindow
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFixedHeight [as 別名]
class MainWindow(QWidget):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
# self.setWindowFlags(Qt.Window | Qt.FramelessWindowHint)
# self.setAttribute(Qt.WA_TranslucentBackground)
self.resize(900, 700)
self.__search_mode = {'fuzzy': 'fuzzy_search',
'precise': 'precise_search',
'reg': 'reg_search'}
# self.__pbn_switch_view = None
# 創建窗口部件
self.__widget_frame = QLabel()
# window title
self.__lab_title_fram = QLabel()
self.__lab_title = QLabel('搜索輔助工具')
self.__lab_title.setAlignment(Qt.AlignCenter)
self.__lab_open_tool = QLabel('打開文件方式')
self.__ln_open_tool = QLineEdit()
self.__pbn_open_tool = QToolButton()
self.__pbn_open_tool.setText('選擇...')
self.__ln_open_tool.setFixedHeight(20)
self.__ln_open_tool.setFixedWidth(150)
self.__pbn_open_tool.setFixedSize(48, 20)
self.__lab_title_fram.setFixedHeight(50)
# search mode
self.__lab_mode_fram = QLabel()
self.__rbn_fuzzy = QRadioButton('模糊搜索')
self.__rbn_precise = QRadioButton('精確搜索')
self.__rbn_reg = QRadioButton('正則表達式搜索')
self.__rbn_fuzzy.setChecked(True)
self.__lab_mode_fram.setFixedHeight(22)
# search pattern
self.__lab_pattern_fram = QLabel()
self.__ln_file_name = QLineEdit()
self.__ln_file_name.setPlaceholderText('請輸入搜索條件或正則表達式......')
self.__rbn_reg_Iyes = QRadioButton('區分大小寫')
self.__rbn_reg_Ino = QRadioButton('不區分大小寫')
self.__lab_pattern_fram.setFixedHeight(20)
# search path
self.__lab_path_fram = QLabel()
self.__ln_file_path = QLineEdit()
self.__ln_file_path.setPlaceholderText('請選擇或輸入路徑......')
self.__pbn_file_path = QToolButton()
self.__pbn_file_path.setText('瀏覽...')
self.__rbn_search_file = QRadioButton('檢索文件名')
self.__rbn_search_content = QRadioButton('檢索文件內容')
self.__pbn_file_path.setFixedSize(48, 20)
self.__lab_path_fram.setFixedHeight(20)
# search state
self.__lab_state_fram = QLabel()
self.__lab_state = QLabel('狀態:暫無搜索結果!')
self.__pbn_search = QPushButton('開始')
self.__pbn_stop = QPushButton('停止')
self.__pbn_search.setFixedWidth(89)
self.__pbn_stop.setFixedWidth(89)
self.__lab_state_fram.setFixedHeight(35)
# search result
self.__tabView = QTabWidget()
self.__browser_result = QListWidget()
self.__browser_error = QTextBrowser()
self.__tabView.addTab(self.__browser_result, '匹配結果')
self.__tabView.addTab(self.__browser_error, '錯誤結果')
self.__btn_group_type = QButtonGroup()
self.__btn_group_type.addButton(self.__rbn_search_file)
self.__btn_group_type.addButton(self.__rbn_search_content)
self.__rbn_search_file.setChecked(True)
# radiobutton group
self.__btn_group_re_I = QButtonGroup()
self.__btn_group_re_I.addButton(self.__rbn_reg_Iyes)
self.__btn_group_re_I.addButton(self.__rbn_reg_Ino)
self.__rbn_reg_Iyes.setChecked(True)
# lines
'''
self.__line_1 = QFrame()
self.__line_1.setFrameStyle(QFrame.HLine | QFrame.Sunken)
'''
# 布局
# open tool
self.__layout_tool_choose = QHBoxLayout()
self.__layout_tool_choose.addWidget(self.__ln_open_tool)
self.__layout_tool_choose.addWidget(self.__pbn_open_tool)
self.__layout_tool_choose.setSpacing(0)
self.__layout_tool_choose.setContentsMargins(0, 0, 0, 0)
self.__layout_open_tool = QHBoxLayout()
self.__layout_open_tool.addWidget(self.__lab_open_tool)
self.__layout_open_tool.addLayout(self.__layout_tool_choose)
self.__layout_open_tool.setSpacing(2)
#.........這裏部分代碼省略.........