pyqt 自动补全

from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *


def get_data(model):
# Searching through the Doc
# Result shows in a dictionary structure
    result = {"alpha": 0, "apple": 1, "agree": 2}
    icon_address = ['....SrcImgA.png', '....SrcImgE.png','....SrcImgO.png']
    for cmd, value in result.items():
        item = QStandardItem(cmd)
        item.setIcon(QIcon(icon_address[value]))
        model.insertRow(0, item)


class CodeAC:

   def __init__(self, input_line):
      self.completer = QCompleter()
      input_line.setCompleter(self.completer)
      self.model = QStandardItemModel()

   def active_script(self):
      get_data(self.model)
      self.completer.setModel(self.model)

   def tip_balloon(self):
      key = self.completer.currentRow()
      print(key)
    

import sys
import ctypes

class MainWindow(QWidget):

    def __init__(self):
        super(MainWindow, self).__init__()
        self.extention = None
        self.entry = QLineEdit(self)

    def init_main(self):
        self.setGeometry(600,600,800,600)
        self.setWindowTitle('VISA Communication')
        self.setWindowIcon(QIcon('....SrcImgicon.png'))
        self.show()

    def active_extention(self):
        self.extention = CodeAC(self.entry)
        self.extention.active_script()

if __name__ == '__main__':

   app = QApplication(sys.argv)
   root = MainWindow()
   root.init_main()
   root.active_extention()
   sys.exit(app.exec_())

转自:https://pastebin.com/nJyVDHPM

转载于:https://www.cnblogs.com/tinyos/p/7290430.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值