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

wx.dialog button event doesn't work

Hello everybody!
I have a program with a button.
When I click on this button a wx.dialog open.
However on my new windows there are two button "Valider" and "Annuler", can you tell me why they don't work, I didn't pass to fix my problem can you help please...
My program:
Expand|Select|Wrap|Line Numbers
  1.  
  2. import wx
  3. import wx.lib.buttons as buttons
  4.  
  5. class FenetrePrincipal(wx.Frame):
  6.     def __init__(self, parent, ID, title):
  7.         wx.Frame.__init__(self, parent, ID, title, wx.DefaultPosition, wx.Size(482, 68), style= wx.FRAME_NO_TASKBAR | wx.STAY_ON_TOP )
  8.  
  9.         #Option Button
  10.         bmpOption = wx.Bitmap('btn_option.png',wx.BITMAP_TYPE_PNG)
  11.         self.btnOption = buttons.GenBitmapButton(self, -1, bmpOption, pos = (2,24),size= (18,18), style=wx.BORDER_NONE)
  12.         self.btnOption.SetToolTipString("Options")
  13.         self.Bind(wx.EVT_BUTTON, self.OnFenetreOptions, self.btnOption)
  14.  
  15.         #Options Windows
  16.         self.fen = wx.Dialog( None, -1 , "Options", size=(250, 200), style=wx.DEFAULT_DIALOG_STYLE | wx.DIALOG_MODAL)
  17.  
  18.         label = wx.StaticText(self.fen, -1, "Pseudo :", (20,20))
  19.         self.pseudo = wx.TextCtrl(self.fen, -1, "", size=(110,-1), pos=(100,20))
  20.  
  21.         label = wx.StaticText(self.fen, -1, "Mot de passe :", (20,45))
  22.         self.pwd = wx.TextCtrl(self.fen, -1,"", size=(110,-1), pos=(100,45),  style=wx.TE_PASSWORD)
  23.  
  24.         label = wx.StaticText(self.fen, -1, "Lancement automatique :", (20,90))
  25.         self.checkbox = wx.CheckBox(self.fen, -1, pos=(150, 90))
  26.  
  27.         btnValider = wx.Button(self.fen, 1001, "Valider", pos=(40,135))
  28.         btnValider.SetDefault()
  29.         btnAnnuler = wx.Button(self.fen, 1002, "Annuler", pos=(130,135))
  30.  
  31.         self.Bind(wx.EVT_BUTTON, self.OnValider,  id = 1001)
  32.         self.Bind(wx.EVT_BUTTON, self.OnAnnuler, id= 1002)
  33.  
  34.  
  35.     def OnFenetreOptions(self,event):
  36.         self.fen.Show()
  37.         event.Skip()
  38.  
  39.     def OnValider(self, event):
  40.         print "Valider"
  41.         self.fen.Destroy()
  42.  
  43.     def OnAnnuler(self, event):
  44.         print "Annuler"
  45.         self.fen.Destroy()
  46.  
  47. class MyApp(wx.App):
  48.     def OnInit(self):
  49.         fen = FenetrePrincipal(None, -1, "Title")
  50.         fen.Show(True)
  51.         self.SetTopWindow(fen)
  52.         return True
  53.  
  54. app = MyApp()
  55. app.MainLoop()
  56.  
Thank !
Oct 8 '07 #1
1 2320
bartonc
6,596 Expert 4TB
Expand|Select|Wrap|Line Numbers
  1. # Bind buttons like this:
  2.         btnValider = wx.Button(self.fen, 1001, "Valider", pos=(40,135))
  3.         btnValider.SetDefault()
  4.         btnAnnuler = wx.Button(self.fen, 1002, "Annuler", pos=(130,135))
  5.  
  6.         btnValider.Bind(wx.EVT_BUTTON, self.OnValider,  id = 1001)
  7.         btnAnnuler.Bind(wx.EVT_BUTTON, self.OnAnnuler, id= 1002)
Per this article.
Oct 8 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dalan | last post by:
I designed a dialog box with a combo to select individual vendors from a form and its related data for print ouput. Though the dialog box seems to work okay, I apparently do not have the filtering...
1
by: Jim Heavey | last post by:
Hello, there is something that I am forgetting, I just don't remember what is. I create a form which will server as a dialog box. I set the "CancelButton", "AcceptButton" and the...
4
by: ronenk | last post by:
I have this code to load an authentication form once my app is loaded. I want the authentication form to be closed if a user is authenticated successfully and to give the option to close app on his...
7
by: theyas | last post by:
How can I get my code to NOT display two "Open/Save/Cancel/More Info" dialog boxes when using the "Response.WriteFile" method to download a file to IE I've asked about this before and didn't get a...
10
by: Guadala Harry | last post by:
I have a modal dialog that currently does all of the following except item 4. 1. lets users select a graphic from a list of thumbnails (and when selected, displays the full-size image in a...
8
by: william | last post by:
Hi All, I have a question about closing a dialog box. The thing is: I have two ASP.NET pages. From one page, I open another page as window.showModalDialog. THere is a button on the second page. On...
11
by: Zytan | last post by:
I have created a new form from the main form. When I close the main form with the 'x' close button, its Form.FormClosed event is run, but not the dialog's. Is this normal? It is ok /...
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...
11
by: VK | last post by:
In the continuation of the discussion at "Making Site Opaque -- This Strategy Feasible?" and my comment at http://groups.google.com/group/comp.lang.javascript/msg/b515a4408680e8e2 I have...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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,...

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.