Pat Stanford Posted April 28, 2022 Share Posted April 28, 2022 Is there a list of installed Python Modules for VW2022? I am looking to use tkinter to store some text to the clipboard in a cross platform script. From looking in the VW App, it appears that tkinter is there, but when I try to use tkinter it can't be found. I know tkinter for dialogs is discourages, but what about for other functions? Can I specify the path as part of the use tkinter? Newbie to Python. Hating the captilazation and white space delimiting. 😉 Thanks for any help. 1 Quote Link to comment
twk Posted April 29, 2022 Share Posted April 29, 2022 Are you on Mac? I've heard somewhere that Tkinter may need to be installed separately as its own package on the MacOS. On my windows one, it comes with Python3.8 that ships with Vectorworks Quote Link to comment
_c_ Posted April 29, 2022 Share Posted April 29, 2022 I tried using tkinter just recently and it stalls VW indefinitely, simply upon loading the import, does anyone see this? Quote Link to comment
Jayme McColgan Posted April 29, 2022 Share Posted April 29, 2022 a down and dirty way is to look at the site-packages folder... /Applications/Vectorworks 2022/Vectorworks 2022.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages Quote Link to comment
DomC Posted April 30, 2022 Share Posted April 30, 2022 tkinter could be installed with the Marionette python Modul importer. But at the Moment this maybe also not work out of the box. And by using tkinter I had negative effects resp. some functions maybe additional code to make it run in an embedded python. Maybe off-topic. For Crossplatform Clipboard, this script could be used: import math import os import subprocess major, minor, maintenance, platform = vs.GetVersion() text = 'Hello World' def addToClipBoardWin(text): command = 'echo ' + text.strip() + ' | clip' os.system(command) def addToClipBoardMac(text): process = subprocess.Popen('pbcopy', env={'LANG': 'en_US.UTF-8'}, stdin=subprocess.PIPE) process.communicate(text.encode('utf-8')) if platform == 1: addToClipBoardMac(str(text)) else: addToClipBoardWin(str(text)) 4 Quote Link to comment
Pat Stanford Posted April 30, 2022 Author Share Posted April 30, 2022 @DomC Thank you for the help. Exactly what I was looking for, a cross platform way to get data onto the clipboard. My script will just be one line to put the data I want into text. 🤣 I found several similar things on-line, but none as clearly done as yours. Thanks again. 2 Quote Link to comment
_c_ Posted May 1, 2022 Share Posted May 1, 2022 (edited) On 4/29/2022 at 3:36 PM, Jayme McColgan said: a down and dirty way is to look at the site-packages folder... /Applications/Vectorworks 2022/Vectorworks 2022.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages It's there. I don't understand what is going on, I file now a report and hopefully @K.Lalkovski can get a look into that. Edit: no, decided not to file a report. Tkinter is not working easily anywhere, particularly on Mac, and there is even the limit of it being somehow commercial. Edited May 1, 2022 by _c_ 1 Quote Link to comment
twk Posted May 2, 2022 Share Posted May 2, 2022 (edited) On a side note, heres a snippet that lists out all installed modules for your python environment (adapted for vectorworks, by adding vs.CreateText(), to be run on design/sheet layer). def list_modules(): import pkg_resources installed_packages = {d.project_name: d.version for d in pkg_resources.working_set} # print(pkg_resources.working_set) text_data = [] for k, v in installed_packages.items(): # print(f"{k} : {v}") text_data.append(f"{k} : {v}") import vs vs.CreateText(f"{vs.Chr(13)}".join(text_data)) Edited May 2, 2022 by twk 3 Quote Link to comment
Pat Stanford Posted May 2, 2022 Author Share Posted May 2, 2022 On 5/1/2022 at 4:05 AM, _c_ said: It's there. I don't understand what is going on, I file now a report and hopefully @K.Lalkovski can get a look into that. Edit: no, decided not to file a report. Tkinter is not working easily anywhere, particularly on Mac, and there is even the limit of it being somehow commercial. Are you sure @_c_? In my clean install of VW2022SP3, tkinter is not in the site-packages folder. It is in: /Applications/Vectorworks 2022/Vectorworks 2022.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9 @DomC gave me what I need without it, so I didn't try moving it to site-packages. I don't have enough Python experience to know it it can just be moved or if there needs to be an official install done. Quote Link to comment
_c_ Posted May 3, 2022 Share Posted May 3, 2022 @Pat Stanford you are correct, it is not in the site-packages folder, it is in pyhton3.9 I am still not in clear about all path nuances between python/VW/editor, so can't really tell if it's wrong. Quote Link to comment
Pat Stanford Posted May 3, 2022 Author Share Posted May 3, 2022 I am filing a VB. One of the samples on the Dev site uses tkinter and won't run on the stock environment. 😞 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.