ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> wxpython-users
wxpython-users
[wxpython-users] Subclassing a ComboBox widget in a frame build with wxGlade
by Timmie other posts by this author
May 6 2008 11:35AM messages near this date
Re: [wxpython-users] To Robin Dunn | Re: [wxpython-users] Subclassing a ComboBox widget in a frame build with wxGlade
Hello,
I am new to wxPython but staedily and slowly finding my way in.

I am building my GUI with wxGlade which works quite well after getting used to
its functionality.

I let wxGlade write my code in a file called myapp_gui.py. Then I use anthother
file myapp_controls.py to subclass the GUI created with wxGlade. I set up my
application in the file myapp.py.

In my GUI I have ComboBox for selecting among a number of choices. I would like
to create the choices available for the ComboBox from an function
provide_buildings_choice_choices which creates a list of all choices instead of
manually entering all choices in wxGlade.

How can I do this?
If I add the function to a method which I insert into my subclass the selection
dialog doesn't show the choices.

I would be glad if anyone can offer some help here.

I hope I described my problem in an understandable manner.

Thanks in advance and kind regards,
Timmie



### myapp_controls.py ###

import sys
import wx

import mypapp_gui as gui

def provide_buildings_choice_choices():
	mylist = [house: 1, tent: 2, tower: 3, lighthouse:4]
	return mylist

class ModifiedMainFrame(gui.MainFrame):
    """
    Main Window of the Application
    """
    def add_choices(self):
        self.buildings_choice = wx.ComboBox(self, -1,
choices=provide_buildings_choice_choices(), style=wx.CB_DROPDOWN) 	### <--- here
is where I can need your help!
        #self.statusbar = self.CreateStatusBar()


### END ###

### myapp.py ###

import wx
import gettext

import myapp_gui as gui
import myapp_controls as ctrl



class MyAppGui(wx.App):
    def OnInit(self):
        wx.InitAllImageHandlers()
        #main_frame = ctrl.ModifiedFrame
        main_frame = ctrl.ModifiedMainFrame(None, -1, "")
        self.SetTopWindow(main_frame)
        main_frame.Show()
        return 1

# end of class MyAppGui

if __name__ == "__main__":
    import gettext
    gettext.install("MyApp") # replace with the appropriate catalog name

    MyApp = MyAppGuiGui(0)
    MyApp.MainLoop()


### END myapp.py ###





### myapp_gui.py ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# generated by wxGlade 0.6.3

import wx

# begin wxGlade: extracode
# end wxGlade



class MainFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: MainFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        
        # Menu Bar
        ...
        # Menu Bar end
        ...
        self.buildings_choice = wx.ComboBox(self, -1, choices=[_("House"),
_("Tent")], style=wx.CB_DROPDOWN)
        self.static_line_4 = wx.StaticLine(self, -1)
	
...

### END myapp_gui.py ###

_______________________________________________
wxpython-users mailing list
wxpython-users@[...].org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Thread:
Timmie
C M
Tim Michelsen
C M
Tim Michelsen
C M

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved