目前我正在尝试在Windows Siete 32位下使用Wx Python 2.9.5.0和Python 2.7.3制作GUI。我是一个屏幕阅读器用户,对我来说,屏幕阅读器会读取我在代码中指定的两个控件,但是朋友说在屏幕上,她看不到其中一个控件。
当启用屏幕阅读器时,该软件可以读取所有小部件,但我有兴趣在屏幕上显示小部件。
有人知道是否存在在屏幕上显示所有小部件的方法?
以下是代码片段:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import wx
class main(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, "Testing an app")
self.Maximize()
panel = wx.Panel(self, -1)
sizer = wx.BoxSizer(wx.HORIZONTAL)
listbox = wx.BoxSizer(wx.HORIZONTAL)
textbox = wx.BoxSizer(wx.HORIZONTAL)
textList = wx.StaticText(panel, -1, "Text1")
self.listBox = wx.ListBox(self, -1, choices=["Some large text", "another large text"], size=(400, 400))
text = wx.StaticText(panel, -1, "Content")
self.text = wx.TextCtrl(panel, -1, "", style=wx.TE_READONLY|wx.TE_MULTILINE, size=(500, 500))
listbox.Add(textList)
listbox.Add(self.listBox)
textbox.Add(text)
textbox.Add(self.text)
sizer.Add(listbox)
sizer.Add(textbox)
self.SetSizer(sizer)
# Some stuff here...
if __name__ == "__main__":
app = wx.App()
frame = main().Show()
app.MainLoop()
答案 0 :(得分:1)
您将ListBox作为框架的替代,而不是面板,并在框架而不是面板上设置sizer。
import wx
class main(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, "Testing an app")
self.Maximize()
panel = wx.Panel(self, -1)
textList = wx.StaticText(panel, -1, "Text1")
self.listBox = wx.ListBox(panel, -1, choices=["Some large text", "another large text"], size=(400, 400))
text = wx.StaticText(panel, -1, "Content")
self.text = wx.TextCtrl(panel, -1, "", style=wx.TE_READONLY|wx.TE_MULTILINE, size=(500, 500))
listbox = wx.BoxSizer(wx.HORIZONTAL)
listbox.Add(textList)
listbox.Add(self.listBox)
textbox = wx.BoxSizer(wx.HORIZONTAL)
textbox.Add(text)
textbox.Add(self.text)
sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add(listbox)
sizer.Add(textbox)
panel.SetSizer(sizer)
# Some stuff here...
if __name__ == "__main__":
app = wx.App()
frame = main().Show()
app.MainLoop()