Dear all,
I wrote 2 scripts and at a certain point of the first I would like to run the second, and when the second is done, to go back to the first and continue with it.
How can I do it?
I put at the desired point of the

from secondscript impot *

and it works. The second script is something like

open a wx window
do something according to what the user chooses in a dropdown menu
write the result to a txt file

and in the I have to read from the txt file and go on.
Everything goes fine till the end of secondscript, but at that point it doesn't go on with the first.

I hope I manage to explain it in the proper way.

Recommended Answers

All 4 Replies

You should put the action in function of secondscript and call it after importing it. Import runs the main script once, it has no effect if module is already loaded.

The point is that the second script is a wx window with class and def already defined.

Ok, to make it easier for me, I inserted the second script in the first but again, when it finishes, it stacks and it doesn't continue with what is after.

I will try to copy here a selection of the code to understand better my error

import wx
import shutil,sys,os,subprocess
from PIL import Image
import PIL.PngImagePlugin
import PIL.JpegImagePlugin
import PIL.TiffImagePlugin

if not os.path.exists(temp_folder):

application = wx.PySimpleApp()

info0 = wx.MessageDialog(None, 'The script will now drive you through the bla bla bla', '.: Title :.', wx.OK)

progressMax = 10
dialog1 = wx.ProgressDialog(".: title :.", "Progress...", progressMax,style=wx.PD_AUTO_HIDE|wx.PD_ELAPSED_TIME|wx.PD_APP_MODAL)
keepGoing = True
count = 0

bla bla bla

count = count + 1
keepGoing = dialog1.Update(count, "Progress...(7%)")

# here I copied the content of the second script

class choice ( wx.Frame ):
	def __init__( self, parent ):
		wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"Image rotation", pos =wx.DefaultPosition, size = wx.Size( 409,371 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
		self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
		self.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_WINDOW ) )

def OnAccept( self, event ):
		global selected2
		imt2 =
		except KeyError:
		if sel==2:
			do something

class start(wx.App):
    def OnInit(self):
        self.m_frame = choice(None)
        return True

app = start(0)

count = count+1
keepGoing = dialog1.Update(count, "Progress...(8%)")


After I close the window, it doesn't update the dialog1 and it doesn't go on.
Where is the error?

Ok, I found my error.
I gave the same name to the main and the secondary app
app = start(0)

So when I was closing the app, I was killing also the first one. I just rename it to app1
... ...

Thanks anyway for reading ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.