Jump to content

Info dialog closes unexpectedly


---
 Share

Recommended Posts

Hi, 

I am messing around with the info dialog widget, as it enables the script to continue in the background, which sounds interesting. 

However, I am experiencing that as soon as I have run: 

gom.script.sys.open_user_defined_dialog(dialog=widget)

- the script will close the dialog-widget afterwards, when it jumps to the next line of code, without the function gom.script.sys.close_user_defined_dialog() being called. Are you supposed to set a state to the dialog so that it remains open? Am I forgetting something?

Full code below: 

import gom

class Dialog: 
	
	def __init__(self): 
		self.START_DIALOG=gom.script.sys.create_user_defined_dialog (content=content)
		self.START_DIALOG.handler = self.dialog_event_handler(widget=self.START_DIALOG) 
		self.open(self.START_DIALOG)
		
	def dialog_event_handler(self, widget):
		pass
	
	def open(self, widget): 
		gom.script.sys.open_user_defined_dialog(dialog=widget)
			
	def close(self, widget):
		gom.script.sys.close_user_defined_dialog (dialog=widget)

if __name__ == '__main__': 
	run = Dialog()
	

Thanks, 

Emil. 

Link to comment
Share on other sites

Do you actually have any code that is executing? When I tried this, I inserted a "delay_script" after the "run = Dialog()" line, and it remained open for the duration of the delay

Although I think this might be an overcomplicated way of doing this info dialog, it can be done easier (I inserted a delay where your code will go). The important part is to have a "gom.script.sys.open_user_defined_dialog" before your code to be executed, and a "gom.script.sys.close_user_defined_dialog" at the end of your code

 

# -*- 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></sizemode>' \
' <size height="142" width="198"/>' \
' <content rows="1" columns="1">' \
'  <widget row="0" rowspan="1" type="label" column="0" columnspan="1">' \
'   <name>label</name>' \
'   <tooltip></tooltip>' \
'   <text>hello world!</text>' \
'   <word_wrap>false</word_wrap>' \
'  </widget>' \
' </content>' \
'</dialog>')

#
#dialog opens and is displayed to the user
#
gom.script.sys.open_user_defined_dialog (dialog=DIALOG)


#
# your code starts here
#
gom.script.sys.delay_script (time=2)
#
# your code ends here
#


#
#dialog closes
#
gom.script.sys.close_user_defined_dialog (dialog=DIALOG)

 

Link to comment
Share on other sites

 Share

×
×
  • Create New...