10 Years
Discussion Span
Last Post by vegaseat

What GUI library are you using? I am a little familiar with Tkinter and wxPython and might be able to help. There are others I am not familiar with.


simple code for creating dropdown box using javascript.
the html code for this, is

<script language="javascript" src="list.js"></script>

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000" onload="fillCategory();">

<FORM name="drop_list"  >
<SELECT  NAME="Category" onChange="SelectDistrict();" >
<Option value="">States</option>
<SELECT id="District" NAME="District" onChange="SelectCollege();">
<Option value="">Districts</option>

<SELECT id="College" NAME="College">
<Option value="">College</option>
<input type="button" name="go" value="Value Selected"



here i am calling javascript writen in another file list.js. The content of list.js is following

function fillCategory(){ 

 // this function is used to fill the category list on load

addOption(document.drop_list.Category, "Karnataka", "Karnataka", "");

addOption(document.drop_list.Category, "Jharkhand", "Jharkhand", "");

addOption(document.drop_list.Category, "Hariyana", "Hariyana", "");


function SelectDistrict(){

// ON selection of category this function will work

addOption(document.drop_list.District, "", "District", "");

if(document.drop_list.Category.value == 'Karnataka'){
addOption(document.drop_list.District,"Bangalore", "Bangalore");
addOption(document.drop_list.District,"Kolar", "Kolar");
addOption(document.drop_list.District,"Hubali", "Hubali");
if(document.drop_list.Category.value == 'Jharkhand'){
addOption(document.drop_list.District,"Ranchi", "Ranchi");
addOption(document.drop_list.District,"Jamshedpur", "Jamshedpur");
addOption(document.drop_list.District,"Hazbagh", "Hazbagh", "");
if(document.drop_list.Category.value == 'Hariyana'){
addOption(document.drop_list.District,"Noida", "Noida");
addOption(document.drop_list.District,"Gurgaon", "Gurgaon");
addOption(document.drop_list.District,"Panipat", "Panipat");


function SelectCollege(){

// ON selection of District this function will work

addOption(document.drop_list.College, "", "College", "");

if(document.drop_list.District.value == 'Bangalore'){
addOption(document.drop_list.College,"BIT Bangalore", "BIT Bangalore");
addOption(document.drop_list.College,"MVIT Bangalore", "MVIT Bangalore");
if(document.drop_list.District.value == 'Kolar'){
addOption(document.drop_list.College,"BIT Kolar", "BIT Kolar");
addOption(document.drop_list.College,"BIT Kolar", "BIT Kolar");
if(document.drop_list.District.value == 'Hubali'){
addOption(document.drop_list.College,"YMCA", "YMCA");
addOption(document.drop_list.College,"IIT", "IIT");
if(document.drop_list.District.value == 'Ranchi'){
addOption(document.drop_list.College,"ZXA", "ZXA");
addOption(document.drop_list.College,"DSA", "DSA");
if(document.drop_list.District.value == 'Jamshedpur'){
addOption(document.drop_list.College,"QWE", "QWE");
addOption(document.drop_list.College,"ZXC", "ZXC");
if(document.drop_list.District.value == 'Hazbagh'){
addOption(document.drop_list.College,"ZDC", "ZDC");
addOption(document.drop_list.College,"FGV", "FGV");
if(document.drop_list.District.value == 'Noida'){
addOption(document.drop_list.College,"uio", "uio");
addOption(document.drop_list.College,"klj", "klj");
if(document.drop_list.District.value == 'Gurgaon'){
addOption(document.drop_list.College,"yhn", "yhn");
addOption(document.drop_list.College,"fgh", "fgh");
if(document.drop_list.District.value == 'Panipat'){
addOption(document.drop_list.College,"olm", "olm");
addOption(document.drop_list.College,"bnm", "bnm");

function removeAllOptions(selectbox)


	var i;







function addOption(selectbox, value, text )


	var optn = document.createElement("OPTION");

	optn.text = text;

	optn.value = value;



this is very simple to understand it.
If any one have code to create dropdown box in Python script plz send me....

Edit: Added code tags vegaseat


Here is an example using wxPython. Once you have Python installed you need to download wxPython appropriate for your system and Python version, it's free!

# the wxChoice() widget, a simple dropdown box
# wx.Choice(parent, id, pos, size, choices, style)
# tested with Python24 and wxPython26
# should work on Windows, Linux, and Unix systems

import wx

class MyFrame(wx.Frame):
    """ class MyFrame inherits wxFrame, uses default ID of -1"""
    def __init__(self ):
        wx.Frame.__init__(self, None, -1, 'wxChoice test', size=(300, 150))

        colorList = ['red', 'green', 'blue', 'yellow','white']
        # create the dropdown box
        self.choice1 = wx.Choice(self, -1, choices=colorList)
        # select item 1 = 'green' to show
        # set focus to receive optional keyboard input
        # eg. type r for red, y for yellow
        # new event handler wxPython version 2.5 and higher
        self.choice1.Bind(wx.EVT_CHOICE, self.onChoice)
    def onChoice(self, event):
        '''get the slected color choice'''
        self.color = self.choice1.GetStringSelection()
        self.SetTitle(self.color)  # test

# this is only a small application
application = wx.PySimpleApp()
# call class MyFrame
frame1 = MyFrame()
# show the frame
# start the event loop
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.