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

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

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

      • <bdo id='eQzFO'></bdo><ul id='eQzFO'></ul>
      <tfoot id='eQzFO'></tfoot>
    1. <small id='eQzFO'></small><noframes id='eQzFO'>

        將信號連接到插槽立即導致信號被發射

        Connecting signal to slot immediately causes signal to be emitted(將信號連接到插槽立即導致信號被發射)
            <tbody id='Sqz5R'></tbody>

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

                1. <small id='Sqz5R'></small><noframes id='Sqz5R'>

                2. <tfoot id='Sqz5R'></tfoot>
                  本文介紹了將信號連接到插槽立即導致信號被發射的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在使用 python 3.3.3 和 pyqt5 編寫程序.我已經連接了許多信號和插槽,沒有問題.這導致了一個問題.我的代碼如下:

                  I am writing a program with python 3.3.3 and pyqt5. I have connected many signals and slots with no problem. This one is causing a problem. My code follows:

                     def populateVendorAndModelComboBoxes(self, vendorComboBox, modelComboBox):
                      dictVendors = {}
                      #for rclass in sorted(list(directory.DRV_TO_RADIO.values())):
                      for rclass in list(directory.DRV_TO_RADIO.values()):
                          if not issubclass(rclass, chirp_common.CloneModeRadio) and 
                                  not issubclass(rclass, chirp_common.LiveRadio):
                              continue
                  
                          if not rclass.VENDOR in dictVendors:
                              dictVendors[rclass.VENDOR] = []
                  
                          dictVendors[rclass.VENDOR].append(rclass)
                  
                      vendorComboBox.addItems(sorted(list(dictVendors)))
                  
                      def _vendorChanged(vendorCBox, vendorsDict, modelCBox):
                  
                          modelsList = vendorsDict[vendorCBox.currentText()]
                  
                          added_models = []
                  
                          modelCBox.clear()
                          for rclass in modelsList:
                              if rclass.MODEL not in added_models:
                                  added_models.append(rclass.MODEL)
                          print("adding to modelCB")
                          modelCBox.addItems(sorted(added_models))
                          print("Done adding to modelCB")
                  
                      vendorComboBox.currentTextChanged.connect(_vendorChanged(vendorComboBox, dictVendors, modelComboBox))
                      _vendorChanged(vendorComboBox, dictVendors, modelComboBox)
                  

                  此代碼使用供應商和模型填充組合框.供應商組合框在啟動時填充.模型組合框填充了每個供應商的不同數據.每次用戶選擇不同的供應商時,必須使用不同的列表更新模型組合框.

                  This code populates comboboxes with vendors and models. The vendor combobox is populated at startup. The model combobox is filled with different data for each vendor. Every time the user picks a different vendor, the model combobox must be updated with a different list.

                  應該發生什么:

                  當調用方法 populateVendorAndModelComboBoxes 時,程序的第一部分將供應商列表放入供應商組合框中.然后將在 currentTextChanged 信號和 _vendorChanged 插槽之間建立連接.然后應該首先調用 _vendorChanged 函數來設置模型組合框.從那時起,每當用戶選擇新的供應商時,都應該調用 _vendorChanged 函數.

                  When the method populateVendorAndModelComboBoxes is called, the first part of the program puts the vendor list in the vendor combobox. Then a connection will be made between the currentTextChanged signal and the _vendorChanged slot. Then the _vendorChanged function should be initially called to setup the Model combobox. From then on, the _vendorChanged function should be called whenever the user picks a new vendor.

                  發生了什么:

                  當 currentTextChanged 信號和 _vendorChanged 槽建立連接時,立即調用 _vendorChanged 函數.它不應立即調用 _vendorChanged 函數.我的任何其他信號/插槽連接都不會發生這種情況._vendorChanged 函數執行沒有錯誤,然后執行點返回到 vendorComboBox.currentTextChanged.connect.... 語句,我立即收到錯誤 TypeError: argument 1 has unexpected type 'NoneType'.

                  When the connection is made between the currentTextChanged signal and the _vendorChanged slot, the _vendorChanged function is immediately called. It should not immediately call the _vendorChanged function. This does not happen with any of my other signal / slot connections. The _vendorChanged function is executed with out error, then the execution point drops back to the vendorComboBox.currentTextChanged.connect.... statement and I immediately get an error TypeError: argument 1 has unexpected type 'NoneType'.

                  如果我注釋掉建立連接的語句,程序就可以正常工作.供應商組合框填充了供應商,模型組合框填充了列表中第一個供應商的模型.這表明 _vendorChanges 代碼工作正常.

                  If I comment out the statement that makes the connection, the program works without error. The vendor combobox is filled with vendors and the model combobox is filled with models of the first vendor in the list. That indicates that the _vendorChanges code is working properly.

                  我有兩個問題.為什么 connect 語句會導致 _vendorChanged 函數立即執行?錯誤信息的原因是什么?

                  I have two questions. Why does the connect statement cause the _vendorChanged function to be immediately executed? What is the cause of the error message?

                  推薦答案

                  基于 ekhumoro 的回答,您還可以讓信號將 currentText 傳遞給 lambda 函數.這意味著您只需將文本傳遞給函數,而不必稍后再獲取 currentText.

                  Building on ekhumoro's answer, you could also let the signal pass the currentText to the lambda function. This means you would just pass the text into the function and not have to get the currentText later.

                  def _vendorChanged(vendorText, vendorsDict, modelCBox):
                  
                      modelsList = vendorsDict[vendorText]
                  
                      added_models = []
                  
                      modelCBox.clear()
                      for rclass in modelsList:
                          if rclass.MODEL not in added_models:
                              added_models.append(rclass.MODEL)
                      print("adding to modelCB")
                      modelCBox.addItems(sorted(added_models))
                      print("Done adding to modelCB")
                  
                  vendorComboBox.currentTextChanged[str].connect(
                      lambda vendorText: _vendorChanged(vendorText, dictVendors, modelComboBox))
                  

                  另外,如果您不需要在每次發出信號時根據 lambda 函數的當前范圍更新對 dictVendors 和 modelComboBox 的引用,您可以將它們排除在參數列表之外,讓 _vendorChanged 函數簡單從它的父范圍繼承它們(這與 lambda 的父范圍相同......所以我不確定有什么區別......).這樣做的吸引力在于您不再需要 lamda 為信號提供可調用的...您可以直接給它 _vendorChanged 函數:

                  Also, if you don't need the references to dictVendors and modelComboBox to update based on the current scope of the lambda function every time the signal is emitted, you could leave them out of the parameter list and let the _vendorChanged function simply inherit them from it's parent scope (which is the same as the lambda's parent scope... so I'm not sure there's be any difference...). The appeal of this is that you no longer need the lamda to provide the signal with a callable... you can give it the _vendorChanged function directly:

                  def _vendorChanged(vendorText):
                  
                      modelsList = dictVendors[vendorText]
                  
                      added_models = []
                  
                      modelComboBox.clear()
                      for rclass in modelsList:
                          if rclass.MODEL not in added_models:
                              added_models.append(rclass.MODEL)
                      print("adding to modelCB")
                      modelComboBox.addItems(sorted(added_models))
                      print("Done adding to modelCB")
                  
                  vendorComboBox.currentTextChanged[str].connect(_vendorChanged)
                  

                  希望有幫助!

                  這篇關于將信號連接到插槽立即導致信號被發射的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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時顯示進度條?)

                  • <legend id='n0a3l'><style id='n0a3l'><dir id='n0a3l'><q id='n0a3l'></q></dir></style></legend>

                      <tbody id='n0a3l'></tbody>

                      <tfoot id='n0a3l'></tfoot>
                        <bdo id='n0a3l'></bdo><ul id='n0a3l'></ul>
                        1. <small id='n0a3l'></small><noframes id='n0a3l'>

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

                          1. 主站蜘蛛池模板: 亚洲国产精品一区二区三区 | 亚洲男人的天堂网站 | 在线观看亚洲一区二区 | 日韩中文字幕在线不卡 | 成人在线视频免费播放 | 中文字幕在线视频网站 | h视频在线看 | 99热这里 | 日本成年免费网站 | 亚洲性免费 | 久久免费视频观看 | 999久久久久久久久6666 | 欧美国产精品一区二区三区 | 国产一级毛片视频 | 亚洲高清视频一区 | 黄色网址在线免费观看 | 精品欧美一区二区三区免费观看 | 欧美mv日韩mv国产网站91进入 | 91传媒在线观看 | 欧美性猛交一区二区三区精品 | 国产精品高潮呻吟久久av野狼 | 亚洲成人午夜在线 | 免费h视频| 国产精品久久久久久久 | 亚洲免费高清 | 精品欧美一区二区久久久伦 | 中文精品视频 | 国产在线资源 | 一区二区三区四区在线视频 | 亚洲成人毛片 | 欧美乱大交xxxxx另类电影 | 天天躁日日躁性色aⅴ电影 免费在线观看成年人视频 国产欧美精品 | 久久久久一区二区 | 色男人天堂av | 91成人在线视频 | 日韩欧美精品一区 | 国产成人一区二区 | 国产69精品久久99不卡免费版 | 欧美一区二区三区四区视频 | 精品欧美一区二区精品久久久 | 九九九久久国产免费 |