Jayme McColgan Posted December 15, 2021 Share Posted December 15, 2021 so i spent some time today building dialog boxes to learn how they work and I'm actually having some fun with it. is it possible to update other fields based on a vs.CreateEditText() field? id like to be able to type something in there and then it update a static text field somewhere else in the dialog box. preferably in real time... i see theres a vs.NotifyPullDownClicked(), which means theres some sort of functionality like that already. also is there a way to set a statictext field ALL THE WAY to the right side of the dialog box? basically above the OK button. Quote Link to comment
MullinRJ Posted December 16, 2021 Share Posted December 16, 2021 Hello @Jayme McColgan, Since the dialog event handler script runs every time you type in your dialog, you can process each character as you type it and update another field at the same time. Use vs.GetItemText() ro read your typed data. In the IF clause for the EditText item use vs.SetControlText() to update a static text field. You can also change EditReal and EditInteger fields in real time with calls to vs.SetEditReal() and vs.SetEditInteger(), respectively. This can be used when two fields are linked like Radius and Diameter of a circle or arc. Changing one updates the other. To your second question, I haven't tried this in the sense you are referring, but you could play with vs.SetEdgeBinding(). I've used it in resizable dialogs but never in a fixed dialog. Also, there is vs.AlignItemEdge(). I've tried to get things to right align with it but haven't done so satisfactorily, and always resorted to other layout methods. HTH, Raymond 1 Quote Link to comment
Jayme McColgan Posted December 18, 2021 Author Share Posted December 18, 2021 On 12/16/2021 at 1:37 AM, MullinRJ said: Hello @Jayme McColgan, Since the dialog event handler script runs every time you type in your dialog, you can process each character as you type it and update another field at the same time. Use vs.GetItemText() ro read your typed data. In the IF clause for the EditText item use vs.SetControlText() to update a static text field. You can also change EditReal and EditInteger fields in real time with calls to vs.SetEditReal() and vs.SetEditInteger(), respectively. This can be used when two fields are linked like Radius and Diameter of a circle or arc. Changing one updates the other. To your second question, I haven't tried this in the sense you are referring, but you could play with vs.SetEdgeBinding(). I've used it in resizable dialogs but never in a fixed dialog. Also, there is vs.AlignItemEdge(). I've tried to get things to right align with it but haven't done so satisfactorily, and always resorted to other layout methods. HTH, Raymond that my friend is exactly what i was looking for! thank you! Quote Link to comment
Jayme McColgan Posted December 18, 2021 Author Share Posted December 18, 2021 (edited) Here is a sample for those looking at this later on in life.... import vs from datetime import datetime def Dialog_Handler(item , data): time = str(datetime.now().strftime("%m/%d/%Y %I:%M:%S %p")).replace(" ", "") ### Get current time and removes spaces wallname = vs.GetItemText(dialog1, 25) ### Get the value of the text field you are updating vs.SetItemText(dialog1, 23, f"{vs.GetFName()}_{wallname}_{time}.png") ### Pushes the new data to a field of your choice Edited December 18, 2021 by Jayme McColgan Quote Link to comment
Jayme McColgan Posted December 18, 2021 Author Share Posted December 18, 2021 @MullinRJ is it possible to create a window to display some 2D shapes that could be updated based on values in the rest of the dialog box? trying to display a visual representation based on the values of the fields in dialog. Quote Link to comment
MullinRJ Posted December 18, 2021 Share Posted December 18, 2021 Hello @Jayme McColgan, I'm not sure. I know you can display Symbols as a dialog control item, so possibly you could create a temporary symbol and update it as you change dialog fields, then update the dialog display to show the change. See vs.CreateSymbolDisplayControl() and vs.CreateSymDispCtrlN(). Also, you can launch another dialog with the push of a button in the first dialog. This I've done before. What you put in the second dialog is wide open, but you must close the second dialog to return control to the first. Good luck, Raymond Quote Link to comment
Jayme McColgan Posted January 7, 2022 Author Share Posted January 7, 2022 using vs.CreateSymbolDisplayControl() and vs.UpdateSymbolDisplayControl() was giving me some unpredictable results when making 2D symbols so i ended up using vs.CreateImageControl2() and vs.UpdateImageControl3() and ended up making my 2d layouts with external libraries. getting much more predictable results! Quote Link to comment
Jiajing Posted January 23, 2022 Share Posted January 23, 2022 On 12/18/2021 at 6:50 AM, MullinRJ said: Hello @Jayme McColgan, I'm not sure. I know you can display Symbols as a dialog control item, so possibly you could create a temporary symbol and update it as you change dialog fields, then update the dialog display to show the change. See vs.CreateSymbolDisplayControl() and vs.CreateSymDispCtrlN(). Also, you can launch another dialog with the push of a button in the first dialog. This I've done before. What you put in the second dialog is wide open, but you must close the second dialog to return control to the first. Good luck, Raymond which function will read the state of a push buttom pressed or not? Tried VS.GetBooleanItem () and couple others , still have not figured it out yet. Thanks Quote Link to comment
Jayme McColgan Posted January 24, 2022 Author Share Posted January 24, 2022 when you press a button it should return the number of the button pressed, you can then process the logic you need to from there. heres an example import vs dialog1 = 0 def start(): global dialog1 dialog1 = vs.CreateLayout('Pixel Map Exporter', False, 'OK', 'Cancel') vs.CreatePushButton(dialog1, 5, "Im a button!") vs.SetFirstLayoutItem(dialog1, 5) result = vs.RunLayoutDialog(dialog1, Dialog_Handler4) return(result) def Dialog_Handler4(item , data): ### Init Setup if item == 12255: pass ### Finished elif item == 1: pass ### Canclled elif item == 2: pass ### Push Buutton Pressed based off the item number you gave it when building the dialog layout elif item == 5: vs.AlrtDialog(str(f"Pushed button! im item #{item}")) return None 1 Quote Link to comment
Jiajing Posted January 24, 2022 Share Posted January 24, 2022 20 hours ago, Jayme McColgan said: when you press a button it should return the number of the button pressed, you can then process the logic you need to from there. heres an example import vs dialog1 = 0 def start(): global dialog1 dialog1 = vs.CreateLayout('Pixel Map Exporter', False, 'OK', 'Cancel') vs.CreatePushButton(dialog1, 5, "Im a button!") vs.SetFirstLayoutItem(dialog1, 5) result = vs.RunLayoutDialog(dialog1, Dialog_Handler4) return(result) def Dialog_Handler4(item , data): ### Init Setup if item == 12255: pass ### Finished elif item == 1: pass ### Canclled elif item == 2: pass ### Push Buutton Pressed based off the item number you gave it when building the dialog layout elif item == 5: vs.AlrtDialog(str(f"Pushed button! im item #{item}")) return None That is good to know, problem solved. Thank you! 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.