architecture-building-systems / revitpythonshell

An IronPython scripting environment for Autodesk Revit and Vasari
MIT License
492 stars 112 forks source link

Does Tkinter work with Revit Python Shell? #107

Closed daveBisMe closed 4 years ago

daveBisMe commented 4 years ago

I grabbed some code to use with pyRevit and it referenced "from tkinter import *", but each time I try to run the script I get an error - "Import Error: No module named tkinter".

I've tried upper case T and lower case. I also tried loading both Python 2.7.18 and 3.8.2

Is this supported as part of RPS? If so, what am I missing to get it running?

I opened a Windows Command Prompt and type "python -m tkinter" and it runs from there.

Just trying to give as much info as possible.

Thanks in advance for any help.

daren-thomas commented 4 years ago

@daveBisMe when you type python in the Windows Command Prompt, you're probably getting another version of python - one you installed separately. Try where python to find out exactly which python is being used in that case. RPS uses IronPython, since the RevitAPI is a .NET API. Instead of using tkinter, you can use the WinForms library. It's easy to find examples of creating WinForms GUI's with IronPython. You might also be able to find ways to make tkinter work with IronPython. Note that Revit runs it's own event loop and getting your head around that might be a bit weird (any example that tells you to do something similar to App.Run etc. won't quite work that way. Good luck :) and don't forget to blog your success for the rest of the world :-)