我试过了:
wx.ToolTip.Enable(False)
wx.ToolTip_Enable(False)
和
wx.ToolTip.Enable(flag=False)
这些说明都没有被拒绝,但它们都没有工作
我正在使用Linux Mint 17
wx.python 2.8.12.1 (gtk2-unicode)
python 2.7
答案 0 :(得分:1)
根据wxpython docs,ToolTop_Enable
似乎,
全局启用或禁用工具提示。
注意可能并非所有平台都支持(例如Cocoa)。
我假设包括您的平台......
相反,您可能需要为窗口本身设置工具提示。我没有为窗口看到的import wx
app = wx.App()
frame = wx.Frame(None, -1, '')
frame.SetToolTip(wx.ToolTip(''))
frame.SetSize(wx.Size(300,250))
frame.Show()
app.MainLoop()
方法,但将工具提示设置为空字符串似乎对我有用,
import wx
EnableTooltips = False
class Tooltip(wx.ToolTip):
'''A subclass of wx.ToolTip which can be disabled'''
def __init__(self, string, Enable=EnableTooltips):
self.tooltip_string = string
self.TooltipsEnabled = Enable
wx.ToolTip.__init__(self, string)
self.Enable(Enable)
def Enable(self, x):
if x is True:
self.SetTip(self.tooltip_string)
self.TooltipsEnabled = True
elif x is False:
self.SetTip("")
self.TooltipsEnabled = False
app = wx.App()
frame = wx.Frame(None, -1, '')
tt = Tooltip('test')
frame.SetToolTip(tt)
frame.SetSize(wx.Size(300,250))
frame.Show()
app.MainLoop()
编辑:定义子工具提示类,可以启用/禁用,默认基于全局值。
Dim CSVString As String
ColsCount = wb.Sheets(1).UsedRange.Columns.Count
RowsCount = wb.Sheets(1).UsedRange.Rows.Count
With wb.Sheets(1)
For r = 1 To RowsCount
Line = Join(Application.Transpose(Application.Transpose(.range(.Cells(r, 1), .Cells(r, ColsCount)).Value)), ";")
CSVString = CSVString & Line & VbCrLf 'Append each Line together with an end of line to form the full contents of the CSV as a String
Next r
End With
' ...and do the writing to the file here? Yup!
Set fso = CreateObject("Scripting.FileSystemObject")
Set oFile = fso.CreateTextFile(FilePath)
oFile.Write CSVString
Call oFile.Close
Set fso = Nothing
Set oFile = Nothing
我不确定这是否会动态起作用(即一旦启动gui,框架工具提示已设置并且更改其值可能不会更新)。
答案 1 :(得分:1)
最终个人工具提示的答案非常简单,却花了很长时间才找到
使用SetToolTipString("my Tool Tip")
设置工具提示,但使用SetToolTip(None)
将其删除,请参阅以下内容:
全局打开和关闭工具提示似乎仍受您的桌面环境控制。
import wx
class MyForm(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, wx.ID_ANY, "Toggle")
self.panel = wx.Panel(self, wx.ID_ANY)
self.dummy = wx.StaticText(self.panel, -1, "")
self.cb1 = wx.CheckBox(self.panel, -1,"Choice 1", pos=(10,10))
self.cb2 = wx.CheckBox(self.panel, -1,"Choice 2", pos=(10,40))
self.cb1.Bind(wx.EVT_CHECKBOX, self.onToggle1)
self.cb2.Bind(wx.EVT_CHECKBOX, self.onToggle2)
self.cb1.SetToolTipString(wx.EmptyString)
self.cb2.SetToolTipString(wx.EmptyString)
#----------------------------------------------------------------------
def onToggle1(self, event):
if self.cb1.GetValue() == True:
self.cb1.SetToolTipString("Check Box 1 is Checked")
else:
self.cb1.SetToolTip(None)
def onToggle2(self, event):
if self.cb2.GetValue() == True:
self.cb2.SetToolTipString("Check Box 2 Is Checked")
else:
self.cb2.SetToolTip(None)
# Run the program
if __name__ == "__main__":
app = wx.App(False)
frame = MyForm()
frame.Show()
app.MainLoop()