久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

        <bdo id='uF6fq'></bdo><ul id='uF6fq'></ul>

      <i id='uF6fq'><tr id='uF6fq'><dt id='uF6fq'><q id='uF6fq'><span id='uF6fq'><b id='uF6fq'><form id='uF6fq'><ins id='uF6fq'></ins><ul id='uF6fq'></ul><sub id='uF6fq'></sub></form><legend id='uF6fq'></legend><bdo id='uF6fq'><pre id='uF6fq'><center id='uF6fq'></center></pre></bdo></b><th id='uF6fq'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='uF6fq'><tfoot id='uF6fq'></tfoot><dl id='uF6fq'><fieldset id='uF6fq'></fieldset></dl></div>

      <legend id='uF6fq'><style id='uF6fq'><dir id='uF6fq'><q id='uF6fq'></q></dir></style></legend>
      1. <tfoot id='uF6fq'></tfoot>

        <small id='uF6fq'></small><noframes id='uF6fq'>

      2. 單擊菜單標題時連接功能

        connect a function when menu title is clicked(單擊菜單標題時連接功能)

        <legend id='ewt9e'><style id='ewt9e'><dir id='ewt9e'><q id='ewt9e'></q></dir></style></legend>

                <tfoot id='ewt9e'></tfoot>

                <i id='ewt9e'><tr id='ewt9e'><dt id='ewt9e'><q id='ewt9e'><span id='ewt9e'><b id='ewt9e'><form id='ewt9e'><ins id='ewt9e'></ins><ul id='ewt9e'></ul><sub id='ewt9e'></sub></form><legend id='ewt9e'></legend><bdo id='ewt9e'><pre id='ewt9e'><center id='ewt9e'></center></pre></bdo></b><th id='ewt9e'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ewt9e'><tfoot id='ewt9e'></tfoot><dl id='ewt9e'><fieldset id='ewt9e'></fieldset></dl></div>
              1. <small id='ewt9e'></small><noframes id='ewt9e'>

                  <tbody id='ewt9e'></tbody>
                • <bdo id='ewt9e'></bdo><ul id='ewt9e'></ul>

                  本文介紹了單擊菜單標題時連接功能的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試查找打開的端口并將它們添加到我的菜單中.現在,我成功地對我的菜單進行了操作(例如,查找端口"),并且只有當它被單擊時——它才會連接到我的功能,以獲得所有可用端口.不幸的是,這不是我想要的.

                  I am trying to find open ports and add them to my menu. Right now, what I succeed having an action to my menu (like, "find ports"), and only if it's clicked - it will connect to my function that gets all free ports. Unfortunately, that's not what I am looking for.

                  我想點擊菜單title,并在我的菜單中獲取所有端口.以下是我的代碼:

                  I want to click on the menu title, and get all port in my menu. Below is the code I have:

                  這是圖形用戶界面部分:

                  This is the GUI part:

                  from PyQt5 import QtCore, QtGui, QtWidgets
                  
                  class Ui_MainWindow(object):
                      def setupUi(self, MainWindow):
                          MainWindow.setObjectName("MainWindow")
                          MainWindow.resize(150, 150)
                          self.centralwidget = QtWidgets.QWidget(MainWindow)
                          self.centralwidget.setObjectName("centralwidget")
                  
                          self.portList = QtWidgets.QPushButton(self.centralwidget)
                          self.portList.setGeometry(QtCore.QRect(10, 50, 65, 23))
                          self.portList.setObjectName("portList")
                  
                          self.productMenu=QtWidgets.QMenu(self.centralwidget)
                  #        self.productMenu.addAction("Find Port") <-------- If I add this, then it works when I click on "Find Port"
                  
                          self.portList.setMenu(self.productMenu)
                  
                          MainWindow.setCentralWidget(self.centralwidget)
                  
                          self.retranslateUi(MainWindow)
                          QtCore.QMetaObject.connectSlotsByName(MainWindow)
                  
                  
                  
                  
                  
                      def retranslateUi(self, MainWindow):
                          _translate = QtCore.QCoreApplication.translate
                          MainWindow.setWindowTitle(_translate("MainWindow", "GUI"))
                          self.portList.setText(_translate("MainWindow", "Ports"))
                  

                  這是我運行我的功能的地方:

                  And this is where I run my functions:

                  from PyQt5 import QtWidgets, QtCore, QtGui
                  from test1 import Ui_MainWindow
                  import serial.tools.list_ports
                  import sys
                  
                  class ApplicationWindow(QtWidgets.QMainWindow):
                      def __init__(self):
                          super(ApplicationWindow, self).__init__()
                  
                          self.ui = Ui_MainWindow()
                          self.ui.setupUi(self)
                  
                          self.ui.productMenu.triggered.connect(self.findPort)
                  
                          self.ui.portList.clicked.connect(self.findPort)
                          ###I tried both lines above, but it doesn't connect to the function###
                      def findPort(self):
                            comPorts = list(serial.tools.list_ports.comports())
                            print("clicked!")
                             for counter in comPorts:
                                 strPort=str(counter)
                                 print(strPort)
                                 self.ui.productMenu.addAction(strPort)
                  
                      def portClick(self,action):
                          print(action.text())
                  
                  
                  if __name__ == "__main__":
                      app = QtWidgets.QApplication(sys.argv)
                      application = ApplicationWindow()
                      application.show()
                      sys.exit(app.exec_())
                  

                  我怎樣才能讓 findport 功能通過按菜單標題進行連接,并使用空閑端口立即更新它?

                  How can I get the findport function to connect by pressing the title of the menu, and get it updated immediately with the free ports?

                  推薦答案

                  你必須使用 aboutToShow 信號:

                  You have to use the aboutToShow signal:

                  self.ui.productMenu.aboutToShow.connect(self.findPort)
                  

                  這篇關于單擊菜單標題時連接功能的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to bind a function to an Action from Qt menubar?(如何將函數綁定到 Qt 菜單欄中的操作?)
                  PyQt progress jumps to 100% after it starts(PyQt 啟動后進度躍升至 100%)
                  How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?(如何將 yaxis 刻度標簽設置在固定位置,以便當我向左或向右滾動時,yaxis 刻度標簽應該可見
                  `QImage` constructor has unknown keyword `data`(`QImage` 構造函數有未知關鍵字 `data`)
                  Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                  How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進度條?)
                      <tbody id='V7grB'></tbody>
                    <legend id='V7grB'><style id='V7grB'><dir id='V7grB'><q id='V7grB'></q></dir></style></legend>

                    1. <tfoot id='V7grB'></tfoot>

                        • <small id='V7grB'></small><noframes id='V7grB'>

                            <bdo id='V7grB'></bdo><ul id='V7grB'></ul>
                            <i id='V7grB'><tr id='V7grB'><dt id='V7grB'><q id='V7grB'><span id='V7grB'><b id='V7grB'><form id='V7grB'><ins id='V7grB'></ins><ul id='V7grB'></ul><sub id='V7grB'></sub></form><legend id='V7grB'></legend><bdo id='V7grB'><pre id='V7grB'><center id='V7grB'></center></pre></bdo></b><th id='V7grB'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='V7grB'><tfoot id='V7grB'></tfoot><dl id='V7grB'><fieldset id='V7grB'></fieldset></dl></div>
                          • 主站蜘蛛池模板: 国产精品久久久av | 久久精品无码一区二区三区 | 中文字幕在线欧美 | 成人在线小视频 | 午夜爽爽爽男女免费观看影院 | 亚洲精品国产成人 | 成人免费激情视频 | 国产精品视频一二三区 | 玖草资源 | 日韩午夜场 | www.youjizz.com日韩 | www.国产.com | 最新国产精品精品视频 | 久久噜噜噜精品国产亚洲综合 | 日本黄色大片免费看 | 精品久久影院 | 日本福利视频免费观看 | 一级片在线免费播放 | 日本在线中文 | 91看片网| 九九免费视频 | 国产成人短视频在线观看 | 成人精品在线观看 | 欧美日韩综合精品 | 日本黄视频在线观看 | 性一区 | 99视频在线 | 五月婷六月丁香 | 午夜视频免费网站 | 欧美国产日韩在线 | 久久婷婷国产麻豆91 | 国产精品69毛片高清亚洲 | 中文字幕精品一区二区三区在线 | 99re99| 国产人免费人成免费视频 | 91大神新作在线观看 | 国产精品成人久久久久 | 久久综合久久久 | 全免费a级毛片免费看视频免费下 | 精品视频在线播放 | 亚洲+变态+欧美+另类+精品 |