当前位置: 首页>>代码示例>>Python>>正文


Python JComboBox.addItem方法代码示例

本文整理汇总了Python中javax.swing.JComboBox.addItem方法的典型用法代码示例。如果您正苦于以下问题:Python JComboBox.addItem方法的具体用法?Python JComboBox.addItem怎么用?Python JComboBox.addItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JComboBox的用法示例。


在下文中一共展示了JComboBox.addItem方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: build_combobox

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import addItem [as 别名]
 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
开发者ID:oracc,项目名称:nammu,代码行数:13,代码来源:EditSettingsView.py

示例2: build_servers_combobox

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import addItem [as 别名]
 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
开发者ID:oracc,项目名称:nammu,代码行数:15,代码来源:EditSettingsView.py

示例3: GameSelector

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import addItem [as 别名]
class GameSelector(ActionListener):
    """ generated source for class GameSelector """

    theGameList = JComboBox()
    theRepositoryList = JComboBox()
    theSelectedRepository = GameRepository()
    theCachedRepositories = Map()

    class NamedItem(object):
        """ generated source for class NamedItem """

        theKey = str()
        theName = str()

        def __init__(self, theKey, theName):
            """ generated source for method __init__ """
            self.theKey = theKey
            self.theName = theName

        def __str__(self):
            """ generated source for method toString """
            return self.theName

    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")

    def actionPerformed(self, e):
        """ generated source for method actionPerformed """
        if e.getSource() == self.theRepositoryList:
            if self.theCachedRepositories.containsKey(theRepositoryName):
                self.theSelectedRepository = self.theCachedRepositories.get(theRepositoryName)
            else:
                if theRepositoryName == "Local Game Repository":
                    self.theSelectedRepository = LocalGameRepository()
                else:
                    self.theSelectedRepository = CloudGameRepository(theRepositoryName)
                self.theCachedRepositories.put(theRepositoryName, self.theSelectedRepository)
            repopulateGameList()

    def getSelectedGameRepository(self):
        """ generated source for method getSelectedGameRepository """
        return self.theSelectedRepository

    def repopulateGameList(self):
        """ generated source for method repopulateGameList """
        theRepository = self.getSelectedGameRepository()
        theKeyList = ArrayList(theRepository.getGameKeys())
        Collections.sort(theKeyList)
        self.theGameList.removeAllItems()
        for theKey in theKeyList:
            if theGame == None:
                continue
            if theName == None:
                theName = theKey
            if 24 > len(theName):
                theName = theName.substring(0, 24) + "..."
            self.theGameList.addItem(self.NamedItem(theKey, theName))

    def getRepositoryList(self):
        """ generated source for method getRepositoryList """
        return self.theRepositoryList

    def getGameList(self):
        """ generated source for method getGameList """
        return self.theGameList

    def getSelectedGame(self):
        """ generated source for method getSelectedGame """
        try:
            return self.getSelectedGameRepository().getGame((self.theGameList.getSelectedItem()).theKey)
        except Exception as e:
            return None
开发者ID:hobson,项目名称:ggpy,代码行数:84,代码来源:GameSelector.py

示例4: ConfigTab

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import addItem [as 别名]
class ConfigTab( ITab, JPanel ):

    def __init__( self, callbacks ):
        self._callbacks = callbacks
        self._helpers = callbacks.getHelpers()
        self.__initLayout__()

    def __initLayout__( self ):
        self._levelComboBox = JComboBox()
        levelComboBoxSize = Dimension( 300, 30 )
        self._levelComboBox.setPreferredSize( levelComboBoxSize )
        self._levelComboBox.setMaximumSize( levelComboBoxSize )
        for level in range( 0, 6 ):
            self._levelComboBox.addItem( str( level ) )

        self._techRenderedCheckBox = JCheckBox( 'Rendered', True )
        self._techTimebasedCheckBox = JCheckBox( 'Time-based', True )

        self._plugin_groups = {}
        for plugin in plugins:
            parent = plugin.__base__.__name__
            if not self._plugin_groups.has_key( parent ):
                self._plugin_groups[ parent ] = []
            self._plugin_groups[ parent ].append( plugin )
        self._pluginCheckBoxes = []
        for pluginGroup in self._plugin_groups.values():
            for plugin in pluginGroup:
                self._pluginCheckBoxes.append( PluginCheckBox( plugin ) )

        self._positionReplaceCheckBox = JCheckBox( 'Replace', True )
        self._positionAppendCheckBox = JCheckBox( 'Append', False )

        displayItems = (
            {
                'label': 'Level',
                'components': ( self._levelComboBox, ),
                'description': 'Level of code context escape to perform (1-5, Default:0).'
            },
            {
                'label': 'Techniques',
                'components': ( self._techRenderedCheckBox, self._techTimebasedCheckBox, ),
                'description': 'Techniques R(endered) T(ime-based blind). Default: RT.'
            },
            {
                'label': 'Template Engines',
                'components': self._pluginCheckBoxes,
                'description': 'Force back-end template engine to this value(s).'
            },
            {
                'label': 'Payload position',
                'components': ( self._positionReplaceCheckBox, self._positionAppendCheckBox, ),
                'description': 'Scan payload position. This feature only appears in BurpExtension.'
            }
        )

        layout = GroupLayout( self )
        self.setLayout( layout )
        layout.setAutoCreateGaps( True )
        layout.setAutoCreateContainerGaps( True )

        labelWidth = 200
        hgroup =  layout.createParallelGroup( GroupLayout.Alignment.LEADING )
        vgroup = layout.createSequentialGroup()
        for displayItem in displayItems:
            label = JLabel( displayItem.get( 'label' ) )
            label.setToolTipText( displayItem.get( 'description' ) )
            _hgroup = layout.createSequentialGroup().addComponent( label, labelWidth, labelWidth, labelWidth )
            _vgroup = layout.createParallelGroup( GroupLayout.Alignment.BASELINE ).addComponent( label )
            for component in displayItem.get( 'components' ):
                _hgroup.addComponent( component )
                _vgroup.addComponent( component )
            hgroup.addGroup( _hgroup )
            vgroup.addGroup( _vgroup )

        layout.setHorizontalGroup( hgroup )
        layout.setVerticalGroup( vgroup )

    def getTabCaption( self ):
        return 'Tplmap'

    def getUiComponent( self ):
        return self

    def getLevel( self ):
        return self._levelComboBox.getSelectedIndex()

    def getTechniques( self ):
        return '%s%s' % ( 'R' if self._techRenderedCheckBox.isSelected() else '', 'T' if self._techTimebasedCheckBox.isSelected() else '' )

    def getEngines( self ):
        return [ checkbox.getPlugin() for checkbox in self._pluginCheckBoxes if checkbox.isSelected() ]

    def getPayloadPosition( self ):
        return { 'replace': self._positionReplaceCheckBox.isSelected(), 'append': self._positionAppendCheckBox.isSelected() }
开发者ID:epinna,项目名称:tplmap,代码行数:96,代码来源:config_tab.py

示例5: ResourcePanel

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import addItem [as 别名]

#.........这里部分代码省略.........
        self.cbOutDir = JComboBox(self.dOutPath)
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.75
        c.gridwidth = 3
        c.gridx = 0
        c.gridy = 4
        self.add(self.cbOutDir, c)
        bloadoutpath= JButton('Output Path',actionPerformed=self.onOpenFolder)
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.25
#         c.gridwidth = 1
        c.gridx = 3
        c.gridy = 4
        self.add(bloadoutpath, c)
        ''' fila 6 '''
        bsaveSource= JButton('Save Resources',actionPerformed=self.saveResources)
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridwidth = 2
        c.gridx = 0
        c.gridy = 5
        self.add(bsaveSource, c)
        bloadSource= JButton('Load Resources',actionPerformed=self.loadResources)
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridwidth = 2
        c.gridx = 2
        c.gridy = 5
        self.add(bloadSource, c)
    
    def onOpenFile(self, event):
        ''' remember to change the path'''
        chooseFile = JFileChooser()
        chooseFile.setCurrentDirectory(File('C:\Users\fragom\PhD_CIM\Modelica\Models')) 
        filtro = FileNameExtensionFilter("mo files", ["mo"])
        chooseFile.addChoosableFileFilter(filtro)
        ret = chooseFile.showDialog(self, "Choose file")
        if ret == JFileChooser.APPROVE_OPTION:
            self.faile= chooseFile.getSelectedFile()
            if event.getActionCommand() == "Load Model":
                self.cbMoFile.addItem(self.faile.getPath())
                self.cbMoFile.selectedItem= self.faile.getPath()
            if event.getActionCommand() == "Load Library":
                self.cbMoLib.addItem(self.faile.getPath())
                self.cbMoLib.selectedItem= self.faile.getPath()
#             print self.faile
    
    def onOpenModel(self, event):
        omcscript= CommandOMC()
        omc= OMCProxy("FTP")
        comando= omcscript.loadFile(self.cbMoFile.selectedItem)
        result = omc.sendExpression(comando)
        ''' Parametrizar este comando '''
        modelname=  self.cbMoFile.selectedItem.split('\\')
#         print modelname[-1].split('.')[0]
        modelname= modelname[-1].split('.')[0]
        comando= omcscript.getClassNames(modelname)
        result = omc.sendExpression(comando)
#         print 'result OMCProxy', result.__class__.__name__
#         print 'result.res', result.res[1:-2]
        listname= result.res[1:-2].split(',')
        for nombre in listname:
            self.cbModel.addItem(nombre)
        
    def onOpenFolder(self, event):
        chooseFile = JFileChooser()
        chooseFile.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        ret = chooseFile.showDialog(self, "Choose folder")
        if ret == JFileChooser.APPROVE_OPTION:
            self.faile= chooseFile.getSelectedFile()
            self.cbOutDir.addItem(self.faile.getPath())
            self.cbOutDir.selectedItem= self.faile.getPath()
    
    def saveResources(self,event):
        self.config= ParameterResources()
        self.config.set_modelPath(self.cbMoFile.selectedItem)
        self.config.set_modelFile(self.cbMoFile.selectedItem)
        self.config.set_modelName(self.cbModel.selectedItem)
        self.config.set_libraryPath(self.cbMoLib.selectedItem)
        self.config.set_libraryFile(self.cbMoLib.selectedItem)
        self.config.set_outputPath(self.cbOutDir.selectedItem)
        nomfile= './config/simParameters.properties'
        self.config.save_Properties(nomfile, 'Simulation resources')
    
    def loadResources(self,event):
        self.config= ParameterResources()
        nomfile= './config/simParameters.properties'
        self.config.load_Properties(nomfile)
        self.cbMoFile.addItem(self.config.get_modelFile())
        self.cbMoFile.selectedItem= self.config.get_modelFile()
        self.cbMoLib.addItem(self.config.get_libraryFile())
        self.cbMoLib.selectedItem= self.config.get_libraryFile()
        self.cbModel.addItem(self.config.get_modelName())
        self.cbModel.selectedItem= self.config.get_modelName()
        self.cbOutDir.addItem(self.config.get_outputPath())
        self.cbOutDir.selectedItem= self.config.get_outputPath()
开发者ID:fran-jo,项目名称:SimuGUI,代码行数:104,代码来源:meegui_jy.py

示例6: EventsPane

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import addItem [as 别名]
class EventsPane(WindowPane, ActionListener, DocumentListener):
    
    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

    def activate(self):
        self.active = True
        if self.must_update_geos:
            self.update_geos()
    def deactivate(self):
        self.active = False
    
    def indent_selection(self):
        return self.script_area.indent_selection()
    def dedent_selection(self):
        return self.script_area.dedent_selection()

    def update_geos(self):
        self.must_update_geos = False
        try:
            self.building_objects_box = True
            self.objects_box.removeAllItems()
            self.geos = self.api.getAllGeos()
            for geo in self.geos:
                tp = API.Geo.getTypeString(geo)
                label = API.Geo.getLabel(geo)
                self.objects_box.addItem(tp + " " + label)
        finally:
            self.building_objects_box = False
        
        if not self.geos:
            self.current = None
            self.objects_box.enabled = False
            self.events_box.enabled = False
            self.language_box.enabled = False
            self.script_area.input = ""
            self.script_area.component.enabled = False
        else:
            changed = False
            if self.current is None:
                index, event = 0, 1
                changed = True
            else:
                geo, event = self.current
                try:
                    index = self.geos.index(geo)
                except ValueError:
                    index, event = 0, 1
                    changed = True
            self.events_box.selectedIndex = event
#.........这里部分代码省略.........
开发者ID:aeriksson,项目名称:geogebra,代码行数:103,代码来源:gui.py


注:本文中的javax.swing.JComboBox.addItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。