473,395 Members | 1,670 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

what does 0 mean in MyApp(0)

I'm looking at a tutorial with the code below

from wxPython.wx import *

class MyApp(wxApp):
def OnInit(self):
frame = wxFrame(NULL, -1, "winApp", size = (800,640))
frame.Show(true)
self.SetTopWindow(frame)
return true

app = MyApp(0)
app.MainLoop()

Everything is explained nicely except the zero parameter in MyApp(0).
Anybody knows what that zero refers to?

Alex

Sep 30 '05 #1
9 2037
i see you inherit from wxApp.
mybe the constructor of that object takes an int value?

Sep 30 '05 #2
"Alex" <li*******@yahoo.se> schrieb im Newsbeitrag
news:11**********************@o13g2000cwo.googlegr oups.com...
| I'm looking at a tutorial with the code below
|
| from wxPython.wx import *
|
| class MyApp(wxApp):
| def OnInit(self):
| frame = wxFrame(NULL, -1, "winApp", size = (800,640))
| frame.Show(true)
| self.SetTopWindow(frame)
| return true
|
| app = MyApp(0)
| app.MainLoop()
|
| Everything is explained nicely except the zero parameter in MyApp(0).
| Anybody knows what that zero refers to?

See:
http://aspn.activestate.com/ASPN/Coo.../Recipe/334620
|

--
Vincent Wehren
| Alex
|
Sep 30 '05 #3
Thanks for the replies. It seems that I have three options
1. app=MyApp()
2. app=MyApp(0)
3. app=MyApp('myfile.txt')

1. In the first case the output stream will be set to stdout/stderr,
which means that errors will be sent to a window which will be closed
when the app crashes.
2. In the second case the output will be set to the command prompt
window, which means that I will be able to catch the errors when my app
crashes.
3. There is also a third alternative which is to set the output to a
file.

Alterbnative 2 is simple and useful, so that's why everybody use that
alternative.

Is that correct?
Alex

Sep 30 '05 #4
"Alex" <li*******@yahoo.se> schrieb im Newsbeitrag
news:11**********************@g44g2000cwa.googlegr oups.com...
| Thanks for the replies. It seems that I have three options
| 1. app=MyApp()
| 2. app=MyApp(0)
| 3. app=MyApp('myfile.txt')
|
| 1. In the first case the output stream will be set to stdout/stderr,
| which means that errors will be sent to a window which will be closed
| when the app crashes.
| 2. In the second case the output will be set to the command prompt
| window, which means that I will be able to catch the errors when my app
| crashes.
| 3. There is also a third alternative which is to set the output to a
| file.
|
| Alterbnative 2 is simple and useful, so that's why everybody use that
| alternative.
|
| Is that correct?

Not entirely:

1. app=MyApp(): stdout/stderr is redirected to its own window, so you're
right here
2. app=MyApp(0): stdout/stderr is not redirected to a window.
Tracebacks will show up at the console. So you're right here to...

But:
3(a). app=MyApp(1, 'some/file/name.txt'):
stdout/stderr is redirected to to the file 'some/file/name.txt').

The arguments you pass to MyApp are named parameters, so for improved
readability you may want to use:

3(b). app=MyApp(redirect=1, filename='some/file/name'): will redirect stdout
to 'filespec'

and instead of 2:

2(b). app=MyApp(redirect=0) # stdout/stderr will stay at the console...

Anyway, if you omit the parameter names, make sure you you position them
correctly, i.e., a filename should only be positioned as /second/ argument.

HTH,
--

Vincent Wehren

| Alex
|
Oct 1 '05 #5
Alex wrote:
Thanks for the replies. It seems that I have three options
1. app=MyApp()
2. app=MyApp(0)
3. app=MyApp('myfile.txt')


I just want to emphasize the part of vincent's reply in which he points
out that using the keyword arguments makes this more readable.

If more examples and actual code would just use the darned "redirect="
keyword argument, you probably wouldn't have had to ask the question.

I remember when I had the same question and spent more time than I
should have had to digging out the answer. Now I try to make sure that
all my wx.Apps are initialized with redirect=False or whatever else I
need to make clear to a reader what I'm doing. For some widely used and
understood methods and constructors, using positional arguments might be
adequate. For ones like wx.App where everyone initializes them but
nobody seems to know what the arguments are doing (sometimes they seem
to be handed down from earlier generations), keyword arguments are a
real blessing.

The world needs more keyword arguments. Use them everywhere! ;-)

-Peter
Oct 2 '05 #6
See the documentation for the __init__() method here

<http://www.wxpython.org/docs/api/wx.App-class.html>

Btw, this is wxPython 2.6, AFAIK.

/Jean Brouwers

Oct 3 '05 #7
Good question, but Y'know, i don't think i'm the only one using a
threaded mail reader. Pls don't hijack others' threads.

David Pratt wrote:
Hi. Is anyone aware of any python based unacceptable language filter
code to scan and detect bad language in text from uploads etc.

Many thanks.
David


Oct 3 '05 #8
Alex wrote:
Alterbnative 2 is simple and useful, so that's why everybody use that
alternative.


Everybody doesn't... Particularly in Windows, it's common that
people make a .pyw-file, and then you don't see any console,
or otherwise they double-click on a .py-file, and if the app
dies with an error, they'll never get a chance to read the
traceback (unless they have a horribly slow computer). Even
worse, it they use command.com as their shell (default on
MS DOS derivates such as Windows ME) copying text from the
shell doesn't work very well, even if the shell didn't close.

Getting all printouts, tracebacks etc into a file is very
convenient during development. In a decent development
environment, you're likely to have a window open where you
do "tail -f" on the file.

Even in production, it's a good thing if it's at least possible
to enable output to a debug file. I've had that as a command
line switch, and asked users to turn that on and mail me the
resulting log file as they reproduced a buggy behaviour.
Oct 4 '05 #9
From Google:

Results 1 - 10 of about 1,340,000,000 for 0. (0.09 seconds)

James

On Friday 30 September 2005 07:15, Alex wrote:
I'm looking at a tutorial with the code below

from wxPython.wx import *

class MyApp(wxApp):
def OnInit(self):
frame = wxFrame(NULL, -1, "winApp", size = (800,640))
frame.Show(true)
self.SetTopWindow(frame)
return true

app = MyApp(0)
app.MainLoop()

Everything is explained nicely except the zero parameter in MyApp(0).
Anybody knows what that zero refers to?

Alex


--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
Oct 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: T-Man | last post by:
Hey All, In VB6, one could the following: VB.Clipboard.SetData frmSubmit.picToolbarIcon.Image or LoadPicture(App.Path & MY_PIC_PATH)
19
by: Charles Law | last post by:
Take a solution with a project hierarchy along the lines of an n-tier system, so that we have a data layer, business layer and presentation layer. The presentation layer is coupled to the business...
2
by: Rob Dob | last post by:
Hi, foe somereason since I have upgraded to VS2005 it is no longer creating a MyApp.dll within the bin directory of my application, aswell it seems to be creating a MyApp.dll within a...
7
by: Brian Shafer | last post by:
I have VS2005 installed on my destop and on my laptop. I created this app with my desktop and i don't get this. Run the IDE on my laptop and this is what I get? Access of shared member, constant...
1
by: Shannon Richards | last post by:
Hello All: I have implemented a custom configuration section in my app.config file as follows: <configSections> <section name="AdminUIConfig" type="TestMgr.UIConfigSection,TestMgr"/>...
2
by: damonjulian | last post by:
hi ,i created 3 buttons such that if button1 is clicked it will disable button2 ,and clicking button3 will restore state of button2 to normal, to my dismay i find that button2 still responds to...
34
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File...
1
by: Alexnb | last post by:
Okay, so I wrote some code of basically what I will be doing, only with exactly what I need for this part of the program but here you go: from Tkinter import* import os class myApp: def...
11
by: Andrus | last post by:
Managed code .NET 3.5 C# WinForms application runs OK from Vista when in local drive. When application is copied to mapped network drive or started from \\othercmp\c\myapp\myapp.exe folder , it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.