pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

        <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="secgaks" 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. 單擊菜單標(biāo)題時(shí)連接功能

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

        <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="0iq00so" 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>

                  本文介紹了單擊菜單標(biāo)題時(shí)連接功能的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

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

                  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.

                  我想點(diǎn)擊菜單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"))
                  

                  這是我運(yùn)行我的功能的地方:

                  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 功能通過按菜單標(biāo)題進(jìn)行連接,并使用空閑端口立即更新它?

                  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 信號(hào):

                  You have to use the aboutToShow signal:

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

                  這篇關(guān)于單擊菜單標(biāo)題時(shí)連接功能的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  How to bind a function to an Action from Qt menubar?(如何將函數(shù)綁定到 Qt 菜單欄中的操作?)
                  PyQt progress jumps to 100% after it starts(PyQt 啟動(dòng)后進(jìn)度躍升至 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 刻度標(biāo)簽設(shè)置在固定位置,以便當(dāng)我向左或向右滾動(dòng)時(shí),yaxis 刻度標(biāo)簽應(yīng)該可見
                  `QImage` constructor has unknown keyword `data`(`QImage` 構(gòu)造函數(shù)有未知關(guān)鍵字 `data`)
                  Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                  How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時(shí)顯示進(jìn)度條?)
                      <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="iyywsym" id='V7grB'><tfoot id='V7grB'></tfoot><dl id='V7grB'><fieldset id='V7grB'></fieldset></dl></div>
                          • 主站蜘蛛池模板: 柔性输送线|柔性链板|齿形链-上海赫勒输送设备有限公司首页[输送机] | 冷油器-冷油器换管改造-连云港灵动列管式冷油器生产厂家 | 合肥注册公司|合肥代办营业执照、2024注册公司流程 | 精雕机-火花机-精雕机 cnc-高速精雕机-电火花机-广东鼎拓机械科技有限公司 | 在线浊度仪_悬浮物污泥浓度计_超声波泥位计_污泥界面仪_泥水界面仪-无锡蓝拓仪表科技有限公司 | 农产品溯源系统_农产品质量安全追溯系统_溯源系统 | 粉末冶金-粉末冶金齿轮-粉末冶金零件厂家-东莞市正朗精密金属零件有限公司 | 储能预警-储能消防系统-电池舱自动灭火装置-四川千页科技股份有限公司官网 | 华禹护栏|锌钢护栏_阳台护栏_护栏厂家-华禹专注阳台护栏、楼梯栏杆、百叶窗、空调架、基坑护栏、道路护栏等锌钢护栏产品的生产销售。 | 慢回弹测试仪-落球回弹测试仪-北京冠测精电仪器设备有限公司 | 北京印刷厂_北京印刷_北京印刷公司_北京印刷厂家_北京东爵盛世印刷有限公司 | 电子巡更系统-巡检管理系统-智能巡检【金万码】 | 安徽成考网-安徽成人高考网 | ISO9001认证咨询_iso9001企业认证代理机构_14001|18001|16949|50430认证-艾世欧认证网 | 食品无尘净化车间,食品罐装净化车间,净化车间配套风淋室-青岛旭恒洁净技术有限公司 | 门禁卡_智能IC卡_滴胶卡制作_硅胶腕带-卡立方rfid定制厂家 | 深圳美安可自动化设备有限公司,喷码机,定制喷码机,二维码喷码机,深圳喷码机,纸箱喷码机,东莞喷码机 UV喷码机,日期喷码机,鸡蛋喷码机,管芯喷码机,管内壁喷码机,喷码机厂家 | 山东聚盛新型材料有限公司-纳米防腐隔热彩铝板和纳米防腐隔热板以及钛锡板、PVDF氟膜板供应商 | 首页-恒温恒湿试验箱_恒温恒湿箱_高低温试验箱_高低温交变湿热试验箱_苏州正合 | 知企服务-企业综合服务(ZiKeys.com)-品优低价、种类齐全、过程管理透明、速度快捷高效、放心服务,知企专家! | 水厂污泥地磅|污泥处理地磅厂家|地磅无人值守称重系统升级改造|地磅自动称重系统维修-河南成辉电子科技有限公司 | 长沙中央空调维修,中央空调清洗维保,空气能热水工程,价格,公司就找维小保-湖南维小保环保科技有限公司 | 齿辊分级破碎机,高低压压球机,立式双动力磨粉机-郑州长城冶金设备有限公司 | 吹田功率计-长创耐压测试仪-深圳市新朗普电子科技有限公司 | 压接机|高精度压接机|手动压接机|昆明可耐特科技有限公司[官网] 胶泥瓷砖胶,轻质粉刷石膏,嵌缝石膏厂家,腻子粉批发,永康家德兴,永康市家德兴建材厂 | 防火窗_耐火窗_防火门厂家_防火卷帘门-重庆三乐门业有限公司 | 江西高职单独招生-江西单招考试-江西高职单招网 | PCB厂|线路板厂|深圳线路板厂|软硬结合板厂|电路板生产厂家|线路板|深圳电路板厂家|铝基板厂家|深联电路-专业生产PCB研发制造 | 板材品牌-中国胶合板行业十大品牌-环保板材-上海声达板材 | 钢衬四氟管道_钢衬四氟直管_聚四氟乙烯衬里管件_聚四氟乙烯衬里管道-沧州汇霖管道科技有限公司 | SOUNDWELL 编码器|电位器|旋转编码器|可调电位器|编码开关厂家-广东升威电子制品有限公司 | 重庆小面培训_重庆小面技术培训学习班哪家好【终身免费复学】 | 耐破强度测试仪-纸箱破裂强度试验机-济南三泉中石单品站 | 韦伯电梯有限公司 | 二氧化碳/活性炭投加系统,次氯酸钠发生器,紫外线消毒设备|广州新奥 | 螺杆真空泵_耐腐蚀螺杆真空泵_水环真空泵_真空机组_烟台真空泵-烟台斯凯威真空 | 电磁流量计厂家_涡街流量计厂家_热式气体流量计-青天伟业仪器仪表有限公司 | 聚合氯化铝-碱式氯化铝-聚合硫酸铁-聚氯化铝铁生产厂家多少钱一吨-聚丙烯酰胺价格_河南浩博净水材料有限公司 | 厂房出租-厂房规划-食品技术-厂房设计-厂房装修-建筑施工-设备供应-设备求购-龙爪豆食品行业平台 | 水篦子|雨篦子|镀锌格栅雨水篦子|不锈钢排水篦子|地下车库水箅子—安平县云航丝网制品厂 | 真空吸污车_高压清洗车厂家-程力专用汽车股份有限公司官网 |