Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion problems getting os.system and wxmenu to read options from a file and then execute
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
eric dexter  
View profile  
 More options Jun 27 2010, 11:45 pm
Newsgroups: comp.lang.python
From: eric dexter <irc.dex...@gmail.com>
Date: Sun, 27 Jun 2010 20:45:10 -0700 (PDT)
Local: Sun, Jun 27 2010 11:45 pm
Subject: Re: problems getting os.system and wxmenu to read options from a file and then execute
On Jun 27, 8:18 pm, MRAB <pyt...@mrabarnett.plus.com> wrote:

> eric dexter wrote:
> > On Jun 27, 5:56 pm, MRAB <pyt...@mrabarnett.plus.com> wrote:
> >> Eric_Dex...@msn.com wrote:
> >>> I managed to get the program running and the menu options are
> >>> appearing on the list but the programs are not running.  I suspect it
> >>> is my onexecutemethod
> >> [snip]

> >>>         #add execute files from the text file list
> >>>         idtool = 400
> >>>         for e in menuoptions:
> >>>             wx.EVT_MENU(self, idtool, self.OnExecute(idtool, e))
> >> This calls the OnExecute method and then passes its result to
> >> wx.EVT_MENU. If, for example, OnExecute is returning None, then that's
> >> what is being passed into wx.EVT_MENU.

> >> What you should actually be doing is passing a function which can be
> >> called when the menu item is clicked, something like this:

> >>              wx.EVT_MENU(self, idtool, lambda idtool=idtool, e=e:
> >> self.OnExecute(idtool, e))

> >>>             idtool += 1
> >>>             ##print e
> >> [snip]
> >>>     def OnExecute(self,tool,e):
> >>>         print tool
> >>>         os.system(e)
> >>>         #print tool
> >>>         # Get rid of the dialog to keep things tidy
> >> [snip]

> > wx.EVT_MENU(self, idtool, self.OnExecute(idtool, e))

> > I changed it to this and it seems to be calling self.OnExecute befour
> > the editor comes up and then after the editor is up it doesn't respond
> > to anything.

>  >
> That is what the line was in your original post, and I explained the
> change you needed to do.

>  > I got rid off all the spaces but one in the text file (I> supose I need to use the strip method in real like though)..  I was
> > able to get an infinite loop by calling the editor as one of the
> > options and then it keeps calling itself.  It may be another problem
> > or perhaps I didn't grasp the answer.

>  >
> I've noticed that you're opening the menu file before the class
> statement but reading from it in the __init__ method. It would be better
> if you opened the file in the __init__ method itself. You can split a
> line on whitespace with:

>      t = line.split()

> It won't then matter how many spaces or tabs are between the fields.

I think it may and that is why there is a strip method.  all 4 files
want to execute befour the editor comes up so there is a problem of
some sort that isn't adressed by that but it probily would be nice if
I coded it that way.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.