Hi everyone.I'm new to wxpython.And i have a little problem.I tried to run the following wxpython app code in IDLE for python25: -
import wx
-
import os
-
import re
-
def z(a):
-
for i in range(1,13):
-
return i*a
-
class Mine(wx.Frame):
-
def __init__(self,parent,id,title,pos,size,):
-
wx.Frame.__init__(self,parent,id,title,pos,size)
-
self.inp=wx.TextCtrl(self,1,'type here')
-
self.buton=wx.Button(self,2,'answer',pos=(50,50))
-
self.b=wx.Button(self,3,'exit',pos=(120,50))
-
wx.EVT_BUTTON(self,2,self.disp)
-
wx.EVT_BUTTON(self,3,self.end)
-
self.Show(True)
-
def disp(self,eve):
-
x=self.inp.GetValue()
-
d=z(x)
-
f=wx.MessageDialog(self,d,wx.OK)
-
f.ShowModal()
-
f.Destroy()
-
def end(self):
-
raise SystemExit()
-
app=wx.PySimpleApp()
-
frame=Mine(None,wx.ID_ANY,'filefinder',pos=wx.DefaultPosition,size=wx.DefaultSize)
-
app.MainLoop()
-
-
And i got the following error:
-
>>>
-
Traceback (most recent call last):
-
File "C:\Python25\mine.py", line 19, in disp
-
f=wx.MessageDialog(self,d,wx.OK)
-
File "C:\Python25\Lib\site-packages\wx-2.8-msw-ansi\wx\_windows.py", line 2898, in __init__
-
_windows_.MessageDialog_swiginit(self,_windows_.new_MessageDialog(*args, **kwargs))
-
TypeError: String or Unicode type required
-
TypeError: end() takes exactly 1 argument (2 given)
-
>>>
Can someone please show me where i have gone wrong?Thanks
5 3860
You pass the wrong number of arguments to the MessageDialog function
Try this: - f = wx.MessageDialog(self, "Message","Title",wx.OK)
bartonc 6,596
Recognized Expert Expert - import wx
-
import os
-
import re
-
-
# Don't hard code ID nubbers! Use NewID()!
-
[wxID_FRAME1, wxID_BUTTON1, wxID_BUTTON2,
-
] = [wx.NewId() for _init_ctrls in range(3)]
-
-
-
class Mine(wx.Frame):
-
def __init__(self, parent, title, pos, size,):
-
wx.Frame.__init__(self, parent, wxID_FRAME1, title, pos, size)
-
self.InputTextCtrl = wx.TextCtrl(self,1,'type here')
-
self.Button1 = wx.Button(self, wxID_BUTTON1, 'answer', pos=(50,50))
-
# Need to Bind() to the event
-
self.Button1.Bind(wx.EVT_BUTTON, self.OnButton1, id=wxID_BUTTON1)
-
-
self.Button2 = wx.Button(self, wxID_BUTTON2, 'exit', pos=(120,50))
-
# Need to Bind() to the event
-
self.Button2.Bind(wx.EVT_BUTTON, self.OnButton2, id=wxID_BUTTON2)
-
-
## wx.EVT_BUTTON(self,2,self.disp)
-
## wx.EVT_BUTTON(self,3,self.end)
-
-
self.Show(True)
-
-
# Use better names for objects and handlers (conventionally start with "On").
-
-
def OnButton1(self, event):
-
x = self.InputTextCtrl.GetValue()
-
## d=z(x)
-
f = wx.MessageDialog(self, "message: x = %s" %x, "title", wx.OK)
-
answer = f.ShowModal()
-
if answer == wx.ID_OK:
-
print "OK"
-
f.Destroy()
-
-
def OnButton2(self, event): # event was left out
-
# let wx cleanup! #
-
self.Destroy()
-
## raise SystemExit()
-
-
-
-
app=wx.PySimpleApp()
-
frame=Mine(None, 'filefinder', pos=wx.DefaultPosition, size=wx.DefaultSize)
-
app.MainLoop()
-
You pass the wrong number of arguments to the MessageDialog function
Try this: - f = wx.MessageDialog(self, "Message","Title",wx.OK)
thank you.
- import wx
-
import os
-
import re
-
-
# Don't hard code ID nubbers! Use NewID()!
-
[wxID_FRAME1, wxID_BUTTON1, wxID_BUTTON2,
-
] = [wx.NewId() for _init_ctrls in range(3)]
-
-
-
class Mine(wx.Frame):
-
def __init__(self, parent, title, pos, size,):
-
wx.Frame.__init__(self, parent, wxID_FRAME1, title, pos, size)
-
self.InputTextCtrl = wx.TextCtrl(self,1,'type here')
-
self.Button1 = wx.Button(self, wxID_BUTTON1, 'answer', pos=(50,50))
-
# Need to Bind() to the event
-
self.Button1.Bind(wx.EVT_BUTTON, self.OnButton1, id=wxID_BUTTON1)
-
-
self.Button2 = wx.Button(self, wxID_BUTTON2, 'exit', pos=(120,50))
-
# Need to Bind() to the event
-
self.Button2.Bind(wx.EVT_BUTTON, self.OnButton2, id=wxID_BUTTON2)
-
-
## wx.EVT_BUTTON(self,2,self.disp)
-
## wx.EVT_BUTTON(self,3,self.end)
-
-
self.Show(True)
-
-
# Use better names for objects and handlers (conventionally start with "On").
-
-
def OnButton1(self, event):
-
x = self.InputTextCtrl.GetValue()
-
## d=z(x)
-
f = wx.MessageDialog(self, "message: x = %s" %x, "title", wx.OK)
-
answer = f.ShowModal()
-
if answer == wx.ID_OK:
-
print "OK"
-
f.Destroy()
-
-
def OnButton2(self, event): # event was left out
-
# let wx cleanup! #
-
self.Destroy()
-
## raise SystemExit()
-
-
-
-
app=wx.PySimpleApp()
-
frame=Mine(None, 'filefinder', pos=wx.DefaultPosition, size=wx.DefaultSize)
-
app.MainLoop()
-
thanks.I actually learned one or two things about wxpython from your message.Thanks again
bartonc 6,596
Recognized Expert Expert
thanks.I actually learned one or two things about wxpython from your message.Thanks again
You are welcome. That's what TheScripts is all about.
Keep posting,
Barton
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: wang xiaoyu |
last post by:
Hello:
i want use activex in wxpython program,but when i use MakeActiveXClass
an exception occurs.
this is my source code dealing the DICOM ocx.I must note that in this
program "hwtxcontrol" is a ocx developed my me use vc6,this ocx works
fine in wxpython.
but you can see i only change this ocx with a new DICOM ocx and set up
eventClass,
|
by: Robert |
last post by:
Hello list,
could somebody point me to a good reference about wxPython event handling?
I have seen many examples but which one is the best. Waht are the advantages
and disadvantages?
Can you also have a short look at the example below and give me some
comments, please?
Example:
|
by: SeeBelow |
last post by:
Do many people think that wxPython should replace Tkinter? Is this
likely to happen?
I ask because I have just started learning Tkinter, and I wonder if I
should abandon it in favor of wxPython.
Mitchell Timin
--
"Many are stubborn in pursuit of the path they have chosen, few in
|
by: fooooo |
last post by:
This is a network app, written in wxPython and the socket module. This
is what I want to happen:
GUI app starts. User clicks a button to 'start' the work of the app.
When start is pressed, a new thread is spawned (threading module) and
this thread starts listening for data on a socket. When someone
connects, a new thread is spawned, It needs to do I/O on that socket
and open a GUI window so the user can communicate with the client...
|
by: Jared Russell |
last post by:
I've recently decided to try my hand at GUI programming with wxPython,
and I've got a couple questions about the general conventions regarding
it.
To mess around with it, I decided to create a small app to check my
Gmail. I want something that will just sit in my system tray checking
for new emails every ten minutes or so. As such, I have no need for an
actual window anywhere. So I'm wondering if I should still use a Frame
or not. ...
| |
by: zxo102 |
last post by:
Hi everyone,
I am using a python socket server to collect data from a socket
client and then control a image location ( wxpython) with the data,
i.e. moving the image around in the wxpython frame.
But the "app.MainLoop()" in wxpython looks like conflicting with
the "while 1:" in socket server. After I commented the
"app.MainLoop()", everything is working except two things:
1. if I click anywhere on the screen with the mouse, the image is...
|
by: defireman |
last post by:
Hi,
Sorry for asking a newbie question, but I am currently using wxPython 2.6, and I don't know how to get the properties of an event object in wxPython when handling events. Is there some sort of documentation that I can use?
for example:
def OnEvent(self, event):
#code here
I would like to see a list of all properties for that event. How would I do this? (I searched for quite a bit, but I can't seem to find good...
|
by: Jimmy |
last post by:
hi, all
I'm having a problem with creating custom events in wxpython.
I have a class A handling some data processing work and another class
B of GUI matter. I need GUI to display information when data in A is
updated.
I know cutom events in wxpython may work. But I found no material
paricularly
helpful :(
|
by: Andrea Gavana |
last post by:
Hi Diez & All,
Do you mind explaining "why" you find it *buttugly*? I am asking just
out of curiosity, obviously. I am so biased towards wxPython that I
won't make any comment on this thread in particular, but I am curious
to know why some people find it "ugly" or "bad" or whatever. It has
its own bugs and missing features, of course, but it is one of the
major GUI player in the arena, together with PyQt and PyGTK.
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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,...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |