本文整理匯總了Python中PyQt5.QtWidgets.QLineEdit.setFixedWidth方法的典型用法代碼示例。如果您正苦於以下問題:Python QLineEdit.setFixedWidth方法的具體用法?Python QLineEdit.setFixedWidth怎麽用?Python QLineEdit.setFixedWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWidgets.QLineEdit
的用法示例。
在下文中一共展示了QLineEdit.setFixedWidth方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFixedWidth [as 別名]
def __init__(self, settings):
super(QWidget, self).__init__()
self._layout = QBoxLayout(QBoxLayout.TopToBottom)
self.setLayout(self._layout)
self.settings = settings
# eq directory
widget = QWidget()
layout = QBoxLayout(QBoxLayout.LeftToRight)
widget.setLayout(layout)
label = QLabel("Everquest Directory: ")
layout.addWidget(label)
text = QLineEdit()
text.setText(self.settings.get_value("general", "eq_directory"))
text.setToolTip(self.settings.get_value("general", "eq_directory"))
text.setDisabled(True)
self._text_eq_directory = text
layout.addWidget(text, 1)
button = QPushButton("Browse...")
button.clicked.connect(self._get_eq_directory)
layout.addWidget(button)
self._layout.addWidget(widget, 0, Qt.AlignTop)
# eq directory info
frame = QFrame()
frame.setFrameShadow(QFrame.Sunken)
frame.setFrameShape(QFrame.Box)
frame_layout = QBoxLayout(QBoxLayout.LeftToRight)
frame.setLayout(frame_layout)
widget = QWidget()
layout = QBoxLayout(QBoxLayout.LeftToRight)
widget.setLayout(layout)
self._label_eq_directory = QLabel()
layout.addWidget(self._label_eq_directory, 1)
frame_layout.addWidget(widget, 1, Qt.AlignCenter)
self._layout.addWidget(frame, 1)
# parse interval
widget = QWidget()
layout = QBoxLayout(QBoxLayout.LeftToRight)
widget.setLayout(layout)
label = QLabel("Seconds between parse checks: ")
layout.addWidget(label, 0, Qt.AlignLeft)
text = QLineEdit()
text.setText(str(self.settings.get_value("general", "parse_interval")))
text.editingFinished.connect(self._parse_interval_editing_finished)
text.setMaxLength(3)
self._text_parse_interval = text
metrics = QFontMetrics(QApplication.font())
text.setFixedWidth(metrics.width("888888"))
layout.addWidget(text, 0, Qt.AlignLeft)
self._layout.addWidget(widget, 0, Qt.AlignTop | Qt.AlignLeft)
# spacing at bottom of window
widget = QWidget()
self._layout.addWidget(widget, 1)
# setup
if settings.get_value("general", "eq_directory") is not None:
self._check_directory_stats()
示例2: addStatControl
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFixedWidth [as 別名]
def addStatControl(self,i,label=None):
statbox = QHBoxLayout()
statbox.addSpacing(1)
statbox.setSpacing(0)
statbox.setAlignment(Qt.AlignCenter)
statlabel = QLabel(self.stats[i] if label is None else label)
statlabel.setContentsMargins(0,0,0,0)
statlabel.setAlignment(Qt.AlignCenter)
statlabel.setFixedWidth(20)
statbox.addWidget(statlabel)
statcontrol = QLineEdit()
statcontrol.setAlignment(Qt.AlignCenter)
statcontrol.setFixedWidth(40)
statcontrol.setText(str(self.skill.multipliers[i]))
v = QDoubleValidator(0,99,3,statcontrol)
v.setNotation(QDoubleValidator.StandardNotation)
#v.setRange(0,100,decimals=3)
statcontrol.setValidator(v)
#print(v.top())
def statFuncMaker(j):
def statFunc(newValue):
self.skill.multipliers[j] = float(newValue)
self.skillsChanged.emit()
return statFunc
statcontrol.textChanged[str].connect(statFuncMaker(i))
statbox.addWidget(statcontrol)
statbox.addSpacing(1)
self.layout.addLayout(statbox)
示例3: _create_name_field
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFixedWidth [as 別名]
def _create_name_field(self):
le = QLineEdit()
le.setFixedWidth(300)
le.textChanged.connect(self.update_full_name)
le.textChanged.connect(self.validate_names)
le.textChanged.connect(self.enable_buttons)
return le
示例4: NetworkChoiceLayout
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFixedWidth [as 別名]
class NetworkChoiceLayout(object):
def __init__(self, network: Network, config, wizard=False):
self.network = network
self.config = config
self.protocol = None
self.tor_proxy = None
self.tabs = tabs = QTabWidget()
server_tab = QWidget()
proxy_tab = QWidget()
blockchain_tab = QWidget()
tabs.addTab(blockchain_tab, _('Overview'))
tabs.addTab(server_tab, _('Server'))
tabs.addTab(proxy_tab, _('Proxy'))
# server tab
grid = QGridLayout(server_tab)
grid.setSpacing(8)
self.server_host = QLineEdit()
self.server_host.setFixedWidth(200)
self.server_port = QLineEdit()
self.server_port.setFixedWidth(60)
self.autoconnect_cb = QCheckBox(_('Select server automatically'))
self.autoconnect_cb.setEnabled(self.config.is_modifiable('auto_connect'))
self.server_host.editingFinished.connect(self.set_server)
self.server_port.editingFinished.connect(self.set_server)
self.autoconnect_cb.clicked.connect(self.set_server)
self.autoconnect_cb.clicked.connect(self.update)
msg = ' '.join([
_("If auto-connect is enabled, Electrum will always use a server that is on the longest blockchain."),
_("If it is disabled, you have to choose a server you want to use. Electrum will warn you if your server is lagging.")
])
grid.addWidget(self.autoconnect_cb, 0, 0, 1, 3)
grid.addWidget(HelpButton(msg), 0, 4)
grid.addWidget(QLabel(_('Server') + ':'), 1, 0)
grid.addWidget(self.server_host, 1, 1, 1, 2)
grid.addWidget(self.server_port, 1, 3)
label = _('Server peers') if network.is_connected() else _('Default Servers')
grid.addWidget(QLabel(label), 2, 0, 1, 5)
self.servers_list = ServerListWidget(self)
grid.addWidget(self.servers_list, 3, 0, 1, 5)
# Proxy tab
grid = QGridLayout(proxy_tab)
grid.setSpacing(8)
# proxy setting
self.proxy_cb = QCheckBox(_('Use proxy'))
self.proxy_cb.clicked.connect(self.check_disable_proxy)
self.proxy_cb.clicked.connect(self.set_proxy)
self.proxy_mode = QComboBox()
self.proxy_mode.addItems(['SOCKS4', 'SOCKS5'])
self.proxy_host = QLineEdit()
self.proxy_host.setFixedWidth(200)
self.proxy_port = QLineEdit()
self.proxy_port.setFixedWidth(60)
self.proxy_user = QLineEdit()
self.proxy_user.setPlaceholderText(_("Proxy user"))
self.proxy_password = QLineEdit()
self.proxy_password.setPlaceholderText(_("Password"))
self.proxy_password.setEchoMode(QLineEdit.Password)
self.proxy_password.setFixedWidth(60)
self.proxy_mode.currentIndexChanged.connect(self.set_proxy)
self.proxy_host.editingFinished.connect(self.set_proxy)
self.proxy_port.editingFinished.connect(self.set_proxy)
self.proxy_user.editingFinished.connect(self.set_proxy)
self.proxy_password.editingFinished.connect(self.set_proxy)
self.proxy_mode.currentIndexChanged.connect(self.proxy_settings_changed)
self.proxy_host.textEdited.connect(self.proxy_settings_changed)
self.proxy_port.textEdited.connect(self.proxy_settings_changed)
self.proxy_user.textEdited.connect(self.proxy_settings_changed)
self.proxy_password.textEdited.connect(self.proxy_settings_changed)
self.tor_cb = QCheckBox(_("Use Tor Proxy"))
self.tor_cb.setIcon(read_QIcon("tor_logo.png"))
self.tor_cb.hide()
self.tor_cb.clicked.connect(self.use_tor_proxy)
grid.addWidget(self.tor_cb, 1, 0, 1, 3)
grid.addWidget(self.proxy_cb, 2, 0, 1, 3)
grid.addWidget(HelpButton(_('Proxy settings apply to all connections: with Electrum servers, but also with third-party services.')), 2, 4)
grid.addWidget(self.proxy_mode, 4, 1)
grid.addWidget(self.proxy_host, 4, 2)
grid.addWidget(self.proxy_port, 4, 3)
grid.addWidget(self.proxy_user, 5, 2)
grid.addWidget(self.proxy_password, 5, 3)
grid.setRowStretch(7, 1)
# Blockchain Tab
grid = QGridLayout(blockchain_tab)
msg = ' '.join([
#.........這裏部分代碼省略.........
示例5: SqliteDbTableEditer
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFixedWidth [as 別名]
class SqliteDbTableEditer(QWidget):
#Db=sqlite3.connect("test.db")
def __init__(self,dbPath,tblName='',parent=None):
self.app=QApplication(sys.argv)
self.SqliteDbTypes=['integer','real','text','blob']
self.DbPath,self.CurrentTable=dbPath,tblName
#連接數據庫
self.Db=sqlite3.connect(self.DbPath)
#構建Gui組件
super(SqliteDbTableEditer,self).__init__(parent)
self.setWindowTitle('Sqlite數據庫表修改器')
screen=QDesktopWidget().availableGeometry(0)
self.setGeometry(screen.width()/3/2-1,
screen.height()/5/2-1,
screen.width()*2/3,
screen.height()*4/5
)
#lay
lay=QVBoxLayout()
self.setLayout(lay)
#數據庫表設置控件
##layDb
layDb=QHBoxLayout()
lay.addLayout(layDb)
###lblDb
lblDb=QLabel('數據庫:')
layDb.addWidget(lblDb)
###self.leDb
self.leDb=QLineEdit()
self.leDb.setText(self.DbPath)
layDb.addWidget(self.leDb)
###btnDb
btnChangeDb=QPushButton('瀏覽')
btnChangeDb.clicked.connect(self.btnChangeDb_Clicked)
layDb.addWidget(btnChangeDb)
###lblTbl
lblTbl=QLabel('數據表:')
layDb.addWidget(lblTbl)
###self.cbbTbls
self.cbbTbls=QComboBox()
tbls=list(map(lambda x:x[1],
list(filter(lambda x:x[0]=='table',
self.Db.execute(
'Select * From sqlite_master'
).fetchall()
)
)
)
)
self.cbbTbls.addItems(tbls)
if self.CurrentTable!='' :
self.cbbTbls.setCurrentIndex(tbls.index(self.CurrentTable))
else:
self.CurrentTable=tbls[0]
self.makeTableInfo()
self.cbbTbls.setCurrentIndex(0)
layDb.addWidget(self.cbbTbls)
###lblRename
lblRename=QLabel('重命名為:')
layDb.addWidget(lblRename)
###self.leRename
self.leRename=QLineEdit()
self.leRename.setFixedWidth(100)
layDb.addWidget(self.leRename)
###btnRename
btnRenameTable=QPushButton('重命名')
btnRenameTable.clicked.connect(self.btnRenameTable_Clicked)
layDb.addWidget(btnRenameTable)
###btnDeleteTable
btnDeleteTable=QPushButton('刪除表')
btnDeleteTable.clicked.connect(self.btnDeleteTable_Clicked)
layDb.addWidget(btnDeleteTable)
###btnShow
self.btnShow=QPushButton('查看表結構')
self.btnShow.clicked.connect(self.btnShow_Clicked)
layDb.addWidget(self.btnShow)
###設置TableView控件self.tv,以呈現表數據
self.tv=QTableView()
lay.addWidget(self.tv)
###self.model基本初始化
self.model=QSqlTableModel(self,QSqlDatabase.addDatabase('QSQLITE'))
self.model.setEditStrategy(QSqlTableModel.OnFieldChange)
###self.tv鏈接到數據源
self.tv.setModel(self.model)
###self.model數據初始化
self.model.database().setDatabaseName(self.DbPath)
self.model.database().open()
self.model.setTable(self.CurrentTable)
self.model.select()
self.cbbTbls.currentIndexChanged.connect(self.changeTable)
##layBtns
layBtns=QHBoxLayout()
lay.addLayout(layBtns)
###btnAddColumn
btnAddColumn=QPushButton('添加列')
btnAddColumn.setToolTip('給當前表添加列')
btnAddColumn.clicked.connect(self.btnAddColumn_Clicked)
layBtns.addWidget(btnAddColumn)
###btnDeleteColumn
#.........這裏部分代碼省略.........
示例6: Ui_TableWindow
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFixedWidth [as 別名]
class Ui_TableWindow(object):
def setupUi(self, TableWindow, name, headers):
TableWindow.setObjectName("TableWindow: " + name)
TableWindow.resize(1240, 800)
self.main_widget = QWidget(TableWindow)
self.main_widget.setObjectName("table_window")
layout_main = QGridLayout(self.main_widget)
layout_table = QVBoxLayout()
layout_controls = QHBoxLayout()
self.table = MyTable(self.main_widget)
self.table.setRowCount(550)
self.table.setColumnCount(len(headers))
HeaderLabels = headers
self.table.setHorizontalHeaderLabels(HeaderLabels)
[self.table.setColumnWidth(i,90) for i in range(10)]
groupbox_table = QGroupBox(self.main_widget)
groupbox_table.setLayout(layout_table)
layout_table.addWidget(self.table)
self.button_load = QPushButton('Load')
self.button_calc = QPushButton('Calculate')
self.button_graph = QPushButton('Graph')
self.check_correct = QCheckBox('Correct')
self.check_background = QCheckBox('Background')
self.button_reabs = QPushButton('Reabsorption')
self.input_reab= QLineEdit()
self.input_reab.setFixedWidth(40)
self.input_reab.setText('1.0')
self.button_filter_calc = QPushButton('Filter calculate')
self.input_filter = QLineEdit()
self.input_filter.setFixedWidth(60)
self.input_filter.setText('0.00538')
self.output_QY = QLineEdit()
self.output_QY.setFixedWidth(60)
status = False
self.button_calc.setEnabled(status)
self.button_graph.setEnabled(status)
self.button_filter_calc.setEnabled(status)
self.button_reabs.setEnabled(status)
self.input_filter.setEnabled(status)
self.input_reab.setEnabled(status)
groubox_controls = QGroupBox(self.main_widget)
groubox_controls.setLayout(layout_controls)
layout_controls.addWidget(self.button_load)
layout_controls.addWidget(self.button_calc)
layout_controls.addWidget(self.check_correct)
layout_controls.addWidget(self.check_background)
layout_controls.addWidget(self.button_graph)
layout_controls.addWidget(self.button_reabs)
layout_controls.addWidget(self.input_reab)
layout_controls.addWidget(self.button_filter_calc)
layout_controls.addWidget(self.input_filter)
layout_controls.addWidget(self.output_QY)
layout_main.addWidget(groupbox_table)
layout_main.addWidget(groubox_controls)
self.main_widget.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.main_widget.setWindowTitle("TableWindow")
self.main_widget.setFocus()
TableWindow.setCentralWidget(self.main_widget)
self.retranslateUi(TableWindow, name)
def retranslateUi(self, TableWindow, name):
_translate = QtCore.QCoreApplication.translate
TableWindow.setWindowTitle(_translate("TableWindow", "Table (raw data): " + name))
示例7: LoadingWindow
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFixedWidth [as 別名]
class LoadingWindow(QWidget):
def __init__(self, application):
'''
Class defining files loading window.
:param application: parent application
'''
super().__init__()
# assigning application as a class attribute just in case, e.g. for getting screen size
self._application = application
# initializing error handler in case of exceptions
self._error_handler = ErrorHandler()
# specifying window size
self._width = 410
self._height = 220
# setting window parameters such as size, position and title
screen_center = self._application.desktop().screen().rect().center()
self.setGeometry(screen_center.x() - self._width * .5,
screen_center.y() - self._height * .5,
self._width,
self._height)
self.setWindowTitle('Ray Tracing Method 4-dimensional visualization')
self.setFixedSize(self._width, self._height)
# creating master file browse label
self._master_file_browse_lbl = QLabel('Input file:', self)
self._master_file_browse_lbl.move(22, 20)
# creating master file path text field
self._master_file_path_text_field = QLineEdit(self)
self._master_file_path_text_field.setFixedWidth(300)
self._master_file_path_text_field.move(20, 40)
# creating master file browsing button
self._master_file_browse_btn = QPushButton('Browse...', self)
self._master_file_browse_btn.setFixedWidth(70)
self._master_file_browse_btn.move(20 + self._master_file_path_text_field.width(), 40)
self._master_file_browse_btn.clicked[bool].connect(self._select_master_file)
# creating load button
self._load_btn = QPushButton('Load file', self)
self._load_btn.setFixedWidth(self._master_file_path_text_field.width() + self._master_file_browse_btn.width())
self._load_btn.setFixedHeight(60)
self._load_btn.move((self._width - self._load_btn.width()) * .5, 90)
self._load_btn.clicked[bool].connect(self._load_files)
# creating close button
self._close_btn = QPushButton('Close', self)
self._close_btn.setFixedWidth(70)
self._close_btn.move((self._width - self._close_btn.width()) * .5,
self._height - self._close_btn.height() - 20)
self._close_btn.clicked[bool].connect(self.close)
self.show()
def _browse_files(self):
'''
Pops file dialog window up.
:returns: path to selected file
'''
file_dialog = QFileDialog()
file_dialog.setFileMode(QFileDialog.ExistingFile)
return file_dialog.getOpenFileName()[0]
def _select_master_file(self):
'''
Calls _browse_files method and assigns selected file to _master_file_path_text_field text.
'''
self._master_file_path_text_field.setText(self._browse_files())
def _load_files(self):
'''
Creates FileLoader instance and loads files specified in text fields.
'''
file_loader = FileLoader()
try:
room_geometry = file_loader.load_master_file(self._master_file_path_text_field.text())
self.close()
self.visualization_window = VisualizationWindow(self._application, room_geometry)
except Exception as e:
self._error_handler.raise_dialog(str(e))
示例8: Example
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFixedWidth [as 別名]
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.label1 = QLabel("待轉換內容:(字符以空格或回車分隔)")
self.label2 = QLabel("轉換結果:")
self.text1 = QTextEdit()
self.text1.setAcceptRichText(False)
self.text2 = QTextEdit()
self.text2.setAcceptRichText(False)
self.check = QCheckBox('自動使用新內容')
self.check.setChecked(True)
self.check.setToolTip('使用上次輸出的結果作為輸入')
self.btn1 = QPushButton('短信轉中文 >>')
self.btn2 = QPushButton('ASCII轉字符 >>')
self.btn4 = QPushButton('字符轉ASCII >>')
self.btn3 = QPushButton('每2個字符加空格 >>')
self.btn5 = QPushButton('HEX386格式處理 >>')
self.btn6 = QPushButton('去掉所有空字符 >>')
self.btn_cpy = QPushButton('複製')
self.btn_clr = QPushButton('清空')
self.btn5.setToolTip('去掉第一行和最後兩行\n去掉開頭9個字符和最後2個字符')
box1 = QHBoxLayout()
lab1 = QLabel('每')
self.selNum = QLineEdit('48')
self.selNum.setFixedWidth(20)
lab2 = QLabel('字符')
self.btn7 = QPushButton('換行 >>')
self.btn7.setFixedWidth(55)
box1.addWidget(lab1)
box1.addWidget(self.selNum)
box1.addWidget(lab2)
box1.addWidget(self.btn7)
leftGrid = QGridLayout()
leftGrid.setSpacing(10)
leftGrid.addWidget(self.label1, 1, 0)
leftGrid.addWidget(self.label2, 1, 1)
leftGrid.addWidget(self.text1, 2, 0)
leftGrid.addWidget(self.text2, 2, 1)
rightVBox = QVBoxLayout()
rightVBox.setAlignment(Qt.AlignVCenter)
rightVBox.addStretch()
rightVBox.addWidget(self.check)
rightVBox.addWidget(self.btn1)
rightVBox.addWidget(self.btn2)
rightVBox.addWidget(self.btn4)
rightVBox.addWidget(self.btn3)
rightVBox.addWidget(self.btn5)
rightVBox.addWidget(self.btn6)
rightVBox.addLayout(box1)
rightVBox.addStretch()
rightVBox.addWidget(self.btn_cpy)
rightVBox.addWidget(self.btn_clr)
mainBox = QHBoxLayout()
mainBox.addLayout(leftGrid, stretch=1)
mainBox.addLayout(rightVBox)
self.setLayout(mainBox)
# 按鈕連接到槽
self.btn1.clicked.connect(self.button1Clicked)
self.btn2.clicked.connect(self.button2Clicked)
self.btn4.clicked.connect(self.button4Clicked)
self.btn3.clicked.connect(self.button3Clicked)
self.btn5.clicked.connect(self.button5Clicked)
self.btn6.clicked.connect(self.button6Clicked)
self.btn7.clicked.connect(self.button7Clicked)
self.btn_cpy.clicked.connect(self.buttonCpyClicked)
self.btn_clr.clicked.connect(self.buttonClrClicked)
self.setGeometry(200, 300, 600, 350)
self.setWindowTitle('字符處理')
self.show()
def get_input(self):
if(self.check.isChecked()):
if(self.text2.toPlainText() != ''):
input_text = self.text2.toPlainText()
self.text1.setPlainText(input_text) # reset text1 content
else:
input_text = self.text1.toPlainText()
else:
input_text = self.text1.toPlainText()
return input_text
def set_output(self, output_result):
return self.text2.setPlainText(output_result)
def button1Clicked(self): # 短信轉中文
string_origin = self.get_input()
#.........這裏部分代碼省略.........
示例9: HyperLprWindow
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFixedWidth [as 別名]
class HyperLprWindow(QMainWindow):
start_init_signal = pyqtSignal()
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.statusBar().showMessage('Ready')
self.image_window_view = HyperLprImageView()
table_widget_header_labels = [
"文件名",
"分割識別",
"置信度",
"顏色",
"E2E識別",
"E2E置信度"]
self.hyperlpr_tableview = QTableWidget(
0, len(table_widget_header_labels))
self.hyperlpr_tableview.setHorizontalHeaderLabels(
table_widget_header_labels)
self.hyperlpr_tableview.setSelectionBehavior(
QAbstractItemView.SelectItems)
self.hyperlpr_tableview.setSelectionMode(
QAbstractItemView.SingleSelection)
self.hyperlpr_tableview.setEditTriggers(
QAbstractItemView.NoEditTriggers)
self.hyperlpr_tableview.horizontalHeader().setSectionResizeMode(
QHeaderView.ResizeToContents)
self.hyperlpr_tableview.setEditTriggers(
QAbstractItemView.NoEditTriggers)
self.hyperlpr_tableview.cellClicked.connect(
self.recognize_one_license_plate)
self.location_label = QLabel("車牌目錄", self)
self.location_text = QLineEdit(self)
self.location_text.setEnabled(False)
self.location_text.setFixedWidth(300)
self.location_button = QPushButton("...")
self.location_button.clicked.connect(self.select_new_dir)
self.location_layout = QHBoxLayout()
self.location_layout.addWidget(self.location_label)
self.location_layout.addWidget(self.location_text)
self.location_layout.addWidget(self.location_button)
self.location_layout.addStretch()
self.check_box = QCheckBox("與文件名比較車牌")
self.check_box.setChecked(True)
self.update_file_path_button = QPushButton('批量識別')
self.update_file_path_button.clicked.connect(
self.batch_recognize_all_images)
self.update_file_path_layout = QHBoxLayout()
self.update_file_path_layout.addWidget(self.check_box)
self.update_file_path_layout.addWidget(self.update_file_path_button)
self.update_file_path_layout.addStretch()
self.bottom_layout = QVBoxLayout()
self.bottom_layout.addLayout(self.location_layout)
self.bottom_layout.addLayout(self.update_file_path_layout)
bottom_widget = QWidget()
bottom_widget.setLayout(self.bottom_layout)
license_plate_iamge_label = QLabel("車牌圖")
self.license_plate_widget = QLabel("")
block_image_label = QLabel("分割圖")
self.block_plate_widget = QLabel("")
filename_label = QLabel("文件名:")
self.filename_edit = QLineEdit()
segmentation_recognition_label = QLabel("分割識別:")
self.segmentation_recognition_edit = QLineEdit()
self.segmentation_recognition_edit.setFont(QFont("黑體", 24, QFont.Bold))
self.segmentation_recognition_edit.setStyleSheet("color:red")
confidence_label = QLabel("置信度")
self.confidence_edit = QLineEdit()
self.confidence_edit.setFont(QFont("黑體", 24, QFont.Bold))
self.confidence_edit.setStyleSheet("color:red")
plate_color_label = QLabel("車牌顏色")
self.plate_color_edit = QLineEdit()
self.plate_color_edit.setFont(QFont("黑體", 24, QFont.Bold))
self.plate_color_edit.setStyleSheet("color:red")
e2e_recognization_label = QLabel("e2e識別:")
self.e2e_recognization_edit = QLineEdit()
#.........這裏部分代碼省略.........
示例10: Overview
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFixedWidth [as 別名]
class Overview():
def __init__(self, changefunc):
self.changefunc = changefunc
self.container = self.make_page()
self.version = MADversion()
def onChange(self):
self.changefunc()
def make_page(self):
# make the full edit widget
page = QFrame()
layout = QFormLayout()
page.setLayout( layout )
self.edit_name = QLineEdit()
self.edit_name.setFixedWidth(250)
self.edit_name.textChanged.connect(self.onChange)
self.edit_desc = QTextEdit()
self.edit_desc.setFixedWidth(250)
self.edit_desc.textChanged.connect(self.onChange)
self.edit_author = QLineEdit()
self.edit_author.setFixedWidth(250)
self.edit_author.textChanged.connect(self.onChange)
self.edit_email = QLineEdit()
self.edit_email.setFixedWidth(250)
self.edit_email.textChanged.connect(self.onChange)
self.edit_units = QComboBoxNoWheel()
self.edit_units.setFixedWidth(250)
self.edit_units.addItem("in")
self.edit_units.addItem("cm")
self.edit_units.addItem("mm")
self.edit_units.currentIndexChanged.connect(self.onChange)
self.edit_sheet_w = QLineEdit()
self.edit_sheet_w.setFixedWidth(250)
self.edit_sheet_w.textChanged.connect(self.onChange)
self.edit_sheet_h = QLineEdit()
self.edit_sheet_h.setFixedWidth(250)
self.edit_sheet_h.textChanged.connect(self.onChange)
self.edit_plans_w = QLineEdit()
self.edit_plans_w.setFixedWidth(250)
self.edit_plans_w.textChanged.connect(self.onChange)
self.edit_plans_h = QLineEdit()
self.edit_plans_h.setFixedWidth(250)
self.edit_plans_h.textChanged.connect(self.onChange)
layout.addRow( "<b>Design Name:</b>", self.edit_name )
layout.addRow( "<b>Description:</b>", self.edit_desc )
layout.addRow( "<b>Author:</b>", self.edit_author )
layout.addRow( "<b>Email:</b>", self.edit_email )
layout.addRow( "<b>Units:</b>", self.edit_units )
layout.addRow( "<b>Mat. Sheet Width:</b>", self.edit_sheet_w )
layout.addRow( "<b>Mat. Sheet Height:</b>", self.edit_sheet_h )
layout.addRow( "<b>Plans Width:</b>", self.edit_plans_w )
layout.addRow( "<b>Plans Height:</b>", self.edit_plans_h )
return page
def get_widget(self):
return self.container
def load(self, node):
self.edit_name.setText(node.getString('name'))
self.edit_desc.setText(node.getString('description'))
self.edit_author.setText(node.getString('author'))
self.edit_email.setText(node.getString('email'))
units = node.getString('units')
sheet_w = node.getString('sheet_width')
sheet_h = node.getString('sheet_height')
if units == "in":
if sheet_w == "":
sheet_w = "24"
if sheet_h == "":
sheet_h = "12"
elif units == "mm":
if sheet_w == "":
sheet_w = "600"
if sheet_h == "":
sheet_h = "300"
elif units == "cm":
if sheet_w == "":
sheet_w = "60"
if sheet_h == "":
sheet_h = "30"
plans_w = node.getString('plans_width')
plans_h = node.getString('plans_height')
if units == "in":
if plans_w == "":
plans_w = "24"
if plans_h == "":
plans_h = "36"
elif units == "mm":
if plans_w == "":
plans_w = "600"
if plans_h == "":
plans_h = "900"
elif units == "cm":
if plans_w == "":
plans_w = "60"
if plans_h == "":
#.........這裏部分代碼省略.........
示例11: Credentials
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFixedWidth [as 別名]
class Credentials(QDialog):
"""
This class shows the main credentials Dialog and prompts user for username and
password. Also a checkbox is shown to store credentials.
"""
def __init__(self, parent):
QDialog.__init__(self, parent)
self.initUI()
def dismiss(self):
"""
Description: Dismisses the QDialog box. Called on successful authentication.
Arguments: None
Returns: Nothing
"""
global conf
if conf.USERNAME:
self.done(0)
def check_creds(self):
"""
Description: Checks whether username or password fields are empty, in which case
an error window is shown. Otherwise, try to authenticate vs. oVirt
Arguments: None
Returns: Nothing, just dismisses the main window on successful authentication.
"""
err = QMessageBox()
uname = self.edit_username.text()
pw = self.edit_pw.text()
if not uname or not pw:
err.critical(self, _('apptitle') + ': ' + _('error'), _('no_empty_creds'))
else:
cc = CheckCreds(self, uname, pw, self.remembercreds.isChecked())
cc.finished.connect(self.dismiss)
def confirm_quit(self):
"""
Description: Confirm whether to quit or not the app. This option must be present
in case the user cannot authenticate against oVirt, in which case the
main window won't be shown but the application will exit instead.
Arguments: None
Returns: Nothing, just quits if user confirms.
"""
cq = QMessageBox.question(self, _('apptitle') + ': ' + _('confirm'), _('confirm_quit'), QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
if cq == QMessageBox.Yes:
quit()
def closeEvent(self, event):
"""
Description: Deactivation of the red 'x' to close the window. We enforce user to choose
whether to authenticate or exit the application.
Arguments: The event.
Returns: Nothing
"""
event.ignore()
def initUI(self):
"""
Description: Shows the main dialog, with the username and password fields. Optionally, if
allowed by configuration, also shows the "store credentials" checkbox.
Arguments: None
Returns: Nothing
"""
global conf
self.setFixedSize(400, 150)
# Keys image
filename = 'imgs/credentials.png'
image = QImage(filename)
imageLabel = QLabel()
imageLabel.setPixmap(QPixmap.fromImage(image))
imageLabel.setAlignment(Qt.AlignCenter)
# Labels for both username and password
lab_username = QLabel(_('username'))
lab_username.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
lab_pw = QLabel(_('password'))
lab_pw.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
# LineEdits for both username and password
self.edit_username = QLineEdit()
self.edit_username.setFixedWidth(150)
self.edit_pw = QLineEdit()
self.edit_pw.setEchoMode(QLineEdit.Password)
self.edit_pw.setFixedWidth(150)
# QCheckBox for storing user + password
self.remembercreds = QCheckBox(_('remember_username_and_password'))
# OK and cancel buttons
okButton = QPushButton(_("ok"))
okButton.setMaximumWidth(100)
#.........這裏部分代碼省略.........
示例12: MainWindow
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFixedWidth [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)
#.........這裏部分代碼省略.........
示例13: RatukiWidget
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFixedWidth [as 別名]
class RatukiWidget(GameWidget):
def createEngine(self):
if self.game != 'Ratuki':
raise Exception("No engine for game {}".format(self.game))
return
self.engine = RatukiEngine()
def initUI(self):
super(RatukiWidget, self).initUI()
self.gameInput = RatukiInputWidget(self.engine, self)
self.gameInput.enterPressed.connect(self.commitRound)
self.roundLayout.addWidget(self.gameInput)
self.configLayout = QGridLayout()
self.matchGroupLayout.addLayout(self.configLayout)
self.topPointsLineEdit = QLineEdit(self.matchGroup)
self.topPointsLineEdit.setText(str(self.engine.getTop()))
self.topPointsLineEdit.setValidator(
QtGui.QIntValidator(1, 10000, self.topPointsLineEdit))
self.topPointsLineEdit.setFixedWidth(50)
sp = QSizePolicy(
QSizePolicy.Fixed, QSizePolicy.Fixed)
self.topPointsLineEdit.setSizePolicy(sp)
self.topPointsLineEdit.textChanged.connect(self.changeTop)
self.topPointsLineEdit.setDisabled(self.engine.getNumRound() > 1)
self.configLayout.addWidget(self.topPointsLineEdit, 0, 0)
self.topPointsLabel = QLabel(self.matchGroup)
self.topPointsLabel.setStyleSheet("QLabel {font-weight: bold; }")
self.configLayout.addWidget(self.topPointsLabel, 0, 1)
self.detailGroup = RatukiRoundsDetail(self.engine, self)
self.detailGroup.edited.connect(self.updatePanel)
self.widgetLayout.addWidget(self.detailGroup, 1, 0)
self.playerGroup = QGroupBox(self)
self.widgetLayout.addWidget(self.playerGroup, 1, 1)
self.playerGroup.setStyleSheet(
"QGroupBox { font-size: 18px; font-weight: bold; }")
self.playersLayout = QVBoxLayout(self.playerGroup)
self.playersLayout.addStretch()
self.playerGroupBox = {}
for i, player in enumerate(self.players):
pw = GamePlayerWidget(player, PlayerColours[i], self.playerGroup)
pw.updateDisplay(self.engine.getScoreFromPlayer(player))
if player == self.engine.getDealer():
pw.setDealer()
self.playersLayout.addWidget(pw)
self.playerGroupBox[player] = pw
self.playersLayout.addStretch()
self.retranslateUI()
def retranslateUI(self):
super(RatukiWidget, self).retranslateUI()
self.topPointsLabel.setText(
i18n("RatukiWidget", "Score Limit"))
# self.playerGroup.setTitle(i18n("RatukiWidget","Score"))
self.detailGroup.retranslateUI()
def checkPlayerScore(self, player, score): return True
def unsetDealer(
self): self.playerGroupBox[self.engine.getDealer()].unsetDealer()
def setDealer(
self): self.playerGroupBox[self.engine.getDealer()].setDealer()
def updatePanel(self):
self.topPointsLineEdit.setReadOnly(True)
self.dealerPolicyCheckBox.setEnabled(False)
for player in self.players:
score = self.engine.getScoreFromPlayer(player)
self.playerGroupBox[player].updateDisplay(score)
if self.engine.getWinner():
self.detailGroup.updateStats()
self.detailGroup.updateRound()
super(RatukiWidget, self).updatePanel()
def changeTop(self, newtop):
try:
newtop = int(newtop)
self.engine.setTop(newtop)
self.detailGroup.updatePlot()
except ValueError:
pass
def setWinner(self):
super(RatukiWidget, self).setWinner()
winner = self.engine.getWinner()
if winner in self.players:
self.playerGroupBox[winner].setWinner()
def updatePlayerOrder(self):
GameWidget.updatePlayerOrder(self)
#.........這裏部分代碼省略.........
示例14: draw_input
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFixedWidth [as 別名]
def draw_input():
input = QLineEdit()
input.setFixedWidth(400)
input.setText("http://")
return input
示例15: MainWindow
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFixedWidth [as 別名]
#.........這裏部分代碼省略.........
self.calculationMenu.addAction(self.calculationSaveAs)
self.calculationMenu.addAction(self.calculationExport)
self.calculationMenu.addSeparator()
#self.calculationMenu.addAction(self.calculationPrint)
#self.calculationMenu.addSeparator()
self.calculationMenu.addAction(self.calculationQuit)
self.menu.addMenu(self.calculationMenu)
# create language menu
self.languageMenu = QMenu(self)
self.languageMenu.addAction(self.languageGerman)
self.languageMenu.addAction(self.languageEnglish)
self.menu.addMenu(self.languageMenu)
# create help menu
self.helpMenu = QMenu(self)
self.helpMenu.addAction(self.helpContents)
self.helpMenu.addAction(self.scientificBasis)
self.helpMenu.addSeparator()
self.helpMenu.addAction(self.helpAbout)
self.menu.addMenu(self.helpMenu)
def createEditBox(self):
# create group box
self.editBox = QGroupBox()
self.editBox.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
gridLayout = QGridLayout(self.editBox)
# create input fields
self.operationInput = QLineEdit(self.model.projectData("operation"))
self.operationInput.setFixedWidth(self._INPUTS_FIXED_WIDTH)
self.operationInput.setClearButtonEnabled(True)
self.operationLabel = QLabel()
self.operationLabel.setBuddy(self.operationInput)
gridLayout.addWidget(self.operationLabel, 0, 0)
gridLayout.addWidget(self.operationInput, 0, 1)
self.districtInput = QLineEdit(self.model.projectData("district"))
self.districtInput.setFixedWidth(self._INPUTS_FIXED_WIDTH)
self.districtInput.setClearButtonEnabled(True)
self.districtLabel = QLabel()
self.districtLabel.setBuddy(self.districtInput)
gridLayout.addWidget(self.districtLabel, 0, 2)
gridLayout.addWidget(self.districtInput, 0, 3)
self.managerInput = QLineEdit(self.model.projectData("manager"))
self.managerInput.setFixedWidth(self._INPUTS_FIXED_WIDTH)
self.managerInput.setClearButtonEnabled(True)
self.managerLabel = QLabel()
self.managerLabel.setBuddy(self.managerInput)
gridLayout.addWidget(self.managerLabel, 1, 0)
gridLayout.addWidget(self.managerInput, 1, 1)
self.locationInput = QLineEdit(self.model.projectData("location"))
self.locationInput.setFixedWidth(self._INPUTS_FIXED_WIDTH)
self.locationInput.setClearButtonEnabled(True)
self.locationLabel = QLabel()
self.locationLabel.setBuddy(self.locationInput)
gridLayout.addWidget(self.locationLabel, 1, 2)
gridLayout.addWidget(self.locationInput, 1, 3)
lineFrame = QFrame(frameShadow=QFrame.Sunken, frameShape=QFrame.VLine)
gridLayout.addWidget(lineFrame, 0, 4, 2, 1)