0

目前我正在尝试在 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()
4

1 回答 1

1

You have the ListBox parented to the frame instead of the panel and setting the sizer on the frame and not the panel.

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()
于 2013-11-05T19:00:09.470 回答