[Ma...] Posted June 14, 2022 Share Posted June 14, 2022 Hi, I don't understand how to use a simple button dialog. I want that, on clicking on it, it open a pdf file. This is the code I used: # -*- coding: utf-8 -*- import gom DIALOG=gom.script.sys.create_user_defined_dialog (content='<dialog>' \ ' <title>Message</title>' \ ' <style></style>' \ ' <control id="OkCancel"/>' \ ' <position>automatic</position>' \ ' <embedding>always_toplevel</embedding>' \ ' <sizemode>automatic</sizemode>' \ ' <size height="110" width="198"/>' \ ' <content columns="1" rows="1">' \ ' <widget row="0" columnspan="1" rowspan="1" type="button::pushbutton" column="0">' \ ' <name>button</name>' \ ' <tooltip></tooltip>' \ ' <text>Button</text>' \ ' <type>push</type>' \ ' <icon_type>none</icon_type>' \ ' <icon_size>icon</icon_size>' \ ' <icon_system_type>ok</icon_system_type>' \ ' <icon_system_size>default</icon_system_size>' \ ' </widget>' \ ' </content>' \ '</dialog>') # # Event handler function called if anything happens inside of the dialog # def dialog_event_handler (widget): pass DIALOG.handler = dialog_event_handler RESULT=gom.script.sys.show_user_defined_dialog (dialog=DIALOG) print (DIALOG.button.value) if DIALOG.button.value==True: os.startfile('S:/QUAREP/Controlli/14000934/00_Report/14000934_200828_BF.pdf') The print (DIALOG.button.value) tell me "false" even if I clicked on it. Why? And is it possible to click only on the button to open the pdf without click on "OK"? Thank you very much. Link to comment Share on other sites More sharing options...
[Ad...] Posted June 15, 2022 Share Posted June 15, 2022 Check this: # -*- coding: utf-8 -*- import gom DIALOG=gom.script.sys.create_user_defined_dialog (content='<dialog>' \ ' <title>Buongiorno</title>' \ ' <style></style>' \ ' <control id="OkCancel"/>' \ ' <position></position>' \ ' <embedding></embedding>' \ ' <sizemode></sizemode>' \ ' <size width="236" height="131"/>' \ ' <content columns="1" rows="1">' \ ' <widget columnspan="1" row="0" type="button::pushbutton" rowspan="1" column="0">' \ ' <name>BTN_OPEN</name>' \ ' <tooltip></tooltip>' \ ' <text>click me</text>' \ ' <type>push</type>' \ ' <icon_type>none</icon_type>' \ ' <icon_size>icon</icon_size>' \ ' <icon_system_type>ok</icon_system_type>' \ ' <icon_system_size>default</icon_system_size>' \ ' </widget>' \ ' </content>' \ '</dialog>') # # Event handler function called if anything happens inside of the dialog # def dialog_event_handler (widget): if widget == DIALOG.BTN_OPEN: print("You clicked me") print("put here Your open file procedure") 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...
[Fr...] Posted June 29, 2022 Share Posted June 29, 2022 There is also a tutorial covering this topic: 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