我在搅拌机中有一个 gui 界面,以下应该是用户的场景:
按下“运行”按钮后,用户可以在输入文本框中输入句子,这样每个句子都应该以点“。”结尾。那么如果用户输入一个句子,那么输入框应该被清除,输入的句子应该显示在输出文本框中。
问题出在代码的以下部分:
while 1:
input = Textbox1.val
if input.__contains__('.'):
Textbox1.val = ''
Textbox2.val = input
这是我的所有代码:
import Blender
from Blender.BGL import *
from Blender.Draw import *
def draw_gui():
global Textbox1, Textbox2
Textbox1 = Create('input')
Textbox2 = Create('output')
glClearColor(0.753, 0.753, 0.753, 0.0)
glClear(GL_COLOR_BUFFER_BIT)
glColor3f(0.000, 0.000, 0.627)
glRecti(20, 150, 730,500)
Button('Exit', 1, 450, 220, 87, 31)
Button('Quit', 2, 350, 220, 87, 31)
Button('Run', 3, 250, 220, 87, 31)
Textbox1 = String('', 4, 50, 400, 650, 50, Textbox1.val, 399, '')
Textbox2 = String('', 4, 50, 300, 650, 50, Textbox2.val, 399, '')
def event(evt, val):
if (evt==QKEY and not val): Exit()
def bevent(evt):
if evt == 1: #cmdExit
Exit()
elif evt == 2 : #cmdQuit
Blender.Quit()
elif evt == 3 : #cmdRun
########################### from here the problem starts
while 1:
input =Textbox1.val
if input.__contains__('.'):
Textbox1.val=''
Textbox2.val=input
#################### and here is the end of it
Blender.Redraw()
Register(draw_gui, event, bevent)