本文整理汇总了Python中javax.swing.JLabel.setText方法的典型用法代码示例。如果您正苦于以下问题:Python JLabel.setText方法的具体用法?Python JLabel.setText怎么用?Python JLabel.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JLabel
的用法示例。
在下文中一共展示了JLabel.setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addMetadata
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setText [as 别名]
def addMetadata(self, objectID, project, language):
"""
Add a JTable at the top of the object tab containing the metadata of
the object presented in that tab.
"""
metadataPanel = JPanel()
# TODO: Need to count protocols to set up Grid dimension
metadataPanel.setLayout(GridLayout(3, 2))
projectLabel = JLabel("Project: ")
projectValue = JLabel(project)
languageLabel = JLabel("Language: ")
languageValue = JLabel(language)
# If language code is in the settings, then display name instead
# of code
for lang, code in self.languages.iteritems():
if code == language:
languageValue.setText(lang)
# TODO Protocols not yet in parsed object
protocolsLabel = JLabel("ATF Protocols: ")
protocolsBox = JComboBox(self.protocols)
metadataPanel.add(projectLabel)
metadataPanel.add(projectValue)
metadataPanel.add(languageLabel)
metadataPanel.add(languageValue)
metadataPanel.add(protocolsLabel)
metadataPanel.add(protocolsBox)
# Add metadataPanel to object tab in main panel
self.objectTabs[objectID].add(metadataPanel)
示例2: StatusPanel
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setText [as 别名]
class StatusPanel(JPanel):
def __init__(self):
JPanel()
self.setLayout(GridLayout(1,1))
#self.add(JLabel('SELWB 1.0'))
self.statusLabel = JLabel('Idle', SwingConstants.CENTER)
self.statusLabel.setBackground(Color.GREEN)
self.statusLabel.setOpaque(True)
self.add(self.statusLabel)
def setStatus(self, str, bgColor = Color.GREEN):
self.statusLabel.setText(str)
self.statusLabel.setBackground(bgColor)
示例3: SummPanel
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setText [as 别名]
class SummPanel(JPanel):
def __init__(self, isTemporal):
self.isTemporal = isTemporal
JPanel()
self.setLayout(GridLayout(6,2))
self.add(JLabel('Total data'))
self.add(JLabel(''))
self.add(JLabel('# Pops' if not isTemporal else "# Gens"))
self.totalPops = JLabel('0', SwingConstants.RIGHT)
self.add(self.totalPops)
self.add(JLabel('# Loci'))
self.totalLoci = JLabel('0', SwingConstants.RIGHT)
self.add(self.totalLoci)
self.add(JLabel('Selected'))
self.add(JLabel(''))
self.add(JLabel('# Pops' if not isTemporal else "# Gens"))
self.selPops = JLabel('0', SwingConstants.RIGHT)
self.add(self.selPops)
self.add(JLabel('# Loci'))
self.selLoci = JLabel('0', SwingConstants.RIGHT)
self.add(self.selLoci)
def update(self, rec, popNames, remPops, remLoci):
total_pops = countPops(rec)
sel_pops = total_pops - len (remPops)
total_loci = len(rec.loci_list)
sel_loci = total_loci - len(remLoci)
self.totalPops.setText(str(total_pops))
self.selPops.setText(str(sel_pops))
self.totalLoci.setText(str(total_loci))
self.selLoci.setText(str(sel_loci))
示例4: getContentPane
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setText [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
示例5: LoadDialog
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setText [as 别名]
class LoadDialog(JDialog, ActionListener):
def __init__(self, frame, what):
JDialog.__init__(self,frame, what, False)
self.frame = frame
pane = self.getRootPane().getContentPane()
panel = JPanel()
panel.add(JLabel('Current population'))
self.status = JLabel(" ")
panel.add(self.status)
pane.add(panel)
self.pack()
self.show()
def update_status(self, curr):
self.status.setText("%d" % (curr,))
Thread.yield()
示例6: MenueFrame
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setText [as 别名]
class MenueFrame(object):
def __init__(self):
self.mainDir = ""
self.frame = JFrame("Dots Quality Check", size=(250,300))
self.frame.setLocation(20,120)
self.Panel = JPanel(GridLayout(0,1))
self.frame.add(self.Panel)
self.openNextButton = JButton('Open Next Random',actionPerformed=openRandom)
self.Panel.add(self.openNextButton)
self.saveButton = JButton('Save',actionPerformed=save)
self.saveButton.setEnabled(False)
self.Panel.add(self.saveButton)
self.cropButton = JButton('Crop values from here', actionPerformed=cropVals)
self.Panel.add(self.cropButton)
self.DiscardButton = JButton('Discard cell', actionPerformed=discardCell)
self.DiscardButton.setEnabled(True)
self.Panel.add(self.DiscardButton)
self.quitButton = JButton('Quit script',actionPerformed=quit)
self.Panel.add(self.quitButton)
annoPanel = JPanel()
#add gridlayout
wtRButton = JRadioButton("wt", actionCommand="wt")
defectRButton = JRadioButton("Defect", actionCommand="defect")
annoPanel.add(wtRButton)
annoPanel.add(defectRButton)
self.aButtonGroup = ButtonGroup()
self.aButtonGroup.add(wtRButton)
self.aButtonGroup.add(defectRButton)
self.Panel.add(annoPanel)
self.ProgBar = JProgressBar()
self.ProgBar.setStringPainted(True)
self.ProgBar.setValue(0)
self.Panel.add(self.ProgBar)
self.pathLabel = JLabel("-- No main directory chosen --")
self.pathLabel.setHorizontalAlignment( SwingConstants.CENTER )
self.Panel.add(self.pathLabel)
WindowManager.addWindow(self.frame)
self.show()
def show(self):
self.frame.visible = True
def getFrame(self):
return self.frame
def setSaveActive(self):
self.saveButton.setEnabled(True)
self.show()
def setSaveInactive(self):
self.saveButton.setEnabled(False)
self.show()
def setMainDir(self, path):
self.mainDir = path
self.pathLabel.setText("MainDir: " + os.path.basename(os.path.split(self.mainDir)[0]))
def getMainDir(self):
return self.mainDir
def setProgBarMax(self, maximum):
self.ProgBar.setMaximum(maximum)
def setProgBarVal(self, value):
self.ProgBar.setValue(value)
def close():
WindowManager.removeWindow(self.frame)
self.frame.dispose()
示例7: Demo
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setText [as 别名]
class Demo(JFrame, Runnable):
def __init__(self):
super(Demo, self).__init__()
self.initUI()
def initUI(self):
self.panel = JPanel(size=(50,50))
self.panel.setLayout(FlowLayout( ))
self.panel.setToolTipText("GPU Demo")
#TODO- change this so that it deletes itself when text is entered
self.textfield1 = JTextField('Smoothing Parameter',15)
self.panel.add(self.textfield1)
joclButton = JButton("JOCL",actionPerformed=self.onJocl)
joclButton.setBounds(100, 500, 100, 30)
joclButton.setToolTipText("JOCL Button")
self.panel.add(joclButton)
javaButton = JButton("Java",actionPerformed=self.onJava)
javaButton.setBounds(100, 500, 100, 30)
javaButton.setToolTipText("Java Button")
self.panel.add(javaButton)
qButton = JButton("Quit", actionPerformed=self.onQuit)
qButton.setBounds(200, 500, 80, 30)
qButton.setToolTipText("Quit Button")
self.panel.add(qButton)
newImage = ImageIO.read(io.File(getDataDir() + "input.png"))
resizedImage = newImage.getScaledInstance(600, 600,10)
newIcon = ImageIcon(resizedImage)
label1 = JLabel("Input Image",newIcon, JLabel.CENTER)
label1.setVerticalTextPosition(JLabel.TOP)
label1.setHorizontalTextPosition(JLabel.RIGHT)
label1.setSize(10,10)
label1.setBackground(Color.orange)
self.panel.add(label1)
self.getContentPane().add(self.panel)
self.clockLabel = JLabel()
self.clockLabel.setSize(1,1)
self.clockLabel.setBackground(Color.orange)
self.clockLabel.setVerticalTextPosition(JLabel.BOTTOM)
self.clockLabel.setHorizontalTextPosition(JLabel.LEFT)
myClockFont = Font("Serif", Font.PLAIN, 50)
self.clockLabel.setFont(myClockFont)
self.panel.add(self.clockLabel)
self.setTitle("Structure-oriented smoothing OpenCL Demo")
self.setSize(1200, 700)
self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
self.setLocationRelativeTo(None)
self.setVisible(True)
def onQuit(self, e): System.exit(0)
def onJocl(self, e):
self.clockLabel.setText('running')
self.started = Calendar.getInstance().getTimeInMillis();
#print self.textfield1.getText()
#time.sleep(5)
iters = toInt(self.textfield1.getText())
jocl_smoother(iters)
elapsed = Calendar.getInstance().getTimeInMillis() - self.started;
self.clockLabel.setText( 'JOCL Elapsed: %.2f seconds' % ( float( elapsed ) / 1000.0 ) )
def onJava(self, e):
self.clockLabel.setText('running')
self.started = Calendar.getInstance().getTimeInMillis();
#print self.textfield1.getText()
#time.sleep(5)
iters = toInt(self.textfield1.getText())
java_smoother(iters)
elapsed = Calendar.getInstance().getTimeInMillis() - self.started;
self.clockLabel.setText( 'Java Elapsed: %.2f seconds' % ( float( elapsed ) / 1000.0 ) )
示例8: Pipeline
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setText [as 别名]
class Pipeline():
def __init__(self):
#If a swing interface is asked for this will be the JFrame.
self.frame = None
#Keeps track of the number of queries processed.
self.jobCount = 0
#Keeps track of the query currently being processed.
self.currentJob = ""
#Keeps track of the massage to be displayed.
self.message = 0
#Messages to be displayed at each stage in the processing of a single query.
self.messages = ["Searching for genes via genemark",
"Extending genes found via genemark",
"Searching for intergenic genes",
"Removing overlapping genes",
"Searching for promoters",
"Using transterm to find terminators",
"Removing transcription signals which conflict with genes",
"Using tRNAscan to find transfer RNAs",
"Writing Artemis file",
"Writing summary .xml, .html, and .xls files"]
self.exception = None
def initializeDisplay(self, queries, swing):
"""
queries: A list of the fasts files to be processed.
swing: If true then updates about progress will be displayed in a swing window, otherwise they will be written to stdout.
Initializes the interface for telling the user about progress in the pipeline. Queries is used to count the
number of queries the pipeline will process and to size the swing display(if it is used) so that text
isn't cutoff at the edge of the window. The swing display is setup if swing is true.
"""
self.numJobs = len(queries)
if swing:
self.frame = JFrame("Neofelis")
self.frame.addWindowListener(PipelineWindowAdapter(self))
contentPane = JPanel(GridBagLayout())
self.frame.setContentPane(contentPane)
self.globalLabel = JLabel(max(queries, key = len))
self.globalProgress = JProgressBar(0, self.numJobs)
self.currentLabel = JLabel(max(self.messages, key = len))
self.currentProgress = JProgressBar(0, len(self.messages))
self.doneButton = JButton(DoneAction(self.frame))
self.doneButton.setEnabled(False)
constraints = GridBagConstraints()
constraints.gridx, constraints.gridy = 0, 0
constraints.gridwidth, constraints.gridheight = 1, 1
constraints.weightx = 1
constraints.fill = GridBagConstraints.HORIZONTAL
contentPane.add(self.globalLabel, constraints)
constraints.gridy = 1
contentPane.add(self.globalProgress, constraints)
constraints.gridy = 2
contentPane.add(self.currentLabel, constraints)
constraints.gridy = 3
contentPane.add(self.currentProgress, constraints)
constraints.gridy = 4
constraints.weightx = 0
constraints.fill = GridBagConstraints.NONE
constraints.anchor = GridBagConstraints.LINE_END
contentPane.add(self.doneButton, constraints)
self.frame.pack()
self.frame.setResizable(False)
self.globalLabel.setText(" ")
self.currentLabel.setText(" ")
self.frame.setLocationRelativeTo(None)
self.frame.setVisible(True)
def updateProgress(self, job):
"""
query: Name of the query currently being processed.
This function use used for updating the progress shown in the interface. If job is not equal to currentJob then
global progress is incremented and shown and the currentProgress is reset and shown. If job is equal to currentJob
then the globalProgress does not change and currentProgress is increased.
"""
if self.exception:
raise self.exception
if self.frame:
if job != self.currentJob:
self.currentProgress.setValue(self.currentProgress.getMaximum())
self.globalLabel.setText(job)
self.globalProgress.setValue(self.jobCount)
print "Processing %s, %.2f%% done" % (job, 100.0*self.jobCount/self.numJobs)
self.jobCount += 1
self.currentJob = job
self.message = -1
self.message += 1
print " %s, %.2f%% done" % (self.messages[self.message], 100.0*self.message/len(self.messages))
self.currentProgress.setValue(self.message)
self.currentLabel.setText(self.messages[self.message])
else:
if job != self.currentJob:
print "Processing %s, %.2f%% done" % (job, 100.0*self.jobCount/self.numJobs)
self.jobCount += 1
#.........这里部分代码省略.........
示例9: FilamentGame_ModelEditor
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setText [as 别名]
class FilamentGame_ModelEditor(EditorExtension, JPanel, MouseListener, MouseMotionListener):
def getExtensionName(self):
return "Filament Model Tool"
def initializeExtension(self, manager):
self.manager = manager
self.frame = JFrame(self.getExtensionName())
self.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
# instance setup
self.state = State.NOTHING
self.entity = Entity()
# Setupgui
self.setupGui()
self.addMouseListener(self)
self.addMouseMotionListener(self)
self.setPreferredSize(Dimension(500, 500))
self.frame.pack()
self.frame.setResizable(False)
self.frame.setVisible(True)
self.cameraPos = [0, 0]
def setupGui(self):
cPanel = JPanel()
# Draw Shape Button
self.drawShapeButton = JButton("Draw", actionPerformed=self.drawShapeButtonAction)
cPanel.add(self.drawShapeButton)
drawShapeButton = JButton("Clear", actionPerformed=self.clearShapeButtonAction)
cPanel.add(drawShapeButton)
# Label
self.infoLabel = JLabel("Shape Editor")
cPanel.add(self.infoLabel)
self.frame.add(BorderLayout.NORTH, cPanel)
self.frame.add(BorderLayout.CENTER, self)
def entitySelected(self, entity):
self.entity = entity
self.repaint()
def sceneChanged(self, scene):
self.scene = scene
self.entity = Entity()
self.repaint()
# BUTTONS
def drawShapeButtonAction(self, e):
if self.state == State.NOTHING:
self.state = State.DRAW_SHAPE
self.infoLabel.setText("Click to Draw Shape")
self.drawShapeButton.setText("Stop Drawing")
elif self.state != State.NOTHING:
self.state = State.NOTHING
self.infoLabel.setText("")
self.drawShapeButton.setText("Draw")
self.revalidate()
def clearShapeButtonAction(self, e):
if self.state != State.NOTHING:
self.drawShapeButtonAction(e)
self.state = State.NOTHING
polygon = self.entity.getModel().pol
polygon.reset()
self.repaint()
# DRAWING
def paintComponent(self, g):
self.super__paintComponent(g)
g.scale(1, -1)
g.translate(-self.cameraPos[0] + self.getWidth() / 2, -self.cameraPos[1] - self.getHeight() / 2)
self.drawGrid(g)
polygon = self.entity.getModel().pol
x = []
y = []
g.setColor(Color.BLACK)
for i in range(polygon.npoints):
x = x + [int(polygon.xpoints[i])]
y = y + [int(polygon.ypoints[i])]
g.drawRect(int(polygon.xpoints[i]) - 2, int(polygon.ypoints[i]) - 2, 4, 4)
g.fillPolygon(x, y, polygon.npoints)
def drawGrid(self, g):
g.setColor(Color.RED)
g.drawLine(50, 0, -50, 0)
g.drawLine(0, 50, 0, -50)
# MOUSE LISTENER
def mouseCicked(self, e):
return
def mouseEntered(self, e):
return
def mouseExited(self, e):
return
#.........这里部分代码省略.........
示例10: BurpExtender
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setText [as 别名]
#.........这里部分代码省略.........
index = 0
listeners = DefaultComboBoxModel()
while (("proxy.listener" + str(index)) in config):
listenerItem = config["proxy.listener" + str(index)]
listenerItems = listenerItem.split(".")
if (listenerItems[0] == "1"):
address = ".".join(listenerItems[2][1:].split("|"))
if (len(address) == 0):
address = "127.0.0.1"
listeners.addElement(address + " : " + listenerItems[1])
index = index + 1
self._listenersCombo.setModel(listeners)
return;
#
# implement button actions
#
def startToggled(self, ev):
if (self._startButton.getModel().isSelected()):
try:
os.chdir(sys.path[0] + os.sep + "riacrawler" + os.sep + "scripts")
except Exception as e:
print >> sys.stderr, "RIA crawler scripts loading error", "I/O error({0}): {1}".format(e.errno, e.strerror)
self._startButton.setSelected(False)
return
phantomJsPath = self._phantomJsPathField.text
target = self._addressTextField.text
config = "crawler.config"
if (self._configFile):
config = self._configFile
listenerAddress = self._listenersCombo.getSelectedItem().replace(" ", "")
p = Popen("{0} --proxy={3} main.js --target={1} --config={2}".format(phantomJsPath, target, config, listenerAddress), shell=True)
self._running = True
self._requestsMadeInfo.setText("")
self._statesFoundInfo.setText("")
self._commandClient.startCrawling()
else:
if (self._running):
self._commandClient.stopCrawling()
self._running = False
def syncCrawlingState(self, result):
print "RIA crawling state: ", result
self._requestsMadeInfo.setText(str(result["requests_made"]))
self._statesFoundInfo.setText(str(result["states_detected"]))
if (result["running"] == False):
self._commandClient.stopCrawling()
self._running = False
self._startButton.setSelected(False)
def loadConfigClicked(self, ev):
openFile = JFileChooser();
openFile.showOpenDialog(None);
self._configFile = openFile.getSelectedFile()
#
# implement DocumentListener for _addressTextField
#
def removeUpdate(self, ev):
self.updateStartButton()
def insertUpdate(self, ev):
self.updateStartButton()
def updateStartButton(self):
self._startButton.setEnabled(len(self._addressTextField.text) > 0)
#
# implement IContextMenuFactory
#
def createMenuItems(self, contextMenuInvocation):
menuItemList = ArrayList()
context = contextMenuInvocation.getInvocationContext()
if (context == IContextMenuInvocation.CONTEXT_MESSAGE_VIEWER_REQUEST or context == IContextMenuInvocation.CONTEXT_MESSAGE_EDITOR_REQUEST or
context == IContextMenuInvocation.CONTEXT_PROXY_HISTORY or context == IContextMenuInvocation.CONTEXT_TARGET_SITE_MAP_TABLE):
self._contextMenuData = contextMenuInvocation.getSelectedMessages()
menuItemList.add(JMenuItem("Send to Phantom RIA Crawler", actionPerformed = self.menuItemClicked))
return menuItemList
def menuItemClicked(self, event):
if (self._running == True):
self._callbacks.issueAlert("Can't set data to Phantom RIA Crawler: crawling is running already.")
return;
dataIsSet = False;
for message in self._contextMenuData:
request = self._helpers.analyzeRequest(message)
url = request.getUrl().toString()
print url
if (url):
dataisSet = True;
self._addressTextField.setText(url)
示例11: getIp
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setText [as 别名]
#.........这里部分代码省略.........
panel3.add(self.chkbox2)
panel3.add(self.chkbox3)
panel3.add(self.chkbox4)
panel3.add(self.chkbox5)
panel3.add(self.chkbox6)
panel3.add(button3)
panel3.add(self.label4)
panel3.add(JScrollPane(self.textArea3))
#
tabPane.addTab("Sebsitive File", panel3)
#
frame.add(tabPane)
frame.setVisible(True)
#用来在第一个TAB打印nmap信息
def setResult(self,text):
self.textArea.append(text)
#用来在第二个TAB打印获得信息
def setResult2(self,textId, textDomain, textIp):
text = str(textId) + "----------------" + textDomain + "----------------" + str(textIp) + os.linesep
self.textArea2.append(text)
#self.textArea2.append("----------------------------------------" + os.linesep)
#用来在第三个TAB打印文件扫描的结果
def setResult3(self, theMess01):
self.textArea3.append(theMess01)
def setLabel(self, a, b):
hg = str(a) + "/" + str(b)
self.label4.setText(hg)
#C段扫描的主引擎
def cNmapScan(self, event):
self.textArea.setText("")
#-------------------------------------------------------------------------------
def ipRange(ipaddr):
"""
Creates a generator that iterates through all of the IP addresses.
The range can be specified in multiple formats.
"192.168.1.0-192.168.1.255" : beginning-end
"192.168.1.0/24" : CIDR
"192.168.1.*" : wildcard
"""
def ipaddr_to_binary(ipaddr):
"""
A useful routine to convert a ipaddr string into a 32 bit long integer
"""
# from Greg Jorgensens python mailing list message
q = ipaddr.split('.')
return reduce(lambda a,b: long(a)*256 + long(b), q)
#-------------------------------------------------------------------------------
def binary_to_ipaddr(ipbinary):
"""
Convert a 32-bit long integer into an ipaddr dotted-quad string
"""
# This one is from Rikard Bosnjakovic
示例12: MenueFrame
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setText [as 别名]
class MenueFrame(JFrame, ActionListener, WindowFocusListener): # should extend JFrame
def __init__(self):
self.mainDir = ""
self.setTitle("Dots Quality Check")
self.setSize(250, 300)
self.setLocation(20,120)
self.addWindowFocusListener(self)
self.Panel = JPanel(GridLayout(0,1))
self.add(self.Panel)
self.openNextButton = JButton("Open Next Random", actionPerformed=self.openRandom)
self.Panel.add(self.openNextButton)
self.saveButton = JButton("Save", actionPerformed=self.save, enabled=False)
self.Panel.add(self.saveButton)
self.cropButton = JButton("Crop values from here", actionPerformed=self.cropVals)
self.Panel.add(self.cropButton)
self.DiscardButton = JButton("Discard cell", actionPerformed=self.discardCell)
self.Panel.add(self.DiscardButton)
self.quitButton = JButton("Quit script",actionPerformed=self.quit)
self.Panel.add(self.quitButton)
annoPanel = JPanel()
#add gridlayout
self.wtRButton = JRadioButton("wt", actionCommand="wt")
self.wtRButton.addActionListener(self)
self.defectRButton = JRadioButton("Defect", actionCommand="defect")
self.defectRButton.addActionListener(self)
annoPanel.add(self.wtRButton)
annoPanel.add(self.defectRButton)
self.aButtonGroup = ButtonGroup()
self.aButtonGroup.add(self.wtRButton)
self.aButtonGroup.add(self.defectRButton)
self.Panel.add(annoPanel)
self.ProgBar = JProgressBar()
self.ProgBar.setStringPainted(True)
self.ProgBar.setValue(0)
self.Panel.add(self.ProgBar)
self.pathLabel = JLabel("-- No main directory chosen --")
self.pathLabel.setHorizontalAlignment( SwingConstants.CENTER )
self.Panel.add(self.pathLabel)
WindowManager.addWindow(self)
self.show()
# - - - - B U T T O N M E T H O D S - - - -
# - - - - - - - - - - - - - - - - - - - - - - -
def openRandom(self, event): # when click here: get random cell and meas.measure(csv, tif, savePath)
if self.mainDir == "":
self.mainDir = DirectoryChooser("Random QC - Please choose main directory containing ctrl and test folders").getDirectory()
self.pathLabel.setText("MainDir: " + os.path.basename(os.path.split(self.mainDir)[0]))
try:
# should be complete disposal!
self.cT.closeWindows()
finally:
inFiles = glob.glob(os.path.join(self.mainDir, "*", G_OPENSUBDIR, "val_*.csv")) # glob.glob returns list of paths
uncheckedCells = [cell(csvPath) for csvPath in inFiles if cell(csvPath).processed == False]
if len(uncheckedCells) > 0:
self.cell = random.choice(uncheckedCells)
#update progressbar
self.ProgBar.setMaximum(len(inFiles)-1)
self.ProgBar.setValue(len(inFiles)-len(uncheckedCells))
# open imp and resultstable
self.cT = correctionTable(self.cell, self) #self, openPath_csv, mF
self.RBActionListener.setCell(self.cell)
# delete previous Radiobutton annotation
self.wtRButton.setSelected(False)
self.defectRButton.setSelected(True)
else:
print "All cells measured!"
def save(self, event):
savepath = self.cell.getQcCsvPath()
anaphase = self.cell.getAnOn()
timeInterval = self.cT.getImp().getCalibration().frameInterval
annotation = self.getAnnotation()
position = str(self.cell.position)
cellIndex = str(self.cell.cellNo)
if not os.path.exists(os.path.split(savepath)[0]): # check if save folder present.
os.makedirs(os.path.split(savepath)[0]) # create save folder, if not present
f = open(savepath, "w")
# Position Cell Phenotype Frame Time AnOn Distance ch0x ch0y ch0z ch0vol ch1x ch1y ch1z ch1vol
f.write("Position,Cell,Phenotype,Frame,Time,Anaphase,Distance,ch0x,ch0y,ch0z,ch0vol,ch1x,ch1y,ch1z,ch1vol\n")
for i in range(self.cT.getLineCount()):
frame, distance, a = self.cT.getLine(i).split("\t")
corrFrame = str(int(frame)-int(anaphase))
time = "%.f" % (round(timeInterval) * int(corrFrame))
if distance == "NA":
ch0x, ch0y, ch0z, ch0vol, ch1x, ch1y, ch1z, ch1vol = ("NA," * 7 + "NA\n").split(",")
else:
ch0x, ch0y, ch0z, ch0vol, ch1x, ch1y, ch1z, ch1vol = self.cT.getXYZtable()[i]
f.write(position+","+cellIndex+","+annotation+","+corrFrame+","+time+","+anaphase+","+distance+","+ch0x+","+ch0y+","+ch0z+","+ch0vol+","+ch1x+","+ch1y+","+ch1z+","+ch1vol)
f.close()
print "Successfully saved!"
def cropVals(self, event): #"this function deletes all values with frame > current cursor"
for line in range(self.cT.getSelectionEnd(), self.cT.getLineCount(), 1):
#.........这里部分代码省略.........
示例13: Config
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setText [as 别名]
#.........这里部分代码省略.........
labels.add(clear_butt)
labels.add(spider_butt)
labels.add(JLabel(""))
labels.add(save_butt)
labels.add(rest_butt)
labels.add(load_plug_butt)
# Tool tips!
self.delim.setToolTipText("Use to manipulate the final URL. "
"See About tab for example.")
self.ext_white_list.setToolTipText("Define a comma delimited list of"
" file extensions to parse. Use *"
" to parse all files.")
self.url.setToolTipText("Enter the target URL")
checkbox.setToolTipText("Parse files line by line using plugins"
" to enumerate language/framework specific"
" endpoints")
parse_butt.setToolTipText("Attempt to enumerate application endpoints")
clear_butt.setToolTipText("Clear status window and the parse results")
spider_butt.setToolTipText("Process discovered endpoints")
save_butt.setToolTipText("Saves the current config settings")
rest_butt.setToolTipText("<html>Restores previous config settings:"
"<br/>-Input Directory<br/>-String Delim"
"<br/>-Ext WL<br/>-URL<br/>-Plugins")
source_butt.setToolTipText("Select the application's "
"source directory or file to parse")
self.path_vars.setToolTipText("Supply a JSON object with values"
"for dynamically enumerated query"
"string variables")
return labels
def set_url(self, menu_url):
"""Changes the configuration URL to the one from the menu event"""
self.url.setText(menu_url)
# Event functions
def set_parse(self, event):
"""
Handles the click event from the UI checkbox
to attempt code level parsing
"""
self.parse_files = not self.parse_files
if self.parse_files:
if not self.loaded_plugins:
self._plugins_missing_warning()
def restore(self, event):
"""Attempts to restore the previously saved configuration."""
jdump = None
try:
jdump = loads(self._callbacks.loadExtensionSetting("config"))
except Exception as exc: # Generic exception thrown directly to user
self.update_scroll(
"[!!] Error during restore!\n\tException: %s" % str(exc))
if jdump is not None:
self.url.setText(jdump.get('URL'))
# self.cookies.setText(jdump.get('Cookies'))
# self.headers.setText(jdump.get("Headers"))
ewl = ""
for ext in jdump.get('Extension Whitelist'):
ewl += ext + ", "
self.ext_white_list.setText(ewl[:-2])
self.delim.setText(jdump.get('String Delimiter'))
self.source_input = jdump.get("Input Directory")
self.config['Plugin Folder'] = jdump.get("Plugin Folder")
if (self.config['Plugin Folder'] is not None and
示例14: EmployeeDetails
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setText [as 别名]
class EmployeeDetails(JPanel):
def __init__(self, employees):
JPanel.__init__(self, preferredSize=(400, 200))
layout = BoxLayout(self, BoxLayout.Y_AXIS)
self.setLayout(layout)
self._employees = employees
employees.add_change_listener(self)
self._create_status_label()
self._create_name_editor()
self._create_start_date_editor()
self._create_save_button()
self._adding_employee = False
def _create_status_label(self):
self._status_label = JLabel(name='status_label',
font=Font(Font.SANS_SERIF, Font.PLAIN, 11))
self.add(self._status_label)
self._add_with_padding(self._status_label, 5)
def _create_name_editor(self):
self.add(JLabel(text='Employee Name:'))
self._name_editor = FixedHeightTextField('name_input')
self._add_with_padding(self._name_editor, 5)
def _create_start_date_editor(self):
self.add(JLabel(text='Start Date (yyyy-mm-dd):'))
self._start_date_editor = FixedHeightTextField('start_input')
self._add_with_padding(self._start_date_editor, 5)
def _create_save_button(self):
self._save_button = JButton('Save', name='save_button', visible=False)
self._save_button.addActionListener(ListenerFactory(ActionListener,
self._save_button_pushed))
self._add_with_padding(self._save_button, 5)
def _add_with_padding(self, component, padding):
self.add(component)
self.add(Box.createRigidArea(Dimension(0, padding)))
def show_employee(self, employee):
self._name_editor.setText(employee.name)
self._start_date_editor.setText(str(employee.startdate))
self._name_editor.setEditable(False)
self._start_date_editor.setEditable(False)
self._save_button.setVisible(False)
if self._adding_employee:
self._adding_employee = False
else:
self._status_label.setText('')
def edit_new_employee(self):
self._name_editor.setText('')
self._start_date_editor.setText('')
self._name_editor.setEditable(True)
self._start_date_editor.setEditable(True)
self._save_button.setVisible(True)
self._adding_employee = True
def _save_button_pushed(self, event):
self._employees.add(self._name_editor.getText(),
self._start_date_editor.getText())
def employee_added(self, employee):
self._status_label.setForeground(Color.BLACK)
self._status_label.setText("Employee '%s' was added successfully." % employee.name)
self._save_button.setVisible(False)
def adding_employee_failed(self, reason):
self._status_label.setForeground(Color.RED)
self._status_label.setText(reason)
示例15: EmployeeDetails
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setText [as 别名]
class EmployeeDetails(JPanel):
def __init__(self, employees, dateprovider):
JPanel.__init__(self, preferredSize=(400, 200))
layout = BoxLayout(self, BoxLayout.Y_AXIS)
self.setLayout(layout)
self._employees = employees
self._dateprovider = dateprovider
employees.add_change_listener(self)
self._create_status_label()
self._create_name_editor()
self._create_start_date_editor()
self._create_save_button()
self._create_vacation_display()
self._adding_employee = False
def _create_status_label(self):
self._status_label = JLabel(name="status_label", font=Font(Font.SANS_SERIF, Font.PLAIN, 11))
self.add(self._status_label)
self._add_with_padding(self._status_label, 5)
def _create_name_editor(self):
self.add(JLabel(text="Employee Name:"))
self._name_editor = FixedHeightTextField("name_input")
self._add_with_padding(self._name_editor, 5)
def _create_start_date_editor(self):
self.add(JLabel(text="Start Date (yyyy-mm-dd):"))
self._start_date_editor = FixedHeightTextField("start_input")
self._add_with_padding(self._start_date_editor, 5)
def _create_save_button(self):
self._save_button = JButton("Save", name="save_button", visible=False)
self._save_button.addActionListener(ListenerFactory(ActionListener, self._save_button_pushed))
self._add_with_padding(self._save_button, 5)
def _create_vacation_display(self):
self._display = JTable(name="vacation_display")
self._header = self._display.getTableHeader()
self.add(self._header)
self.add(self._display)
def _add_with_padding(self, component, padding):
self.add(component)
self.add(Box.createRigidArea(Dimension(0, padding)))
def show_employee(self, employee):
self._name_editor.setText(employee.name)
self._start_date_editor.setText(str(employee.startdate))
self._name_editor.setEditable(False)
self._start_date_editor.setEditable(False)
self._save_button.setVisible(False)
if self._adding_employee:
self._adding_employee = False
else:
self._status_label.setText("")
self._display.setVisible(True)
self._display.setModel(VacationTableModel(employee, self._dateprovider))
self._header.setVisible(True)
def edit_new_employee(self):
self._name_editor.setText("")
self._start_date_editor.setText("")
self._name_editor.setEditable(True)
self._start_date_editor.setEditable(True)
self._save_button.setVisible(True)
self._display.setVisible(False)
self._header.setVisible(False)
self._adding_employee = True
def _save_button_pushed(self, event):
self._employees.add(self._name_editor.getText(), self._start_date_editor.getText())
def employee_added(self, employee):
self._status_label.setForeground(Color.BLACK)
self._status_label.setText("Employee '%s' was added successfully." % employee.name)
self._save_button.setVisible(False)
def adding_employee_failed(self, reason):
self._status_label.setForeground(Color.RED)
self._status_label.setText(reason)