本文整理匯總了Python中PyQt5.QtWidgets.QLineEdit.setObjectName方法的典型用法代碼示例。如果您正苦於以下問題:Python QLineEdit.setObjectName方法的具體用法?Python QLineEdit.setObjectName怎麽用?Python QLineEdit.setObjectName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWidgets.QLineEdit
的用法示例。
在下文中一共展示了QLineEdit.setObjectName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: OptionWizard
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setObjectName [as 別名]
class OptionWizard(QDialog):
def __init__(self, wizardtype, translator):
super(OptionWizard, self).__init__()
self.tran = translator
self.layout = QGridLayout(self)
self.title = self.tran.get_text(wizardtype)
self.setWindowTitle(self.title)
self.setWindowIcon(QIcon("./resources/Logo_v2.png"))
self.key_label = QLabel(self)
self.key_label.setObjectName("wizard_key_label")
self.key_label.setText(self.tran.get_text(self.key_label.objectName()))
self.keyinput = QLineEdit(self)
self.keyinput.setObjectName("wizard_key_input")
self.keyinput.setText(self.tran.get_text(self.keyinput.objectName()))
self.value_label = QLabel(self)
self.value_label.setObjectName("wizard_value_label")
self.value_label.setText(self.tran.get_text(self.value_label.objectName()))
self.valueinput = QLineEdit(self)
self.valueinput.setObjectName("wizard_value_input")
self.valueinput.setText(self.tran.get_text(self.valueinput.objectName()))
self.confirm = QPushButton(self)
self.confirm.setObjectName("wizard_button_confirm")
self.confirm.setText(self.tran.get_text(self.confirm.objectName()))
self.confirm.clicked.connect(self.close)
self.layout.addWidget(self.key_label, 0, 0, 1, 3)
self.layout.addWidget(self.keyinput, 0, 3, 1, 7)
self.layout.addWidget(self.value_label, 1, 0, 1, 3)
self.layout.addWidget(self.valueinput, 1, 3, 1, 7)
self.layout.addWidget(self.confirm, 2, 8, 2, 1)
self.show()
def setting_name(self):
if self.keyinput:
return self.keyinput.text()
else:
return None
def setting_value(self):
if self.valueinput:
return self.valueinput.text()
else:
return ""
示例2: _initUi
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setObjectName [as 別名]
def _initUi(self):
self.resize(250, 150)
self.move(300, 300)
self.setWindowTitle("Simple")
layout = QVBoxLayout()
headWidget = QWidget()
headLayout = QHBoxLayout()
headWidget.setLayout(headLayout)
layout.addWidget(headWidget)
edit_icon = QWidget(self)
edit_icon.resize(30,30)
edit_icon.setStyleSheet("background: url(:/images/edit-icon);")
edit_icon.move(20,15)
label = QLabel("Login Form", self)
label.resize(label.sizeHint())
label.move(60,20)
edit = QLineEdit()
edit.setObjectName("username")
edit.setPlaceholderText("username")
layout.addWidget(edit)
edit = QLineEdit()
edit.setObjectName("password")
edit.setPlaceholderText("password")
layout.addWidget(edit)
widget = QWidget()
layout.addWidget(widget)
loginLayout = QHBoxLayout()
loginLayout.setContentsMargins(0,-10,0,0)
loginLayout.setSpacing(30)
widget.setLayout(loginLayout)
# widget.setStyleSheet("background-color:blue")
btn = QPushButton("登錄")
loginLayout.addWidget(btn)
btn.clicked.connect(self.login)
btn.setStyleSheet("margin:0;padding:5 0;border:0px;background-color: #26b9a5;color:white;")
btn.setAutoDefault(False)
btn = QPushButton("取消")
loginLayout.addWidget(btn)
btn.clicked.connect(self.close)
btn.setStyleSheet("padding:5px 0;border:0px;background-color: #26b9a5;color:white;")
btn.setAutoDefault(False)
# layout.setContentsMargins(11,11,11,11)
self.setLayout(layout)
示例3: Example
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setObjectName [as 別名]
class Example(QWidget):
def __init__(self):
super(Example, self).__init__()
self.lb = QLabel('URL: ', self)
self.le = QLineEdit(self)
self.le.setObjectName("url")
self.btn = QPushButton("Sipppp", self)
self.btn.clicked.connect(self.buttonClicked)
hbox1 = QHBoxLayout()
hbox1.addWidget(self.lb)
hbox1.addWidget(self.le)
hbox2 = QHBoxLayout()
hbox2.addWidget(self.btn)
vbox = QVBoxLayout()
vbox.addLayout(hbox1)
vbox.addLayout(hbox2)
self.setLayout(vbox)
self.setGeometry(300, 300, 300, 100)
self.setWindowTitle('Event sender')
def buttonClicked(self):
url=self.le.text()
req=urllib2.Request(url)
response=urllib2.urlopen(req)
soup=BeautifulSoup(response.read())
styles=['zh-question-collapsed-link','zm-item-vote','zh-answers-title','zm-votebar','zm-item-comment-el','zm-item-vote-info','zu-top','zu-global-notify','zm-side-section','zh-footer','zh-webshare-dialog','zh-feedback-form','zh-add-question-form','view','business-selection']
soup=RemoveStyle('div',styles,soup)
soup=RemoveStyle('h2',['zm-item-title'],soup)
soup=RemoveStyle('a',['collapse','zg-link-litblue'],soup)
for tag in soup.findAll('body'):
tag['style']='margin:0px auto text-align:center'
html=soup.prettify('utf-8')
with open('a.html','wb') as f:
f.write(html)
name=soup.find('title').getText()
ConvertEpub(name+'.epub',['a.html'])
示例4: _get_rows
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setObjectName [as 別名]
def _get_rows(self, model, main_window):
"""
Default row for a form is QLabel, QLineEdit
But for foreign fields it's QComboBox
Maybe later I will add QCalendar for dates and etc.
"""
for column in model.__table__.columns:
if column.name == 'id' or column.default:
continue
if column.foreign_keys:
label, widget = self._get_combobox(column, model.__mapper__.relationships, main_window)
else:
label = column.name
widget = QLineEdit()
widget.textEdited.connect(self._check_input)
widget.setObjectName(column.name)
if self.item:
widget.setText(getattr(self.item, column.name, ''))
yield QLabel(_(label)), widget
示例5: MyCurrencyBox
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setObjectName [as 別名]
class MyCurrencyBox(QFrame):
_amount = None
def __init__(self, *args):
super(MyCurrencyBox, self).__init__(*args)
Lumberjack.info('spawning a << MyCurrencyBox >>')
self.currencyBoxlayout = QHBoxLayout(self)
self.currencyBoxlayout.setObjectName("currencyBoxlayout")
self.currencyLabel = QLabel('€')
self.euroLineEdit = QLineEdit()
self.euroLineEdit.setText('0')
self.euroLineEdit.setAlignment(Qt.AlignRight)
self.euroLineEdit.setObjectName("euroLineEdit")
euroValidator = QIntValidator()
self.euroLineEdit.setValidator(euroValidator)
self.euroLineEdit.setMaxLength(6)
self.commaLabel = QLabel(',')
self.centsLineEdit = QLineEdit()
self.centsLineEdit.setText('00')
self.euroLineEdit.setAlignment(Qt.AlignRight)
self.centsLineEdit.setObjectName("centsLineEdit")
centsValidator = QIntValidator(0, 99)
self.centsLineEdit.setValidator(centsValidator)
self.centsLineEdit.setMaxLength(2)
spacerItem1 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
spacerItem2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
self.currencyBoxlayout.addItem(spacerItem1)
self.currencyBoxlayout.addWidget(self.currencyLabel)
self.currencyBoxlayout.addWidget(self.euroLineEdit)
self.currencyBoxlayout.addWidget(self.commaLabel)
self.currencyBoxlayout.addWidget(self.centsLineEdit)
self.currencyBoxlayout.addItem(spacerItem2)
self.centsLineEdit.textChanged.connect(self.on_text_input)
self.euroLineEdit.textChanged.connect(self.on_text_input)
def getAmount(self):
Lumberjack.info('< MyCurrencyBox > - -> (getAmount)')
if self._amount is None:
return None
euros = self.euroLineEdit.text()
cents = self.centsLineEdit.text()
full_amount = euros + cents
self._amount = int(full_amount)
return self._amount
def setAmount(self, amount):
Lumberjack.info('< MyCurrencyBox > - -> (setAmount)')
if amount is None:
self._amount = None
euros = '0'
cents = '00'
else:
euros = str(amount)[:-2]
if euros == '':
euros = '0'
cents = str(amount)[-2:]
if cents == '0':
cents = '00'
self.euroLineEdit.setText(euros)
self.centsLineEdit.setText(cents)
self._amount = amount
amount = pyqtProperty(int, fget=getAmount, fset=setAmount)
def on_text_input(self):
Lumberjack.info('< MyCurrencyBox {}> - -> (on_text_input)')
euros = self.euroLineEdit.text()
cents = self.centsLineEdit.text()
full_amount = euros + cents
self._amount = int(full_amount)
示例6: EditView
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setObjectName [as 別名]
#.........這裏部分代碼省略.........
#self._cursor_moved()
self.Editor.setFocus(Qt.TabFocusReason)
# Lots of other code needs a textcursor for the current document.
def get_cursor(self):
return QTextCursor(self.Editor.textCursor())
# Return the essence of the cursor as a tuple (pos,anc)
def get_cursor_val(self):
return (self.Editor.textCursor().position(), self.Editor.textCursor.anchor())
# Some other code likes to reposition the edit selection:
def set_cursor(self, tc):
self.Editor.setTextCursor(tc)
# Make a valid cursor based on position and anchor values possibly
# input by the user.
def make_cursor(self, position, anchor):
mx = self.document.characterCount()
tc = QTextCursor(self.Editor.textCursor())
anchor = min( max(0,anchor), mx )
position = min ( max(0,position), mx )
tc.setPosition(anchor)
tc.setPosition(position,QTextCursor.KeepAnchor)
return tc
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# INITIALIZE UI
#
# First we built the Edit panel using Qt Creator which produced a large
# and somewhat opaque block of code that had to be mixed in by
# multiple inheritance. This had several drawbacks, so the following
# is a "manual" UI setup using code drawn from the generated code.
#
def _uic(self):
# First set up the properties of "self", a QWidget.
self.setObjectName("EditViewWidget")
sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
sizePolicy.setHorizontalStretch(1)
sizePolicy.setVerticalStretch(1)
sizePolicy.setHeightForWidth(False) # don't care to bind height to width
self.setSizePolicy(sizePolicy)
self.setMinimumSize(QSize(250, 250))
self.setFocusPolicy(Qt.StrongFocus)
self.setContextMenuPolicy(Qt.CustomContextMenu)
self.setWindowTitle("")
self.setToolTip("")
self.setStatusTip("")
self.setWhatsThis("")
# Set up our primary widget, the editor
self.Editor = PTEditor(self,self.my_book)
self.Editor.setObjectName("Editor")
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(2) # Edit deserves all available space
sizePolicy.setVerticalStretch(2)
sizePolicy.setHeightForWidth(False)
self.Editor.setSizePolicy(sizePolicy)
self.Editor.setFocusPolicy(Qt.StrongFocus)
self.Editor.setContextMenuPolicy(Qt.NoContextMenu)
self.Editor.setAcceptDrops(True)
self.Editor.setLineWidth(2)
self.Editor.setDocumentTitle("")
self.Editor.setLineWrapMode(QPlainTextEdit.NoWrap)
# Set up the frame that will contain the bottom row of widgets
# It doesn't need a parent and doesn't need to be a class member
# because it will be added to a layout, which parents it.
bot_frame = QFrame()
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
示例7: WindowHead
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setObjectName [as 別名]
class WindowHead(QWidget):
got_network_music_url = QtCore.pyqtSignal(str, str)
def __init__(self, parent=None):
super(WindowHead, self).__init__(parent)
# self.lab_frame = QLabel()
self.__labWindowLogo = QLabel()
self.__labWindowLogo.setFixedSize(30, 30)
self.__labWindowLogo.setStyleSheet('border-image: url(Images/logo);')
self.__lab_window_title = QLabel('<html><font color="yellow" size=4>大黃狗播放器 汪~汪~</font></html>')
# 搜索框
self.search_frame = QWidget()
self.search_frame.setFixedSize(150, 18)
self.ln_search = QLineEdit(self.search_frame)
self.ln_search.setFixedSize(self.search_frame.size())
self.ln_search.setPlaceholderText('輸入歌曲名')
self.tbn_search = QToolButton(self.search_frame)
self.tbn_search.setGeometry(128, 2, 15, 15)
self.__tbnCloseWindow = QToolButton()
self.__tbnMiniWindow = QToolButton()
self.__tbnSetting = QToolButton()
self.__tbnCloseWindow.setFixedSize(11, 11)
self.__tbnMiniWindow.setFixedSize(11, 11)
self.__tbnSetting.setFixedSize(11, 11)
self.setObjectName('lab_frame')
self.ln_search.setObjectName('ln_search')
self.tbn_search.setObjectName('tbn_search')
self.__tbnCloseWindow.setObjectName('closeWindow')
self.__tbnMiniWindow.setObjectName('miniWindow')
self.__tbnSetting.setObjectName('setting')
self.setStyleSheet('''
#lab_frame{background: rgba(0, 0, 0, 120);}
#ln_search{
border: 1px; white;
border-radius: 9px;
height: 18px;
}
#tbn_search{
border-image: url(Images/search.png);
}
#closeWindow{border-image: url(Images/closeWindow);}
#closeWindow:hover{border-image: url(Images/closeWindow_hover);}
#miniWindow{border-image: url(Images/miniWindow);}
#miniWindow:hover{border-image: url(Images/miniWindow_hover);}
#setting{border-image: url(Images/setting);}
#setting:hover{border-image: url(Images/setting_hover);}
''')
self.__layout = QHBoxLayout()
self.__layout.addWidget(self.__labWindowLogo)
self.__layout.addStretch(5)
self.__layout.addWidget(self.__lab_window_title)
self.__layout.addStretch(1)
self.__layout.addWidget(self.search_frame)
self.__layout.addStretch(1)
self.__layout.addWidget(self.__tbnSetting)
self.__layout.addWidget(self.__tbnMiniWindow)
self.__layout.addWidget(self.__tbnCloseWindow)
self.__layout.setSpacing(10)
self.__layout.setContentsMargins(0, 0, 0, 0)
self.setLayout(self.__layout)
self.network = Network.NetWork()
self.__tbnCloseWindow.clicked.connect(self.parentWidget().close)
self.__tbnMiniWindow.clicked.connect(self.parentWidget().showMinimized)
self.tbn_search.clicked.connect(self.get_music_play_url)
def get_music_play_url(self):
music_name = self.ln_search.text()
music_url_play_url = self.network.get_music_play_url(music_name)
self.got_network_music_url.emit(music_name, music_url_play_url)
print(music_url_play_url)
示例8: Ui_chem
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setObjectName [as 別名]
class Ui_chem(QWidget):
def __init__(self):
super(Ui_chem, self).__init__()
self.initUi(self)
def initUi(self, chem):
chem.setObjectName(_fromUtf8("chem"))
chem.resize(601, 430)
self.pushButton = QPushButton(chem)
self.pushButton.setGeometry(QtCore.QRect(340, 390, 110, 32))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.pushButton_2 = QPushButton(chem)
self.pushButton_2.setGeometry(QtCore.QRect(449, 390, 151, 32))
self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
self.line_name = QLineEdit(chem)
self.line_name.setGeometry(QtCore.QRect(140, 40, 431, 31))
self.line_name.setObjectName(_fromUtf8("line_name"))
self.label_name = QLabel(chem)
self.label_name.setGeometry(QtCore.QRect(30, 50, 56, 13))
self.label_name.setObjectName(_fromUtf8("label_name"))
self.line_vendor = QLineEdit(chem)
self.line_vendor.setGeometry(QtCore.QRect(140, 100, 211, 21))
self.line_vendor.setObjectName(_fromUtf8("line_vendor"))
self.label_vendor = QLabel(chem)
self.label_vendor.setGeometry(QtCore.QRect(30, 100, 56, 13))
self.label_vendor.setObjectName(_fromUtf8("label_vendor"))
self.line_vpid = QLineEdit(chem)
self.line_vpid.setGeometry(QtCore.QRect(140, 140, 211, 21))
self.line_vpid.setObjectName(_fromUtf8("line_vpid"))
self.label_vpid = QLabel(chem)
self.label_vpid.setGeometry(QtCore.QRect(30, 150, 111, 16))
self.label_vpid.setObjectName(_fromUtf8("label_vpid"))
self.line_cas = QLineEdit(chem)
self.line_cas.setGeometry(QtCore.QRect(140, 200, 211, 21))
self.line_cas.setObjectName(_fromUtf8("line_cas"))
self.label_cas = QLabel(chem)
self.label_cas.setGeometry(QtCore.QRect(30, 210, 111, 16))
self.label_cas.setObjectName(_fromUtf8("label_cas"))
self.line_size = QLineEdit(chem)
self.line_size.setGeometry(QtCore.QRect(140, 250, 211, 21))
self.line_size.setObjectName(_fromUtf8("line_size"))
self.label_size = QLabel(chem)
self.label_size.setGeometry(QtCore.QRect(30, 250, 111, 16))
self.label_size.setObjectName(_fromUtf8("label_size"))
self.label_storage = QLabel(chem)
self.label_storage.setGeometry(QtCore.QRect(30, 310, 111, 16))
self.label_storage.setObjectName(_fromUtf8("label_storage"))
self.label_room = QLabel(chem)
self.label_room.setGeometry(QtCore.QRect(320, 310, 111, 16))
self.label_room.setObjectName(_fromUtf8("label_room"))
self.line_storage = QLineEdit(chem)
self.line_storage.setGeometry(QtCore.QRect(90, 300, 211, 21))
self.line_storage.setObjectName(_fromUtf8("line_storage"))
self.line_room = QLineEdit(chem)
self.line_room.setGeometry(QtCore.QRect(370, 300, 211, 21))
self.line_room.setObjectName(_fromUtf8("line_room"))
self.line_id = QLineEdit(chem)
self.line_id.setGeometry(QtCore.QRect(370, 350, 211, 21))
self.line_id.setObjectName(_fromUtf8("line_id"))
self.label_id = QLabel(chem)
self.label_id.setGeometry(QtCore.QRect(320, 350, 111, 16))
self.label_id.setObjectName(_fromUtf8("label_id"))
self.retranslateUi(chem)
QtCore.QMetaObject.connectSlotsByName(chem)
#connections
#self.connect(self.pushButton, QtCore.SIGNAL("released()"), self.save)
#self.connect(self.pushButton_2, QtCore.SIGNAL("released()"), self.quit)
self.pushButton.clicked.connect(self.save)
self.pushButton_2.clicked.connect(self.quit)
def save (self) :
allconn=cursor.connection()
curs=allconn[0]
data=allconn[1]
name=str(self.line_name.text())
vendor=str(self.line_vendor.text())
vpid=str(self.line_vpid.text())
cas=str(self.line_cas.text())
size=str(self.line_size.text())
storage=str(self.line_storage.text())
room=str(self.line_room.text())
idnum=str(self.line_id.text())
idtupl=(idnum,)
val=(name,vendor,vpid,cas,size,storage,room,idnum)
curs.execute('''DELETE FROM chem WHERE id=?''', idtupl)
data.commit()
curs.execute('''INSERT INTO chem VALUES (?,?,?,?,?,?,?,?)''', val)
data.commit()
data.close()
self.close()
def quit (self) :
self.close()
#.........這裏部分代碼省略.........
示例9: WinsWidget
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setObjectName [as 別名]
class WinsWidget(QWidget):
"""主窗口。"""
def __init__(self, parent=None):
logger.debug("_init__:begin")
super(WinsWidget, self).__init__(parent)
self.setObjectName('winsWidget')
self.setWindowFlags(Qt.FramelessWindowHint)
self.setWindowTitle('wins的小工具')
self.setWindowIcon(QIcon('icons/titleIcon.png'))
self.resize(1000, 650)
# 按鈕start.
self.btn_exit = QPushButton(self)
self.btn_min = QPushButton(self)
self.btn_max = QPushButton(self)
self.btn_login = QPushButton("Unlogin", self)
self.btn_search = QPushButton(self)
self.btn_qry_stock = QPushButton(self)
self.btn_add_stock = QPushButton(self)
self.btn_del_stock = QPushButton(self)
# 按鈕end.
# 標簽start.
self.lbe_pic = QLabel(self)
self.header_hr = QLabel(self)
self.header_icon = QLabel(self)
self.header_text = QLabel(self)
self.spacing = QLabel(self)
self.spacing2 = QLabel(self)
self.spacing3 = QFrame()
self.spacing4 = QFrame()
# -------
# 輸入框start.
self.search_line = QLineEdit(self)
# 輸入框end.
# -------
# 列表框start.
self.stockTableView = QtWidgets.QTableView(self)
self.stockTableModel=QSqlTableModel(self)
# -------
# 布局與屬性設置。
self.mainLayout = QGridLayout()
self.topLayout = QHBoxLayout()
self.leftLayout = QVBoxLayout()
self.centerLayout = QHBoxLayout()
self.rightLayout = QVBoxLayout()
self.rightLayout1 = QHBoxLayout()
self.rightLayout2 = QVBoxLayout()
self.rightLayout21 = QHBoxLayout()
self.bottomLayout = QHBoxLayout()
self.bottomLayout1 = QVBoxLayout()
self.playLayout = QHBoxLayout()
self.set_buttons()
self.set_labels()
self.set_lines()
self.load_stock_tableview()
# -------
# 其他功能。
self.load_login()
self.setLayout(self.set_layouts())
logger.debug("_init__:end")
# 設置布局。
def set_layouts(self):
"""
布局。
"""
# 頭布局start.
logger.debug("set_layouts:begin")
self.topLayout.setObjectName('Headerhbox')
self.topLayout.addWidget(self.header_icon)
self.topLayout.addWidget(self.header_text)
self.topLayout.addWidget(self.spacing2)
self.topLayout.addWidget(self.search_line)
self.topLayout.addWidget(self.btn_search)
self.topLayout.addStretch(1)
self.topLayout.addWidget(self.lbe_pic)
self.topLayout.addWidget(self.btn_login)
self.topLayout.addWidget(self.spacing)
self.topLayout.addWidget(self.btn_min)
self.topLayout.addWidget(self.btn_max)
self.topLayout.addWidget(self.btn_exit)
self.topLayout.setSpacing(7)
# -------
self.mainLayout.addLayout(self.topLayout, 0, 0, Qt.AlignTop)
self.mainLayout.addWidget(self.header_hr, 1, 0, Qt.AlignTop)
# 頭布局end.
# --------
# 中心布局start.
# 左部分start.
self.leftLayout.addWidget(self.btn_qry_stock)
self.leftLayout.addWidget(self.btn_add_stock)
self.leftLayout.addWidget(self.btn_del_stock)
self.leftLayout.setSpacing(10)
# 左部分end。
# -------
#.........這裏部分代碼省略.........
示例10: configureWidget
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setObjectName [as 別名]
class configureWidget(QWidget):
def __init__(self,parent_):
super(configureWidget,self).__init__(parent_)
self.parent_=parent_
self.obj=parent_.obj
self.initUI()
def initUI(self):
self.qle1 = QLineEdit(self)
self.qle1.setObjectName("qle")
self.qle1.setPlaceholderText("Enter Your Moodle Username")
self.qle2 = QLineEdit(self)
self.qle2.setEchoMode(QLineEdit.Password)
self.qle2.setObjectName("qle")
self.qle2.setPlaceholderText("Enter Your Moodle Password")
lbltxt = ['Username', 'Password','Auto-Download', 'Keep Notifying', 'Update Interval' ]
lbl=[]
self.status_label = QLabel(self)
self.status_label.setObjectName('slbl')
self.status_label.setText(self.obj.config_status)
for i in range(0,len(lbltxt)):
lbl.append(QLabel(self))
lbl[i].setText(lbltxt[i])
lbl[i].setObjectName("lbl")
self.combo = QComboBox(self)
self.combo.setObjectName("combo")
self.combo2 = QComboBox(self)
self.combo2.setObjectName("combo")
for i1 in range(1,7):
self.combo.addItem(str(i1)+" hrs")
self.combo2.addItem("Turn Off")
for i4 in range(1,9):
self.combo2.addItem(str(i4*5)+" mins")
btn=QPushButton("Configure")
btn.setObjectName("btn")
btn.clicked.connect(self.callRetrieve)
self.c = QCheckBox()
self.c.stateChanged.connect(self.selectDirs)
self.path_=''
grid = QGridLayout()
for i2 in range(0,len(lbl)):
grid.addWidget(lbl[i2],i2+1 , 0)
grid.addWidget(self.qle1,1,1)
grid.addWidget(self.qle2,2,1)
grid.addWidget(self.c,3,1)
grid.addWidget(self.combo2,4,1)
grid.addWidget(self.combo,5,1)
grid.addWidget(btn, 6,0)
grid.addWidget(self.status_label,6,1)
grid.setHorizontalSpacing(50)
grid.setVerticalSpacing(0)
grid.setContentsMargins(150, 40, 150, 0)
self.setLayout(grid)
def keyPressEvent(self,event):
if event.key() == QtCore.Qt.Key_Return:
self.callRetrieve()
def selectDirs(self,event):
if self.c.isChecked():
self.path_ = QFileDialog.getExistingDirectory(self, 'Select Directory(for downloaded files)')
if self.path_ =='':
if self.obj.dir_url =='':
self.path_ = os.environ['PROGRAMFILES']
self.path_ = os.path.join(path_,"Moodly")
self.c.setText(self.path_)
else:
self.path_ = self.obj.dir_url
self.c.setText(self.path_)
else:
self.c.setText('')
self.path_=''
def callRetrieve(self):
if self.c.isChecked():
str_=1
else:
str_=0
self.obj.saveUserData(str(self.qle1.text()),
#.........這裏部分代碼省略.........
示例11: EditView
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setObjectName [as 別名]
#.........這裏部分代碼省略.........
self.Editor.centerCursor()
self.Editor.setFocus(Qt.TabFocusReason)
# Lots of other code needs a textcursor for the current document.
def get_cursor(self):
return QTextCursor(self.Editor.textCursor())
# Return the essence of the cursor as a tuple (pos,anc)
def get_cursor_val(self):
return (self.Editor.textCursor().position(), self.Editor.textCursor().anchor())
# Some other code likes to reposition the edit selection:
def set_cursor(self, tc):
self.Editor.setTextCursor(tc)
# Make a valid cursor based on position and anchor values possibly
# input by the user.
def make_cursor(self, position, anchor):
mx = self.document.characterCount()
tc = QTextCursor(self.Editor.textCursor())
anchor = min( max(0,anchor), mx )
position = min ( max(0,position), mx )
tc.setPosition(anchor)
tc.setPosition(position,QTextCursor.KeepAnchor)
return tc
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# INITIALIZE UI
#
# First we built the Edit panel using Qt Creator which produced a large
# and somewhat opaque block of code that had to be mixed in by
# multiple inheritance. This had several drawbacks, so the following
# is a "manual" UI setup using code drawn from the generated code.
#
def _uic(self):
# First set up the properties of "self", a QWidget.
self.setObjectName("EditViewWidget")
sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
sizePolicy.setHorizontalStretch(1)
sizePolicy.setVerticalStretch(1)
sizePolicy.setHeightForWidth(False) # don't care to bind height to width
self.setSizePolicy(sizePolicy)
self.setMinimumSize(QSize(250, 250))
self.setFocusPolicy(Qt.StrongFocus)
self.setContextMenuPolicy(Qt.CustomContextMenu)
self.setWindowTitle("")
self.setToolTip("")
self.setStatusTip("")
self.setWhatsThis("")
# Set up our primary widget, the editor
self.Editor = PTEditor(self,self.my_book)
self.Editor.setObjectName("Editor")
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(2) # Edit deserves all available space
sizePolicy.setVerticalStretch(2)
sizePolicy.setHeightForWidth(False)
self.Editor.setSizePolicy(sizePolicy)
self.Editor.setFocusPolicy(Qt.StrongFocus)
self.Editor.setContextMenuPolicy(Qt.NoContextMenu)
self.Editor.setAcceptDrops(True)
self.Editor.setLineWidth(2)
self.Editor.setDocumentTitle("")
self.Editor.setLineWrapMode(QPlainTextEdit.NoWrap)
# Set up the frame that will contain the bottom row of widgets
# It doesn't need a parent and doesn't need to be a class member
# because it will be added to a layout, which parents it.
bot_frame = QFrame()
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
示例12: MainWindow
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setObjectName [as 別名]
#.........這裏部分代碼省略.........
self.__layout_path = QHBoxLayout()
self.__layout_path.addLayout(self.__layout_choose_path)
self.__layout_path.addWidget(self.__rbn_search_file)
self.__layout_path.addWidget(self.__rbn_search_content)
self.__layout_path.setContentsMargins(0, 0, 0, 0)
self.__lab_path_fram.setLayout(self.__layout_path)
# search state
self.__layout_state = QHBoxLayout()
self.__layout_state.addWidget(self.__lab_state)
self.__layout_state.addWidget(self.__pbn_search)
self.__layout_state.addWidget(self.__pbn_stop)
self.__layout_state.setContentsMargins(0, 0, 0, 10)
self.__lab_state_fram.setLayout(self.__layout_state)
# top layout
self.__layout_top = QVBoxLayout()
self.__layout_top.addWidget(self.__lab_title_fram)
self.__layout_top.addWidget(self.__lab_mode_fram)
self.__layout_top.addWidget(self.__lab_pattern_fram)
self.__layout_top.addWidget(self.__lab_path_fram)
self.__layout_top.addWidget(self.__lab_state_fram)
self.__layout_top.addWidget(self.__tabView)
self.__layout_top.setSpacing(10)
self.__widget_frame.setLayout(self.__layout_top)
self.__layout_fram = QGridLayout()
self.__layout_fram.addWidget(self.__widget_frame, 0, 0, 1, 1)
self.__layout_fram.setContentsMargins(0, 0, 0, 0)
self.setLayout(self.__layout_fram)
# set object name
self.__widget_frame.setObjectName('fram')
self.__lab_title.setObjectName('lab_title')
self.__ln_open_tool.setObjectName('ln_open_tool')
self.__lab_mode_fram.setObjectName('mode_fram')
self.__ln_file_name.setObjectName('ln_pattern')
self.__ln_file_path.setObjectName('ln_path')
self.__lab_state.setObjectName('state')
self.__tabView.setObjectName('tabView')
self.__browser_result.setObjectName('browser_result')
self.__browser_error.setObjectName('browser_error')
self.setStyleSheet(
'#fram{'
'border-image: url(Images/bg);'
'}'
'#lab_title{'
'color: white;'
'font-size: 18pt;'
'}'
'#open_tool{'
'color: black;'
'}'
'#mode_fram{'
# 'border-top: 1px solid rgba(20, 20, 20, 100);'
# 'border-bottom: 1px solid rgba(20, 20, 20, 100);'
'background: rgba(0, 0, 0, 40);'
'}'
'#ln_open_tool, #ln_path{'
'border-top-left-radius: 2px;'
'border-bottom-left-radius: 2px;'
'}'
'#ln_pattern{'
'border-radius: 2px;'
示例13: Ui_Dialog
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setObjectName [as 別名]
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName(_fromUtf8("Dialog"))
Dialog.resize(430, 486)
icon = QIcon()
icon.addPixmap(QPixmap(_fromUtf8("images/icon.ico")), QIcon.Normal, QIcon.Off)
Dialog.setWindowIcon(icon)
self.formLayoutWidget_2 = QWidget(Dialog)
self.formLayoutWidget_2.setGeometry(QRect(230, 80, 181, 131))
self.formLayoutWidget_2.setObjectName(_fromUtf8("formLayoutWidget_2"))
self.formLayout_2 = QFormLayout(self.formLayoutWidget_2)
self.formLayout_2.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)
self.formLayout_2.setObjectName(_fromUtf8("formLayout_2"))
self.label_5 = QLabel(self.formLayoutWidget_2)
self.label_5.setObjectName(_fromUtf8("label_5"))
self.formLayout_2.setWidget(0, QFormLayout.LabelRole, self.label_5)
self.ball_box = QComboBox(self.formLayoutWidget_2)
self.ball_box.setObjectName(_fromUtf8("ball_box"))
self.ball_box.addItem(_fromUtf8(""))
self.ball_box.addItem(_fromUtf8(""))
self.ball_box.addItem(_fromUtf8(""))
self.ball_box.addItem(_fromUtf8(""))
self.ball_box.addItem(_fromUtf8(""))
self.ball_box.addItem(_fromUtf8(""))
self.ball_box.addItem(_fromUtf8(""))
self.ball_box.addItem(_fromUtf8(""))
self.ball_box.addItem(_fromUtf8(""))
self.ball_box.addItem(_fromUtf8(""))
self.formLayout_2.setWidget(0, QFormLayout.FieldRole, self.ball_box)
self.label_6 = QLabel(self.formLayoutWidget_2)
self.label_6.setObjectName(_fromUtf8("label_6"))
self.formLayout_2.setWidget(2, QFormLayout.LabelRole, self.label_6)
self.status_box = QComboBox(self.formLayoutWidget_2)
self.status_box.setObjectName(_fromUtf8("status_box"))
self.status_box.addItem(_fromUtf8(""))
self.status_box.addItem(_fromUtf8(""))
self.status_box.addItem(_fromUtf8(""))
self.status_box.addItem(_fromUtf8(""))
self.status_box.addItem(_fromUtf8(""))
self.status_box.addItem(_fromUtf8(""))
self.formLayout_2.setWidget(2, QFormLayout.FieldRole, self.status_box)
spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
self.formLayout_2.setItem(1, QFormLayout.FieldRole, spacerItem)
spacerItem1 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
self.formLayout_2.setItem(3, QFormLayout.FieldRole, spacerItem1)
self.captured_edit = QLineEdit(self.formLayoutWidget_2)
self.captured_edit.setObjectName(_fromUtf8("captured_edit"))
self.formLayout_2.setWidget(4, QFormLayout.FieldRole, self.captured_edit)
self.label = QLabel(self.formLayoutWidget_2)
self.label.setObjectName(_fromUtf8("label"))
self.formLayout_2.setWidget(4, QFormLayout.LabelRole, self.label)
self.formLayoutWidget_3 = QWidget(Dialog)
self.formLayoutWidget_3.setGeometry(QRect(20, 80, 171, 131))
self.formLayoutWidget_3.setObjectName(_fromUtf8("formLayoutWidget_3"))
self.formLayout_3 = QFormLayout(self.formLayoutWidget_3)
self.formLayout_3.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)
self.formLayout_3.setObjectName(_fromUtf8("formLayout_3"))
self.label_8 = QLabel(self.formLayoutWidget_3)
self.label_8.setObjectName(_fromUtf8("label_8"))
self.formLayout_3.setWidget(0, QFormLayout.LabelRole, self.label_8)
self.pokemon_Name_box = QComboBox(self.formLayoutWidget_3)
self.pokemon_Name_box.setObjectName(_fromUtf8("pokemon_Name_box"))
self.formLayout_3.setWidget(0, QFormLayout.FieldRole, self.pokemon_Name_box)
spacerItem2 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
self.formLayout_3.setItem(1, QFormLayout.FieldRole, spacerItem2)
self.label_9 = QLabel(self.formLayoutWidget_3)
self.label_9.setObjectName(_fromUtf8("label_9"))
self.formLayout_3.setWidget(2, QFormLayout.LabelRole, self.label_9)
self.level_edit = QLineEdit(self.formLayoutWidget_3)
self.level_edit.setObjectName(_fromUtf8("level_edit"))
self.formLayout_3.setWidget(2, QFormLayout.FieldRole, self.level_edit)
self.label_10 = QLabel(self.formLayoutWidget_3)
self.label_10.setObjectName(_fromUtf8("label_10"))
self.formLayout_3.setWidget(3, QFormLayout.LabelRole, self.label_10)
self.hp_edit = QLineEdit(self.formLayoutWidget_3)
self.hp_edit.setObjectName(_fromUtf8("hp_edit"))
self.formLayout_3.setWidget(3, QFormLayout.FieldRole, self.hp_edit)
self.spriteLabel = QLabel(self.formLayoutWidget_3)
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.spriteLabel.sizePolicy().hasHeightForWidth())
self.spriteLabel.setSizePolicy(sizePolicy)
self.spriteLabel.setText(_fromUtf8(""))
self.spriteLabel.setObjectName(_fromUtf8("spriteLabel"))
self.formLayout_3.setWidget(1, QFormLayout.LabelRole, self.spriteLabel)
self.textBrowser = QTextBrowser(Dialog)
self.textBrowser.setGeometry(QRect(20, 260, 391, 192))
self.textBrowser.setObjectName(_fromUtf8("textBrowser"))
self.label_3 = QLabel(Dialog)
self.label_3.setGeometry(QRect(335, 460, 71, 20))
self.label_3.setObjectName(_fromUtf8("label_3"))
self.label_4 = QLabel(Dialog)
self.label_4.setGeometry(QRect(20, 30, 251, 16))
font = QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label_4.setFont(font)
self.label_4.setObjectName(_fromUtf8("label_4"))
#.........這裏部分代碼省略.........
示例14: BrowserWindow
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setObjectName [as 別名]
#.........這裏部分代碼省略.........
@pyqtSlot()
def onUrlChanged(self):
if self.hoveredUrl != '':
self.urlLabel.setText('<span style="color: gray">{}</span>'.format(html.escape(self.hoveredUrl)))
else:
self.urlLabel.setText(html.escape(self.url().toDisplayString()))
@pyqtSlot()
def onTitleChanged(self):
title = self.webView.page().title()
if title == '':
self.setWindowTitle('shower')
else:
self.setWindowTitle('shower: ' + title)
def addShortcut(self, key, handler):
shortcut = QShortcut(QKeySequence(key), self)
shortcut.activated.connect(handler)
return shortcut
@pyqtSlot()
def onLoadStarted(self):
self.isLoading = True
self.stopShortcut.setEnabled(True)
self.progressLabel.setText('<span style="color: yellow">[ 0%]</span>')
@pyqtSlot(int)
def onLoadProgress(self, n):
if n == 100:
self.progressLabel.setText('<span style="color: green">[100]</span>'.format(n))
else:
self.progressLabel.setText('<span style="color: yellow">[{:2d}%]</span>'.format(n))
@pyqtSlot()
def onLoadFinished(self):
self.isLoading = False
self.stopShortcut.setEnabled(False)
self.urlChanged.emit()
def initUI(self, windowType):
self.setStyleSheet("""
#cmdLine, #bar, #bar > * { border: 0px; background: #070707; font-family: "Pro Font"; font-size: 10px; color: white; min-height: 17px }
""")
self.setWindowTitle('shower')
self.setAttribute(Qt.WA_DeleteOnClose)
vbox = QVBoxLayout()
self.setLayout(vbox)
vbox.setContentsMargins(0, 0, 0, 0)
vbox.setSpacing(0)
bar = QWidget()
bar.setObjectName('bar')
hbox = QHBoxLayout()
hbox.setContentsMargins(2, 0, 0, 0)
hbox.setSpacing(0)
bar.setLayout(hbox)
vbox.addWidget(bar)
self.urlLabel = QLabel()
self.urlLabel.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred)
self.urlLabel.setTextFormat(Qt.RichText)
hbox.addWidget(self.urlLabel)
hbox.setStretch(0, 1)
self.progressLabel = QLabel()
self.progressLabel.setTextFormat(Qt.RichText)
hbox.addWidget(self.progressLabel)
self.cmdLine = QLineEdit()
self.cmdLine.setObjectName('cmdLine')
vbox.addWidget(self.cmdLine)
self.webView = QWebEngineView()
self.webView.setPage(BrowserPage(self))
vbox.addWidget(self.webView)
self.cmdLine.returnPressed.connect(self.handleCommand)
self.webView.page().linkHovered.connect(self.onLinkHovered)
self.webView.page().urlChanged.connect(self.urlChanged)
self.webView.page().titleChanged.connect(self.onTitleChanged)
self.webView.page().loadProgress.connect(self.onLoadProgress)
self.webView.page().loadStarted.connect(self.onLoadStarted)
self.webView.page().loadFinished.connect(self.onLoadFinished)
self.urlChanged.connect(self.onUrlChanged)
self.addShortcut("Alt+Left", lambda: self.webView.page().triggerAction(QWebEnginePage.Back))
self.addShortcut("Alt+Right", lambda: self.webView.page().triggerAction(QWebEnginePage.Forward))
self.addShortcut("Ctrl+R", lambda: self.webView.page().triggerAction(QWebEnginePage.Reload))
self.addShortcut("Ctrl+Shift+R", lambda: self.webView.page().triggerAction(QWebEnginePage.ReloadAndBypassCache))
self.stopShortcut = self.addShortcut("Esc", lambda: self.webView.page().triggerAction(QWebEnginePage.Stop))
self.addShortcut("Ctrl+W", lambda: self.close())
self.addShortcut("Ctrl+L", lambda: self.beginEnteringCommand(None))
self.addShortcut("Ctrl+K", lambda: self.beginEnteringCommand('? '))
self.addShortcut("Ctrl+/", lambda: self.beginEnteringCommand('/ '))
self.addShortcut("Ctrl+U", lambda: self.toggleSource())
示例15: reConfigureWidget
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setObjectName [as 別名]
class reConfigureWidget(QWidget):
def __init__(self,parent_):
super(reConfigureWidget,self).__init__(parent_)
self.parent_=parent_
self.obj=parent_.obj
self.initUI()
def initUI(self):
self.qle1 = QLineEdit(self)
self.qle1.setObjectName("qle")
self.qle1.setText(self.obj.uname)
self.qle1.setReadOnly(True)
self.qle2 = QLineEdit(self)
self.qle2.setEchoMode(QLineEdit.Password)
self.qle2.setObjectName("qle")
self.qle2.setText(self.obj.passwd)
self.updating=False
lbltxt = ['Username', 'Password','Auto-Download', 'Keep Notifying', 'Update Interval' ]
lbl=[]
self.status_label = QLabel(self)
self.status_label.setObjectName('slbl')
self.obj.config_status =''
self.c = QCheckBox()
self.c.setText(self.obj.dir_url)
if int(self.obj.dwnld)==1:
self.c.toggle()
self.c.stateChanged.connect(self.selectDirs)
self.path_ =self.obj.dir_url
self.status_label.setText('')
for i in range(0,len(lbltxt)):
lbl.append(QLabel(self))
lbl[i].setText(lbltxt[i])
lbl[i].setObjectName("lbl")
self.combo = QComboBox(self)
self.combo.setObjectName("combo")
self.combo2 = QComboBox(self)
self.combo2.setObjectName("combo")
for i1 in range(1,7):
self.combo.addItem(str(i1)+" hrs")
index = self.combo.findText(self.obj.upIntval,QtCore.Qt.MatchExactly)
self.combo.setCurrentIndex(index)
self.combo2.addItem("Turn Off")
for i4 in range(1,9):
self.combo2.addItem(str(i4*5)+" mins")
index1 = self.combo2.findText(self.obj.nIntval,QtCore.Qt.MatchExactly)
self.combo2.setCurrentIndex(index1)
btn1=QPushButton("Save")
btn1.setObjectName("btn")
btn1.clicked.connect(self.callValidate)
btn2=QPushButton("Cancel")
btn2.setObjectName("gbtn")
btn2.clicked.connect(self.closeConfig)
grid = QGridLayout()
for i2 in range(0,len(lbl)):
grid.addWidget(lbl[i2],i2+1 , 0)
grid.addWidget(self.qle1,1,1)
grid.addWidget(self.qle2,2,1)
grid.addWidget(self.c,3,1)
grid.addWidget(self.combo2,4,1)
grid.addWidget(self.combo,5,1)
grid.addWidget(btn1, 6,0)
grid.addWidget(btn2, 6,1)
grid.setHorizontalSpacing(70)
grid.setVerticalSpacing(30)
grid.setContentsMargins(160, 18, 150, 0)
hbox1 = QHBoxLayout()
hbox1.addLayout(grid)
self.hbox2 = QHBoxLayout()
self.hbox2.setContentsMargins(160,0,0,0)
self.hbox2.setSpacing(0)
self.hbox2.addWidget(self.status_label)
vbox = QVBoxLayout()
vbox.setContentsMargins(0,48,0,0)
vbox.setSpacing(0)
vbox.addLayout(hbox1)
vbox.addLayout(self.hbox2)
#.........這裏部分代碼省略.........