473,396 Members | 2,109 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,396 software developers and data experts.

wxpython: bringing up a dialog box with a button

I'm not exactly sure how to call the method ShowModal(). This is what I
have so far:

--------------

import wx
class InputForm(wx.Frame):

def __init__(self, parent=None, id=wx.ID_ANY, title=''):
wx.Frame.__init__(self, parent, id, title)
panel = wx.Panel(self)

btnModal = wx.Button(panel, -1, 'Modal')
dialog = wx.Dialog(self, -1, 'Modal Dialog')
self.Bind(wx.EVT_BUTTON, dialog.ShowModal, btnModal)

class MyApp(wx.App):

def OnInit(self):
frame = InputForm(title='Data Entry Form')
self.SetTopWindow(frame)
frame.Show()
return True
app = MyApp(redirect=False)
app.MainLoop()

---------------------

and this is what I get:
Traceback (most recent call last):
File "C:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx\_windows.py",
line 688, in ShowModal
return _windows_.Dialog_ShowModal(*args, **kwargs)
TypeError: Dialog_ShowModal() takes exactly 1 argument (2 given)


Hope someone can correct me here!
Jun 13 '06 #1
2 2193
John Salerno a écrit :
import wx
class InputForm(wx.Frame):

def __init__(self, parent=None, id=wx.ID_ANY, title=''):
wx.Frame.__init__(self, parent, id, title)
panel = wx.Panel(self)
btnModal = wx.Button(panel, -1, 'Modal')
dialog = wx.Dialog(self, -1, 'Modal Dialog')
self.Bind(wx.EVT_BUTTON, dialog.ShowModal, btnModal) Don't bind directly ShowModal to EVT_BUTTON Traceback (most recent call last):
File "C:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx\_windows.py",
line 688, in ShowModal
return _windows_.Dialog_ShowModal(*args, **kwargs)
TypeError: Dialog_ShowModal() takes exactly 1 argument (2 given)

When your button gives an event, wx send two arguments : the object
itself and an event object. So you can't bind directly.
What you have to do is to use an intermediate method. Something like:
self.dialog = wx.Dialog(self, -1, 'Modal Dialog')
self.Bind(wx.EVT_BUTTON, self.OnClick, b)
def OnClick(self, event):
self.dialog.ShowModal()

Regards,
jm
Jun 13 '06 #2
jean-michel bain-cornu wrote:
When your button gives an event, wx send two arguments : the object
itself and an event object. So you can't bind directly.


Ah, that explains it! Thank you!
Jun 14 '06 #3

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

Similar topics

1
by: Anand | last post by:
I am calling a python script from LabVIEW. This is achieved by making a dll call to python22.dll. It works perfectly well for most of my code. I now want to throwup dialog boxes from python. It...
4
by: Ya | last post by:
Problem: In a computer it is wanted to install an application that must show information in different languages. Thanks to the module we, gettext, have been able to implement that the texts that...
1
by: flupke | last post by:
Hi, i'm trying to convert my java console app to a python gui. Now, the only problem i seem to have at the moment are the resizers for the layout. It seems that for the purpose of what i'm...
2
by: Alain Paschoud | last post by:
Hi all, I made a small dialog in WxPython. I can run the python script with a double-click or through command line, and everything goes fine (dialog appears, which means that wx module has been...
9
by: Tyler | last post by:
Hello All: I am currently working on a project to create an FEM model for school. I was thinking about using wxPython to gather the 12 input variables from the user, then, after pressing the...
4
by: Marcpp | last post by:
Hi I need to call a widget from a button in WXPYTHON. I've tried to this from a function like this, but when push the button, the program opens a window and do error. Any idea? ...... def...
7
by: Terry Carroll | last post by:
I'm trying to use wx.ProgressBar, and the cancel button is not responding. Here is a simple program that exhibits the problem: ######################################################### import...
8
by: Janwillem | last post by:
Is there a way to force the wx.FileDialog to show as default the thumbnails vie in stead of list view? thanks, janwillem
6
by: Iain King | last post by:
Hi. I have a modal dialog whcih has a "Browse..." button which pops up a file selector. This all works fine, but the first thing the user has to do when they open the dialog is select a file, so...
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...
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
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...

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.