簡體   English   中英

如何禁用/刪除wx.lib.filebrowsebutton.FileBrowseButton中的輸入框?

[英]How to disable/remove the input box in wx.lib.filebrowsebutton.FileBrowseButton?

看起來像沒有內置選項來禁用/刪除InputBox/TextCtrl部分wx.lib.filebrowsebutton.FileBrowseButton ,以及我沒有拿出其被簡單地設置一個解決方法labelText空白,然后它的大小縮小以適合只按鈕本身,從視覺上看,您無法分辨它與普通按鈕的區別,但是我認為它不適合使用。

那么有沒有辦法完全禁用/刪除InputBox部分? 或者也許是一種將普通按鈕與文件瀏覽器功能綁定的方法?

如果您不需要textctrl ,則實際上不需要wx.lib.FileBrowseButton 您只需要一個普通的wx.Button啟動wx.FileDialog實例。 實際上,這就是wx.lib.FileBrowsBbutton 這是相關的源代碼,可以在這里查看整個內容: https : //github.com/wxWidgets/wxPython/blob/master/wx/lib/filebrowsebutton.py

def OnBrowse (self, event = None):
        """ Going to browse for file... """
        current = self.GetValue()
        directory = os.path.split(current)
        if os.path.isdir( current):
            directory = current
            current = ''
        elif directory and os.path.isdir( directory[0] ):
            current = directory[1]
            directory = directory [0]
        else:
            directory = self.startDirectory
            current = ''
        dlg = wx.FileDialog(self, self.dialogTitle, directory, current,
                            self.fileMask, self.fileMode)

        if dlg.ShowModal() == wx.ID_OK:
            self.SetValue(dlg.GetPath())
        dlg.Destroy()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM