[Ti...] Posted June 11, 2023 Share Posted June 11, 2023 I want to test something where after a scan the part number of the scan gets automatically placed as the part number for the report. Currently we type this in. Is there a way I can input a variable into the ?????????? field below: part_number = '111222' # User interface for entering in parts to scan DIALOG=gom.script.sys.create_user_defined_dialog (content='<dialog>' \ ' <title>Part Number</title>' \ ' <style></style>' \ ' <control id="OkCancel"/>' \ ' <position></position>' \ ' <embedding></embedding>' \ ' <sizemode></sizemode>' \ ' <size width="247" height="361"/>' \ ' <content rows="9" columns="2">' \ ' <widget rowspan="1" column="0" type="label" columnspan="1" row="0">' \ ' <name>label_7</name>' \ ' <tooltip></tooltip>' \ ' <text>Enter Part #</text>' \ ' <word_wrap>false</word_wrap>' \ ' </widget>' \ ' <widget rowspan="1" column="1" type="input::string" columnspan="1" row="0">' \ ' <name>PN</name>' \ ' <tooltip></tooltip>' \ ' <value>??????????</value>' \ Thanks Link to comment Share on other sites More sharing options...
[Mi...] Posted June 12, 2023 Share Posted June 12, 2023 You can replace the last line of your script with: ' <value>%d</value>' % part_number \ The Python documentation has additional information on this: 7. Input and Output — Python 3.11.4 documentation Link to comment Share on other sites More sharing options...
[Ti...] Posted June 12, 2023 Author Share Posted June 12, 2023 Please sign in to view this username. Thanks, I tried looking this up, but really didn't know what to ask for when searching. The html was throwing me off. I'll give this a shot. I also thought I would have to pass the variable/argument into the function call, no? Link to comment Share on other sites More sharing options...
[Mi...] Posted June 13, 2023 Share Posted June 13, 2023 Are you trying to get the part number out of the dialog after the user has chosen a value from an input widget? In this case I would suggest to have a look at the following article about user defined dialogs. There are multiple ways to do this, maybe you will need to write a handler function to access values from the dialog. Scripting - User-Defined Dialogs - GOM FAQ - GOM Connect Link to comment Share on other sites More sharing options...
[Ti...] Posted June 17, 2023 Author Share Posted June 17, 2023 Please sign in to view this username. I export the part number of the last scan and I am trying to pre-populate the report scan so operators have less data to enter. Below, you can see I hard coded the last part scanned as ‘111222’. When the user runs this script they get this dialog and they have to enter in up to 15 numbers. 99% of the time they run the same part number as the last scan so I’d like to pre-populate it. It looks like the html is overriding your method of getting this variable in to the dialog. Also, the dialog is a function within the import GOM module isn’t it, so that would need to get passed the argument ‘part_number’ wouldn’t it? Link to comment Share on other sites More sharing options...
[Ti...] Posted June 18, 2023 Author Share Posted June 18, 2023 A coworker solve this...below inputs the variable into the html. Not sure why it doesn't need to get this argument passed into the function call, but I am a beginner novice still with python. part_number = '111222' # User interface for entering in parts to scan DIALOG=gom.script.sys.create_user_defined_dialog (content='<dialog>' \ ' <title>Part Number</title>' \ ' <style></style>' \ ' <control id="OkCancel"/>' \ ' <position></position>' \ ' <embedding></embedding>' \ ' <sizemode></sizemode>' \ ' <size width="247" height="361"/>' \ ' <content rows="9" columns="2">' \ ' <widget rowspan="1" column="0" type="label" columnspan="1" row="0">' \ ' <name>label_7</name>' \ ' <tooltip></tooltip>' \ ' <text>Enter Part #</text>' \ ' <word_wrap>false</word_wrap>' \ ' </widget>' \ ' <widget rowspan="1" column="1" type="input::string" columnspan="1" row="0">' \ ' <name>PN</name>' \ ' <tooltip></tooltip>' \ ' <value>\' + part_number + '</value>' \ Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in