473,386 Members | 1,819 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.

wxGlade

hi,given that I'm a newbie in python,
I have a little problem with wx...
Maybe it's a stupid thing,but if u want help me!
I used wxglade to generate a simple window with a button!
wxglade generates the code,and now I try to insert events,but I have an
error,I don't understand!
The code is this:

from wxPython.wx import *

class MyFrame(wxFrame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] = wxDEFAULT_FRAME_STYLE
wxFrame.__init__(self, *args, **kwds)
self.button_1 = wxButton(self, -1, "button_1")

self.__set_properties()
self.__do_layout()
# end wxGlade
EVT_BUTTON(self, 1003, self.event)

def __set_properties(self):
# begin wxGlade: MyFrame.__set_properties
self.SetTitle("frame_1")
# end wxGlade

def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
sizer_1 = wxBoxSizer(wxVERTICAL)
sizer_1.Add(self.button_1, 0, 0, 0)
self.SetAutoLayout(1)
self.SetSizer(sizer_1)
sizer_1.Fit(self)
sizer_1.SetSizeHints(self)
self.Layout()
# end wxGlade
def event(self):
print "ciao"

# end of class MyFrame
class MyApp(wxApp):
def OnInit(self):
frame = MyFrame(NULL, -1, "Hello from wxPython")
frame.Show(true)
self.SetTopWindow(frame)
return true

app = MyApp(0)
app.MainLoop()

Thanks
-pilu-
Jul 18 '05 #1
2 2147
I'm a newbie regarding wxPython, nevertheless I worked this out:
class MyFrame(wxFrame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] = wxDEFAULT_FRAME_STYLE
wxFrame.__init__(self, *args, **kwds)
self.button_1 = wxButton(self, -1, "button_1")
self.__set_properties()
self.__do_layout()
# end wxGlade
EVT_BUTTON(self, 1003, self.event)
You have to set the identifier of the button:
self.button_1 = wxButton(self, 1003, "button_1")
def event(self):
print "ciao"


The triggered method also needs the event as a parameter:

def event(self, event):
print "ciao"
Markus
Jul 18 '05 #2
Markus Faltin wrote:
I'm a newbie regarding wxPython, nevertheless I worked this out:

class MyFrame(wxFrame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] = wxDEFAULT_FRAME_STYLE
wxFrame.__init__(self, *args, **kwds)
self.button_1 = wxButton(self, -1, "button_1")
self.__set_properties()
self.__do_layout()
# end wxGlade
EVT_BUTTON(self, 1003, self.event)

You have to set the identifier of the button:
self.button_1 = wxButton(self, 1003, "button_1")


Not necessarily, you can keep the -1 designation and then
EVT_BUTTON(self, self.button_1.GetId(), self.event)

I prefer this method since it is less book keeping for me.

Brian Kelley

Jul 18 '05 #3

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

Similar topics

1
by: Donald 'Paddy' McCarthy | last post by:
Hi, I am having a few problems with a GUI. I am new to traits and wxGlade. I have used wxGlade to create a Form with an embedded space for a CustomWidget. I have the traits demo and would like...
1
by: Somesh Bartakkay | last post by:
i installed wxGlade on System xp, when i started it ..its not running ?
0
by: LenS | last post by:
I have installed wxGlade on a MS XP machine. It executed on completion of the install. However, when I try to double click on the wxGlade icon to start nothing happens. I searched the NG and...
2
by: physci | last post by:
I've been combing google for the past week trying to find an appropriate set of tools for a project I'm working on. Simply put, what I need is a GUI, powered by python, (I really don't want to...
7
by: diffuser78 | last post by:
I recently tried a hand at wxGlade and was happy to see it designs a GUI for you in minutes. I am a newbie Python coder. I am not completely aware of GUI programming. I can easily make menubars...
2
by: crystalattice | last post by:
I'm making a GUI for a console-based program I just wrote. I figured it would be mostly straight forward to convert it over in wxPython but now I'm confused. In my console program, I have...
9
by: agsupriya86 | last post by:
How to add keyboard event to a button in wxglade??
3
by: Steve Holden | last post by:
I've been trying to use wxGlade recently and I am finding it something of a challenge. Is there any user who finds the user interface satisfactory and the operation of the program predictable? ...
10
by: exodus | last post by:
As a fun little task to gain more knowledge of python, i decided to try to mimick the ipod UI with it. here's what i've got so far #!/usr/bin/env python # -*- coding: utf-8 -*- # generated by...
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: 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:
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
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
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.