當前位置: 首頁>>代碼示例>>Python>>正文


Python JMenuItem.setIcon方法代碼示例

本文整理匯總了Python中javax.swing.JMenuItem.setIcon方法的典型用法代碼示例。如果您正苦於以下問題:Python JMenuItem.setIcon方法的具體用法?Python JMenuItem.setIcon怎麽用?Python JMenuItem.setIcon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JMenuItem的用法示例。


在下文中一共展示了JMenuItem.setIcon方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: add_check_item

# 需要導入模塊: from javax.swing import JMenuItem [as 別名]
# 或者: from javax.swing.JMenuItem import setIcon [as 別名]
 def add_check_item(self, tool, view, check, viewMenu):
     checkItem = JMenuItem(check.title)
     if check.icon is not None:
         checkItem.setIcon(check.icon)
     checkItem.addActionListener(QatMenuActionListener(self.app,
                                                       "check",
                                                       tool,
                                                       view,
                                                       check))
     viewMenu.add(checkItem)
開發者ID:alex85k,項目名稱:qat_script,代碼行數:12,代碼來源:QatMenu.py

示例2: __init__

# 需要導入模塊: from javax.swing import JMenuItem [as 別名]
# 或者: from javax.swing.JMenuItem import setIcon [as 別名]
    def __init__(self, app, menuTitle):
        JMenu.__init__(self, menuTitle)
        self.app = app
        #quat dialog item
        dialogItem = JCheckBoxMenuItem(self.app.dlg.toggleAction)
        self.add(dialogItem)
        self.addSeparator()

        #tool submenu
        for tool in self.app.tools:
            if tool.name == "favourites":
                self.addSeparator()
            toolMenu = JMenu(tool.title)
            toolMenu.setIcon(tool.bigIcon)
            if tool.uri != "":
                #Website link
                iconFile = File.separator.join([self.app.SCRIPTDIR,
                                                "images",
                                                "icons",
                                                "browser.png"])
                urlItem = JMenuItem(tool.title)
                urlItem.setIcon(ImageIcon(iconFile))
                urlItem.addActionListener(QatMenuActionListener(self.app,
                                                                "link",
                                                                tool))
                toolMenu.add(urlItem)
                toolMenu.addSeparator()
            #View submenu
            for view in tool.views:
                viewMenu = JMenu(view.title)
                if tool.name == "favourites":
                    self.app.favouritesMenu = viewMenu
                #Check item
                for check in view.checks:
                    self.add_check_item(tool, view, check, viewMenu)
                toolMenu.add(viewMenu)
            self.add(toolMenu)
        #Local file with errors
        localFileItem = JMenuItem(self.app.strings.getString("Open_GPX"))
        localFileItem.setIcon(ImageProvider.get("open"))
        localFileItem.addActionListener(QatMenuActionListener(self.app, "local file"))
        self.add(localFileItem)
        self.addSeparator()
        #False positive dialog
        falsepositiveItem = JMenuItem(self.app.strings.getString("False_positives..."))
        falsepositiveItem.addActionListener(QatMenuActionListener(self.app, "dialog"))
        self.add(falsepositiveItem)
        #Preferences dialog
        preferencesItem = JMenuItem(self.app.strings.getString("Preferences..."))
        preferencesItem.addActionListener(QatMenuActionListener(self.app, "dialog"))
        self.add(preferencesItem)
        #About dialog item
        aboutItem = JMenuItem(self.app.strings.getString("About..."))
        aboutItem.addActionListener(QatMenuActionListener(self.app, "dialog"))
        self.add(aboutItem)
開發者ID:alex85k,項目名稱:qat_script,代碼行數:57,代碼來源:QatMenu.py

示例3: QatDialog

# 需要導入模塊: from javax.swing import JMenuItem [as 別名]
# 或者: from javax.swing.JMenuItem import setIcon [as 別名]
class QatDialog(ToggleDialog):
    """ToggleDialog for error type selection and buttons for reviewing
       errors in sequence
    """
    def __init__(self, name, iconName, tooltip, shortcut, height, app):
        ToggleDialog.__init__(self, name, iconName, tooltip, shortcut, height)
        self.app = app
        tools = app.tools

        #Main panel of the dialog
        mainPnl = JPanel(BorderLayout())
        mainPnl.setBorder(BorderFactory.createEmptyBorder(0, 1, 1, 1))

### First tab: errors selection and download ###########################
        #ComboBox with tools names
        self.toolsComboModel = DefaultComboBoxModel()
        for tool in tools:
            self.add_data_to_models(tool)
        self.toolsCombo = JComboBox(self.toolsComboModel,
                                    actionListener=ToolsComboListener(app))
        renderer = ToolsComboRenderer(self.app)
        renderer.setPreferredSize(Dimension(20, 20))
        self.toolsCombo.setRenderer(renderer)
        self.toolsCombo.setToolTipText(app.strings.getString("Select_a_quality_assurance_tool"))

        #ComboBox with categories names ("views"), of the selected tool
        self.viewsCombo = JComboBox(actionListener=ViewsComboListener(app))
        self.viewsCombo.setToolTipText(app.strings.getString("Select_a_category_of_error"))

        #Popup for checks table
        self.checkPopup = JPopupMenu()
        #add favourite check
        self.menuItemAdd = JMenuItem(self.app.strings.getString("Add_to_favourites"))
        self.menuItemAdd.setIcon(ImageIcon(File.separator.join([self.app.SCRIPTDIR,
                                                                "tools",
                                                                "data",
                                                                "Favourites",
                                                                "icons",
                                                                "tool_16.png"])))
        self.menuItemAdd.addActionListener(PopupActionListener(self.app))
        self.checkPopup.add(self.menuItemAdd)
        #remove favourite check
        self.menuItemRemove = JMenuItem(self.app.strings.getString("Remove_from_favourites"))
        self.menuItemRemove.setIcon(ImageIcon(File.separator.join([self.app.SCRIPTDIR,
                                                                   "tools",
                                                                   "data",
                                                                   "Favourites",
                                                                   "icons",
                                                                   "black_tool_16.png"])))
        self.menuItemRemove.addActionListener(PopupActionListener(self.app))
        self.checkPopup.add(self.menuItemRemove)
        #Help link for selected check
        self.menuItemHelp = JMenuItem(self.app.strings.getString("check_help"))
        self.menuItemHelp.setIcon(ImageIcon(File.separator.join([self.app.SCRIPTDIR,
                                                                 "images",
                                                                 "icons",
                                                                 "info_16.png"])))
        self.checkPopup.add(self.menuItemHelp)
        self.menuItemHelp.addActionListener(PopupActionListener(self.app))

        #Table with checks of selected tool and view
        self.checksTable = JTable()
        self.iconrenderer = IconRenderer()
        self.iconrenderer.setHorizontalAlignment(JLabel.CENTER)
        scrollPane = JScrollPane(self.checksTable)
        self.checksTable.setFillsViewportHeight(True)

        tableSelectionModel = self.checksTable.getSelectionModel()
        tableSelectionModel.addListSelectionListener(ChecksTableListener(app))

        self.checksTable.addMouseListener(ChecksTableClickListener(app,
            self.checkPopup,
            self.checksTable))

        #Favourite area status indicator
        self.favAreaIndicator = JLabel()
        self.update_favourite_zone_indicator()
        self.favAreaIndicator.addMouseListener(FavAreaIndicatorListener(app))

        #label with OSM id of the object currently edited and number of
        #errors still to review
        self.checksTextFld = JTextField("",
                                        editable=0,
                                        border=None,
                                        background=None)

        #checks buttons
        btnsIconsDir = File.separator.join([app.SCRIPTDIR, "images", "icons"])
        downloadIcon = ImageIcon(File.separator.join([btnsIconsDir, "download.png"]))
        self.downloadBtn = JButton(downloadIcon,
                                   actionPerformed=app.on_downloadBtn_clicked,
                                   enabled=0)
        startIcon = ImageIcon(File.separator.join([btnsIconsDir, "start_fixing.png"]))
        self.startBtn = JButton(startIcon,
                                actionPerformed=app.on_startBtn_clicked,
                                enabled=0)
        self.downloadBtn.setToolTipText(app.strings.getString("Download_errors_in_this_area"))
        self.startBtn.setToolTipText(app.strings.getString("Start_fixing_the_selected_errors"))

        #tab layout
#.........這裏部分代碼省略.........
開發者ID:floscher,項目名稱:qat_script,代碼行數:103,代碼來源:QatDialog.py


注:本文中的javax.swing.JMenuItem.setIcon方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。