creating a sub menu in an editor for running another program

Hi,

Now I am going to develop an Editor which has been written by another
people, the editor has some sub menus in it's menu bar( such as :
FILE, EDIT, HELP), and now i am going to add another menu to this
collection, i called the new sub menu as ' Tools menu' , then I tried
to add two other sub menus under this 'Tools menu', each time by
clicking on one of these sub_menu(e.g.verify) some commands should be
called, theses commands are those that i normally used to write in
command prompt while i am trying to run an specific java program.

So, Until now,i have used the same format that they developers of
Editor have been implemented for creating the menus( such as File and
Edit..), however i need to make it special for my own purpose. now i
would like to add the functionality for calling the commands for
running the java program.

do you have any idea about how to tackle with event handling in
wx.python in such a case when we want to call the commands for
running another file in java!

Thank you in advance!
regards.
Massoud.

Bind event handlers for the wx.EVT_MENU events for the items that you add to the menu. In the event handler you can use standard Python library modules and functions to run the commands, such as os.system or subprocess.Popen.

···

On 11/17/09 7:09 AM, MASOUD wrote:

Hi,

Now I am going to develop an Editor which has been written by another
people, the editor has some sub menus in it's menu bar( such as :
FILE, EDIT, HELP), and now i am going to add another menu to this
collection, i called the new sub menu as ' Tools menu' , then I tried
to add two other sub menus under this 'Tools menu', each time by
clicking on one of these sub_menu(e.g.verify) some commands should be
called, theses commands are those that i normally used to write in
command prompt while i am trying to run an specific java program.

So, Until now,i have used the same format that they developers of
Editor have been implemented for creating the menus( such as File and
Edit..), however i need to make it special for my own purpose. now i
would like to add the functionality for calling the commands for
running the java program.

do you have any idea about how to tackle with event handling in
wx.python in such a case when we want to call the commands for
running another file in java!

--
Robin Dunn
Software Craftsman

Hi,
I could use this command for Binding the event like:

self.Bind(wx.EVT_MENU, self.OnVerifyMenu,id=wx.ID_ABORT)
Even i am not sure about if i have wrote the " id=wx.ID_ABORT " correctly or not! but it works, i expect to have something like
" id=wx.ID_VERIFY" instead, but it gave error that " ID_VERIFY " have not been defined or module have not attribute ‘ID_VERIFY’. maybe i should define it a specific way i didn’t know how?

the " OnVerifyMenu " is a method which will be called and hopefully it works, but now
i need to write something within this method in order to call the commands which are
in another file, the commands that will run an external java program.

as you did mention for second problem (i.e. running the commands…):" we would use standard Python
library modules and functions to run the commands" i tried to find one that might
be useful for this purpose, but still have not find something.
Would you please direct me how to reach this goal for running the commands in such a case,
Thank you
Regards
Massoud.

···

On Tue, Nov 17, 2009 at 6:19 PM, Robin Dunn robin@alldunn.com wrote:

On 11/17/09 7:09 AM, MASOUD wrote:

Hi,

Now I am going to develop an Editor which has been written by another

people, the editor has some sub menus in it’s menu bar( such as :

FILE, EDIT, HELP), and now i am going to add another menu to this

collection, i called the new sub menu as ’ Tools menu’ , then I tried

to add two other sub menus under this ‘Tools menu’, each time by

clicking on one of these sub_menu(e.g.verify) some commands should be

called, theses commands are those that i normally used to write in

command prompt while i am trying to run an specific java program.

So, Until now,i have used the same format that they developers of

Editor have been implemented for creating the menus( such as File and

Edit…), however i need to make it special for my own purpose. now i

would like to add the functionality for calling the commands for

running the java program.

do you have any idea about how to tackle with event handling in

wx.python in such a case when we want to call the commands for

running another file in java!

Bind event handlers for the wx.EVT_MENU events for the items that you

add to the menu. In the event handler you can use standard Python

library modules and functions to run the commands, such as os.system or

subprocess.Popen.

Robin Dunn

Software Craftsman

http://wxPython.org

>

[...]

>
> So, Until now,i have used the same format that they developers of
> Editor have been implemented for creating the menus( such as File and
> Edit..), however i need to make it special for my own purpose. now i
> would like to add the functionality for calling the commands for
> running the java program.
>
> do you have any idea about how to tackle with event handling in
> wx.python in such a case when we want to call the commands for
> running another file in java!

Bind event handlers for the wx.EVT_MENU events for the items that you
add to the menu. In the event handler you can use standard Python
library modules and functions to run the commands, such as

os.system

This one will block the main GUI application until the child program exits

subprocess.Popen.

This one could be useful to communicate both process using stdout and
stdin , but possibly `subprocess` module is yet more flexible and
powerful .

Most of the time I use os.spawn?? functions (which don't block the
main application ;o) or `startfile` if I want to perform Windows shell
operations (please read below ;o)

{{{
startfile( path[, operation])

Start a file with its associated application.

When operation is not specified or 'open', this acts like
double-clicking the file in Windows Explorer, or giving the file name
as an argument to the start command from the interactive command
shell: the file is opened with whatever application (if any) its
extension is associated.

When another operation is given, it must be a ``command verb'' that
specifies what should be done with the file. Common verbs documented
by Microsoft are 'print' and 'edit' (to be used on files) as well as
'explore' and 'find' (to be used on directories).

startfile() returns as soon as the associated application is launched.

}}}

Hi,

:slight_smile:

[...]

as you did mention for second problem (i.e. running the commands....):" we
would use standard Python
library modules and functions to run the commands" i tried to find one that
might
be useful for this purpose, but still have not find something.
Would you please direct me how to reach this goal for running the commands
in such a case,

Read above ;o)

···

On Tue, Nov 17, 2009 at 6:19 PM, Robin Dunn <robin@alldunn.com> wrote:

On 11/17/09 7:09 AM, MASOUD wrote:

On Thu, Nov 19, 2009 at 4:01 AM, Massoud Alahdini <massoud.aladini@gmail.com> wrote:

--
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article: