本文整理汇总了Python中javax.swing.JLabel.setHorizontalAlignment方法的典型用法代码示例。如果您正苦于以下问题:Python JLabel.setHorizontalAlignment方法的具体用法?Python JLabel.setHorizontalAlignment怎么用?Python JLabel.setHorizontalAlignment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JLabel
的用法示例。
在下文中一共展示了JLabel.setHorizontalAlignment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setHorizontalAlignment [as 别名]
def __init__(self):
self.setAlwaysOnTop(False);
self.setSize(500, 500);
menubar = JMenuBar();
menu = JMenu("A Menu");
menu_ac = menu.getAccessibleContext();
menu_ac.setAccessibleDescription("The only menu in this program");
menuitem = JMenuItem("A Menu Item");
menu.add(menuitem);
menubar.add(menu);
self.setJMenuBar(menubar);
lbl = JLabel("A Label");
lbl.setHorizontalAlignment(JLabel.CENTER);
lbl.setVerticalAlignment(JLabel.CENTER);
self.setContentPane(lbl);
self.setVisible(True);
示例2: MenueFrame
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setHorizontalAlignment [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()
示例3: MenueFrame
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setHorizontalAlignment [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):
#.........这里部分代码省略.........