예제 #1
0
class positionDialog(JFrame):
    def __init__(self):
        self.frame = JFrame("CellCropper: Experiment details", size=(400,200))
        self.frame.setLocation(20,120)
        self.Panel = JPanel(GridLayout(4,2))
        self.frame.add(self.Panel)
        self.Panel.add(JLabel("Date:"))
        self.dateField = JTextField( str(date.today()), 8 )
        self.Panel.add(self.dateField)
        self.strainField = JTextField( "2926",4 )
        self.Panel.add(self.strainField)
        self.tempField = JTextField( "34",2 )
        self.Panel.add(self.tempField)
        self.ODField = JTextField( "0.5",3 )
        self.Panel.add(self.ODField)
        self.condField = JTextField( "0.5",3 )
        self.Panel.add(self.condField)

        self.OKButton = JButton("OK",actionPerformed=closeAndMakePos)
        self.Panel.add(self.OKButton)
        self.frame.pack()
        WindowManager.addWindow(self.frame)
        self.show()

    def show(self):
        self.frame.visible = True
    
    def close(self):
        return self.dateField.text, self.strainField.text, self.tempField.text, self.ODField.text, self.condField.text
        WindowManager.removeWindow(self.frame)
        self.frame.dispose()
예제 #2
0
def initial():
    global f  ##文件
    global txt
    global number_of_occurrence
    reload(sys)
    sys.setdefaultencoding('utf-8')
    ctr.init()
    ctr.set_value('flag', 0)
    ctr.set_value('reload_check', 0)
    ctr.set_value('world_boss_check', 0)
    ctr.set_value('raid_check', 0)
    #ctr.set_value('raid_check',None)
    number_of_occurrence = 0
    ctr.set_value('max_level_check', None)
    ctr.set_value('return_check', 0)
    ticks = time.time()
    date = time.strftime("%Y_%m_%d_%H_%M_%S", time.localtime(ticks)) + '_日誌'
    f = open(date + '.txt', 'w', 0)

    frame = JFrame("Log")
    txt = JTextArea(19, 55)
    scrollPane = JScrollPane(txt)
    ##frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    frame.setLocation(2000, 100)
    frame.setSize(480, 450)
    frame.setLayout(FlowLayout())
    ##label = JLabel('記錄:')
    scrollPane.setHorizontalScrollBarPolicy(
        JScrollPane.HORIZONTAL_SCROLLBAR_NEVER)
    ##frame.add(label)
    frame.add(scrollPane)
    frame.setVisible(True)
예제 #3
0
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)
예제 #4
0
    def run( self ) :
        frame = JFrame(
            'WSAShelp_01',
            locationRelativeTo = None,
            defaultCloseOperation = JFrame.EXIT_ON_CLOSE
        )
#       text = Help.help()
#       tabs = text.count( '\t' )
#       text = Help.help().expandtabs()
#       rows = text.count( '\n' ) + 1
#       cols = max( [ len( x ) for x in text.splitlines() ] )
#       cols = max( [ len( x.expandtabs() ) for x in text.splitlines() ] )
#       print '\nrows: %d  cols: %d  tabs: %d' % ( rows, cols, tabs )
        frame.add(
            JScrollPane(
                JTextArea(
#                   text,
                    Help.help().expandtabs(),
                    20,
                    80,
                    font = Font( 'Courier' , Font.PLAIN, 12 )
                )
            )
        )
        frame.pack()
        size = frame.getSize()
#       print 'frame.getSize():', size
        loc = frame.getLocation()
#       print 'frame.getLocation():', loc
        loc.x -= ( size.width  >> 1 )
        loc.y -= ( size.height >> 1 )
        frame.setLocation( loc )
        frame.setVisible( 1 )
예제 #5
0
 def gui_open(path):
     label = JLabel(ImageIcon(ImageIO.read(File(URL(path).getFile()))))
     frame = JFrame()
     frame.getContentPane().add(label)
     frame.pack()
     frame.setLocation(200, 200)
     frame.setVisible(True)
def changePasswordForm(check):
    global frame
    global tfOldPassword
    global tfNewPassword
    global tfConfirmPassword
    global value

    value = check

    frame = JFrame("Change Password")
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    frame.setSize(500, 350)
    frame.setLocation(200, 200)
    frame.setLayout(None)
    frame.setVisible(True)

    panel = JPanel()
    panel.setSize(500, 350)
    panel.setLocation(0, 0)
    panel.setLayout(None)
    panel.setVisible(True)
    panel.setBackground(Color.LIGHT_GRAY)

    heading = JLabel("Change Password")
    heading.setBounds(200, 30, 150, 40)

    lbOldPassword = JLabel("Old Password")
    lbNewPassword = JLabel("New Password")
    lbConfirmPassword = JLabel("Confirm Password")

    tfOldPassword = JTextField()
    tfNewPassword = JTextField()
    tfConfirmPassword = JTextField()

    lbOldPassword.setBounds(50, 100, 150, 30)
    lbNewPassword.setBounds(50, 150, 150, 30)
    lbConfirmPassword.setBounds(50, 200, 150, 30)

    tfOldPassword.setBounds(220, 100, 150, 30)
    tfNewPassword.setBounds(220, 150, 150, 30)
    tfConfirmPassword.setBounds(220, 200, 150, 30)

    btnSave = JButton("Save", actionPerformed=clickSave)
    btnCancel = JButton("Cancel", actionPerformed=clickCancel)

    btnSave.setBounds(350, 280, 100, 30)
    btnCancel.setBounds(50, 280, 100, 30)

    panel.add(heading)
    panel.add(lbOldPassword)
    panel.add(lbNewPassword)
    panel.add(lbConfirmPassword)
    panel.add(tfOldPassword)
    panel.add(tfNewPassword)
    panel.add(tfConfirmPassword)
    panel.add(btnSave)
    panel.add(btnCancel)

    frame.add(panel)
예제 #7
0
def addCourse():
    global tfCourseName
    global tfCourseId
    global tfCourseFee
    global frame
    global btnEnter

    frame = JFrame("Add Course ")
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    frame.setSize(450, 450)
    frame.setLocation(200, 200)
    frame.setLayout(None)
    frame.setVisible(True)

    panel = JPanel()
    panel.setSize(450, 450)
    panel.setLocation(0, 0)
    panel.setLayout(None)
    panel.setVisible(True)
    panel.setBackground(Color.LIGHT_GRAY)

    heading = JLabel("ADD COURSE")
    heading.setBounds(200, 30, 150, 40)

    lbCourseName = JLabel("Course Name ")
    lbCourseId = JLabel("Course Id")
    lbCourseFee = JLabel(" Course Fee")

    tfCourseName = JTextField()
    tfCourseId = JTextField()
    tfCourseFee = JTextField()

    lbCourseName.setBounds(70, 120, 130, 30)
    lbCourseId.setBounds(70, 170, 130, 30)
    lbCourseFee.setBounds(70, 220, 130, 30)

    tfCourseName.setBounds(220, 120, 150, 30)
    tfCourseId.setBounds(220, 170, 150, 30)
    tfCourseFee.setBounds(220, 220, 150, 30)

    btnEnter = JButton("Enter", actionPerformed=clickAddCourseFee)
    btnEnter.setBounds(300, 300, 100, 40)

    btnCancel = JButton("Cancel", actionPerformed=clickCancel)
    btnCancel.setBounds(70, 300, 100, 40)

    panel.add(heading)
    panel.add(lbCourseName)
    panel.add(lbCourseId)
    panel.add(lbCourseFee)
    panel.add(tfCourseFee)
    panel.add(tfCourseName)
    panel.add(tfCourseId)
    panel.add(tfCourseFee)
    panel.add(btnEnter)
    panel.add(btnCancel)

    frame.add(panel)
예제 #8
0
def cachedBPROM(genome, fileName, frame):
  """
  genome: Genome as a string.
  fileName: File to save the BPROM results in.
  swing: A JFrame or None.  If this is None then messages will be printed, if it isn't then
         they will also be put in a dialog box.

  return: Results of the BPROM prediction stored in a list of Promoter objects.

  If the file Specified by fileName already exists then this function simply parses the file
  already there.  Also, if a request is made to BPROM and nothing is returned, no file is
  created, the user is warned, and an empty list is returned.
  """
  offset = 25 if ".forward.bprom" in fileName else 50
  direction = "forward" if offset == 50 else "reverse"
    
  def getPromoters():
    input = open(fileName, "r")
    results = parseBPROM(input.read())
    input.close()
    return results

  if not os.path.isfile(fileName):
    results = urllib.urlopen("http://linux1.softberry.com/cgi-bin/programs/gfindb/bprom.pl",
                             urllib.urlencode({"DATA" : genome}))
    resultString = results.read()
    results.close()
    resultString = resultString[resultString.find("<pre>"):resultString.find("</pre>")]
    resultString = re.sub("<+.+>+", "", resultString).strip()
    if resultString:
      output = open(fileName, "w")
      output.write(resultString)
      output.close()
      return getPromoters()
    else:
      if frame:
        messageFrame = JFrame("BPROM Error",
                              defaultCloseOperation = WindowConstants.DISPOSE_ON_CLOSE)
        messageFrame.setLocation(frame.location().x + offset, frame.location().y + offset)
        messageFrame.contentPane.layout = GridBagLayout()
        constraints = GridBagConstraints()
        constraints.gridx, constraints.gridy = 0, 0
        constraints.gridwidth, constraints.gridheight = 1, 1
        constraints.fill = GridBagConstraints.BOTH
        constraints.weightx, constraints.weighty = 1, 1
        messageFrame.contentPane.add(JLabel("<html>The pipeline will continue to run but BPROM<br/>did not process the request for promoters on the<br/>" + direction + " strand.  Try again tomorrow.</html>"), constraints)
        constraints.gridx, constraints.gridy = 0, 1
        constraints.fill = GridBagConstraints.NONE
        constraints.weightx, constraints.weighty = 1, 1
        constraints.anchor = GridBagConstraints.LINE_END
        messageFrame.contentPane.add(JButton("Ok", actionPerformed = lambda e: messageFrame.dispose()), constraints)
        messageFrame.pack()
        messageFrame.visible = True
      print "BPROM Error:", "The pipeline will continue to run but BPROM did not process the request for promoters on the " + direction + " strand.  Try again tomorrow"
      return []
  else:
    return getPromoters()
예제 #9
0
def studentLogined(stObj):
    global panel
    global table
    global heading
    global frame

    frame = JFrame("Student  Page ")
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    frame.setSize(500, 600)
    frame.setLocation(200, 200)
    frame.setLayout(None)

    panel = JPanel()
    panel.setSize(500, 580)
    panel.setLocation(0, 20)
    panel.setLayout(None)
    panel.setVisible(True)
    panel.setBackground(Color.WHITE)

    heading = JLabel()
    heading.setBounds(210, 10, 200, 30)

    table = JTable()
    table.setBounds(0, 50, 500, 470)
    sp = JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                     ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS)

    bar = JMenuBar()

    profile = JMenu("Profile")
    showProfile = JMenuItem("Show Profile",
                            actionPerformed=clickShowStudentProfile)
    changePassword = JMenuItem("Change Password",
                               actionPerformed=changeStudentPassword)
    profile.add(showProfile)
    profile.add(changePassword)
    bar.add(profile)

    attendence = JMenu("Attendence")
    showAllAttendence = JMenuItem("Show All Attendence",
                                  actionPerformed=clickAllAttendence)
    showAttendenceInMonth = JMenuItem("show attendence in month",
                                      actionPerformed=clickAttendenceInMonth)
    attendence.add(showAllAttendence)
    attendence.add(showAttendenceInMonth)
    bar.add(attendence)

    logout = JMenuItem("logout", actionPerformed=clickLogout)
    bar.add(logout)

    panel.add(table)

    frame.setJMenuBar(bar)
    frame.add(panel)

    frame.setVisible(True)
def get_file_name():
    frame = JFrame("Filename")
    frame.setLocation(100, 100)
    frame.setSize(500, 400)
    frame.setLayout(None)
    fc = JFileChooser()
    result = fc.showOpenDialog(frame)
    if not result == JFileChooser.APPROVE_OPTION:
        return None
    file_name = fc.getSelectedFile()
    return file_name
예제 #11
0
 def run(self):
     #-----------------------------------------------------------------------
     # Size the frame to use 1/2 of the screen
     #-----------------------------------------------------------------------
     screenSize = Toolkit.getDefaultToolkit().getScreenSize()
     frameSize = Dimension(screenSize.width >> 1, screenSize.height >> 1)
     frame = JFrame('javadocInfo',
                    size=frameSize,
                    defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
     #-----------------------------------------------------------------------
     # Reposition the frame to be in the center of the screen
     #-----------------------------------------------------------------------
     frame.setLocation((screenSize.width - frameSize.width) >> 1,
                       (screenSize.height - frameSize.height) >> 1)
     #-----------------------------------------------------------------------
     # Initialize the list to have exactly 1 element
     #-----------------------------------------------------------------------
     self.List = JList(['One moment please...'],
                       valueChanged=self.pick,
                       selectionMode=ListSelectionModel.SINGLE_SELECTION)
     #-----------------------------------------------------------------------
     # Put the List in a ScrollPane and place it in the middle of a pane
     #-----------------------------------------------------------------------
     pane = JPanel(layout=BorderLayout())
     pane.add(JScrollPane(self.List), BorderLayout.CENTER)
     #-----------------------------------------------------------------------
     # Add a TextField [for the URL of the selected entry] at the bottom
     #-----------------------------------------------------------------------
     self.msg = JTextField()
     pane.add(self.msg, BorderLayout.SOUTH)
     #-----------------------------------------------------------------------
     # Add the pane and a scrollable TextArea to a SplitPane in the frame
     #-----------------------------------------------------------------------
     self.area = JTextArea()
     sPane = JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
                        pane,
                        JScrollPane(self.area),
                        propertyChange=self.propChange)
     sPane.setDividerLocation(234)
     frame.add(sPane)
     #-----------------------------------------------------------------------
     # Create a separate thread to locate & proces the remote URL
     #-----------------------------------------------------------------------
     self.Links = {}  # Initialize the Links dictionary
     soupTask(
         self.List,  # The visible JList instance
         self.msg,  # The message area (JTextField)
         JAVADOC_URL,  # Remote web page URL to be processed
         self.Links  # Dictionary of links found
     ).execute()
     frame.setVisible(1)
예제 #12
0
def install(helper):
    print('install called')

    frame = JFrame("Please Input Values")
    frame.setLocation(100, 100)
    frame.setSize(500, 400)
    frame.setLayout(None)

    lbl1 = JLabel("Input1: ")
    lbl1.setBounds(60, 20, 60, 20)
    txt1 = JTextField(100)
    txt1.setBounds(130, 20, 200, 20)
    lbl2 = JLabel("Input2: ")
    lbl2.setBounds(60, 50, 100, 20)
    txt2 = JTextField(100)
    txt2.setBounds(130, 50, 200, 20)
    lbl3 = JLabel("Input3: ")
    lbl3.setBounds(60, 80, 140, 20)
    txt3 = JTextField(100)
    txt3.setBounds(130, 80, 200, 20)
    lbl4 = JLabel("Input4: ")
    lbl4.setBounds(60, 110, 180, 20)
    txt4 = JTextField(100)
    txt4.setBounds(130, 110, 200, 20)

    def getValues(event):
        print "clicked"
        ScriptVars.setGlobalVar("Input1", str(txt1.getText()))
        print(ScriptVars.getGlobalVar("Input1"))
        ScriptVars.setGlobalVar("Input2", str(txt2.getText()))
        print(ScriptVars.getGlobalVar("Input2"))
        ScriptVars.setGlobalVar("Input3", str(txt3.getText()))
        print(ScriptVars.getGlobalVar("Input3"))
        ScriptVars.setGlobalVar("Input4", str(txt4.getText()))
        print(ScriptVars.getGlobalVar("Input4"))

    btn = JButton("Submit", actionPerformed=getValues)
    btn.setBounds(160, 150, 100, 20)

    frame.add(lbl1)
    frame.add(txt1)
    frame.add(lbl2)
    frame.add(txt2)
    frame.add(btn)
    frame.add(lbl3)
    frame.add(txt3)
    frame.add(lbl4)
    frame.add(txt4)
    frame.setVisible(True)
예제 #13
0
def install(helper):
  	print('install called'); 
	
	frame = JFrame("Please Input Values")
	frame.setLocation(100,100)
	frame.setSize(500,400)
	frame.setLayout(None)

	lbl1 = JLabel("Input1: ")
	lbl1.setBounds(60,20,60,20)
	txt1 = JTextField(100)
	txt1.setBounds(130,20,200,20)
	lbl2 = JLabel("Input2: ")
	lbl2.setBounds(60,50,100,20)
	txt2 = JTextField(100)
	txt2.setBounds(130,50,200,20)
	lbl3 = JLabel("Input3: ")
	lbl3.setBounds(60,80,140,20)
	txt3 = JTextField(100)
	txt3.setBounds(130,80,200,20)
	lbl4 = JLabel("Input4: ")
	lbl4.setBounds(60,110,180,20)
	txt4 = JTextField(100)
	txt4.setBounds(130,110,200,20)
	
	def getValues(event):
		print "clicked"
		ScriptVars.setGlobalVar("Input1",str(txt1.getText()))
		print(ScriptVars.getGlobalVar("Input1"))
		ScriptVars.setGlobalVar("Input2",str(txt2.getText()))
		print(ScriptVars.getGlobalVar("Input2"))
		ScriptVars.setGlobalVar("Input3",str(txt3.getText()))
		print(ScriptVars.getGlobalVar("Input3"))
		ScriptVars.setGlobalVar("Input4",str(txt4.getText()))
		print(ScriptVars.getGlobalVar("Input4"))		
		
	btn = JButton("Submit", actionPerformed = getValues)
	btn.setBounds(160,150,100,20)
		
	frame.add(lbl1)
	frame.add(txt1)
	frame.add(lbl2)
	frame.add(txt2)
	frame.add(btn)
	frame.add(lbl3)
	frame.add(txt3)
	frame.add(lbl4)
	frame.add(txt4)
	frame.setVisible(True)
예제 #14
0
파일: NuView.py 프로젝트: scijava/visad
    def __init__(self, title, display, panel):
        from java.awt import Toolkit
        from javax.swing import JFrame
        self.display = display

        frame = JFrame(title, windowClosing=self.desty)
        frame.getContentPane().add(panel)
        frame.pack()
        frame.invalidate()

        fSize = frame.getSize()
        screensize = Toolkit.getDefaultToolkit().getScreenSize()
        frame.setLocation((screensize.width - fSize.width) / 2,
                          (screensize.height - fSize.height) / 2)
        frame.setVisible(1)
예제 #15
0
파일: NuView.py 프로젝트: Devanshi26/visad
  def __init__(self, title, display, panel):
    from java.awt import Toolkit
    from javax.swing import JFrame
    self.display = display

    frame = JFrame(title, windowClosing=self.desty)
    frame.getContentPane().add(panel)
    frame.pack()
    frame.invalidate()

    fSize = frame.getSize()
    screensize = Toolkit.getDefaultToolkit().getScreenSize()
    frame.setLocation((screensize.width - fSize.width)/2,
                      (screensize.height - fSize.height)/2)
    frame.setVisible(1)
예제 #16
0
    def run(self):
        frame = JFrame('KeyBindings',
                       locationRelativeTo=None,
                       defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
        headings = ('KeyStroke,Unmodified,Ctrl,Shift,Shift-Ctrl').split(',')
        table = JTable(myTM(self.data(), headings), columnSelectionAllowed=1)
        table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF)
        setColumnWidths(table)
        frame.add(JScrollPane(table))
        frame.pack()
        size = frame.getSize()
        loc = frame.getLocation()
        frame.setLocation(
            Point(loc.x - (size.width >> 1), loc.y - (size.height >> 1)))

        frame.setVisible(1)
예제 #17
0
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)
예제 #18
0
def showLoginIdPassword(data):    
    global frame
    
    frame = JFrame("Show Id  Password ")
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    frame.setSize(500,350)
    frame.setLocation(200,200)
    frame.setLayout(None)
    frame.setVisible(True)
    
    panel = JPanel()
    panel.setSize(500,350)
    panel.setLocation(0,0)
    panel.setLayout(None)
    panel.setVisible(True)
    panel.setBackground(Color.LIGHT_GRAY)
    
    heading = JLabel("LoginId AND Password")
    heading.setBounds(200,30,150,40)
    
    lbLoginId = JLabel("LoginId")
    lbPassword = JLabel("password")
    
    tfLoginId = JTextField(data[0].encode('ascii'))
    tfPassword = JTextField(data[1].encode('ascii'))
    
    tfLoginId.setEditable(False)
    tfPassword.setEditable(False)
    
    lbLoginId.setBounds(50,100,150,30)
    lbPassword.setBounds(50,150,150,30)
    
    tfLoginId.setBounds(220,100,150,30)
    tfPassword.setBounds(220,150,150,30)
    
    btnOk = JButton("Ok",actionPerformed=clickOk)
    
    btnOk.setBounds(250,220,100,30)
    
    panel.add(heading)
    panel.add(lbLoginId)
    panel.add(lbPassword)
    panel.add(tfLoginId)
    panel.add(tfPassword)
    panel.add(btnOk)
    frame.add(panel)
예제 #19
0
    def run_update(self):
        #from javax.swing import JFrame, JButton

        frame = JFrame("Hello")
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
        frame.setLocation(100, 100)
        frame.setSize(300, 200)

        def updatePressed(event):
            jmri.jmrit.signalling.SignallingPanel.updatePressed(ActionEvent)(e)

        btn = JButton("Add", actionPerformed=updatePressed)
        frame.add(btn)

        frame.setVisible(True)
        btn.doClick
        frame.dispose()
def getCourseName(check):    
    global frame
    global tfStudentCourseChoice
    global value

    value = check
    
    frame = JFrame("Course Name ")
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    frame.setSize(500,250)
    frame.setLocation(200,200)
    frame.setLayout(None)
    frame.setVisible(True)
    
    panel = JPanel()
    panel.setSize(500,250)
    panel.setLocation(0,0)
    panel.setLayout(None)
    panel.setVisible(True)
    panel.setBackground(Color.LIGHT_GRAY)
    
    heading = JLabel("Get Course Name")
    heading.setBounds(200,30,150,40)
    
    lbStudentCourseChoice = JLabel("Student course name")
    tfStudentCourseChoice = JTextField()
    
    lbStudentCourseChoice.setBounds(50,70,150,30)
    tfStudentCourseChoice.setBounds(220,70,150,30)
    
    btnEnter = JButton("Enter",actionPerformed=clickStudentCourseChoice)
    btnCancel = JButton("Cancel",actionPerformed=clickBtnCancel)
    
    btnEnter.setBounds(350,150,100,30)
    btnCancel.setBounds(50,150,100,30)
    
    panel.add(heading)
    panel.add(lbStudentCourseChoice)
    panel.add(tfStudentCourseChoice)
    panel.add(btnEnter)
    panel.add(btnCancel)
    frame.add(panel)
예제 #21
0
def showStudentAttendenceSheetTeacherLogin():
    global table
    global heading
    global frame
    global panel
    global btnSave
    global btnCancel
    
    frame = JFrame("Student Attendence Sheet ")
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    frame.setSize(500,600)
    frame.setLocation(200,200)
    frame.setLayout(None)
    frame.setVisible(True)
    
    panel = JPanel()
    panel.setSize(500,600)
    panel.setLocation(0,0)
    panel.setLayout(None)
    panel.setVisible(True)
    panel.setBackground(Color.WHITE)
    
    heading = JLabel()
    heading.setBounds(200,10,150,30)
    
    table = JTable()
    table.setBounds(0,50,500,450)
    panel.add(table)
    
    btnSave = JButton("Save",actionPerformed = clickSaveBtn)
    btnCancel = JButton("Cancel",actionPerformed = clickCancelBtn)
    
    btnSave.setBounds(350,540,100,40)
    btnCancel.setBounds(70,540,100,40)

    panel.add(heading)
    panel.add(table)
    panel.add(btnSave)
    panel.add(btnCancel)
    
    frame.add(panel)
예제 #22
0
    def run(self):
        screenSize = Toolkit.getDefaultToolkit().getScreenSize()
        frameSize = Dimension(  # Initial frame size
            screenSize.width >> 2,  # 1/4 screen width
            screenSize.height >> 2  # 1/4 screen height
        )
        frame = JFrame('WSAShelp_02',
                       size=frameSize,
                       locationRelativeTo=None,
                       defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
        #-----------------------------------------------------------------------
        # Reposition the frame to be in the center of the screen
        # Note: This is done based upon initial frameSize, not packed() size...
        #-----------------------------------------------------------------------
        frame.setLocation((screenSize.width - frameSize.width) >> 1,
                          (screenSize.height - frameSize.height) >> 1)

        #-----------------------------------------------------------------------
        # Create & Populate the JTabbedPane
        #-----------------------------------------------------------------------
        objs = [('Help', Help), ('AdminApp', AdminApp),
                ('AdminConfig', AdminConfig), ('AdminControl', AdminControl),
                ('AdminTask', AdminTask)]
        tabs = JTabbedPane()
        for name, obj in objs:
            tabs.addTab(
                name,
                JScrollPane(
                    JTextArea(obj.help().expandtabs(),
                              20,
                              90,
                              font=Font('Courier', Font.PLAIN, 12))))
        #-----------------------------------------------------------------------
        # Add the tabbed pane to the frame & show the result
        #-----------------------------------------------------------------------
        frame.add(tabs)
        frame.pack()
        frame.setVisible(1)
예제 #23
0
 def run( self ) :
     #-----------------------------------------------------------------------
     # Size the frame to use 1/2 of the screen
     #-----------------------------------------------------------------------
     screenSize = Toolkit.getDefaultToolkit().getScreenSize()
     frameSize  = Dimension( screenSize.width >> 1, screenSize.height >> 1 )
     frame = JFrame(
         'javadocInfo_10',
         size = frameSize,
         defaultCloseOperation = JFrame.EXIT_ON_CLOSE
     )
     #-----------------------------------------------------------------------
     # Reposition the frame to be in the center of the screen
     #-----------------------------------------------------------------------
     frame.setLocation(
         ( screenSize.width  - frameSize.width  ) >> 1,
         ( screenSize.height - frameSize.height ) >> 1
     )
     #-----------------------------------------------------------------------
     # Initialize the list to have exactly 1 element
     #-----------------------------------------------------------------------
     model = DefaultListModel()
     model.addElement( 'One moment please...' )
     self.List = JList(
         model,
         valueChanged  = self.pick,
         selectionMode = ListSelectionModel.SINGLE_SELECTION
     )
     #-----------------------------------------------------------------------
     # Put the List in a ScrollPane and place it in the middle of a pane
     #-----------------------------------------------------------------------
     pane = JPanel( layout = BorderLayout() )
     pane.add(
         JScrollPane(
             self.List,
             minimumSize = ( 300, 50 )
         ),
         BorderLayout.CENTER
     )
     #-----------------------------------------------------------------------
     # Add a TextField [for the URL of the selected entry] at the bottom
     #-----------------------------------------------------------------------
     self.text = JTextField(
         'Enter text...',
         caretUpdate = self.caretUpdate
     )
     pane.add( self.text, BorderLayout.SOUTH )
     #-----------------------------------------------------------------------
     # Add the pane and a scrollable TextArea to a SplitPane in the frame
     #-----------------------------------------------------------------------
     self.area = JEditorPane(
         'text/html',
         '<html><h3>Nothing selected</h3></html>',
         editable = 0
     )
     self.splitPane = JSplitPane(
         JSplitPane.HORIZONTAL_SPLIT,
         pane,
         self.area
     )
     self.splitPane.setDividerLocation( 234 )
     frame.add( self.splitPane )
     #-----------------------------------------------------------------------
     # Create a separate thread to locate & proces the remote URL
     #-----------------------------------------------------------------------
     self.Links   = {}    # Initialize the Links dictionary
     self.classes = None  # complete list of all classes found
     soupTask(
         self.List,       # The visible JList instance
         self.text,       # User input field
         JAVADOC_URL,     # Remote web page URL to be processed
         self.Links,      # Dictionary of links found
     ).execute()
     frame.setVisible( 1 )
예제 #24
0
파일: PokerApp.py 프로젝트: medikid/holdem
class PokerApp:
    def __init__(self):
        self._frame = JFrame("PokerApp", size=(600,400), defaultCloseOperation=JFrame.EXIT_ON_CLOSE)

    def minimizeFrame(self, true_false):
        if true_false == True:
            self._frame.state = JFrame.ICONIFIED
        else:
            self._frame.MAXIMIZED_BOTH
#            self._frame.state = JFrame.NORMAL

    def launchPlayNowApp(self, action):
            
            self.playNowApp = PlayNowApp()
            self.pokerTable = PokerTable()
            if (action=="open") :
                self.playNowApp.open()
                self.msg.text += "Play now app opened"
            elif action=="playNowLogin":
                self.playNowApp.login()
                self.msg.text += "Logged into PlayNow app"
            elif action=="texasHoldem":
                self.playNowApp.go_to_texas_holdem()
            elif action=="practiceTable":
                self.playNowApp.go_to_practice_tables()
                self.minimizeFrame(False)
            elif action=="joinTable":
                self.pokerTable.join_table()
            elif action=="highlightObservations":
                self.pokerTable.highlight_regions_all()
            elif action=="leaveTable":
                self.pokerTable.leave_table()
            elif action=="playNowClose":
                self.playNowApp.close()
            else:
                self.minimizeFrame(True)
                self.playNowApp.open()
                self.msg.text += "Play now app opened"
                self.playNowApp.login()
                self.msg.text += "Logged into PlayNow app"
                self.playNowApp.go_to_texas_holdem()
                self.playNowApp.go_to_practice_tables()
                self.minimizeFrame(False)
                self.pokerTable.join_table()
                


    def getScreenSize(self):
        return Toolkit.getDefaultToolkit().getScreenSize()

    def setFrameLocation(self, side):
            screenSize = self.getScreenSize()
            if side == 'Right':
                self._frame.setSize( int(screenSize.width * 0.31), int(screenSize.height * 0.95) )
                self._frame.setLocation( int(screenSize.width * 0.69), 0 )
            

    def playNowApp_startThread(self, action):
            self.setFrameLocation("Right")
            Thread(name="AppLaunch", target=self.launchPlayNowApp, args=(action,) ).start()
            
            

    def setMenuBar(self):
        menuBar = JMenuBar()
        
        menuApp = JMenu("Apps")
        menuApp.setMnemonic('A')
        
        menuSettings = JMenu("Settings")
        menuSettings.setMnemonic('S')
        
        #set submenus
        menuPlayNow = JMenu("PlayNow" )
        
        menuPlayNowOpen = JMenuItem("Open", actionPerformed = (lambda x, param="open": self.playNowApp_startThread(param)) )
        menuPlayNow.add(menuPlayNowOpen)
        
        menuPlayNowLogin = JMenuItem("Login", actionPerformed = lambda x, action="playNowLogin": self.playNowApp_startThread(action) )
        menuPlayNow.add(menuPlayNowLogin)
        
        menuPlayNowClose = JMenuItem("Close", actionPerformed = lambda x, action="playNowClose": self.playNowApp_startThread(action) )
        menuPlayNow.add(menuPlayNowClose)
        
        menuPokerTable = JMenu("PokerTable")
        menuPokerTableJoin = JMenuItem("Find Practice Table", actionPerformed = lambda x, action="practiceTable": self.playNowApp_startThread(action) )
        menuPokerTable.add(menuPokerTableJoin)
        
        menuPokerTableJoin = JMenuItem("Join Table", actionPerformed = lambda x, action="joinTable": self.playNowApp_startThread(action) )
        menuPokerTable.add(menuPokerTableJoin)
        
        menuPokerTableAddChips = JMenuItem("Add Chips", actionPerformed = lambda x, action="addChips": self.playNowApp_startThread(action) )
        menuPokerTable.add(menuPokerTableAddChips)
        
        menuPokerTableSitOut = JMenuItem("Sit Out", actionPerformed = lambda x, action="sitOut": self.playNowApp_startThread(action) )
        menuPokerTable.add(menuPokerTableSitOut)
        
        menuPokerTableLeaveTable = JMenuItem("Leave Table", actionPerformed = lambda x, action="leaveTable": self.playNowApp_startThread(action) )
        menuPokerTable.add(menuPokerTableLeaveTable)
        
        menuPokerAppExit = JMenuItem("Exit")
        
        menuApp.add(menuPlayNow)
        menuApp.add(menuPokerTable)
        menuApp.addSeparator()
        menuApp.add(menuPokerAppExit)
        
        menuBar.add(menuApp)
        menuBar.add(menuSettings)
        
        self._frame.setJMenuBar(menuBar)

    def startGui(self):
        
#        self.gridPanel = JPanel(GridLayout(self.numRows, self.numCols))
#        self.cellButtons = self._doForAllCells(self._createCellButton)
#        self.grid = self._doForAllCells(lambda r,c: False)
#        frame.add(self.gridPanel)
#        buttonPanel = JPanel(FlowLayout())
#        stepButton = JButton("Step", actionPerformed=self._step)
#        runButton = JToggleButton("Run", actionPerformed=self._run)
#        buttonPanel.add(stepButton)
#        buttonPanel.add(runButton)
#        frame.add(buttonPanel, SOUTH)
#        frame.pack()
#        frame.locationRelativeTo = None
        self.setMenuBar()
        
        image_path = "D:\\wamp\\www\\holdem\\src\\poker\\th\\images\\As.png"
        myPicture = ImageIcon(image_path)
        myPictureLabel = JLabel("Pocket: ", myPicture, JLabel.LEFT)
        
        cardPanel = JPanel()
        cardPanel.setLayout(None)
        cardPanel.add(myPictureLabel)
        myPictureLabel.setBounds(10,10,36,52);
        
        self._frame.getContentPane().add(cardPanel)

        
        self.msg=JLabel("Hello")
        self._frame.add(self.msg, NORTH)
        self._frame.locationRelativeTo = None
        self._frame.visible = True
예제 #25
0
# Importing Java packages for simpler Java calls
from java.util import LinkedList, Arrays
python_list = [1, 2, 3]
java_list = LinkedList(Arrays.asList(1, 2, 3))
print str(type(python_list))
print str(type(java_list))

# Python adds helpful syntax to Java data structures
print python_list[0]
print java_list[0]   # can't normally do this in java
print java_list[0:2] # can't normally do this in java

# Iterate over Java collection the Python way
for entry in java_list:
    print entry

# "in" keyword compatibility
print str(3 in java_list)

# Create GUI with Java Swing
from javax.swing import JFrame
frame = JFrame() # don't call constructor with "new"
frame.setSize(400,400)
frame.setLocation(200, 200)
frame.setTitle("Jython JFrame")
frame.setVisible(True)

# Use JavaBean properties in constructor with keyword arguments!
JFrame(title="Super Jython JFrame", size=(400,400), visible=True)
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()
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()     
예제 #28
0
class Menue(object):
    def __init__(self, p):
        self.cellCounter = 1
        self.olay = Overlay()
        self.position = p
        print p.getRoiPath()
        if p.getRoiPath() != None:         # check if there is an existing overlay file and load it!
            p.loadRois()

        self.frame = JFrame("CellCropper", size=(200,200))
        self.frame.setLocation(20,120)
        self.Panel = JPanel(GridLayout(0,1))
        self.frame.add(self.Panel)
        #self.nameField = JTextField("p" + "_c",15)
        self.nameField = JTextField("p" + str(self.position.getID()) + "_c",15)
        self.Panel.add(self.nameField)
        self.cutoutButton = JButton("Cut out cell",actionPerformed=cut)
        self.Panel.add(self.cutoutButton)
        self.delOlButton = JButton("Delete Overlay",actionPerformed=delOverlay)
        self.Panel.add(self.delOlButton)
        self.saveOlButton = JButton("Save Overlay",actionPerformed=saveOverlay)
        self.Panel.add(self.saveOlButton) 
        self.quitButton = JButton("Quit script",actionPerformed=quit)
        self.Panel.add(self.quitButton)
        self.frame.pack()
        WindowManager.addWindow(self.frame)
        self.show()
        #IJ.setTool("freehand")

    '''def getPosition(self, path, filename):
       moved to containers.position.determineID(path, filename)'''

    def eventtest(self, event):
        print "eventtest"

    def setTextField(self, pos):
        name = "p" + str(pos) + "_c"
        self.nameField.setText(name)

    def openOl(self, path, fileName):
        print "aaaaah"

    def show(self):
        self.frame.visible = True

    def close(self):
        if self.olay != None:
            yncd = YesNoCancelDialog(self.frame, "Save overlay?", "Save overlay?") #frame, title, message
            if yncd.yesPressed():
                self.saveOverlay()
        WindowManager.removeWindow(self.frame)
        self.frame.dispose()
        
    def resetCounter(self):
        self.cellCounter = 0
        
    def increaseCounter(self):
        self.cellCounter += 1
        
    def setCounter(self):
        self.cellCounter += 1
        
    #'get' functions
    def getImp(self):
        return self.imp
    
    def getCounter(self):
        return self.cellCounter
        
    def getFrame(self):
        return self.frame
        
    def getFilePath(self):
        return self.filePath

    def getTextField(self):
        return self.nameField.text
    
    def getPosition(self):
        return self.position
    
    # overlay functions
    def addOlay(self, roi):
        self.olay.add(roi)

    def getOverlay(self):
        return self.olay

    def clearOverlay(self):
        self.olay.clear()
        self.cellCounter = 1

    def saveOverlay(self):
        self.position.saveRois()   
예제 #29
0
class NewAccountGUI:
    def __init__(self, amgui):
        self.amgui = amgui
        self.am = amgui.acctmanager
        self.buildgwinfo()
        self.autologin = JCheckBox("Automatically Log In")
        self.acctname = JTextField()
        self.gwoptions = JPanel(doublebuffered)
        self.gwoptions.border = TitledBorder("Gateway Options")
        self.buildgwoptions("Twisted")
        self.mainframe = JFrame("New Account Window")
        self.buildpane()

    def buildgwinfo(self):
        self.gateways = {
            "Twisted": {
                "ident": JTextField(),
                "passwd": JPasswordField(),
                "host": JTextField("twistedmatrix.com"),
                "port": JTextField("8787"),
                "service": JTextField("twisted.words"),
                "persp": JTextField(),
            },
            "AIM": {
                "ident": JTextField(),
                "passwd": JPasswordField(),
                "host": JTextField("toc.oscar.aol.com"),
                "port": JTextField("9898"),
            },
            "IRC": {
                "ident": JTextField(),
                "passwd": JPasswordField(),
                "host": JTextField(),
                "port": JTextField("6667"),
                "channels": JTextField(),
            },
        }
        self.displayorder = {
            "Twisted": [
                ["Identity Name", "ident"],
                ["Password", "passwd"],
                ["Host", "host"],
                ["Port", "port"],
                ["Service Name", "service"],
                ["Perspective Name", "persp"],
            ],
            "AIM": [["Screen Name", "ident"], ["Password", "passwd"], ["Host", "host"], ["Port", "port"]],
            "IRC": [
                ["Nickname", "ident"],
                ["Password", "passwd"],
                ["Host", "host"],
                ["Port", "port"],
                ["Channels", "channels"],
            ],
        }

    def buildgwoptions(self, gw):
        self.gwoptions.removeAll()
        self.gwoptions.layout = GridLayout(len(self.gateways[gw]), 2)
        for mapping in self.displayorder[gw]:
            self.gwoptions.add(JLabel(mapping[0]))
            self.gwoptions.add(self.gateways[gw][mapping[1]])

    def buildpane(self):
        gw = JPanel(GridLayout(1, 2), doublebuffered)
        gw.add(JLabel("Gateway"))
        self.gwlist = JComboBox(self.gateways.keys())  # , actionPerformed=self.changegw)
        self.gwlist.setSelectedItem("Twisted")
        gw.add(self.gwlist)

        stdoptions = JPanel(GridLayout(2, 2), doublebuffered)
        stdoptions.border = TitledBorder("Standard Options")
        stdoptions.add(JLabel())
        stdoptions.add(self.autologin)
        stdoptions.add(JLabel("Account Name"))
        stdoptions.add(self.acctname)

        buttons = JPanel(FlowLayout(), doublebuffered)
        buttons.add(JButton("OK", actionPerformed=self.addaccount))
        buttons.add(JButton("Cancel", actionPerformed=self.cancel))

        mainpane = self.mainframe.getContentPane()
        mainpane.layout = BoxLayout(mainpane, BoxLayout.Y_AXIS)
        mainpane.add(gw)
        mainpane.add(self.gwoptions)
        mainpane.add(stdoptions)
        mainpane.add(buttons)

    def show(self):
        self.mainframe.setLocation(100, 100)
        self.mainframe.pack()
        self.mainframe.show()

    # actionlisteners
    def changegw(self, ae):
        self.buildgwoptions(self.gwlist.getSelectedItem())
        self.mainframe.pack()
        self.mainframe.show()

    def addaccount(self, ae):
        gwselection = self.gwlist.getSelectedItem()
        gw = self.gateways[gwselection]
        name = gw["ident"].text
        passwd = gw["passwd"].text
        host = gw["host"].text
        port = int(gw["port"].text)
        autologin = self.autologin.isSelected()
        acctname = self.acctname.text

        if gwselection == "Twisted":
            sname = gw["service"].text
            perspective = gw["persp"].text
            self.am.addAccount(PBAccount(acctname, autologin, name, passwd, host, port, [[stype, sname, perspective]]))
        elif gwselection == "AIM":
            self.am.addAccount(TOCAccount(acctname, autologin, name, passwd, host, port))
        elif gwselection == "IRC":
            channels = gw["channels"].text
            self.am.addAccount(IRCAccount(acctname, autologin, name, passwd, host, port, channels))

        self.amgui.update()
        print "Added new account"
        self.mainframe.dispose()

    def cancel(self, ae):
        print "Cancelling new account creation"
        self.mainframe.dispose()
def loginPage():
    global heading
    global rbAdmin
    global rbTeacher
    global rbStudent
    global frame
    global tfLoginId
    global tfPassword

    frame = JFrame("Login Form ")
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    frame.setSize(500, 500)
    frame.setLocation(200, 200)
    frame.setLayout(None)
    frame.setVisible(True)

    panel = JPanel()
    panel.setSize(500, 500)
    panel.setLocation(0, 0)
    panel.setLayout(None)

    panel.setBackground(Color.BLUE)

    heading = JLabel("Admin Login")
    heading.setBounds(200, 50, 150, 30)

    rbAdmin = JRadioButton("Admin", actionPerformed=clickRadio)
    rbTeacher = JRadioButton("Teacher", actionPerformed=clickRadio)
    rbStudent = JRadioButton("Student", actionPerformed=clickRadio)

    rbAdmin.setBounds(100, 150, 100, 20)
    rbTeacher.setBounds(200, 150, 100, 20)
    rbStudent.setBounds(300, 150, 100, 20)

    btnGroup = ButtonGroup()
    btnGroup.add(rbAdmin)
    btnGroup.add(rbTeacher)
    btnGroup.add(rbStudent)

    lbLoginId = JLabel("LoginId")
    lbPassword = JLabel("Password")

    lbLoginId.setBounds(100, 230, 150, 30)
    lbPassword.setBounds(100, 300, 150, 30)

    tfLoginId = JTextField()
    tfPassword = JTextField()

    tfLoginId.setBounds(250, 230, 150, 30)
    tfPassword.setBounds(250, 300, 150, 30)

    btnLogin = JButton("Login", actionPerformed=clickLogin)
    btnLogin.setBounds(350, 350, 100, 30)

    btnReg = JButton("New Institute Registration", actionPerformed=clickReg)
    btnReg.setBounds(350, 400, 100, 30)

    panel.add(heading)
    panel.add(rbAdmin)
    panel.add(rbTeacher)
    panel.add(rbStudent)
    panel.add(lbLoginId)
    panel.add(lbPassword)
    panel.add(tfLoginId)
    panel.add(tfPassword)
    panel.add(btnLogin)
    panel.add(btnReg)

    panel.setVisible(True)

    frame.add(panel)
예제 #31
0
class PropertyEditor(WindowAdapter):
    """
    Edits Tabular Properties of a given WindowAdapter
    """
    instances = {}
    last_location = None
    locations = {}
    last_size = None
    sizes = {}

    NEW_WINDOW_OFFSET = 32
    offset = NEW_WINDOW_OFFSET

    @staticmethod
    def get_instance(text="Property Editor",
                     columns=None,
                     data=None,
                     empty=None,
                     add_actions=True,
                     actions=None):
        """
        Singleton Method based on the text property. It tries to generate only one property configuration page per text.

        :param text: getinstance key
        :param columns: proparty columns it should be an array alike
        :param data: it contains the current property rows
        :param empty: empty row property when adding a new one
        :param add_actions: include or not new actions
        :param actions: default set of actions to be appended to Add and Delete Rows
        :return: a new instance of PropertyEditor or a reused one.
        """
        if not actions: actions = []
        if not columns: columns = []
        if data == None: data = []
        if not empty: empty = []
        try:
            PropertyEditor.instances[text]
        except KeyError:
            PropertyEditor.instances[text] = \
                PropertyEditor().__private_init__(text, columns, data, empty, add_actions, actions)
            try:
                PropertyEditor.instances[text].this.setLocation(
                    PropertyEditor.locations[text])
            except KeyError:
                if PropertyEditor.last_location:
                    PropertyEditor.instances[text].this.setLocation(
                        PropertyEditor.last_location.x + PropertyEditor.offset,
                        PropertyEditor.last_location.y + PropertyEditor.offset)
                    PropertyEditor.offset = PropertyEditor.NEW_WINDOW_OFFSET
            try:
                PropertyEditor.instances[text].this.setSize(
                    PropertyEditor.sizes[text])
            except KeyError:
                if PropertyEditor.last_size:
                    PropertyEditor.instances[text].this.setSize(
                        PropertyEditor.last_size)
            PropertyEditor.last_location = PropertyEditor.instances[
                text].this.getLocation()
            PropertyEditor.last_size = PropertyEditor.instances[
                text].this.getSize()
        ## Hack ON: Bring on Front
        PropertyEditor.instances[text].this.setAlwaysOnTop(True)
        PropertyEditor.instances[text].this.setAlwaysOnTop(False)
        ## Hack OFF
        return PropertyEditor.instances[text]

    def __private_init__(self,
                         text="Property Editor",
                         columns=None,
                         data=None,
                         empty=None,
                         add_actions=True,
                         actions=None):
        if not actions: actions = []
        if not columns: columns = []
        if data == None: data = []
        if not empty: empty = []

        self._text = text
        self.this = JFrame(text)
        self._table = JTable()
        self._dtm = DefaultTableModel(0, 0)
        self._dtm.setColumnIdentifiers(columns)
        self._table.setModel(self._dtm)
        self._data = data
        for d in data:
            self._dtm.addRow(d)
        self._pane = JScrollPane(self._table)
        self.this.add(self._pane)
        self._empty = empty

        self.this.addWindowListener(self)

        self._dtm.addTableModelListener(lambda _: self._update_model())
        self.this.setLocation(PropertyEditor.NEW_WINDOW_OFFSET,
                              PropertyEditor.NEW_WINDOW_OFFSET)

        if add_actions:
            self._popup = JPopupMenu()
            self._pane.setComponentPopupMenu(self._popup)
            inherits_popup_menu(self._pane)

            self._actions = actions
            self._actions.append(
                ExecutorAction('Remove Selected Rows',
                               action=lambda e: self._remove_row()))
            self._actions.append(
                ExecutorAction('Add New Row',
                               action=lambda e: self._add_row()))

            for action in self._actions:
                self._popup.add(action.menuitem)

        self.this.setForeground(Color.black)
        self.this.setBackground(Color.lightGray)
        self.this.pack()
        self.this.setVisible(True)
        self.this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE)

        return self

    def _add_row(self):
        """
        Add a new row the selection

        :return: None
        """
        self._dtm.addRow(self._empty)

    def _remove_row(self):
        """
        Remove all the selected rows from the selection
        :return:
        """
        rows = self._table.getSelectedRows()
        for i in range(0, len(rows)):
            self._dtm.removeRow(rows[i] - i)

    def windowClosing(self, evt):
        """
        Overrides WindowAdapter method

        :param evt: unused
        :return: None
        """
        PropertyEditor.locations[self._text] = self.this.getLocation()
        PropertyEditor.sizes[self._text] = self.this.getSize()
        PropertyEditor.last_location = self.this.getLocation()
        PropertyEditor.last_size = self.this.getSize()
        PropertyEditor.offset = 0
        self.this.setVisible(False)
        self.this.dispose()
        del PropertyEditor.instances[self._text]

    def _update_model(self):
        """
        Update the data content with the updated rows

        :return: None
        """
        del self._data[:]
        nRow = self._dtm.getRowCount()
        nCol = self._dtm.getColumnCount()
        for i in range(0, nRow):
            self._data.append([None] * nCol)
            for j in range(0, nCol):
                d = str(self._dtm.getValueAt(i, j)).lower()
                if d == 'none' or d == '':
                    self._data[i][j] = None
                elif d == 'true' or d == 't':
                    self._data[i][j] = True
                elif d == 'false' or d == 'f':
                    self._data[i][j] = False
                else:
                    try:
                        self._data[i][j] = int(self._dtm.getValueAt(i, j))
                    except ValueError:
                        self._data[i][j] = self._dtm.getValueAt(i, j)
예제 #32
0
def createStudentFeeForm(stFeeObj):
    
    global tfStudentId
    global tfStudentName
    global tfTotalAmount
    global tfPaidAmount
    global tfRemainingAmount 
    global frame
    
    frame = JFrame("Student Fee Form ")
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    frame.setSize(500,500)
    frame.setLocation(200,200)
    frame.setLayout(None)
    frame.setVisible(True)
    
    panel = JPanel()
    panel.setSize(500,500)
    panel.setLocation(0,0)
    panel.setLayout(None)
    panel.setVisible(True)
    panel.setBackground(Color.LIGHT_GRAY)
    
    heading = JLabel("STUDENT FEE")
    heading.setBounds(200,30,150,40)

    lbStudentId = JLabel(" Student id")
    lbStudentName = JLabel(" student name")
    lbTotalAmount = JLabel("Total Amount ")
    lbPaidAmount = JLabel("Paid Amount")
    lbRemainingAmount = JLabel("Remaining amount")
    
    studentId =getattr(stFeeObj,'studentId')
    studentName =getattr(stFeeObj,'studentName')
    totalAmount =getattr(stFeeObj,'totalAmount')
    paidAmount =getattr(stFeeObj,'paidAmount')
    remainingAmount =getattr(stFeeObj,'remainingAmount')
    
    
    tfStudentId = JTextField(str(studentId))
    tfStudentName = JTextField(str(studentName))
    tfTotalAmount = JTextField(str(totalAmount))
    tfPaidAmount = JTextField(str(paidAmount))
    tfRemainingAmount = JTextField(str(remainingAmount))
    
    tfStudentId.setEditable(False)
    tfStudentName.setEditable(False)
    tfTotalAmount.setEditable(False)
    tfRemainingAmount.setEditable(False)
    
    lbStudentId.setBounds(70,100,130,30)
    lbStudentName.setBounds(70,150,130,30)
    lbTotalAmount.setBounds(70,200,130,30)
    lbPaidAmount.setBounds(70,250,130,30)
    lbRemainingAmount.setBounds(70,300,130,30)
    
    tfStudentId.setBounds(220,100,130,30)
    tfStudentName.setBounds(220,150,130,30)
    tfTotalAmount.setBounds(220,200,130,30)
    tfPaidAmount.setBounds(220,250,130,30)
    tfRemainingAmount.setBounds(220,300,130,30)
    
    btnPay = JButton("Paid",actionPerformed=clickPay)
    btnPay.setBounds(350,410,100,40)
    
    btnCancel = JButton("Cancel",actionPerformed=clickbtnCancelForm)
    btnCancel.setBounds(50,410,100,40)
    
    panel.add(heading)
    panel.add(lbStudentId)
    panel.add(lbStudentName)
    panel.add(lbTotalAmount)
    panel.add(lbPaidAmount)
    panel.add(lbRemainingAmount)
    panel.add(tfStudentId)
    panel.add(tfStudentName)
    panel.add(tfTotalAmount)
    panel.add(tfPaidAmount)
    panel.add(tfRemainingAmount)
    panel.add(btnPay)
    panel.add(btnCancel)
    
    frame.add(panel)
예제 #33
0
def instReg():
    global frame
    global tfName
    global tfPhone
    global taAddress
    global tfAdminLoginId
    global tfAdminPassword
    
    frame = JFrame("Registration Form ")
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    frame.setSize(500,550)
    frame.setLocation(200,200)
    frame.setLayout(None)
    frame.setVisible(True)
    
    panel = JPanel()
    panel.setSize(500,550)
    panel.setLocation(0,0)
    panel.setLayout(None)
    panel.setBackground(Color.LIGHT_GRAY)
    
    heading = JLabel("Institute Registration Form ")
    heading.setBounds(200,30,150,30)
    
    lbName = JLabel("Name")
    lbPhone =JLabel("Phone no ")
    lbAddress = JLabel("Address")
    lbAdminLoginId = JLabel("Admin login  ")
    lbAdminPassword =JLabel("Admin Password")

    font =  Font("Courier",Font.PLAIN,16)		
    
    tfName = JTextField()
    tfPhone = JTextField()
    taAddress =JTextArea()
    tfAdminLoginId = JTextField()
    tfAdminPassword = JTextField()
    
    lbName.setBounds(70,100,150,40)
    lbPhone.setBounds(70,150,150,40)
    lbAddress.setBounds(70,200,150,40)
    lbAdminLoginId.setBounds(70,310,150,40)
    lbAdminPassword.setBounds(70,360,150,40)
    
    tfName = JTextField()
    tfPhone = JTextField()
    taAddress = JTextArea()
    tfAdminLoginId = JTextField()
    tfAdminPassword = JTextField()
    
    tfName.setBounds(250,100,200,40)
    tfPhone.setBounds(250,150,200,40)
    taAddress.setBounds(250,200,200,100)
    tfAdminLoginId.setBounds(250,310,200,40)
    tfAdminPassword.setBounds(250,360,200,40)
    
    tfName.setFont(font)
    tfPhone.setFont(font)
    taAddress.setFont(font)
    tfAdminLoginId.setFont(font)
    tfAdminPassword.setFont(font) 
    
    sp = JScrollPane(taAddress)
    c = frame.getContentPane()
    
    btnSave = JButton("Save",actionPerformed=clickAdminReg)
    btnSave.setBounds(350,420,80,30)
    
    
    
    #panel.add(lbName)
    #panel.add(lbPhone)
    #panel.add(lbAddress)
    #panel.add(lbAdminLoginId)
    #panel.add(lbAdminPassword)
    #panel.add(tfName)
    #panel.add(tfPhone)
    #panel.add(c)
    #panel.add(tfAdminLoginId)
    #panel.add(tfAdminPassword)
    #panel.add(btnSave)
    #panel.add(btnLogin)
    
    c.add(lbName)
    c.add(lbPhone)
    c.add(lbAddress)
    c.add(lbAdminLoginId)
    c.add(lbAdminPassword)
    c.add(tfName)
    c.add(tfPhone)
    c.add(taAddress)
    c.add(tfAdminLoginId)
    c.add(tfAdminPassword)
    c.add(btnSave)
    
    frame.add(c)
예제 #34
0
class TicTacToeGame(WindowAdapter):

    # Tic Tac Toe game with Mario and Dizzy animated icons/music.
    # Computer plays with Mario and player plays with Dizzy.

    # game title
    game_title = "Tic Tac Toe: You vs Mario"
    # welcome status message.
    welcome_status = "Welcome! Please make your first move."
    # in-game status message.
    in_game_status = "Mario chases You! Hurry up!"
    # board 3x3 with the default color - white
    board = [[' ', ' ', ' '], [' ', ' ', ' '], [' ', ' ', ' ']]
    # total number of cells
    size = len(board) * len(board)
    # size of cell
    tile_size = 128
    # status bar height
    status_bar_height = 50
    # status bar top margin
    status_bar_margin_top = -15
    # status bar left margin
    status_bar_margin_left = 10
    # number of cells in a row/column
    cells = 3
    # winner
    winner = None
    # Mario image
    mario = '/MARIO_128x128.gif'
    # Dizzy image
    dizzy = None

    # Blank
    blank = '/BLANK.gif'
    # supported musice sounds
    sounds = ['/DIZZY.wav', '/MARIO.wav']
    # currently played sound
    sound = None
    # last chosen sound
    last_sound = 0
    # won sound
    won_sound = '/WON.wav'
    # lose sound
    lose_sound = '/LOSE.wav'
    # tie sound
    tie_sound = '/TIE.wav'
    # action sound
    action_sound = '/ACTION.wav'

    def __init__(self, resources_directory):

        # Game constructor.
        #
        # Parameters:
        #   resources_directory Directory to look for images and audio files.

        is_windows = platform.platform().lower().find('win') > 0
        self.main_window_padding_right = 20 if is_windows else 0
        self.main_window_padding_bottom = 40 if is_windows else 0

        self.resources_directory = resources_directory

        self.button1 = JButton("", actionPerformed=self.clicked1)
        self.button2 = JButton("", actionPerformed=self.clicked2)
        self.button3 = JButton("", actionPerformed=self.clicked3)
        self.button4 = JButton("", actionPerformed=self.clicked4)
        self.button5 = JButton("", actionPerformed=self.clicked5)
        self.button6 = JButton("", actionPerformed=self.clicked6)
        self.button7 = JButton("", actionPerformed=self.clicked7)
        self.button8 = JButton("", actionPerformed=self.clicked8)
        self.button9 = JButton("", actionPerformed=self.clicked9)
        image_size = self.tile_size
        self.button1.setBounds(0 * image_size, 0 * image_size, image_size,
                               image_size)
        self.button2.setBounds(1 * image_size, 0 * image_size, image_size,
                               image_size)
        self.button3.setBounds(2 * image_size, 0 * image_size, image_size,
                               image_size)
        self.button4.setBounds(0 * image_size, 1 * image_size, image_size,
                               image_size)
        self.button5.setBounds(1 * image_size, 1 * image_size, image_size,
                               image_size)
        self.button6.setBounds(2 * image_size, 1 * image_size, image_size,
                               image_size)
        self.button7.setBounds(0 * image_size, 2 * image_size, image_size,
                               image_size)
        self.button8.setBounds(1 * image_size, 2 * image_size, image_size,
                               image_size)
        self.button9.setBounds(2 * image_size, 2 * image_size, image_size,
                               image_size)
        self.buttons = [
            self.button1, self.button2, self.button3, self.button4,
            self.button5, self.button6, self.button7, self.button8,
            self.button9
        ]
        self.buttons_mapped = [[self.button1, self.button2, self.button3],
                               [self.button4, self.button5, self.button6],
                               [self.button7, self.button8, self.button9]]

        width = self.tile_size * self.cells
        height = width
        self.frame = JFrame(self.game_title,
                            size=(width, height + self.status_bar_height))
        self.frame.setLocation(200, 100)
        self.frame.setLayout(None)

        for button in self.buttons:
            self.frame.add(button)

        self.status_label = JLabel("")
        self.status_label.setBounds(self.status_bar_margin_left,
                                    height + self.status_bar_margin_top, width,
                                    self.status_bar_height)
        self.frame.add(self.status_label)

        self.frame.setVisible(True)
        self.frame.addWindowListener(self)
        random.shuffle(self.sounds)

        self.restart()

    # Restarts the game.
    def restart(self):

        self.dizzy = None
        self.dizzy = self.choosePlayer()
        self.winner = None
        self.board = [[' ', ' ', ' '], [' ', ' ', ' '], [' ', ' ', ' ']]
        for button in self.buttons:
            button.setIcon(ImageIcon(self.resources_directory + self.blank))
        self.stop_playing_background()
        self.sound = self.play_sound_safe(self.sounds[self.last_sound])
        self.last_sound = self.last_sound + 1
        if self.last_sound >= len(self.sounds):
            self.last_sound = 0
        self.status_label.setText(self.welcome_status)

    # Stops playing any background music, if any playing now.
    def stop_playing_background(self):

        if self.sound != None:
            self.sound.stopPlaying()
            self.sound = None

    def set_dizzy(self, button):

        # Draws Dizzy in a given button, sets game status to "Playing" and
        # plays action sound.
        #
        # Parameters:
        #   button to set Dizzy icon to.

        button.setIcon(ImageIcon(self.resources_directory + self.dizzy))
        self.status_label.setText(self.in_game_status)
        self.play_sound_safe(self.action_sound)

    def set_mario(self, button):

        # Draws Mario in a given button.
        #
        # Parameters:
        #   button to set Mario icon to.

        button.setIcon(ImageIcon(self.resources_directory + self.mario))

    def clicked1(self, event):

        # Event listener method for the button of the game at 0x0.
        #
        # Parameters:
        #  event Click event.

        if self.board[0][0] != ' ':
            return
        self.board[0][0] = 'X'
        self.set_dizzy(self.button1)
        self.computer_move()

    def clicked2(self, event):

        # Event listener method for the button of the game at 0x1.
        #
        # Parameters:
        #  event Click event.

        if self.board[0][1] != ' ':
            return
        self.board[0][1] = 'X'
        self.set_dizzy(self.button2)
        self.computer_move()

    def clicked3(self, event):

        # Event listener method for the button of the game at 0x2.
        #
        # Parameters:
        #  event Click event.

        if self.board[0][2] != ' ':
            return
        self.board[0][2] = 'X'
        self.set_dizzy(self.button3)
        self.computer_move()

    def clicked4(self, event):

        # Event listener method for the button of the game at 1x0.
        #
        # Parameters:
        #  event Click event.

        if self.board[1][0] != ' ':
            return
        self.board[1][0] = 'X'
        self.set_dizzy(self.button4)
        self.computer_move()

    def clicked5(self, event):

        # Event listener method for the button of the game at 1x1.
        #
        # Parameters:
        #  event Click event.

        if self.board[1][1] != ' ':
            return
        self.board[1][1] = 'X'
        self.set_dizzy(self.button5)
        self.computer_move()

    def clicked6(self, event):

        # Event listener method for the button of the game at 1x2.
        #
        # Parameters:
        #  event Click event.

        if self.board[1][2] != ' ':
            return
        self.board[1][2] = 'X'
        self.set_dizzy(self.button6)
        self.computer_move()

    def clicked7(self, event):

        # Event listener method for the button of the game at 2x0.
        #
        # Parameters:
        #  event Click event.

        if self.board[2][0] != ' ':
            return
        self.board[2][0] = 'X'
        self.set_dizzy(self.button7)
        self.computer_move()

    def clicked8(self, event):

        # Event listener method for the button of the game at 2x1.

        # Parameters:
        #  event Click event.

        if self.board[2][1] != ' ':
            return
        self.board[2][1] = 'X'
        self.set_dizzy(self.button8)
        self.computer_move()

    def clicked9(self, event):

        # Event listener method for the button of the game at 2x2.
        #
        # Parameters:
        #  event Click event.

        if self.board[2][2] != ' ':
            return
        self.board[2][2] = 'X'
        self.set_dizzy(self.button9)
        self.computer_move()

    # Makes the next move on the board on behalf of the computer.
    def computer_move(self):

        # first move optimization - always start in the middle if possible
        if self.board[1][1] == ' ':
            self.board[1][1] = '0'
            self.set_mario(self.buttons_mapped[1][1])
            self.test_state()
            return
        while self.has_empty_cell():
            y = random.randint(0, self.cells - 1)
            x = random.randint(0, self.cells - 1)
            if self.board[y][x] == ' ':
                self.board[y][x] = '0'
                self.set_mario(self.buttons_mapped[y][x])
                break
        self.test_state()

    def test_state(self):

        # Tests the board for a winning state.
        # If there is a winner then stops currently playing
        # background sound, creates winning label, plays result
        # sound and notifies/asks the user about continuation.

        if self.is_any_line_filled('X'):
            self.winner = self.dizzy  # dizzy
        elif self.is_any_line_filled('0'):
            self.winner = self.mario  # mario
        elif not self.has_empty_cell():
            self.winner = self.blank  # tie
        if self.winner:
            label = 'Tie.'
            self.stop_playing_background()
            if self.winner == self.mario:
                label = 'You lose!'
                self.play_sound_safe(self.lose_sound)
            elif self.winner == self.dizzy:
                label = 'You won!'
                self.play_sound_safe(self.won_sound)
            else:
                self.play_sound_safe(self.tie_sound)
            self.notify_and_ask_about_continuation(label)

    def notify_and_ask_about_continuation(self, label):

        # Shows modal window with the result of the game and asks the use whether they want to
        # continue the game.
        # If user answers "Y" or "y" restarts the game.
        # If user answers "N" or "n" closes the game window and frees the resources.

        # Parameters:
        #   label Game result label.

        answer = None
        self.status_label.setText(label)
        while True:
            answer = str(
                requestString(label + "\r\n" +
                              "Do you want to play again? (Y/N)"))
            if answer.lower() == "y":
                self.restart()
                break
            elif answer.lower() == "n":
                self.windowClosing(None)
                break

    def is_any_line_filled(self, character):

        # Checks the winning condition for the given character 'X' or '0'.
        #
        # Returns:
        #  Whether the given character 'X' or '0' has a winning line filled.

        is_row = self.is_row_filled(character)
        is_col = self.is_col_filled(character)
        is_d1 = self.is_diag_filled1(character)
        is_d2 = self.is_diag_filled2(character)

        return is_row or is_col or is_d1 or is_d2

    def has_empty_cell(self):

        #Checks if the game board contains an empty cell for the next move.
        #
        #Returns:
        #  Whether there is an empty cell on the board.

        for row in range(len(self.board)):
            for col in range(len(self.board)):
                if self.board[row][col] == ' ':
                    return True
        return False

    def is_row_filled(self, color):

        # Check row win condition.
        #
        # Parameters:
        #   color (string) - color to check if the whole row of the same color
        # Returns:
        #   True (boolean) - if the whole row of the same color
        #   False (boolean) - if the row is not of the same color

        for row in range(len(self.board)):
            count = 0
            for col in range(len(self.board)):
                if self.board[row][col] == color:
                    count = count + 1
            if count == self.cells:
                return True
        return False

    def is_col_filled(self, color):

        #Check column win condition.
        #
        # Parameters:
        #   color (string) - color to check if the whole column of the same color
        # Returns:
        #   True (boolean) - if the whole column of the same color
        #   False (boolean) - if the column is not of the same color

        for col in range(len(self.board)):
            count = 0
            for row in range(len(self.board)):
                if self.board[row][col] == color:
                    count = count + 1
            if count == self.cells:
                return True
        return False

    def is_diag_filled1(self, color):

        # Checks first diagonal win condition.
        #
        # Parameters:
        #   color (string) - color to check if the whole diagonal of the same color
        # Returns:
        #    True (boolean) - if the whole diagonal of the same color
        #    False (boolean) - if the diagonal is not of the same color

        count = 0
        for idx in range(len(self.board)):
            if self.board[idx][idx] == color:
                count = count + 1
        return count == self.cells

    def is_diag_filled2(self, color):

        # Checks second diagonal win condition.
        #
        # Parameters:
        #   color (string) - color to check if the whole diagonal of the same color
        # Returns:
        #    True (boolean) - if the whole diagonal of the same color
        #   False (boolean) - if the diagonal is not of the same color

        count = 0
        for idx in range(len(self.board)):
            if self.board[idx][self.cells - 1 - idx] == color:
                count = count + 1
        return count == self.cells

    def play_sound_safe(self, sound):

        # Method tries to play given sound catching possible exceptions.
        # For example, if the sound wasn't found in resource directory
        #
        # Parameters:
        #    sound string with a file of a sound with leading slash '/'.
        # Returns:
        #    Created Sound object fromo makeSound.

        snd = None
        try:
            snd = makeSound(self.resources_directory + sound)
            play(snd)
        except:
            showError("Error while playing sound " + str(sound) + ".")
        return snd

    def windowClosing(self, event):

        # Method is invoked when a user closes game window or finishes playing.
        # It is the implementation of WindowAdapter interface.
        #
        # Parameters: final event from Swing/AWT

        self.stop_playing_background()
        self.buttons = []
        self.buttons_mapped = []
        self.button1 = None
        self.button2 = None
        self.button3 = None
        self.button4 = None
        self.button5 = None
        self.button6 = None
        self.button7 = None
        self.button8 = None
        self.button9 = None
        self.status_label = None
        self.frame.getContentPane().removeAll()
        self.frame.dispose()
        self.frame = None

    def choosePlayer(self):

        while true:

            select = requestString(
                "You are against Mario. Choose Your Character: penguin chrome fox fish bird charizard sonic "
            )
            selection = select.lower()

            if selection == "penguin":
                return rpenguin
                break
            if selection == "chrome":
                return rchrome
                break
            if selection == "fox":
                return rfox
                break
            if selection == "fish":
                return rfish
                break
            if selection == "bird":
                return rbird
                break
            if selection == "charizard":
                return rcharizard
                break
            if selection == "sonic":
                return rsonic
                break
예제 #35
0
   print "Temp ROIs OPENED"

   for i in range(0, rm.getCount()):
      roi = rm.getRoi(i)
      new_roi = RoiEnlarger.enlarge(roi, -pixels) # Key to use this instead of the IJ.run("Enlarge... much faster!!
      rm.setRoi(new_roi,i)

   gvars['eroded_pixels'] = pixels # Store globally the amount of pixels used to later save them in the ROI file name


###########################################################
####################  Window #1 ###########################
###########################################################

frame1 = JFrame("LabelToRoi: Single or Multiple")
frame1.setLocation(100,100)
frame1.setSize(450,200)
frame1.setLayout(None)

def clic_single(event):
   frame1.setVisible(False)
   frame2.setVisible(True)

def clic_multiple(event):
   print("Click Multiple")
   frame1.setVisible(False)
   frame4.setVisible(True)

# Single Image Button
btn_single = JButton("Single Image", actionPerformed = clic_single)
btn_single.setBounds(120,20,200,50)
예제 #36
0
status.editable = False
status.wrapStyleWord = True
status.lineWrap = True
status.setBackground(JC.white)
status.setFont(JFONT("Dialog", JFONT.PLAIN, 15))
status.setBounds(1550, 0, 250, 50)
layout.add(status)
pauseButton = JButton('Pause (+30 min.)', actionPerformed=pause_click)
pauseButton.setBounds(1250, 0, 150, 50)
layout.add(pauseButton)
resumeButton = JButton('Lancer maintenant', actionPerformed=resume)
resumeButton.setBounds(1400, 0, 150, 50)
layout.add(resumeButton)
box.pack()
box.setSize(1800, 100)
box.setLocation(0, 0)
box.visible = True

# ============================== DÉBUT DU PROGRAMME =========================================================
current_world = 0
POMO_skip = 0
next_run = .25
clearlog()
clearRemote()

while 1:
    resumeButton.setEnabled(True)
    status.setText(" ")
    while next_run > 0:
        countdown = min(60, 60 * next_run)
        while countdown > 0:
예제 #37
0
def updateTeacherForm(data):

    global heading
    global tfTeacherName
    global tfTeacherPhone
    global taTeacherAddress
    global tfTeacherEmail
    global tfTeacherCourse
    global tfTeacherPayment
    global frame
    global btnEnter

    frame = JFrame(" Teacher ")
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    frame.setSize(500, 600)
    frame.setLocation(200, 200)
    frame.setLayout(None)
    frame.setVisible(True)

    panel = JPanel()
    panel.setSize(500, 600)
    panel.setLocation(0, 0)
    panel.setLayout(None)
    panel.setVisible(True)
    panel.setBackground(Color.LIGHT_GRAY)

    heading = JLabel(" TEACHER PROFILE")
    heading.setBounds(200, 30, 150, 40)

    lbTeacherName = JLabel("Teacher Name ")
    lbTeacherPhone = JLabel("Phone")
    lbTeacherEmail = JLabel("Email")
    lbTeacherAddress = JLabel("Address")
    lbTeacherCourse = JLabel("Teacher Course ")
    lbTeacherPayment = JLabel("Teacher Payment")

    teacherName = data[0].encode('ascii')
    teacherPhone = data[1].encode('ascii')
    teacherEmail = data[2].encode('ascii')
    teacherAddress = data[3].encode('ascii')
    teacherCourse = data[4].encode('ascii')
    teacherPayment = data[5]

    tfTeacherName = JTextField(teacherName)
    tfTeacherPhone = JTextField(teacherPhone)
    taTeacherAddress = JTextArea(teacherAddress)
    tfTeacherEmail = JTextField(teacherEmail)
    tfTeacherCourse = JTextField(teacherCourse)
    tfTeacherPayment = JTextField(str(teacherPayment))

    tfTeacherCourse.setEditable(False)
    tfTeacherPayment.setEditable(False)
    tfTeacherName.setEditable(False)

    lbTeacherName.setBounds(70, 100, 130, 30)
    lbTeacherPhone.setBounds(70, 150, 130, 30)
    lbTeacherEmail.setBounds(70, 200, 130, 30)
    lbTeacherAddress.setBounds(70, 250, 130, 30)
    lbTeacherCourse.setBounds(70, 350, 130, 30)
    lbTeacherPayment.setBounds(70, 400, 130, 30)

    tfTeacherName.setBounds(220, 100, 130, 30)
    tfTeacherPhone.setBounds(220, 150, 130, 30)
    tfTeacherEmail.setBounds(220, 200, 130, 30)
    taTeacherAddress.setBounds(220, 250, 130, 80)
    tfTeacherCourse.setBounds(220, 350, 130, 30)
    tfTeacherPayment.setBounds(220, 400, 130, 30)

    btnEnter = JButton("Update", actionPerformed=clickUpdateTeacher)
    btnEnter.setBounds(350, 450, 100, 40)

    btnCancel = JButton("Cancel", actionPerformed=clickCancel)
    btnCancel.setBounds(100, 450, 100, 40)

    panel.add(heading)
    panel.add(lbTeacherName)
    panel.add(lbTeacherPhone)
    panel.add(lbTeacherEmail)
    panel.add(lbTeacherAddress)
    panel.add(lbTeacherCourse)
    panel.add(lbTeacherPayment)
    panel.add(tfTeacherName)
    panel.add(tfTeacherPhone)
    panel.add(tfTeacherEmail)
    panel.add(taTeacherAddress)
    panel.add(tfTeacherCourse)
    panel.add(tfTeacherPayment)
    panel.add(btnEnter)
    panel.add(btnCancel)

    frame.add(panel)
예제 #38
0
class NewAccountGUI:
    def __init__(self, amgui):
        self.amgui = amgui
        self.am = amgui.acctmanager
        self.buildgwinfo()
        self.autologin = JCheckBox("Automatically Log In")
        self.acctname = JTextField()
        self.gwoptions = JPanel(doublebuffered)
        self.gwoptions.border = TitledBorder("Gateway Options")
        self.buildgwoptions("Twisted")
        self.mainframe = JFrame("New Account Window")
        self.buildpane()

    def buildgwinfo(self):
        self.gateways = {
            "Twisted": {
                "ident": JTextField(),
                "passwd": JPasswordField(),
                "host": JTextField("twistedmatrix.com"),
                "port": JTextField("8787"),
                "service": JTextField("twisted.words"),
                "persp": JTextField()
            },
            "AIM": {
                "ident": JTextField(),
                "passwd": JPasswordField(),
                "host": JTextField("toc.oscar.aol.com"),
                "port": JTextField("9898")
            },
            "IRC": {
                "ident": JTextField(),
                "passwd": JPasswordField(),
                "host": JTextField(),
                "port": JTextField("6667"),
                "channels": JTextField()
            }
        }
        self.displayorder = {
            "Twisted": [["Identity Name", "ident"], ["Password", "passwd"],
                        ["Host", "host"], ["Port", "port"],
                        ["Service Name", "service"],
                        ["Perspective Name", "persp"]],
            "AIM": [["Screen Name", "ident"], ["Password", "passwd"],
                    ["Host", "host"], ["Port", "port"]],
            "IRC": [["Nickname", "ident"], ["Password", "passwd"],
                    ["Host", "host"], ["Port", "port"],
                    ["Channels", "channels"]]
        }

    def buildgwoptions(self, gw):
        self.gwoptions.removeAll()
        self.gwoptions.layout = GridLayout(len(self.gateways[gw]), 2)
        for mapping in self.displayorder[gw]:
            self.gwoptions.add(JLabel(mapping[0]))
            self.gwoptions.add(self.gateways[gw][mapping[1]])

    def buildpane(self):
        gw = JPanel(GridLayout(1, 2), doublebuffered)
        gw.add(JLabel("Gateway"))
        self.gwlist = JComboBox(
            self.gateways.keys())  #, actionPerformed=self.changegw)
        self.gwlist.setSelectedItem("Twisted")
        gw.add(self.gwlist)

        stdoptions = JPanel(GridLayout(2, 2), doublebuffered)
        stdoptions.border = TitledBorder("Standard Options")
        stdoptions.add(JLabel())
        stdoptions.add(self.autologin)
        stdoptions.add(JLabel("Account Name"))
        stdoptions.add(self.acctname)

        buttons = JPanel(FlowLayout(), doublebuffered)
        buttons.add(JButton("OK", actionPerformed=self.addaccount))
        buttons.add(JButton("Cancel", actionPerformed=self.cancel))

        mainpane = self.mainframe.getContentPane()
        mainpane.layout = BoxLayout(mainpane, BoxLayout.Y_AXIS)
        mainpane.add(gw)
        mainpane.add(self.gwoptions)
        mainpane.add(stdoptions)
        mainpane.add(buttons)

    def show(self):
        self.mainframe.setLocation(100, 100)
        self.mainframe.pack()
        self.mainframe.show()

    #actionlisteners
    def changegw(self, ae):
        self.buildgwoptions(self.gwlist.getSelectedItem())
        self.mainframe.pack()
        self.mainframe.show()

    def addaccount(self, ae):
        gwselection = self.gwlist.getSelectedItem()
        gw = self.gateways[gwselection]
        name = gw["ident"].text
        passwd = gw["passwd"].text
        host = gw["host"].text
        port = int(gw["port"].text)
        autologin = self.autologin.isSelected()
        acctname = self.acctname.text

        if gwselection == "Twisted":
            sname = gw["service"].text
            perspective = gw["persp"].text
            self.am.addAccount(
                PBAccount(acctname, autologin, name, passwd, host, port,
                          [[stype, sname, perspective]]))
        elif gwselection == "AIM":
            self.am.addAccount(
                TOCAccount(acctname, autologin, name, passwd, host, port))
        elif gwselection == "IRC":
            channels = gw["channels"].text
            self.am.addAccount(
                IRCAccount(acctname, autologin, name, passwd, host, port,
                           channels))

        self.amgui.update()
        print "Added new account"
        self.mainframe.dispose()

    def cancel(self, ae):
        print "Cancelling new account creation"
        self.mainframe.dispose()
def addTeacher():

    global heading
    global tfTeacherName
    global tfTeacherPhone
    global taTeacherAddress
    global tfTeacherEmail
    global tfTeacherCourse
    global tfTeacherPayment
    global frame
    global btnEnter

    frame = JFrame("Add Teacher ")
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    frame.setSize(500, 600)
    frame.setLocation(200, 200)
    frame.setLayout(None)
    frame.setVisible(True)

    panel = JPanel()
    panel.setSize(500, 600)
    panel.setLocation(0, 0)
    panel.setLayout(None)
    panel.setVisible(True)
    panel.setBackground(Color.LIGHT_GRAY)

    heading = JLabel("ADD TEACHER")
    heading.setBounds(200, 30, 150, 40)

    lbTeacherName = JLabel("Teacher Name ")
    lbTeacherPhone = JLabel("Phone")
    lbTeacherEmail = JLabel("Email")
    lbTeacherAddress = JLabel("Address")
    lbTeacherCourse = JLabel("Teacher Course ")
    lbTeacherPayment = JLabel("Teacher Payment")

    tfTeacherName = JTextField()
    tfTeacherPhone = JTextField()
    taTeacherAddress = JTextArea()
    tfTeacherEmail = JTextField()
    tfTeacherCourse = JTextField()
    tfTeacherPayment = JTextField()

    lbTeacherName.setBounds(70, 100, 130, 30)
    lbTeacherPhone.setBounds(70, 150, 130, 30)
    lbTeacherEmail.setBounds(70, 200, 130, 30)
    lbTeacherAddress.setBounds(70, 250, 130, 30)
    lbTeacherCourse.setBounds(70, 350, 130, 30)
    lbTeacherPayment.setBounds(70, 400, 130, 30)

    tfTeacherName.setBounds(220, 100, 130, 30)
    tfTeacherPhone.setBounds(220, 150, 130, 30)
    tfTeacherEmail.setBounds(220, 200, 130, 30)
    taTeacherAddress.setBounds(220, 250, 130, 80)
    tfTeacherCourse.setBounds(220, 350, 130, 30)
    tfTeacherPayment.setBounds(220, 400, 130, 30)

    btnEnter = JButton("ADD", actionPerformed=clickAddTeacher)
    btnEnter.setBounds(350, 450, 100, 40)

    panel.add(heading)
    panel.add(lbTeacherName)
    panel.add(lbTeacherPhone)
    panel.add(lbTeacherEmail)
    panel.add(lbTeacherAddress)
    panel.add(lbTeacherCourse)
    panel.add(lbTeacherPayment)
    panel.add(tfTeacherName)
    panel.add(tfTeacherPhone)
    panel.add(tfTeacherEmail)
    panel.add(taTeacherAddress)
    panel.add(tfTeacherCourse)
    panel.add(tfTeacherPayment)
    panel.add(btnEnter)

    frame.add(panel)