本文整理汇总了Python中javax.swing.JComboBox类的典型用法代码示例。如果您正苦于以下问题:Python JComboBox类的具体用法?Python JComboBox怎么用?Python JComboBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JComboBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initExport
def initExport(self):
#
## init enforcement detector tab
#
exportLType = JLabel("File Type:")
exportLType.setBounds(10, 10, 100, 30)
exportLES = JLabel("Enforcement Statuses:")
exportLES.setBounds(10, 50, 160, 30)
exportFileTypes = ["HTML","CSV"]
self.exportType = JComboBox(exportFileTypes)
self.exportType.setBounds(100, 10, 200, 30)
exportES = ["All Statuses", self._enfocementStatuses[0], self._enfocementStatuses[1], self._enfocementStatuses[2]]
self.exportES = JComboBox(exportES)
self.exportES.setBounds(100, 50, 200, 30)
exportLES = JLabel("Statuses:")
exportLES.setBounds(10, 50, 100, 30)
self.exportButton = JButton("Export",actionPerformed=self.export)
self.exportButton.setBounds(390, 25, 100, 30)
self.exportPnl = JPanel()
self.exportPnl.setLayout(None);
self.exportPnl.setBounds(0, 0, 1000, 1000);
self.exportPnl.add(exportLType)
self.exportPnl.add(self.exportType)
self.exportPnl.add(exportLES)
self.exportPnl.add(self.exportES)
self.exportPnl.add(self.exportButton)
示例2: __initDropDownBox
def __initDropDownBox(self, table):
smells = [ x[0].label for x in groupBy((entity == 'smell'), label)]
smells.sort()
smells.remove('ForTestersOnly')
dropdown = JComboBox(jarray.array(smells, String))
dropdown.addActionListener(DropDownListener(table))
self.add(dropdown, self.__createDropDownConstraints())
示例3: build_combobox
def build_combobox(self, choices, default):
'''
Generic method to construct a combobox. choices should be an iterable
of strings of the choices to be made and default should be a string
which is equal to one of the values within the iterable.
'''
combo = JComboBox()
for choice in choices:
combo.addItem(choice)
combo.setSelectedItem(default)
return combo
示例4: __init__
def __init__(self):
""" generated source for method __init__ """
super(GameSelector, self).__init__()
self.theGameList = JComboBox()
self.theGameList.addActionListener(self)
self.theRepositoryList = JComboBox()
self.theRepositoryList.addActionListener(self)
self.theCachedRepositories = HashMap()
self.theRepositoryList.addItem("games.ggp.org/base")
self.theRepositoryList.addItem("games.ggp.org/dresden")
self.theRepositoryList.addItem("games.ggp.org/stanford")
self.theRepositoryList.addItem("Local Game Repository")
示例5: __init__
def __init__(self, window, api):
self.api = api
self.component = JPanel(BorderLayout())
# Create editor pane
scrollpane = JScrollPane()
self.script_area = InputPane(window)
self.script_area.undo = UndoManager()
line_numbers = LineNumbering(self.script_area.component)
scrollpane.viewport.view = self.script_area.component
scrollpane.rowHeaderView = line_numbers.component
self.component.add(scrollpane, BorderLayout.CENTER)
# Create Selection pane
select_pane = JPanel()
self.objects_box = JComboBox([], actionCommand="object")
select_pane.add(self.objects_box)
self.events_box = JComboBox(
["update", "click"],
actionCommand="event"
)
self.event_types = [EventType.UPDATE, EventType.CLICK]
select_pane.add(self.events_box)
self.languages = list(ScriptType.values())
self.language_box = JComboBox(
[l.getName() for l in self.languages],
actionCommand="language"
)
select_pane.add(self.language_box)
self.save_btn = JButton("Save")
select_pane.add(self.save_btn)
self.component.add(select_pane, BorderLayout.PAGE_START)
self.events_box.addActionListener(self)
self.objects_box.addActionListener(self)
self.language_box.addActionListener(self)
self.save_btn.addActionListener(self)
self.current = None
self.update_geos()
interface.addEventListener("add", self.event_listener)
interface.addEventListener("remove", self.event_listener)
interface.addEventListener("rename", self.event_listener)
# Listen to script_area changes in order to know when the save
# button can be activated
self.script_area.doc.addDocumentListener(self)
# Hack to be able to change the objects_box
self.building_objects_box = False
self.active = False
示例6: PrefsPanel
class PrefsPanel(JPanel):
"""JPanle with gui for tool preferences
"""
def __init__(self, app):
strings = app.strings
self.setLayout(GridLayout(3, 2, 5, 5))
userLbl = JLabel(strings.getString("osmose_pref_username"))
self.userTextField = JTextField(20)
self.userTextField.setToolTipText(strings.getString("osmose_pref_username_tooltip"))
levelLbl = JLabel(strings.getString("osmose_pref_level"))
self.levels = ["1", "1,2", "1,2,3", "2", "3"]
self.levelsCombo = JComboBox(self.levels)
self.levelsCombo.setToolTipText(strings.getString("osmose_pref_level_tooltip"))
limitLbl = JLabel(strings.getString("osmose_pref_limit"))
self.limitTextField = JTextField(20)
self.limitTextField.setToolTipText(strings.getString("osmose_pref_limit_tooltip"))
self.add(userLbl)
self.add(self.userTextField)
self.add(levelLbl)
self.add(self.levelsCombo)
self.add(limitLbl)
self.add(self.limitTextField)
def update_gui(self, preferences):
"""Update preferences gui
"""
self.userTextField.setText(preferences["username"])
self.levelsCombo.setSelectedIndex(self.levels.index(preferences["level"]))
self.limitTextField.setText(str(preferences["limit"]))
def read_gui(self):
"""Read preferences from gui
"""
username = self.userTextField.getText()
level = self.levelsCombo.getSelectedItem()
limit = self.limitTextField.getText()
try:
limit = Integer.parseInt(limit)
if limit > 500:
limit = 500
limit = str(limit)
except NumberFormatException:
limit = ""
preferences = {"username": username.strip(),
"level": level,
"limit": limit}
return preferences
示例7: build_servers_combobox
def build_servers_combobox(self):
combo = JComboBox()
# Go through list of servers and add to combo box.
for server in self.servers.keys():
if server != "default":
combo_item = "{}: {}:{}".format(server,
self.servers[server]['url'],
self.servers[server]['port'])
combo.addItem(combo_item)
# If this item is the default one, set it as selected
if server == self.servers['default']:
combo.setSelectedItem(combo_item)
return combo
示例8: makeScriptComboBox
def makeScriptComboBox(list):
from javax.swing import JComboBox, JButton, JPanel
from java.awt.event import ActionListener
jcb = JComboBox(list)
jcb.setSelectedIndex(0)
plot_btn = JButton("Plot station")
# create a Python class
class PlotButtonAction(ActionListener):
# defines a constructor
def __init__(self, combo_box):
self.cb = combo_box
def actionPerformed(self, event):
plotStation(self.cb.getSelectedIndex(), None)
# registers an instance of the action object with the button
plot_btn.addActionListener(PlotButtonAction(jcb))
#
alltw_btn = JButton("All Data")
class AllButtonAction(ActionListener):
# defines a constructor
def __init__(self, combo_box):
self.cb = combo_box
def actionPerformed(self, event):
plotStation(self.cb.getSelectedIndex(), 1)
alltw_btn.addActionListener(AllButtonAction(jcb))
#
quit_btn = JButton("Quit")
class QuitButtonAction(ActionListener):
# defines a constructor
def __init__(self, combo_box):
self.cb = combo_box
def actionPerformed(self, event):
fr.dispose()
quit_btn.addActionListener(QuitButtonAction(jcb))
# add both button and combo box to a panel
panel = JPanel()
panel.setLayout(GridLayout(2, 2))
panel.add(alltw_btn)
panel.add(jcb)
panel.add(plot_btn)
panel.add(quit_btn)
return panel
示例9: __init__
class _AccountAdder:
def __init__(self, contactslist):
self.contactslist = contactslist
self.mainframe = JFrame("Add New Contact")
self.account = JComboBox(self.contactslist.clientsByName.keys())
self.contactname = JTextField()
self.buildpane()
def buildpane(self):
buttons = JPanel()
buttons.add(JButton("OK", actionPerformed=self.add))
buttons.add(JButton("Cancel", actionPerformed=self.cancel))
acct = JPanel(GridLayout(1, 2), doublebuffered)
acct.add(JLabel("Account"))
acct.add(self.account)
mainpane = self.mainframe.getContentPane()
mainpane.setLayout(BoxLayout(mainpane, BoxLayout.Y_AXIS))
mainpane.add(self.contactname)
mainpane.add(acct)
mainpane.add(buttons)
self.mainframe.pack()
self.mainframe.show()
#action listeners
def add(self, ae):
acct = self.contactslist.clientsByName[self.account.getSelectedItem()]
acct.addContact(self.contactname.getText())
self.mainframe.dispose()
def cancel(self, ae):
self.mainframe.dispose()
示例10: __init__
def __init__(self,hostname):
self.hostname=hostname
JPanel.__init__(self,BorderLayout())
self.cbActionListener=foo2(self)
#imglist=os.listdir('./img')
#try:imglist.remove('.svn')
#except:pass
imglist=['01-CircleOfFifths.gif','Fifths.png','circle-o-fifths.jpg','Circle_Of_Fifths.gif','Keywheel.gif','circle-of-fifths.gif','ColorFifths.jpg','cof.gif']
self.cb=JComboBox(imglist,actionListener=self.cbActionListener)#
#self.cb.addItemListener(self.cbCB)
tb=JPanel()
tb.setLayout(FlowLayout(FlowLayout.CENTER))
tb.add(self.cb)
self.add(tb,'Center')
self.img=None
if hostname[0:7]=='http://':
self.img=ImageIO.read(URL(self.hostname+'/static/sightreadingtrainer/img/'+imglist[0]))
else:
self.img=ImageIO.read(File(self.hostname+'img/'+imglist[0]))
icon=ImageIcon(self.img)
self.label=JLabel(icon)
self.add(self.label,'North')
示例11: __init__
def __init__(self, cattr):
self.attr = cattr
self.cbox = JColorChooser(self.attr.color)
self.sym_panel = EditSymbolAttr(cattr.sym_prop)
self.thickness_field = JTextField(str(cattr.thickness),2)
self.draw_symbol_box = JCheckBox("Draw Symbol?",cattr.draw_symbol)
self.dps_field = JTextField(str(self.attr.data_per_symbol),2)
self.dash_box = JComboBox(CurveProps.DASH_TYPES.keys())
self.dash_box.setSelectedItem(self.attr.dash_type)
self.dash_box.setBorder(BorderFactory.createTitledBorder("Dash type: (Only JDK2 & Slow!)"))
tpanelx = JPanel()
tpanelx.add(self.thickness_field)
tpanelx.setBorder(BorderFactory.createTitledBorder("curve thickness (integer)"))
tpanely = JPanel()
tpanely.add(self.dps_field)
tpanely.setBorder(BorderFactory.createTitledBorder("data per symbol(integer)"))
tpanel = JPanel();tpanel.setLayout(GridLayout(2,2));
tpanel.add(self.draw_symbol_box); tpanel.add(tpanelx);
tpanel.add(tpanely); tpanel.add(self.dash_box);
panel1 = JPanel()
panel1.setLayout(BorderLayout())
panel1.add(self.cbox,BorderLayout.CENTER)
panel1.add(tpanel, BorderLayout.SOUTH)
panel2 = JPanel()
panel2.setLayout(BorderLayout())
panel2.add(self.sym_panel,BorderLayout.CENTER)
tp1 = JTabbedPane()
tp1.addTab("Curve Attributes",panel1)
tp1.addTab("Symbol Attributes",panel2)
tp1.setSelectedComponent(panel1)
self.setLayout(BorderLayout())
self.add(tp1,BorderLayout.CENTER)
示例12: draw
def draw(self):
try:
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
except:
pass
self.images_dict = dict()
self.canvas = Canvas(self.images_dict, None)
self.canvas.addMouseListener(self)
self.frame = JFrame("SimplePyzzle", visible = 1)
self.frame.setMinimumSize(Dimension(300, 300))
self.frame.setLocationRelativeTo(None)
self.generate_button = JButton("Generate Puzzle")
self.bottom_panel = JPanel()
self.combo_box_list = [9, 16, 25, 36, 49]
self.combo_box = JComboBox(self.combo_box_list)
self.frame.contentPane.add(self.canvas, BorderLayout.CENTER)
self.frame.contentPane.add(self.bottom_panel, BorderLayout.SOUTH)
self.bottom_panel.add(self.generate_button, BorderLayout.EAST)
self.bottom_panel.add(self.combo_box, BorderLayout.WEST)
self.generate_button.actionPerformed = self.generate_board
self.frame.setSize(500, 500)
self.frame.defaultCloseOperation = JFrame.EXIT_ON_CLOSE;
self.frame.pack()
示例13: GlobalPanel
class GlobalPanel(JPanel, ActionListener):
def __init__(self,options):
self.options=options
self.layout=BoxLayout(self,BoxLayout.Y_AXIS)
self.opt_color=JCheckBox('Colour',True,actionPerformed=self.options.changed)
self.add(self.opt_color)
self.dpi=JTextField('80',actionPerformed=self.options.changed)
self.add(make_option('dpi',self.dpi))
self.metrics=JComboBox(['mean','median','sd','var'],editable=False)
self.metrics.selectedIndex=0
self.metrics.addActionListener(self)
self.add(make_option('metric',self.metrics))
def actionPerformed(self,event):
self.options.changed(event)
示例14: EditSymbolAttr
class EditSymbolAttr(JPanel):
def __init__(self, sattr):
self.attr = sattr
self.cbox = JColorChooser(self.attr.color)
self.sz_field = JTextField(str(self.attr.size))
szpanel = JPanel()
szpanel.add(self.sz_field)
szpanel.setBorder(BorderFactory.createTitledBorder("symbol size (integer)"))
self.filled_box = JCheckBox("Filled ?:",self.attr.filled)
self.shape_cbox = JComboBox(SymbolProps.sym_shape_map.keys())
self.shape_cbox.setSelectedItem(self.attr.shape)
self.shape_cbox.setBorder(BorderFactory.createTitledBorder("Shape"))
panel1 = JPanel()
panel1.setLayout(BorderLayout())
panel1.add(szpanel,BorderLayout.NORTH)
panel2 = JPanel()
panel2.setLayout(GridLayout(1,2))
panel2.add(self.shape_cbox)
panel2.add(self.filled_box)
panel1.add(panel2,BorderLayout.SOUTH)
self.setLayout(BorderLayout())
self.add(self.cbox,BorderLayout.CENTER)
self.add(panel1,BorderLayout.SOUTH)
def setAttribute(self,sattr):
self.attr = sattr
self.cbox.color = self.attr.color
self.sz_field.text = str(self.attr.size)
self.shape_cbox.setSelectedItem(self.attr.shape)
def update(self):
self.attr.color = self.cbox.getColor()
self.attr.size = string.atoi(self.sz_field.getText())
self.attr.filled = self.filled_box.isSelected()
self.attr.shape = self.shape_cbox.getSelectedItem()
self.attr.sym = self.attr.createSymbol()
示例15: __init__
def __init__(self,options):
self.options=options
self.layout=BoxLayout(self,BoxLayout.Y_AXIS)
self.area=JCheckBox('CI area',False,actionPerformed=self.options.changed)
self.add(self.area)
self.x_axis=JComboBox(['equal','linear','log'],editable=False)
self.x_axis.selectedIndex=0
self.x_axis.addActionListener(self)
self.y_axis=JComboBox(['linear','log'],editable=False)
self.y_axis.selectedIndex=0
self.y_axis.addActionListener(self)
axis=JPanel(border=BorderFactory.createTitledBorder('axis'))
axis.layout=BoxLayout(axis,BoxLayout.X_AXIS)
axis.add(JLabel('x:'))
axis.add(self.x_axis)
axis.add(JLabel('y:'))
axis.add(self.y_axis)
axis.maximumSize=axis.minimumSize
self.add(axis)