本文整理汇总了Python中javax.swing.JFrame.setContentPane方法的典型用法代码示例。如果您正苦于以下问题:Python JFrame.setContentPane方法的具体用法?Python JFrame.setContentPane怎么用?Python JFrame.setContentPane使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JFrame
的用法示例。
在下文中一共展示了JFrame.setContentPane方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: VacalcFrame
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setContentPane [as 别名]
class VacalcFrame(object):
def __init__(self, employees, dateprovider):
self._frame = JFrame("Vacation Calculator", defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
self._frame.setContentPane(self._create_ui(employees, dateprovider))
self._frame.pack()
def _create_ui(self, employees, dateprovider):
panel = JPanel(layout=FlowLayout())
self._overview = EmployeeOverview(employees, self)
self._details = EmployeeDetails(employees, dateprovider)
self._welcome = Welcome()
panel.add(self._overview)
panel.add(self._welcome)
return panel
def show(self):
self._frame.setVisible(True)
def employee_selected(self, employee):
self._ensure_details_shown()
self._details.show_employee(employee)
def edit_new_employee(self):
self._ensure_details_shown()
self._details.edit_new_employee()
def _ensure_details_shown(self):
if self._welcome:
self._frame.contentPane.remove(self._welcome)
self._frame.contentPane.add(self._details)
self._frame.pack()
self._welcome = None
示例2: startGui
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setContentPane [as 别名]
def startGui():
frame = JFrame("MonkeyPySon")
frame.setContentPane(getContentPane())
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
frame.pack()
frame.setVisible(True)
frame.addWindowFocusListener(GuiWindowFocusListener())
startLookingDevices()
示例3: start_ashdi
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setContentPane [as 别名]
def start_ashdi():
loadKeyLayout("data_2.0/ashdi_keylayout.xml")
global frame
frame = JFrame(FRAME_TITLE)
frame.setContentPane(getContentPane())
frame.windowClosing = lambda x: windowClosing()
frame.pack()
frame.setVisible(True)
frame.addWindowFocusListener(GuiWindowFocusListener())
start_android_waker()
handleConnectedDevBtn(True)
check_move_support()
示例4: main
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setContentPane [as 别名]
def main(args):
_WIDTH = 300
_HEIGHT = 300
fps = 20#frames per second
bgColor = Color.white
frame = JFrame("Graphics!")
frame.setBackground(bgColor);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
drawgraphics = DrawGraphics()
content = Animator(drawgraphics, _WIDTH, _HEIGHT, fps)
content.setBackground(bgColor)
content.setSize(_WIDTH, _HEIGHT)
content.setMinimumSize(Dimension(_WIDTH, _HEIGHT))
content.setPreferredSize(Dimension(_WIDTH, _HEIGHT))
frame.setSize(_WIDTH, _HEIGHT)
frame.setContentPane(content)
frame.setResizable(True)
frame.pack()
Thread(content).start()
frame.setVisible(True)
示例5: Pipeline
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setContentPane [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
#.........这里部分代码省略.........
示例6: getArguments
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setContentPane [as 别名]
def getArguments(self):
"""
This function brings up a window to retreive any required arguments. It uses a window with fields for each argument, filled with any arguments already given.
While this window is visible the program will wait, once it is no longer visible all the arguments will be filled with the entries in the fields.
"""
class LocationAction(AbstractAction):
"""
Action to set the text of a text field to a folder or directory.
"""
def __init__(self, field):
AbstractAction.__init__(self, "...")
self.field = field
def actionPerformed(self, event):
fileChooser = JFileChooser()
fileChooser.fileSelectionMode = JFileChooser.FILES_AND_DIRECTORIES
if fileChooser.showOpenDialog(None) == JFileChooser.APPROVE_OPTION:
self.field.text = fileChooser.selectedFile.absolutePath
class HelpAction(AbstractAction):
"""
Displays a help page in a web browser.
"""
def __init__(self):
AbstractAction.__init__(self, "Help")
def actionPerformed(self, event):
browsers = ["google-chrome", "firefox", "opera", "epiphany", "konqueror", "conkeror", "midori", "kazehakase", "mozilla"]
osName = System.getProperty("os.name")
helpHTML = ClassLoader.getSystemResource("help.html").toString()
if osName.find("Mac OS") == 0:
Class.forName("com.apple.eio.FileManager").getDeclaredMethod( "openURL", [String().getClass()]).invoke(None, [helpHTML])
elif osName.find("Windows") == 0:
Runtime.getRuntime().exec( "rundll32 url.dll,FileProtocolHandler " + helpHTML)
else:
browser = None
for b in browsers:
if browser == None and Runtime.getRuntime().exec(["which", b]).getInputStream().read() != -1:
browser = b
Runtime.getRuntime().exec([browser, helpHTML])
class OKAction(AbstractAction):
"""
Action for starting the pipeline. This action will simply make the window invisible.
"""
def __init__(self):
AbstractAction.__init__(self, "Ok")
def actionPerformed(self, event):
frame.setVisible(False)
class CancelAction(AbstractAction):
"""
Action for canceling the pipeline. Exits the program.
"""
def __init__(self):
AbstractAction.__init__(self, "Cancel")
def actionPerformed(self, event):
sys.exit(0)
frame = JFrame("Neofelis")
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
constraints = GridBagConstraints()
contentPane = JPanel(GridBagLayout())
frame.setContentPane(contentPane)
blastField = JTextField(self.blastLocation)
genemarkField = JTextField(self.genemarkLocation)
transtermField = JTextField(self.transtermLocation)
tRNAscanField = JTextField(self.tRNAscanLocation)
databaseLocationField = JTextField(os.path.split(self.database)[0])
databaseField = JTextField(os.path.split(self.database)[1])
matrixField = JTextField(str(self.matrix))
eValueField = JTextField(str(self.eValue))
minLengthField = JTextField(str(self.minLength))
scaffoldingDistanceField = JTextField(str(self.scaffoldingDistance))
promoterScoreField = JTextField(str(self.promoterScoreCutoff))
queryField = JTextField(self.sources[0])
constraints.gridx = 0
constraints.gridy = 0
constraints.gridwidth = 1
constraints.gridheight = 1
constraints.fill = GridBagConstraints.HORIZONTAL
constraints.weightx = 0
constraints.weighty = 0
contentPane.add(JLabel("Blast Location"), constraints)
constraints.gridy = 1
contentPane.add(JLabel("Genemark Location"), constraints)
constraints.gridy = 2
contentPane.add(JLabel("Transterm Location"), constraints)
constraints.gridy = 3
contentPane.add(JLabel("tRNAscan Location"), constraints)
constraints.gridy = 4
contentPane.add(JLabel("Databases Location"), constraints)
constraints.gridy = 5
contentPane.add(JLabel("Database"), constraints)
constraints.gridy = 6
contentPane.add(JLabel("Matrix(Leave blank to use heuristic matrix)"), constraints)
#.........这里部分代码省略.........
示例7: indices
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setContentPane [as 别名]
class Image:
"""Holds an image of RGB pixels accessed by column and row indices (col, row).
Origin (0, 0) is at upper left."""
# QUESTION: For efficiency, should we also extract and save self.pixels (at image reading time)?
# Also make setPixel(), getPixel(), setPixels() and getPixels() work on/with self.pixels.
# And when writing, use code in current setPixels() to update image buffer, before writing it out?
# This is something to try.
def __init__(self, filename, width=None, height=None):
"""Create an image from a file, or an empty (black) image with specified dimensions."""
# Since Python does not allow constructors with different signatures,
# the trick is to reuse the first argument as a filename or a width.
# If it is a string, we assume they want is to open a file.
# If it is an int, we assume they want us to create a blank image.
if type(filename) == type(""): # is it a string?
self.filename = filename # treat is a filename
self.image = BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB) # create a dummy image
self.read(filename) # and read external image into ti
elif type(filename) == type(1): # is it a int?
# create blank image with specified dimensions
self.filename = "Untitled"
self.width = filename # holds image width (shift arguments)
self.height = width # holds image height
self.image = BufferedImage(self.width, self.height, BufferedImage.TYPE_INT_RGB) # holds image buffer (pixels)
else:
raise TypeError("Image(): first argument must a filename (string) or an blank image width (int).")
# display image
self.display = JFrame() # create frame window to hold image
icon = ImageIcon(self.image) # wrap image appropriately for displaying in a frame
container = JLabel(icon)
self.display.setContentPane(container) # and place it
self.display.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE)
self.display.setTitle(self.filename)
self.display.setResizable(False)
self.display.pack()
self.display.setVisible(True)
def getWidth(self):
"""Returns the width of the image."""
return self.width
def getHeight(self):
"""Returns the height of the image."""
return self.height
def getPixel(self, col, row):
"""Returns a list of the RGB values for this pixel, e.g., [255, 0, 0]."""
# Obsolete - convert the row so that row zero refers to the bottom row of pixels.
#row = self.height - row - 1
color = Color(self.image.getRGB(col, row)) # get pixel's color
return [color.getRed(), color.getGreen(), color.getBlue()] # create list of RGB values (0-255)
def setPixel(self, col, row, RGBlist):
"""Sets this pixel's RGB values, e.g., [255, 0, 0]."""
# Obsolete - convert the row so that row zero refers to the bottom row of pixels.
#row = self.height - row - 1
color = Color(RGBlist[0], RGBlist[1], RGBlist[2]) # create color from RGB values
self.image.setRGB(col, row, color.getRGB())
def getPixels(self):
"""Returns a 2D list of pixels (col, row) - each pixel is a list of RGB values, e.g., [255, 0, 0]."""
pixels = [] # initialize list of pixels
#for row in range(self.height-1, 0, -1): # load pixels from image
for row in range(0, self.height): # load pixels from image
pixels.append( [] ) # add another empty row
for col in range(self.width): # populate row with pixels
# RGBlist = self.getPixel(col, row) # this works also (but slower)
color = Color(self.image.getRGB(col, row)) # get pixel's color
RGBlist = [color.getRed(), color.getGreen(), color.getBlue()] # create list of RGB values (0-255)
pixels[-1].append( RGBlist ) # add a pixel as (R, G, B) values (0-255, each)
# now, 2D list of pixels has been created, so return it
return pixels
def setPixels(self, pixels):
"""Sets image to the provided 2D list of pixels (col, row) - each pixel is a list of RGB values, e.g., [255, 0, 0]."""
self.height = len(pixels) # get number of rows
self.width = len(pixels[0]) # get number of columns (assume all columns have same length
#for row in range(self.height-1, 0, -1): # iterate through all rows
for row in range(0, self.height): # iterate through all rows
for col in range(self.width): # iterate through every column on this row
#.........这里部分代码省略.........