473,804 Members | 4,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.SetTopWind ow(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 2064
i see you inherit from wxApp.
mybe the constructor of that object takes an int value?

Sep 30 '05 #2
"Alex" <li*******@yaho o.se> schrieb im Newsbeitrag
news:11******** **************@ o13g2000cwo.goo glegroups.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.SetTopWind ow(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('myfi le.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*******@yaho o.se> schrieb im Newsbeitrag
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
| Thanks for the replies. It seems that I have three options
| 1. app=MyApp()
| 2. app=MyApp(0)
| 3. app=MyApp('myfi le.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(redir ect=1, filename='some/file/name'): will redirect stdout
to 'filespec'

and instead of 2:

2(b). app=MyApp(redir ect=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('myfi le.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.or g/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.SetTopWind ow(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
1460
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
2904
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 layer, and the business layer is coupled to the data layer. So far so good. Suppose the data layer raises an event, and it passes Me (the sender) as an object, and e (MyEventArgs, a descendent of EventArgs) to the layer above (the business...
2
1202
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 \\VSWebCache\ directory, what is this all about, does vs2005 not create things in the same manner.. thanks,
7
1833
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 member, enum member or nested type through an instance; qualifying expression will not be evaluated.
1
15523
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"/> </configSections> <AdminUIConfig name="Admin" caption="Administrator" captionLC="administrator">
2
2890
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 clicks even if it is greyed out here is the code..am i doing something wrong? is there a way to truly disable the button?
34
5375
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 "<pyshell#10>", line 1, in <module> os.startfile("C:\Documents and Settings\Alex\My Documents\My
1
1147
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 __init__(self, parent):
11
4410
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 does not start: Vista shows MyApp has stopped working Windows is checking for a solution to the problem.. How to fix ?
0
9710
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10329
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10085
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7626
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4304
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3000
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.