本文整理汇总了Python中PySide.QtGui.QComboBox.clearEditText方法的典型用法代码示例。如果您正苦于以下问题:Python QComboBox.clearEditText方法的具体用法?Python QComboBox.clearEditText怎么用?Python QComboBox.clearEditText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QComboBox
的用法示例。
在下文中一共展示了QComboBox.clearEditText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ConsoleWidget
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import clearEditText [as 别名]
#.........这里部分代码省略.........
def query(self, sql):
if not self._connection:
self.logEdit.appendPlainText('No connection')
return None
try:
query = self._connection.NewObject('Query', sql)
result = query.Execute()
except Exception as e:
self.logEdit.appendPlainText(str(e))
return None
return result
def refresh(self, result):
self.model.clear()
columns = list()
result_columns = result.Columns
for index in range(result_columns.Count()):
name = result_columns.Get(index).Name
columns.append(name)
self.model.setColumnCount(len(columns))
for section, name in enumerate(columns):
self.model.setHeaderData(section, Qt.Horizontal, name)
select = result.Choose()
self.logEdit.appendPlainText('Selected %d records' % select.Count())
while select.Next():
items = list()
for index in range(len(columns)):
value = select.Get(index)
item = QStandardItem('')
if isinstance(value, bool):
item.setText(value and 'Yes' or 'No')
elif isinstance(value, (int, str)):
item.setText(str(value))
elif isinstance(value, datetime.datetime):
item.setText(value.strftime('%Y.%m.%d %H:%M:%S'))
else:
item.setText(str(value))
items.append(item)
self.model.appendRow(items)
@Slot()
def executeQuery(self):
sql = self.sqlEdit.toPlainText()
result = self.query(sql)
if result:
path = os.path.join(self._home, 'last-sql.txt')
open(path, 'w').write(sql)
self.refresh(result)
@Slot()
def connectOneS(self):
uri = self.connectionUriCombo.currentText().strip()
if not uri:
self.logEdit.appendPlainText('Need a connection string')
return
version = self.onesVersionCombo.currentText()
comName = "V%s.COMConnector" % str(version).replace('.', '')
pythoncom.CoInitialize()
try:
obj = win32com.client.Dispatch(comName)
self._connection = obj.Connect(uri)
except Exception as e:
self.logEdit.appendPlainText(str(e))
return
self.connectAction.setDisabled(True)
self.disconnectAction.setEnabled(True)
self.queryAction.setEnabled(True)
uri_history = list()
for i in range(self.connectionUriCombo.count()):
uri_history.append(self.connectionUriCombo.itemText(i))
if uri not in uri_history:
self.connectionUriCombo.clearEditText()
self.connectionUriCombo.addItem(uri)
self.connectionUriCombo.setCurrentIndex(len(uri_history))
uri_history.append(uri)
path = os.path.join(self._home, 'uri_history.txt')
open(path, 'w').write('\n'.join(uri_history))
@Slot()
def disconnectOneS(self):
pythoncom.CoUninitialize()
self._connection = None
self.connectAction.setEnabled(True)
self.disconnectAction.setDisabled(True)
self.queryAction.setDisabled(True)