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


Python JFrame.setTitle方法代码示例

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


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

示例1: tree

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setTitle [as 别名]
def tree():
  """
  tree(xmlfile="dsm2.xml")
    creates a tree view on a given xml file of dsm2 input data
  """
  tv = TreeViewer()
  mp2 = JPanel()
  mp2.setLayout(BorderLayout())
  tf = JTextField("dsm2.inp")
  pb = JButton("parse")
  mp2.add(tf,BorderLayout.CENTER)
  mp2.add(pb,BorderLayout.EAST)
  class ParseListener(ActionListener):
    def __init__(self,tf,tv,fr):
      self.tf = tf
      self.tv = tv
      self.fr = fr
    def actionPerformed(self,evt):
      dsm2file = self.tf.getText()
      parser = DSM2Parser(dsm2file)
      self.tv.xdoc = parser.dsm2_data.toXml()
      self.fr.getContentPane().add(self.tv.gui(),BorderLayout.CENTER)
      self.fr.pack()
      self.fr.setVisible(1)
  fr = JFrame()
  fr.setTitle("DSM2Tree")
  fr.setLocation(100,100)
  fr.setSize(600,60)
  fr.getContentPane().setLayout(BorderLayout())
  fr.getContentPane().add(mp2,BorderLayout.NORTH)
  al = ParseListener(tf,tv,fr)
  pb.addActionListener(al)
  fr.pack()
  fr.setVisible(1)
开发者ID:GTP-CalLitGUI,项目名称:CalLiteGUI_RW1,代码行数:36,代码来源:dsm2.py

示例2: ConversationWindow

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setTitle [as 别名]
class ConversationWindow(Conversation):
    """A GUI window of a conversation with a specific person"""
    def __init__(self, person, chatui):
        """ConversationWindow(basesupport.AbstractPerson:person)"""
        Conversation.__init__(self, person, chatui)
        self.mainframe = JFrame("Conversation with "+person.name)
        self.display = JTextArea(columns=100,
                                 rows=15,
                                 editable=0,
                                 lineWrap=1)
        self.typepad = JTextField()
        self.buildpane()
        self.lentext = 0

    def buildpane(self):
        buttons = JPanel(doublebuffered)
        buttons.add(JButton("Send", actionPerformed=self.send))
        buttons.add(JButton("Hide", actionPerformed=self.hidewindow))

        mainpane = self.mainframe.getContentPane()
        mainpane.setLayout(BoxLayout(mainpane, BoxLayout.Y_AXIS))
        mainpane.add(JScrollPane(self.display))
        self.typepad.actionPerformed = self.send
        mainpane.add(self.typepad)
        mainpane.add(buttons)

    def show(self):
        self.mainframe.pack()
        self.mainframe.show()

    def hide(self):
        self.mainframe.hide()

    def sendText(self, text):
        self.displayText("\n"+self.person.client.name+": "+text)
        Conversation.sendText(self, text)

    def showMessage(self, text, metadata=None):
        self.displayText("\n"+self.person.name+": "+text)

    def contactChangedNick(self, person, newnick):
        Conversation.contactChangedNick(self, person, newnick)
        self.mainframe.setTitle("Conversation with "+newnick)

    #GUI code
    def displayText(self, text):
        self.lentext = self.lentext + len(text)
        self.display.append(text)
        self.display.setCaretPosition(self.lentext)

    #actionlisteners
    def hidewindow(self, ae):
        self.hide()

    def send(self, ae):
        text = self.typepad.getText()
        self.typepad.setText("")
        if text != "" and text != None:
            self.sendText(text)
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:61,代码来源:jychat.py

示例3: geom_viewer

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setTitle [as 别名]
def geom_viewer(dsm2file = "dsm2.inp"):
  """
  geom_viewer(dsm2file = "dsm2.inp")
  starts off a dsm2 geometry viewer for dsm2 input data
  Irregular xsections are plotted if available otherwise
  regular xsections are plotted.
  """
  dgv = DSM2GeomViewer(dsm2file)
  mp = dgv.gui()
  fr = JFrame()
  fr.setTitle('Geom Viewer')
  fr.getContentPane().add(mp)
  fr.setLocation(300,100)
  fr.pack()
  sz = fr.getSize()
  fr.setSize(250,sz.height)
  fr.setVisible(1)
开发者ID:GTP-CalLitGUI,项目名称:CalLiteGUI_RW1,代码行数:19,代码来源:dsm2.py

示例4: indices

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setTitle [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
         
#.........这里部分代码省略.........
开发者ID:HenryStevens,项目名称:jes,代码行数:103,代码来源:image.py

示例5: GroupConversationWindow

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setTitle [as 别名]
class GroupConversationWindow(GroupConversation):
    """A GUI window of a conversation witha  group of people"""
    def __init__(self, group, chatui):
        GroupConversation.__init__(self, group, chatui)
        self.mainframe = JFrame(self.group.name)
        self.headers = ["Member"]
        self.memberdata = UneditableTableModel([], self.headers)
        self.display = JTextArea(columns=100, rows=15, editable=0, lineWrap=1)
        self.typepad = JTextField()
        self.buildpane()
        self.lentext = 0

    def show(self):
        self.mainframe.pack()
        self.mainframe.show()

    def hide(self):
        self.mainframe.hide()

    def showGroupMessage(self, sender, text, metadata=None):
        self.displayText(sender + ": " + text)

    def setGroupMembers(self, members):
        GroupConversation.setGroupMembers(self, members)
        self.updatelist()

    def setTopic(self, topic, author):
        topictext = "Topic: " + topic + ", set by " + author
        self.mainframe.setTitle(self.group.name + ": " + topictext)
        self.displayText(topictext)

    def memberJoined(self, member):
        GroupConversation.memberJoined(self, member)
        self.updatelist()

    def memberChangedNick(self, oldnick, newnick):
        GroupConversation.memberChangedNick(self, oldnick, newnick)
        self.updatelist()

    def memberLeft(self, member):
        GroupConversation.memberLeft(self, member)
        self.updatelist()

    #GUI code
    def buildpane(self):
        buttons = JPanel(doublebuffered)
        buttons.add(JButton("Hide", actionPerformed=self.hidewindow))

        memberpane = JTable(self.memberdata)
        memberframe = JScrollPane(memberpane)

        chat = JPanel(doublebuffered)
        chat.setLayout(BoxLayout(chat, BoxLayout.Y_AXIS))
        chat.add(JScrollPane(self.display))
        self.typepad.actionPerformed = self.send
        chat.add(self.typepad)
        chat.add(buttons)

        mainpane = self.mainframe.getContentPane()
        mainpane.setLayout(BoxLayout(mainpane, BoxLayout.X_AXIS))
        mainpane.add(chat)
        mainpane.add(memberframe)

    def displayText(self, text):
        self.lentext = self.lentext + len(text)
        self.display.append(text)
        self.display.setCaretPosition(self.lentext)

    def updatelist(self):
        self.memberdata.setDataVector([self.members], self.headers)

    #actionListener
    def send(self, ae):
        text = self.typepad.getText()
        self.typepad.setText("")
        if text != "" and text != None:
            GroupConversation.sendText(self, text)

    def hidewindow(self, ae):
        self.hide()
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:82,代码来源:jychat.py

示例6: correctionTable

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setTitle [as 别名]
class correctionTable(TextPanel):
    """A class that displays an imagePlus and a resultstable. Resultstable and imp are linked in such a 
     way that click on a table row shows the imps respective timeframe."""
    def __init__(self, cell, mF, title="Results"): # add mF?
        # Call constructor of superclass
        TextPanel.__init__(self)
        # pass menue for setting save active/inactive
        self.cell = cell
        self.mF = mF
        # Create a window to show the content in
        self.window = JFrame()
        self.window.add(self)
        self.window.setTitle(title)
        # Add event listeners for keyboard and mouse responsiveness
        
        self.addKeyListener(ListenToKey())
        self.addMouseListener(ListenToMouse())
        
        # TODO: unpacking info out of cell object should be done in cell object itself and accessible e. g. via getData()
        self.imp = self.openImp(self.cell.getMeasTifPath())
        csvFile = open(self.cell.getCsvPath())        
        lines = csvFile.readlines()
        heads = lines.pop(0)
        self.setColumnHeadings("Frame\tDistance\tAnaphase")
        self.XYZtable = []
        for line in lines:      # load file lines in textPanel.
            frame, timepoint, dist, ch0x, ch0y, ch0z, ch0vol, ch1x, ch1y, ch1z, ch1vol = line.split(",")
            self.append(frame + "\t" + dist + "\t" )
            self.XYZtable.append((ch0x, ch0y, ch0z, ch0vol, ch1x, ch1y, ch1z, ch1vol))
        self.setSelection(0,0) # int startline, int endline
        self.changeFrame()
        self.mF.setSaveInactive()
        self.requestFocus()

        self.window.setSize(Dimension(220, 600))
        x = int(self.imp.getWindow().getLocation().getX()) + int(self.imp.getWindow().getWidth()) + 10
        self.window.setLocation(x, int(self.imp.getWindow().getLocation().getY()) )
        self.window.show()

    # Methods implementing KeyAdapter and MouseListener
    #... no multiple inheritance for Java classes?
    

    # - - - - Event driven methods - - - -
    # ------------------------------------

    def changeFrame(self):
        if self.getSelectionEnd() >= 0:
            frame, dist, AOCol = self.getLine(self.getSelectionEnd()).split("\t")
            self.imp.setSlice(int(frame)+1)
    
    def setAnaphase(self):
        frame, Distance, x = self.getLine(self.getSelectionEnd()).split("\t")
        #set anaphase onset
        self.cell.setAnOn(frame)
        for i in range(self.getLineCount()):   # very unelegantly solved, but it works.
            blFr, blDist, blAOCol = self.getLine(i).split("\t")
            self.setLine(i, blFr + "\t" + blDist + "\t")
            frame, distance, AOCol = self.getLine(self.getSelectionEnd()).split("\t") # get old line
            self.setLine(self.getSelectionEnd(), frame + "\t" + distance + "\tX")
        # setFocus back to tw,tp
        self.mF.setSaveActive()
        print "Anaphase set to", self.cell.getAnOn()

    def delVal(self):
        frame, distance, AOCol = self.getLine(self.getSelectionEnd()).split("\t")
        self.setLine(self.getSelectionEnd(), frame + "\tNA" + "\t" + AOCol)

    # - other methods
    def openImp(self, path):
        imp = ImagePlus(path)  # open associated tif file
        imp.show()
        imp.getWindow().setLocationAndSize(280, 120, imp.getWidth()*4, imp.getHeight()*4) # int x, int y, int width, int height
        return imp

    def getImp(self):
        return self.imp

    def getXYZtable(self):
        return self.XYZtable
        
    def closeWindows(self):
        self.imp.close()
        WindowManager.removeWindow(self.window)
        self.window.dispose()
开发者ID:schiklen,项目名称:BatchMeasurement,代码行数:87,代码来源:04-QualityControl_v9.py


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