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

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

      <bdo id='E5L9y'></bdo><ul id='E5L9y'></ul>
  • <legend id='E5L9y'><style id='E5L9y'><dir id='E5L9y'><q id='E5L9y'></q></dir></style></legend>

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

        如何獲取在 Kivy 中使用 fileChooser 選擇的文件的信

        How do I get info of a file selected with fileChooser in Kivy?(如何獲取在 Kivy 中使用 fileChooser 選擇的文件的信息?)
        <i id='9DR6G'><tr id='9DR6G'><dt id='9DR6G'><q id='9DR6G'><span id='9DR6G'><b id='9DR6G'><form id='9DR6G'><ins id='9DR6G'></ins><ul id='9DR6G'></ul><sub id='9DR6G'></sub></form><legend id='9DR6G'></legend><bdo id='9DR6G'><pre id='9DR6G'><center id='9DR6G'></center></pre></bdo></b><th id='9DR6G'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='9DR6G'><tfoot id='9DR6G'></tfoot><dl id='9DR6G'><fieldset id='9DR6G'></fieldset></dl></div>
        <tfoot id='9DR6G'></tfoot>
          1. <legend id='9DR6G'><style id='9DR6G'><dir id='9DR6G'><q id='9DR6G'></q></dir></style></legend>

            <small id='9DR6G'></small><noframes id='9DR6G'>

              <tbody id='9DR6G'></tbody>

                • <bdo id='9DR6G'></bdo><ul id='9DR6G'></ul>
                • 本文介紹了如何獲取在 Kivy 中使用 fileChooser 選擇的文件的信息?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  如何獲取通過 fileChooser 選擇的文件的信息?以下是我的一些代碼塊:

                  How do I grab info of a file I select through the fileChooser? Here are some chunks of code I have:

                  self.fileChooser = fileChooser = FileChooserListView(size_hint_y=None, path='/home/')
                  ...
                  btn = Button(text='Ok')
                  btn.bind(on_release=self.load(fileChooser.path, fileChooser.selection))
                  ...
                  def load(self, path, selection):
                      print path,  selection
                  

                  它的作用是在我最初打開 fileChooser 時打印實例中的路徑和選擇.當我選擇一個文件并單擊確定"時,沒有任何反應.

                  What this does is print the path and the selection in the instance when I initially open the fileChooser. When I select a file and click 'Ok', nothing happens.

                  推薦答案

                  btn.bind(on_release=self.load(fileChooser.path, fileChooser.selection))
                  
                  ...
                  def load(self, path, selection):
                      print path,  selection
                  

                  這是對 python 語法的誤用.問題是,您需要將 function 傳遞給 btn.bind.該函數被存儲,然后當on_release事件發生時,該函數被調用.

                  This is a misuse of python syntax. The problem is, you need to pass a function to btn.bind. The function is stored, then when the on_release event occurs, the function is called.

                  你所做的不是傳入函數,而是簡單地調用它并傳遞結果.這就是為什么您在打開文件選擇器時會看到打印一次的路徑和選擇 - 這是該函數被實際調用的唯一一次.

                  What you have done is not pass in the function, but simply call it and pass the result. That's why you see the path and selection printed once when you open the filechooser - that's the one and only time the function is actually called.

                  相反,您需要傳入要調用的實際函數.由于范圍可變,您必須在這里小心一點,并且有多種潛在的解決方案.以下是一種可能性的基礎知識:

                  Instead, you need to pass in the actual function you want to call. You have to be a bit careful here because of variable scoping, and there are multiple potential solutions. Below is the basics of one possibility:

                  def load_from_filechooser(self, filechooser):
                      self.load(filechooser.path, filechooser.selection)
                  def load(self, path, selection):
                      print path,  selection
                  ...
                  from functools import partial
                  btn.bind(on_release=partial(self.load_from_filechooser, fileChooser))
                  

                  partial 函數接受一個函數和一些參數,并返回一個自動傳遞這些參數的新函數.這意味著當 on_release 發生時,bind 實際上有一些東西要調用,這反過來又會調用 load_from_filechooser,而后者又會調用你原來的 load 函數.

                  The partial function takes a function and some arguments, and returns a new function that automatically passes those arguments. That means bind actually has something to call when on_release occurs, which in turn calls load_from_filechooser which in turn calls your original load function.

                  您也可以在不使用局部的情況下執行此操作,但這是一種有用的通用技術,在這種情況下(我認為)有助于弄清楚發生了什么.

                  You could also do this without partial, but it's a useful general technique and in this case helps (I think) to make it clear what's going on.

                  我使用了對 fileChooser 的引用,因為您不能直接在函數中引用 fileChooser.path 和 fileChooser.selection - 您只能在定義函數時獲取它們的值.這樣,我們跟蹤 fileChooser 本身,僅在稍后調用該函數時提取路徑和選擇.

                  I used a reference to fileChooser because you can't reference fileChooser.path and fileChooser.selection directly in your function - you would only get their values at the time the function is defined. This way, we track the fileChooser itself and only extract the path and selection when the function is later called.

                  這篇關于如何獲取在 Kivy 中使用 fileChooser 選擇的文件的信息?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  How to make a discord bot that gives roles in Python?(如何制作一個在 Python 中提供角色的不和諧機器人?)
                  Discord bot isn#39;t responding to commands(Discord 機器人沒有響應命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關于我嗎?Discord 機器人的功能?(不和諧.py))
                  message.channel.id Discord PY(message.channel.id Discord PY)
                  How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機器人?)
                  discord.py - Automaticaly Change an Role Color(discord.py - 自動更改角色顏色)
                    <bdo id='WEWdx'></bdo><ul id='WEWdx'></ul>

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

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

                          • <tfoot id='WEWdx'></tfoot>
                            <legend id='WEWdx'><style id='WEWdx'><dir id='WEWdx'><q id='WEWdx'></q></dir></style></legend>
                          • 主站蜘蛛池模板: 欧美视频区 | 国产精品久久9 | av黄色在线观看 | 白浆在线| 7777奇米影视 | 一级在线毛片 | 色av一区 | 亚洲午夜在线 | 天天搞天天操 | 毛片一级网站 | 在线观看亚洲 | 午夜免费电影 | 久热免费 | 宅男伊人| 国产亚洲欧美在线视频 | 亚洲欧美精品国产一级在线 | 久热国产精品 | 亚洲综合久久久 | 美女一级毛片 | 精品日韩一区二区 | 91麻豆精品国产91久久久更新资源速度超快 | 久久99精品久久久久久 | 欧美一区二区 | 91av视频| 日韩亚洲欧美综合 | 高清欧美性猛交xxxx黑人猛交 | 欧美日韩高清在线观看 | 九九热精品视频 | 欧美成人免费在线视频 | 欧美三区在线观看 | 伊人色综合久久久天天蜜桃 | 在线色网 | 国内精品视频在线 | 国产色网站 | 中文字幕精品一区 | xxx视频| 亚洲天堂二区 | 亚洲国产精品久久 | 羞羞视频网 | 一区二区三区四区在线免费观看 | 欧美三级久久久 |