码迷,mamicode.com
首页 > 其他好文 > 详细

pyqt 自动补全

时间:2017-08-05 16:44:03      阅读:269      评论:0      收藏:0      [点我收藏+]

标签:comm   item   super   pyqt   ems   ini   import   title   tip   

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

pyqt 自动补全

标签:comm   item   super   pyqt   ems   ini   import   title   tip   

原文地址:http://www.cnblogs.com/tinyos/p/7290430.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!