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


Python JLabel.setIcon方法代码示例

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


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

示例1: getContentPane

# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setIcon [as 别名]
def getContentPane():
    global contentPane
    global REMAP_WIDTH
    global REMAP_HEIGHT
    global MARGIN
    if not contentPane:
        global mainScreen
        global mainScreenImg
        mainScreen = JLabel()

        cursorImg = BufferedImage(16,16,BufferedImage.TYPE_INT_ARGB)
        blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, Point(0,0), "blank cursor")
        mainScreen.setCursor(blankCursor)
        mainScreen.setPreferredSize(
                Dimension(REMAP_WIDTH + MARGIN, REMAP_HEIGHT + MARGIN))
        mainScreen.setText("main screen!")
        image = BufferedImage(REMAP_WIDTH + MARGIN, REMAP_HEIGHT + MARGIN
                , BufferedImage.TYPE_INT_ARGB)
        g = image.createGraphics()
        g.setColor(Color.BLACK)
        g.fillRect(0, 0, REMAP_WIDTH + MARGIN, REMAP_HEIGHT + MARGIN)
        g.setColor(Color.WHITE)
        g.setFont(Font("Serif", Font.BOLD, 20))
        g.drawString("Cursor will display on your device.", 50, 30)
        mainScreenImg = image
        mainScreen.setIcon(swing.ImageIcon(image))

        mouseListener = ScrMouseListener()
        mainScreen.addMouseListener(mouseListener)
        mainScreen.addMouseMotionListener(mouseListener)
        mainScreen.addMouseWheelListener(mouseListener)

        keyListener = ScrKeyListener()
        mainScreen.addKeyListener(keyListener)
        
        mainScreen.setFocusable(True)

        scrPanel = JPanel()
        scrPanel.setLayout(BoxLayout(scrPanel, BoxLayout.Y_AXIS))
        scrPanel.add(mainScreen)


        contentPane = JPanel()
        contentPane.setLayout(BorderLayout())
        contentPane.add(scrPanel, BorderLayout.WEST)
#        contentPAne.add(controlPanel(). BorderLayout.EAST)

    return contentPane
开发者ID:JeKim,项目名称:MonkeyPySon,代码行数:50,代码来源:monkeypyson.py

示例2: C5Panel

# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setIcon [as 别名]
class C5Panel(JPanel):
	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')
	
	
	def cbCB(self,e):
		try:
			item=self.cb.getSelectedItem()
			if DEBUG:print item
			if self.hostname[0:7]=='http://':
				self.img=ImageIO.read(URL(self.hostname+'/static/sightreadingtrainer/img/'+item))
			else:
				self.img=ImageIO.read(File(self.hostname+'img/'+item))
			
			if DEBUG:print self.img
			icon=ImageIcon(self.img)
			self.label.setIcon(icon)
		except Exception,e:
			if DEBUG:print e
开发者ID:asymptopia,项目名称:sightreadingtrainer,代码行数:47,代码来源:c5panel.py

示例3: build_help_label

# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setIcon [as 别名]
 def build_help_label(self, tooltip_text):
     icon = ImageIcon(find_image_resource('smallhelp'))
     label = JLabel()
     label.setIcon(icon)
     label.setToolTipText(tooltip_text)
     return label
开发者ID:oracc,项目名称:nammu,代码行数:8,代码来源:NewAtfView.py

示例4: QatDialog

# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel 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

示例5: BurpExtender

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

#.........这里部分代码省略.........
                        <a href="javascript:divHideShow('Table_%s_Command_06');" style="color:#191970">OPEN / CLOSE >>></a>
                        </div>

                        <div id="Table_%s_Command_06" style="display: none;margin-top: 25px;">
                        %s
                        <b>
                                            </td>
                                        </tr>

                                                        <tr>
                                            <td>
                        <div style="font-size: 16px;font-weight: bold;">
                        <span style="color:#000000">Images</span> 
                        <a href="javascript:divHideShow('Table_%s_Command_07');" style="color:#191970">OPEN / CLOSE >>></a>
                        </div>

                        <div id="Table_%s_Command_07" style="display: none;margin-top: 25px;">
                        %s
                        <b>
                    </td>
                </tr>
            </table>
        </div><br><br>""" % (name,number,number,severity,number,number,description,number,number,mitigation,number,number,request,number,number,response,number,number,images)

    def clearVulnerabilityTab(self, rmVuln=True):
        if rmVuln:
            self.vulnName.setText("")
        self.descriptionString.setText("")
        self.mitigationStr.setText("")
        self.colorCombo.setSelectedIndex(0)
        self.threatLevel.setSelectedIndex(0)
        self.screenshotsList.clear()
        self.addButton.setText("Add")
        self.firstPic.setIcon(None)

    def saveRequestResponse(self, type, requestResponse, vulnName):
        path = self.getVulnReqResPath(type,vulnName)
        f = open(path, 'wb')
        f.write(requestResponse)
        f.close()

    def openProj(self, event):
        os.system('explorer ' + self.projPath.getText())

    def getVulnReqResPath(self, requestOrResponse, vulnName):
        return self.getCurrentProjPath() + "/" + self.clearStr(vulnName) + "/"+requestOrResponse+"_" + self.clearStr(vulnName)

    def htmlEscape(self,data):
        return data.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace('"', '&quot;').replace("'", '&#39;')

    def generateReportFromDocxTemplate(self, zipname, newZipName, filename):      
        newZipName = self.getCurrentProjPath() + "/" + newZipName
        with zipfile.ZipFile(zipname, 'r') as zin:
            with zipfile.ZipFile(newZipName, 'w') as zout:
                zout.comment = zin.comment
                for item in zin.infolist():
                    if item.filename != filename:
                        zout.writestr(item, zin.read(item.filename))
                    else:
                        xml_content = zin.read(item.filename)
                        result = re.findall("(.*)<w:body>(?:.*)<\/w:body>(.*)",xml_content)[0]
                        newXML = result[0]
                        templateBody = re.findall("<w:body>(.*)<\/w:body>", xml_content)[0]
                        newBody = ""

                        for i in range(0,self._log.size()):
开发者ID:anhnt4288,项目名称:PT-Manager,代码行数:70,代码来源:PTManager.py

示例6: AlbumArt

# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setIcon [as 别名]
class AlbumArt(SongContextView):

    def __init__(self):
        # set up the layout
        self.__component = JPanel(GridBagLayout())
        self.__image = JLabel()
        self.__album = JLabel()
        self.__artist = JLabel()
        self.__application = None
        self.__image.setVerticalAlignment(SwingConstants.TOP)
        self.__album.setVerticalAlignment(SwingConstants.TOP)
        self.__artist.setVerticalAlignment(SwingConstants.TOP)
        gbc = GridBagConstraints()
        gbc.fill = GridBagConstraints.VERTICAL
        gbc.anchor = GridBagConstraints.NORTHWEST
        gbc.gridx = 0
        gbc.gridy = 0
        gbc.weighty = 2
        gbc.gridheight = 2
        self.__component.add(self.__image, gbc)
        gbc.fill = GridBagConstraints.HORIZONTAL
        gbc.anchor = GridBagConstraints.NORTHWEST
        gbc.gridx = 1
        gbc.gridy = 0
        gbc.gridheight = 1
        gbc.weighty = 0
        gbc.insets = Insets(0, 10, 0, 10)
        self.__component.add(self.__album, gbc)
        gbc.fill = GridBagConstraints.BOTH
        gbc.anchor = GridBagConstraints.NORTHWEST
        gbc.gridx = 1
        gbc.gridy = 1
        gbc.weightx = 2
        gbc.weighty = 2
        gbc.gridheight = 1
        self.__component.add(self.__artist, gbc)


    # Is called when this view should be updated.
    def update(self, song):
        # check for None!
        if (song != None):
            albumArt = song.getImage()
            if (albumArt != None):
                self.__image.setIcon(ImageIcon(ImageScaler.scale(albumArt, 300, 300)));
            else:
                self.__image.setIcon(None);

            self.__album.setText("<html><font size='+3'>" + song.getAlbum() + "</font></html>");
            self.__artist.setText("<html><font color='#555555' size='-1'>by " + song.getArtist() + "</font></html>");
        else:
            self.__image.setIcon(None);
            self.__album.setText(None);
            self.__artist.setText(None);



    # Every SongContextView needs to be accompanied by a
    # SongContextComponentShowHideAction.
    # Return the action's id here.
    def getShowHideActionId(self):
        return "jython.albumart.showhide"


    # The visual component to be shown in this view.
    def getComponent(self):
        return self.__component


    def setApplication(self, application):
        self.__application = application


    def getApplication(self):
        return self.__application


    def getId(self):
        return "jython.albumart"


    def init(self):
        pass

    def shutdown(self):
        pass
开发者ID:beatunes,项目名称:beaTlet-samples,代码行数:88,代码来源:AlbumArt.py


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