【问题标题】:how to get value to a variable using wxpython如何使用 wxpython 获取变量的值
【发布时间】:2014-05-06 12:53:08
【问题描述】:

请任何人告诉我我必须做什么才能将我在 textctrl 中写入的内容写入变量。

from visual import *
import wx
L = 320

w = window(width=2*(L+window.dwidth), height=L+window.dheight+window.menuheight,
       menus=True, title='Widgets')
p=w.panel
d = 20
tc = wx.TextCtrl(p, pos=(1.4*L,90),size=(150,90))
yy=GetValue()

GetValue 在这里不起作用。请帮忙。

【问题讨论】:

    标签: python wxpython


    【解决方案1】:

    您可能是指yy = tc.GetValue()(代码的最后一行),它实际上从您创建的wx.TextCtrl 中获取值。

    您的代码将像现在一样引发NameError

    【讨论】:

      【解决方案2】:

      我认为您正在尝试获取名为 tc 的 textctrl 的内容。在这种情况下,这一行

      yy = GetValue() 在你的代码中应该是

      yy = tc.GetValue()

      我还建议您为变量使用一些有意义的名称。例如,使用 textctrlValuetextctrlContenttcValuetcContent 代替 yy,这样您就知道这个变量的实际用途了。

      【讨论】:

      • 您能否在问题中提供完整的代码
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-23
      • 1970-01-01
      相关资源
      最近更新 更多