[Er...] Posted October 20, 2022 Share Posted October 20, 2022 Hallo! Ich experimentiere gerade mit den Widgets herum. Der Schieberegler hat da gerade meinen Focus. Gibt es hier die Möglichkeit den Reglerwert (oder auch Skalenwert) in einem Textfeld oder ähnlichem anzeigen zu lassen? Soll ungefähr so aussehen: Den Wert, den der Regler ausgibt, kann ich erst im Anschluss an die Ausgabe (also nach OK Button) als print Anweisung ausgeben. (print (REULST.input.value)) Mit freundlichen Grüßen E. Pusch Link to comment Share on other sites More sharing options...
[71...] Posted October 20, 2022 Share Posted October 20, 2022 If you use an extendable break dialog, you can set the value of the textfield to the value of the slider anytime the slider is changed. This script limits the textfield to 2 decimal places, but if you wanted to change that, change the "{0:.2f}" to however many decimal places you want (for example, for 3 decimal places, use "{0:.3f}"). Without formatting the textfield, the dialog behaves strangely from constantly resizing. # -*- coding: utf-8 -*- import gom DIALOG=gom.script.sys.create_user_defined_dialog (content='<dialog>' \ ' <title>Dialog Title</title>' \ ' <style></style>' \ ' <control id="OkCancel"/>' \ ' <position></position>' \ ' <embedding></embedding>' \ ' <sizemode>fixed</sizemode>' \ ' <size height="104" width="298"/>' \ ' <content columns="2" rows="1">' \ ' <widget column="0" rowspan="1" row="0" columnspan="1" type="input::slider">' \ ' <name>slider_input</name>' \ ' <tooltip></tooltip>' \ ' <orientation>horizontal</orientation>' \ ' <value>0</value>' \ ' <minimum>0</minimum>' \ ' <maximum>100</maximum>' \ ' <precision>2</precision>' \ ' <step>1</step>' \ ' <tick_interval>10</tick_interval>' \ ' </widget>' \ ' <widget column="1" rowspan="1" row="0" columnspan="1" type="label">' \ ' <name>slider_value</name>' \ ' <tooltip></tooltip>' \ ' <text>0.00</text>' \ ' <word_wrap>false</word_wrap>' \ ' </widget>' \ ' </content>' \ '</dialog>') def dialog_event_handler (widget): if widget == DIALOG.slider_input: DIALOG.slider_value.text = '{0:.2f}'.format(DIALOG.slider_input.value) DIALOG.handler = dialog_event_handler RESULT=gom.script.sys.show_user_defined_dialog (dialog=DIALOG) Link to comment Share on other sites More sharing options...
[Er...] Posted October 20, 2022 Author Share Posted October 20, 2022 Hallo! Hab es geschafft. Das ganze muss in den: def dialog_event_handler (widget): nun gehts. 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