Does anybody know how to fix this error in RevitPythonShell 2018.1.0.0?
@GTN, it looks like the code that is running the shell is trying to parse the line as code. That is probably due to how it tries to figure out what your input was. I remember being very confused with all of this when I first created RPS.
Instead, try doing this:
print("bunny rabbits lay eggs? yes/no")
answer = raw_input()
EDIT: I checked. It doesn't work.
Here's a solution that uses Forms:
import clr
clr.AddReference("System.Windows.Forms")
clr.AddReference("System.Drawing")
from System.Drawing import Point
from System.Windows.Forms import Form, TextBox, Button, Label, TableLayoutPanel, DockStyle, DialogResult, AnchorStyles
class InputBox(Form):
def __init__(self, question):
self.Text = question
self.tlp = TableLayoutPanel()
self.tlp.RowCount = 3
self.tlp.ColumnCount = 1
self.tlp.Dock = DockStyle.Fill
self.label = Label()
self.label.Text = question
self.label.AutoSize = True
self.label.Dock = DockStyle.Fill
self.label.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom
self.tlp.Controls.Add(self.label)
self.answer = TextBox()
self.answer.Dock = DockStyle.Fill
self.answer.AutoSize = True
self.answer.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom
self.tlp.Controls.Add(self.answer)
self.ok = Button()
self.ok.Text = "OK"
self.ok.AutoSize = True
self.ok.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom
self.ok.DialogResult = DialogResult.OK
self.tlp.Controls.Add(self.ok)
self.Controls.Add(self.tlp)
def raw_input(question):
input_box = InputBox(question)
result = input_box.ShowDialog()
if result == DialogResult.OK:
return input_box.answer.Text
print raw_input("bunny rabbits lay eggs??")