<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.dabo.leafe.com/index.php?action=history&amp;feed=atom&amp;title=HowToReturnAValueFromAModalForm</id>
	<title>HowToReturnAValueFromAModalForm - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.dabo.leafe.com/index.php?action=history&amp;feed=atom&amp;title=HowToReturnAValueFromAModalForm"/>
	<link rel="alternate" type="text/html" href="https://wiki.dabo.leafe.com/index.php?title=HowToReturnAValueFromAModalForm&amp;action=history"/>
	<updated>2026-11-21T12:02:34Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.12</generator>
	<entry>
		<id>https://wiki.dabo.leafe.com/index.php?title=HowToReturnAValueFromAModalForm&amp;diff=4170&amp;oldid=prev</id>
		<title>Ed: Created page with &quot;Normally, you make the value an attribute of the form, or, in the alternative, create a method that returns the value(s) you need. Then when the form is closed, instead of rel...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.dabo.leafe.com/index.php?title=HowToReturnAValueFromAModalForm&amp;diff=4170&amp;oldid=prev"/>
		<updated>2020-05-15T18:48:44Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Normally, you make the value an attribute of the form, or, in the alternative, create a method that returns the value(s) you need. Then when the form is closed, instead of rel...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Normally, you make the value an attribute of the form, or, in the alternative, create a method that returns the value(s) you need. Then when the form is closed, instead of releasing it, simply hide() it. This will end the modal state, and allow processing to continue from the point at which the form was originally shown. You then query the form for the desired values, and when you have them, release the form.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&amp;lt;span style=&amp;quot;color: red&amp;#039;;&amp;quot;&amp;gt;NOTE&amp;lt;/span&amp;gt;&amp;#039;&amp;#039;&amp;#039;: - as of Feb. 2007, &amp;#039;&amp;#039;&amp;#039;wxPython&amp;#039;&amp;#039;&amp;#039; still does not support modal forms. Please use dialog classes if you need modal behavior.&lt;br /&gt;
&lt;br /&gt;
If you are using the [[dOkCancelDialog]] class as your base, it has a property called &amp;lt;code&amp;gt;Accepted&amp;lt;/code&amp;gt; that is set to &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; if they click &amp;lt;code&amp;gt;OK&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; if they click &amp;lt;code&amp;gt;Cancel&amp;lt;/code&amp;gt;. That way you know whether to process the results or not. It is generally easier to work with dialogs when you need modal states, as wxPython doesn&amp;#039;t handle modal forms very well.&lt;br /&gt;
&lt;br /&gt;
== Examples: ==&lt;br /&gt;
&lt;br /&gt;
==== Dialog: ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
class ExampleDialog(dabo.ui.dOkCancelDialog):&lt;br /&gt;
   def addControls(self):&lt;br /&gt;
      # add your controls here&lt;br /&gt;
&lt;br /&gt;
dlg = ExampleDialog()&lt;br /&gt;
dlg.show()&lt;br /&gt;
if dlg.Accepted:&lt;br /&gt;
   self.doSomethingWithNames(dlg.firstname, dlg.lastname)&lt;br /&gt;
dlg.release()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Modal Form: ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
frm = dabo.ui.dForm(None)&lt;br /&gt;
frm.addObject(whatever...)&lt;br /&gt;
# NOTE: this doesn&amp;#039;t show modally (yet)&lt;br /&gt;
frm.showModal()&lt;br /&gt;
firstname, lastname = frm.getNames()&lt;br /&gt;
if firstname is not None:&lt;br /&gt;
   self.doSomethingWithNames(firstname, lastname)&lt;br /&gt;
frm.release()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ed</name></author>
	</entry>
</feed>