Hi <br><br>No if I run that code - and I am presented with the MainForm form, when I hit the close button on the top of the form - the application is still running in the background. If I try to close the Log_In form programatically, instead of just hiding it, the whole application closes - without letting me go the MainForm form. <br>
So not to sure how to accomplish this - have spent quite a lot of time on the net trying to get the answer - to no avail. Hope that you&#39;ll be able to resolve this issue for me, as I&#39;m stuck in my project, until I can get this right!<br>
<br>Regards<br><br>Anthony<br><br><div style="margin: 0pt;" name="sig_d755fb7dfb"></div><div class="gmail_quote">On Mon, Jun 14, 2010 at 12:03 PM, Michael Foord <span dir="ltr">&lt;<a href="mailto:fuzzyman@voidspace.org.uk">fuzzyman@voidspace.org.uk</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">


  
  

<div bgcolor="#ffffff" text="#000000"><div class="im">
On 14/06/2010 08:53, Anthony wrote:
<blockquote type="cite">Hi Michael <br>
  <br>
Sorry for the late reply - only got back to my email this morning :-)<br>
I tried to close the form - but when doing that - the whole application
closed - I think this was mainly due to the fact that that form was
seen as the &quot;main form&quot;?? </blockquote>
<br></div>
I thought closing the whole application was what you wanted to do? In
your original email you asked:<div class="im"><br>
<br>
    The program runs fine - except that when I close
the MainForm form - the application is still running. I know it&#39;s
because a login.py object is hidden. What I&#39;m asking is how construct
the programming in such a way that this does not happen - that when the
second form is closed - the application closes;<br>
<br></div>
So now the application closing is a problem?<br>
<br>
All the best,<br><font color="#888888">
<br>
Michael</font><div><div></div><div class="h5"><br>
<br>
<br>
<blockquote type="cite">Sorry about this real noob question - but I&#39;m just
starting out - and this is very frustrating for me, I know it&#39;s
probably something stupid that I&#39;m doing! Let me post my code here -
and see what you can see!<br>
Here is my code<br>
  <br>
Program.py<br>
import clr<br>
clr.AddReference(&#39;System.Windows.Forms&#39;)<br>
clr.AddReference(&#39;System.Drawing&#39;)<br>
#clr.AddReference(&#39;System.Data.SQLite&#39;)<br>
#clr.AddReference(&#39;Ironpython&#39;)<br>
#clr.AddReference(&#39;System.Security.Policy&#39;)<br>
from System.Security.Policy import Hash<br>
from System.Data.SQLite import *<br>
import sys<br>
sys.path.append(&quot;C:\Python26\Lib&quot;)<br>
sys.path.append(&quot;C:\Program Files\IronPython 2.6\Lib&quot;)<br>
from System.Windows.Forms import Application<br>
  <br>
import Log_In<br>
import MainForm<br>
import sqlite3<br>
  <br>
  <br>
Application.EnableVisualStyles()<br>
#form = MainForm.Log_In()<br>
form = Log_In.Log_In()<br>
Application.Run(form)<br>
  <br>
  <br>
**********************************************<br>
  <br>
  <br>
  <br>
Log_In.py<br>
  <br>
  <br>
import System.Drawing<br>
import System.Windows.Forms<br>
  <br>
from System.Drawing import *<br>
from System.Windows.Forms import *<br>
import MainForm<br>
#import sqlite3<br>
  <br>
#import System.Data.SQLite<br>
  <br>
  <br>
  <br>
class Log_In(Form):<br>
    def __init__(self):<br>
        self.InitializeComponent()<br>
    <br>
    def InitializeComponent(self):<br>
        self._label1 = System.Windows.Forms.Label()<br>
        self._txt_Login = System.Windows.Forms.TextBox()<br>
        self._label2 = System.Windows.Forms.Label()<br>
        self._txt_pwd = System.Windows.Forms.MaskedTextBox()<br>
        self._bt_login = System.Windows.Forms.Button()<br>
        self._bt_cancel = System.Windows.Forms.Button()<br>
        self.SuspendLayout()<br>
        # <br>
        # label1<br>
        # <br>
        self._label1.Location = System.Drawing.Point(40, 116)<br>
        self._label1.Name = &quot;label1&quot;<br>
        self._label1.Size = System.Drawing.Size(107, 25)<br>
        self._label1.TabIndex = 0<br>
        self._label1.Text = &quot;Login Name&quot;<br>
        self._label1.TextAlign =
System.Drawing.ContentAlignment.MiddleCenter<br>
        # <br>
        # txt_Login<br>
        # <br>
        self._txt_Login.Location = System.Drawing.Point(173, 121)<br>
        self._txt_Login.Name = &quot;txt_Login&quot;<br>
        self._txt_Login.Size = System.Drawing.Size(160, 20)<br>
        self._txt_Login.TabIndex = 1<br>
        self._txt_Login.Text = &quot;cc&quot;<br>
        self._txt_Login.TextChanged += self.Txt_LoginTextChanged<br>
        # <br>
        # label2<br>
        # <br>
        self._label2.Location = System.Drawing.Point(40, 174)<br>
        self._label2.Name = &quot;label2&quot;<br>
        self._label2.Size = System.Drawing.Size(107, 22)<br>
        self._label2.TabIndex = 2<br>
        self._label2.Text = &quot;Password&quot;<br>
        self._label2.TextAlign =
System.Drawing.ContentAlignment.MiddleCenter<br>
        # <br>
        # txt_pwd<br>
        # <br>
        self._txt_pwd.Location = System.Drawing.Point(173, 174)<br>
        self._txt_pwd.Name = &quot;txt_pwd&quot;<br>
        self._txt_pwd.PasswordChar = &quot;*&quot;<br>
        self._txt_pwd.Size = System.Drawing.Size(160, 20)<br>
        self._txt_pwd.TabIndex = 3<br>
        # <br>
        # bt_login<br>
        # <br>
        self._bt_login.Location = System.Drawing.Point(85, 252)<br>
        self._bt_login.Name = &quot;bt_login&quot;<br>
        self._bt_login.Size = System.Drawing.Size(164, 41)<br>
        self._bt_login.TabIndex = 4<br>
        self._bt_login.Text = &quot;Login&quot;<br>
        self._bt_login.UseVisualStyleBackColor = True<br>
        self._bt_login.Click += self.Bt_loginClick<br>
        # <br>
        # bt_cancel<br>
        # <br>
        self._bt_cancel.Location = System.Drawing.Point(346, 255)<br>
        self._bt_cancel.Name = &quot;bt_cancel&quot;<br>
        self._bt_cancel.Size = System.Drawing.Size(165, 37)<br>
        self._bt_cancel.TabIndex = 5<br>
        self._bt_cancel.Text = &quot;Cancel&quot;<br>
        self._bt_cancel.UseVisualStyleBackColor = True<br>
        self._bt_cancel.Click += self.Bt_cancelClick<br>
        # <br>
        # Log_In<br>
        # <br>
        self.AcceptButton = self._bt_login<br>
        self.ClientSize = System.Drawing.Size(649, 401)<br>
        self.Controls.Add(self._bt_cancel)<br>
        self.Controls.Add(self._bt_login)<br>
        self.Controls.Add(self._txt_pwd)<br>
        self.Controls.Add(self._label2)<br>
        self.Controls.Add(self._txt_Login)<br>
        self.Controls.Add(self._label1)<br>
        self.Name = &quot;Log_In&quot;<br>
        self.Text = &quot;&quot;&quot; &lt;summary&gt;<br>
     Description of Class1.<br>
     &lt;/summary&gt;<br>
    &quot;&quot;&quot;<br>
        self.ResumeLayout(False)<br>
        self.PerformLayout()<br>
  <br>
  <br>
    def Bt_loginClick(self, sender, e):<br>
        MsgBox = System.Windows.Forms.MessageBox<br>
        <br>
        if self._txt_Login.Text == &quot;test&quot; and self._txt_pwd.Text ==
&quot;test&quot;:<br>
            #MsgBox.Show(&quot;Welcome to the Wonderful World of Visual
Basic&quot;)<br>
            MF = mf()<br>
            MF.Show()<br>
            MF.Activate()<br>
            MF.Select()<br>
            self.Hide()<br>
            #MF.SetTopLevel = &quot;True&quot;<br>
        else:<br>
            MsgBox.Show(&quot;UserName Or Password Incorrect&quot;)<br>
            <br>
        #pass<br>
  <br>
    def Txt_LoginTextChanged(self, sender, e):<br>
        pass<br>
  <br>
    def Bt_cancelClick(self, sender, e):<br>
        self.Close()<br>
  <br>
class mf(MainForm.MainForm):<br>
    pass<br>
#conn = sqlite3.connect(r&quot;c:\tester.sqlite&quot;)<br>
#c = conn.cursor()<br>
#c.execute(&quot;&quot;&quot;insert into test values (Null,&#39;Bozz11&#39;,&#39;Crazyman11&#39;)&quot;&quot;&quot;)<br>
#conn.commit()<br>
#c.close()<br>
  <br>
  <br>
  <br>
class encrypt_a(object):<br>
    <br>
    def EncryptString(self, strEncrypted):<br>
        b = System.Text.ASCIIEncoding.ASCII.GetBytes(strEncrypted)<br>
        encryptedConnectionString = System.Convert.ToBase64String(b)<br>
        return encryptedConnectionString<br>
  <br>
    def __init__(self):<br>
        pass<br>
    <br>
class decrypt_a(object):<br>
    <br>
    def DecryptString(self, encrString):<br>
        b = System.Convert.FromBase64String(encrString)<br>
        decryptedConnectionString =
System.Text.ASCIIEncoding.ASCII.GetString(b)<br>
        return decryptedConnectionString<br>
  <br>
#ac = &quot;Anthony&quot;<br>
#cc = encrypt_a().EncryptString(ac)<br>
#cca = Log_In()._txt_Login.Text = &quot;tett<br>
  <br>
  <br>
  <br>
*******************************************************************************<br>
  <br>
MainForm.py<br>
  <br>
  <br>
import System.Drawing<br>
import System.Windows.Forms<br>
  <br>
from System.Drawing import *<br>
from System.Windows.Forms import *<br>
import Log_In<br>
  <br>
  <br>
  <br>
  <br>
class MainForm(Form):<br>
    def __init__(self):<br>
        #pass<br>
  <br>
        self.InitializeComponent()<br>
    <br>
        <br>
    def InitializeComponent(self):<br>
        #xx.Close()<br>
        self._textBox1 = System.Windows.Forms.TextBox()<br>
        self.SuspendLayout()<br>
        # <br>
        # textBox1<br>
        # <br>
        self._textBox1.Location = System.Drawing.Point(129, 101)<br>
        self._textBox1.Name = &quot;textBox1&quot;<br>
        self._textBox1.Size = System.Drawing.Size(231, 20)<br>
        self._textBox1.TabIndex = 0<br>
        # <br>
        # MainForm<br>
        # <br>
        self.ClientSize = System.Drawing.Size(503, 356)<br>
        self.Controls.Add(self._textBox1)<br>
        self.Name = &quot;MainForm&quot;<br>
        self.Text = &quot;HS&amp;E&quot;<br>
        self.Load += self.MainFormLoad<br>
        self.ResumeLayout(False)<br>
        #self.PerformLayout()<br>
        #self.OnFormClosing(Application.Exit())<br>
        <br>
        <br>
        <br>
        <br>
        <br>
  <br>
    def MainFormLoad(self, sender, e):<br>
        pass<br>
  <br>
  <br>
  <br>
  <br>
Hope you can help out with this!<br>
  <br>
  <br>
  <br>
  <br>
  <br>
  <br>
  <br>
  <br>
  <br>
  
  <div class="gmail_quote">On Sun, Jun 13, 2010 at 1:52 AM, Michael
Foord <span dir="ltr">&lt;<a href="mailto:fuzzyman@voidspace.org.uk" target="_blank">fuzzyman@voidspace.org.uk</a>&gt;</span>
wrote:<br>
  <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
    <div text="#000000" bgcolor="#ffffff">
    <div>
    <div>On 12/06/2010 16:22, Anthony wrote:
    <blockquote type="cite">Hi All<br>
      <br>
Just to state - I&#39;m a real newbie to programming &amp; ironpython<br>
I have an application that has 2 forms. The application gets started in
the progam.py module(btw i&#39;m using #develop). This calls another module
- login.py. This is a login form which validates user names/passwords.
Once this is validated I <u>hide</u> the form and call the second
module - MainForm.py. The program runs fine - except that when I close
the MainForm form - the application is still running. I know it&#39;s
because a login.py object is hidden. What I&#39;m asking is how construct
the programming in such a way that this does not happen - that when the
second form is closed - the application closes; or is there a better
way to do this?<br>
    </blockquote>
    <br>
    </div>
    </div>
How about closing the login form instead of hiding it? Another way is
to handle the Closing event on your main form and close the login form
then. You can also call Application.Exit()  (I believe - this is off
the top of my head so you should check) to exit the GUI event loop.<br>
    <br>
All the best,<br>
    <br>
Michael<br>
    <br>
    <blockquote type="cite"><br>
Regards<br>
      <br>
Anthony<br>
      <pre><fieldset></fieldset>
_______________________________________________
Users mailing list
<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a>
  </pre>
    </blockquote>
    <br>
    <br>
    <pre cols="72">-- 
<a href="http://www.ironpythoninaction.com/" target="_blank">http://www.ironpythoninaction.com/</a>
<a href="http://www.voidspace.org.uk/blog" target="_blank">http://www.voidspace.org.uk/blog</a>

READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.

    </pre>
    </div>
  </blockquote>
  </div>
  <br>
</blockquote>
<br>
<br>
<pre cols="72">-- 
<a href="http://www.ironpythoninaction.com/" target="_blank">http://www.ironpythoninaction.com/</a>
<a href="http://www.voidspace.org.uk/blog" target="_blank">http://www.voidspace.org.uk/blog</a>

READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.

</pre>
</div></div></div>

</blockquote></div><br>