473,385 Members | 1,863 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,385 software developers and data experts.

wxPython beginners problem

Hello all,

I'm new to python, new as newbies get, so please, don't take wrongly
if this seems like a stupid or overly simple question.

I'm going through examples in a book I have ("Beginning python", by
Hetland Marcus) and I just started doing wxPython examples.

But every sample I try, for example:

import wx
app = wx.App()
win = wx.Frame(None, title="Simple editor")
loadButton = wx.Button(win, label='Open')
saveButton = wx.Button(win, label='Save')
win.Show
app.MainLoop()

closes too fast. After running in python IDLE just the line
=== restart ===
shows up.

How can I keep the window to "stay alive" so I see what I get ?
I'm on a winxp platform using python 2.5.2. if that matters.

Please, any help, constructive advice and ideas are very much
appreciated.

Best regards
Ivan Reborin
Aug 15 '08 #1
6 1549
On Fri, 15 Aug 2008 18:31:16 +0200, Ivan Reborin <ir******@gmail.com>
wrote:
>Hello all,

I'm new to python, new as newbies get, so please, don't take wrongly
if this seems like a stupid or overly simple question.

I'm going through examples in a book I have ("Beginning python", by
Hetland Marcus) and I just started doing wxPython examples.

But every sample I try, for example:

import wx
app = wx.App()
win = wx.Frame(None, title="Simple editor")
loadButton = wx.Button(win, label='Open')
saveButton = wx.Button(win, label='Save')
win.Show
app.MainLoop()

closes too fast. After running in python IDLE just the line
=== restart ===
shows up.

How can I keep the window to "stay alive" so I see what I get ?
I'm on a winxp platform using python 2.5.2. if that matters.

Please, any help, constructive advice and ideas are very much
appreciated.

Best regards
Ivan Reborin
I would just add that actually the process doesn't finish at all. When
I look at the task manager, the process pythonw.exe stays there (about
22mb memory).

Tkinter examples work on the other hand.

And, just another question, if I may while I'm here. The reason that
I'm learning python (apart from finishing my degree :) is that I'm
trying to create a gui for my fortran subroutines:
- back calculating in fortran, very time consuming processes (about
15min per calculation on 2ghz dual core cpu, and I have a lot of
those) so I'm not even thinking of doing it in any other languages,
and a gui in python which will have to draw some x-y diagrams as a
result of the calculation
I choose python because I like the syntax and 'its way of thinking',
and because I've heard it has a good reputation of 'getting along'
with other languages.

Has anyone done something like this ? Is there any differences,
advantages and disadvantages against one or the other gui-s currently
available (i like wxpython and tkinter for now, as I've heard a lot of
good comments about them) ?

I would appreciate your opinion, if you can spare the time. All
comments would be greatly appreciated.

Best regards
Ivan Reborin

p.s. Sorry if my english is not so good. It's not my main language,
actually, not even my secondary language :-( but I'm trying to improve
it.
Aug 15 '08 #2
Ivan Reborin wrote:
win.Show
This line isn't doing anything. It needs to be:
win.Show() # note the parentheses

--
Brian

Aug 15 '08 #3
On Aug 15, 11:31 am, Ivan Reborin <ir******@gmail.comwrote:
Hello all,

I'm new to python, new as newbies get, so please, don't take wrongly
if this seems like a stupid or overly simple question.

I'm going through examples in a book I have ("Beginning python", by
Hetland Marcus) and I just started doing wxPython examples.

But every sample I try, for example:

import wx
app = wx.App()
win = wx.Frame(None, title="Simple editor")
loadButton = wx.Button(win, label='Open')
saveButton = wx.Button(win, label='Save')
win.Show
app.MainLoop()
There are a couple of things you're missing. Here is the fix:

import wx

# First of all, I'd recommend you to pass False as
# the 'redirect' parameter, so that any errors appear
# on the console
app = wx.App(redirect=False)

win = wx.Frame(None, title="Simple editor")
loadButton = wx.Button(win, label='Open')
saveButton = wx.Button(win, label='Save')

# Now you need to set the frame as the top-level
# window

app.SetTopWindow(frame)

# In the line
#
# win.Show
#
# Python recognizes this as a method, but you're
# not calling it, so its value is discarded. It's
# a meaningless, albeit legal statement.

win.Show()

# Now, let the fun begin
app.MainLoop()

# Sebastian

Aug 15 '08 #4
On Aug 15, 11:31*am, Ivan Reborin <irebo...@gmail.comwrote:
Hello all,

I'm new to python, new as newbies get, so please, don't take wrongly
if this seems like a stupid or overly simple question.

I'm going through examples in a book I have ("Beginning python", by
Hetland Marcus) and I just started doing wxPython examples.

But every sample I try, for example:

import wx
app = wx.App()
win = wx.Frame(None, title="Simple editor")
loadButton = wx.Button(win, label='Open')
saveButton = wx.Button(win, label='Save')
win.Show
app.MainLoop()

closes too fast. After running in python IDLE just the line
=== restart ===
shows up.

How can I keep the window to "stay alive" so I see what I get ?
I'm on a winxp platform using python 2.5.2. if that matters.

Please, any help, constructive advice and ideas are very much
appreciated.

Best regards
Ivan Reborin
See what Brian said about your issue. As for whether or not this
toolkit is for you, that's a subjective question. Try them both and
see which one suits you. I like wx better, but I needed its widgets
for what I was doing and Tkinter didn't seem to have what I needed at
the time.

Anyway, wxPython has an excellent user's group, where you can learn
lots and the group is nice to new people too!

http://wxpython.org/maillist.php

Mike
Aug 15 '08 #5
In article <ad********************************@4ax.com>,
Ivan Reborin <ir******@gmail.comwrote:
Hello all,

I'm new to python, new as newbies get, so please, don't take wrongly
if this seems like a stupid or overly simple question.

I'm going through examples in a book I have ("Beginning python", by
Hetland Marcus) and I just started doing wxPython examples.

But every sample I try, for example:

import wx
app = wx.App()
win = wx.Frame(None, title="Simple editor")
loadButton = wx.Button(win, label='Open')
saveButton = wx.Button(win, label='Save')
win.Show
app.MainLoop()
As mentioned, it should be win.Show().

If that doesn't help, try saving it to something.py
and executing that instead of running it inside IDLE.
closes too fast. After running in python IDLE just the line
=== restart ===
shows up.

How can I keep the window to "stay alive" so I see what I get ?
I'm on a winxp platform using python 2.5.2. if that matters.

Please, any help, constructive advice and ideas are very much
appreciated.

Best regards
Ivan Reborin
--
David C. Ullrich
Aug 16 '08 #6
On Fri, 15 Aug 2008 17:48:39 +0000 (UTC), Brian Victor
<ho*********@brianhv.orgwrote:
>Ivan Reborin wrote:
>win.Show

This line isn't doing anything. It needs to be:
win.Show() # note the parentheses
Yes, that was the problem. I must've been tired while writing it, for
I haven't noticed it after several repetitions.
Thank you (and everyone else on their useful comments and
suggestions).

Best regards
Ivan
Aug 16 '08 #7

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

Similar topics

5
by: Daniel Ehrenberg | last post by:
I'm trying to learn wxPython, but I can't seem to find much documentation. The wxPython website says that all advanced (and even some basic) documentation for wxPython is only available in C++...
1
by: timothy.williams | last post by:
I'm trying to install wxPython 2.5.3.1 using Python 2.3.2 on a Fedora 2 machine. I have python in a non-standard place, but I'm using --prefix with the configure script to point to where I have...
1
by: James Stroud | last post by:
Hello All, I will soon have an excuse to install a new operating system on my computer. I would like to know exactly what operating system I should have so that I can get wxPython going....
0
by: Robin Dunn | last post by:
Announcing ---------- The 2.6.3.0 release of wxPython is now available for download at http://wxpython.org/download.php. There have been many enhancements and fixes implemented in this...
6
by: Robin Dunn | last post by:
Announcing ---------- The 2.6.3.2 release of wxPython is now available for download at http://wxpython.org/download.php. This is a mostly bug fix release and takes care of several "unfortunate...
0
by: Robin Dunn | last post by:
Announcing ---------- The 2.6.3.2 release of wxPython is now available for download at http://wxpython.org/download.php. This is a mostly bug fix release and takes care of several "unfortunate...
5
by: John Salerno | last post by:
Sorry for posting here again. I tried the wxPython list but I'm not sure I'm sending to the right email address! It bounced back. Besides, your opinions are too good to pass up. ;) My question...
2
by: Marco | last post by:
Hi, I have a problem to install wxPython on my MacBook (Pythonversion 2.5). If would install the wxPython (python setup.py install), then I got this error: Traceback (most recent call last):...
8
by: Sean DiZazzo | last post by:
Is there something special you have to do to get a wxPython app to run remotely under xwindows? My Tkinter apps always automatically work that way, so I was surprised to even be confronted with...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.