如何使用wxPython隐藏垂直和水平滚动条?
我用这段代码创建了一个文本窗口,但我不知道如何隐藏滚动条 我看到一些wxpython不支持的答案,有什么想法吗?? 谢谢 注意:隐藏滚动条不会禁用滚动如何使用wxPython隐藏垂直和水平滚动条?,wxpython,Wxpython,我用这段代码创建了一个文本窗口,但我不知道如何隐藏滚动条 我看到一些wxpython不支持的答案,有什么想法吗?? 谢谢 注意:隐藏滚动条不会禁用滚动 谢谢:) StyledTextCtrl类具有SetUseHorizontalScrollBar和SetUseVerticalScrollBar方法 谢谢,你永远不会相信我在那里搜索了多少-_- import wx import wx.lib.dialogs import wx.stc as stc faces = {'times':'Tim
谢谢:)
StyledTextCtrl类具有
SetUseHorizontalScrollBar
和SetUseVerticalScrollBar
方法
谢谢,你永远不会相信我在那里搜索了多少-_-
import wx
import wx.lib.dialogs
import wx.stc as stc
faces = {'times':'Times New Roman','helv':"Arial","size":18}
class MainWindow(wx.Frame):
def __init__(self,parent,title):
self.filepath =''
self.leftMarginWidth = 25
wx.Frame.__init__(self,parent,title=title,size=(1350,720))
self.control=stc.StyledTextCtrl(self,style=wx.TE_MULTILINE | wx.TE_WORDWRAP|wx.TE_NO_VSCROLL)
self.control.CmdKeyAssign(ord("+"),stc.STC_SCMOD_CTRL,stc.STC_CMD_ZOOMIN) #Ctrl + + to zoom in
self.control.CmdKeyAssign(ord("-"),stc.STC_SCMOD_CTRL,stc.STC_CMD_ZOOMOUT) #Ctrl + - to zoom out
self.control.SetViewWhiteSpace(False)
self.control.SetMargins(5,0)
self.control.SetMarginType(1,stc.STC_MARGIN_NUMBER)
self.control.SetMarginWidth(1,self.leftMarginWidth)
self.control.Bind(wx.EVT_CHAR,self.OnCharEvent)
#don't forget the statusBar
#file men if you want it
self.Show()
def OnSave(self,e):
try:
f= open(self.filepath,"w")
f.write(self.control.GetText())
f.close()
except:
self.OnSaveAs(self)
def OnSaveAs(self,e):
try:
dlg=wx.FileDialog(self,'save file as',self.filepath,"untitled","*.*",wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
print dlg
if (dlg.ShowModal()== wx.ID_OK):
self.filepath = dlg.GetPath()
f=open(self.filepath,"w")
f.write(self.control.GetText())
f.close()
dlg.Destroy()
except:
pass
def OnOpen(self,e):
dlg=wx.FileDialog(self,"Choose a file",self.filepath,'',"*.*",wx.FD_OPEN)
if(dlg.ShowModal() == wx.ID_OK):
self.filepath = dlg.GetPath()
f=open(self.filepath,"r")
self.control.SetText(f.read())
f.close()
dlg.Destroy()
def OnCharEvent(self,e):
keycode=e.GetKeyCode()
print keycode
if (keycode == 15):
self.OnOpen(self)
elif keycode == 19:
self.OnSave(self)
else:
e.Skip()
app=wx.App()
frame = MainWindow(None,"my text Editor")
app.MainLoop()