[wxPython-users] A quick wxPython Question about Panels
Saketh Bhamidipati
saketh.bhamidipati at gmail.com
Sun Jun 25 14:12:41 PDT 2006
On 6/25/06, Daniel Johnson <diffuser78 at gmail.com> wrote:
>
> Some quick 2-3 questions
>
> 1. Since we can't add anything on top of Panel, Why should one use Panels
> ? What is its utility in creating GUI.
>
> 2. I want to create a window with Menu bar and items in it. When we click
> on some item of menu bar say File--> CreateFile it should open a new
> windows where it would let user create new config file. How can we do thi=
s ?
> I am newbie. I thought of creating another frame or and calling it on menu
> item click event.....am i right in my approach ??
> Please guide and if possible tell me some sample source code place.
>
> Thanks,
>
> All your responses are appreciated,
>
> Daniel
>
>
>
>
1. Panels are "containers" - they combine different components
together into one Window, so that you can pass the panel as a parameter =
to
other functions. For example, if you wanted to create a popup menu, you
would have to specify which panel the menu is in. Although at first pane=
ls
may not make sense, looking at examples is very helpful. There are plent=
y on
the wxPyWiki.
2. Menu creation is documented very well in the tutorials on the wiki;
just search for "menu." There's a lot more information out there about m=
enu
creation in wxPython than I can contain in this one message.
Here is a sample snippet of code that shows you how to make a File -->
CreateFile menu (although I think "New" is a better title than
"CreateFile"). I am assuming that you are putting this code in a class that
derives from wx.Frame - this way I can type self.Bind() instead of
frame.connect() for the event binds.
menubar =3D wx.MenuBar() # The menu bar
filemenu =3D wx.Menu() # Creates the "file" in the menu
filecreate =3D filemenu.Append(101, '&CreateFile', 'Create a file') # The 1=
01
is an ID, and the '&' tells you which letter to underline
menubar.Append(filemenu, '&File') # Add the filemenu to the menubar
self.Bind(wx.EVT_MENU, self.OnNew, filecreate) # Bind the function
self.OnNew to filecreate
...
def OnNew(self, e):
pass
You see that I put pass in OnNew. What you want is called a FileDialog, and
it looks like the native file creation dialogs. Again, there's more
information about it in the documentation and the wiki.
-Saketh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200606=
25/bfa242fe/attachment.htm
More information about the wxpython-users
mailing list