本文整理汇总了Python中javax.swing.JFrame.setVisible方法的典型用法代码示例。如果您正苦于以下问题:Python JFrame.setVisible方法的具体用法?Python JFrame.setVisible怎么用?Python JFrame.setVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JFrame
的用法示例。
在下文中一共展示了JFrame.setVisible方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setVisible [as 别名]
def show():
""" adapted from here: http://wiki.gephi.org/index.php/Toolkit_-_Reuse_the_Preview_Applet"""
from javax.swing import JFrame
from java.awt import BorderLayout
pc = PreviewController
pc.refreshPreview();
# New Processing target, get the PApplet
target = pc.getRenderTarget("processing")
applet = target.getApplet()
applet.init()
# Refresh the preview and reset the zoom
try:
pc.render(target)
except Exception:
# throws sun.dc.pr.PRError: sun.dc.pr.PRError: setPenT4: invalid pen transformation (singular)
pass
target.refresh()
target.resetZoom()
# Add the applet to a JFrame and display
frame = JFrame("Preview")
frame.setLayout(BorderLayout())
# frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
frame.add(applet, BorderLayout.CENTER)
frame.pack()
frame.setVisible(True)
示例2: gui_open
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setVisible [as 别名]
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)
示例3: tree
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setVisible [as 别名]
def tree():
"""
tree(xmlfile="dsm2.xml")
creates a tree view on a given xml file of dsm2 input data
"""
tv = TreeViewer()
mp2 = JPanel()
mp2.setLayout(BorderLayout())
tf = JTextField("dsm2.inp")
pb = JButton("parse")
mp2.add(tf,BorderLayout.CENTER)
mp2.add(pb,BorderLayout.EAST)
class ParseListener(ActionListener):
def __init__(self,tf,tv,fr):
self.tf = tf
self.tv = tv
self.fr = fr
def actionPerformed(self,evt):
dsm2file = self.tf.getText()
parser = DSM2Parser(dsm2file)
self.tv.xdoc = parser.dsm2_data.toXml()
self.fr.getContentPane().add(self.tv.gui(),BorderLayout.CENTER)
self.fr.pack()
self.fr.setVisible(1)
fr = JFrame()
fr.setTitle("DSM2Tree")
fr.setLocation(100,100)
fr.setSize(600,60)
fr.getContentPane().setLayout(BorderLayout())
fr.getContentPane().add(mp2,BorderLayout.NORTH)
al = ParseListener(tf,tv,fr)
pb.addActionListener(al)
fr.pack()
fr.setVisible(1)
示例4: VacalcFrame
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setVisible [as 别名]
class VacalcFrame(object):
def __init__(self, employees, dateprovider):
self._frame = JFrame("Vacation Calculator", defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
self._frame.setContentPane(self._create_ui(employees, dateprovider))
self._frame.pack()
def _create_ui(self, employees, dateprovider):
panel = JPanel(layout=FlowLayout())
self._overview = EmployeeOverview(employees, self)
self._details = EmployeeDetails(employees, dateprovider)
self._welcome = Welcome()
panel.add(self._overview)
panel.add(self._welcome)
return panel
def show(self):
self._frame.setVisible(True)
def employee_selected(self, employee):
self._ensure_details_shown()
self._details.show_employee(employee)
def edit_new_employee(self):
self._ensure_details_shown()
self._details.edit_new_employee()
def _ensure_details_shown(self):
if self._welcome:
self._frame.contentPane.remove(self._welcome)
self._frame.contentPane.add(self._details)
self._frame.pack()
self._welcome = None
示例5: startGui
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setVisible [as 别名]
def startGui():
frame = JFrame("MonkeyPySon")
frame.setContentPane(getContentPane())
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
frame.pack()
frame.setVisible(True)
frame.addWindowFocusListener(GuiWindowFocusListener())
startLookingDevices()
示例6: ApplicationTestCase
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setVisible [as 别名]
class ApplicationTestCase(unittest.TestCase):
def setUp(self):
Robot().mouseMove(800, 600)
self.launch_app()
self.app = ApplicationTestApp()
def tearDown(self):
self.frame.setVisible(False)
self.frame.dispose()
def launch_app(self):
self.frame = JFrame("Test Window", defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
pane = self.frame.getContentPane()
layout = SpringLayout()
pane.setLayout(layout)
label = JLabel("Test Label")
pane.add(label)
layout.putConstraint(SpringLayout.WEST, label, 20, SpringLayout.WEST, pane)
layout.putConstraint(SpringLayout.NORTH, label, 20, SpringLayout.NORTH, pane)
self.frame.pack()
self.frame.setVisible(True)
self.frame.setSize(800, 600)
def test_init_window(self):
window = self.app.init_window(ApplicationTestWindow)
self.assertNotEqual(window, None)
self.assertTrue(isinstance(window, ApplicationTestWindow))
self.assertEqual((window.region.getW(), window.region.getH()), (800, 600))
def test_create_image_folders(self):
path = os.path.join('images', 'application_test_window', 'test_label')
shutil.move(os.path.join(path, 'enabled.png'), os.path.join('images', '.enabled.png.tmp'))
shutil.rmtree(os.path.join('images', 'application_test_window'))
self.app.create_image_folders()
self.assertTrue(os.path.exists(path))
shutil.move(os.path.join('images', '.enabled.png.tmp'), os.path.join(path, 'enabled.png'))
# TODO: test_capture_screenshots
# TODO: test_open
def test_find_focused_window(self):
window = self.app.find_focused_window()
self.assertNotEqual(window, None)
self.assertTrue(isinstance(window, ApplicationTestWindow))
def test_focused_window(self):
before_time = time.time()
window = self.app.focused_window(10)
after_time = time.time()
self.assertTrue(after_time >= before_time + 10)
self.assertNotEqual(window, None)
self.assertTrue(isinstance(window, ApplicationTestWindow))
示例7: start_ashdi
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setVisible [as 别名]
def start_ashdi():
loadKeyLayout("data_2.0/ashdi_keylayout.xml")
global frame
frame = JFrame(FRAME_TITLE)
frame.setContentPane(getContentPane())
frame.windowClosing = lambda x: windowClosing()
frame.pack()
frame.setVisible(True)
frame.addWindowFocusListener(GuiWindowFocusListener())
start_android_waker()
handleConnectedDevBtn(True)
check_move_support()
示例8: readSVG
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setVisible [as 别名]
def readSVG(svgPath):
#parser = XMLResourceDescriptor.getXMLParserClassName()
#f = SAXSVGDocumentFactory(parser)
#print(svgPath)
#doc = f.createDocument(svgPath.toURI().toString())
#print(doc)
svgCanvas = JSVGCanvas()
svgCanvas.setURI(svgPath.toURI().toString())
f = JFrame('SVG image', size=(1000, 1000), locationRelativeTo=None)
p = JPanel()
p.add(svgCanvas)
f.getContentPane().add(p)
f.setVisible(True)
示例9: createFrame
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setVisible [as 别名]
def createFrame():
global isDominant
manager = doAction()
if isTemporal:
frame = JFrame("LosiTemp - LOoking for Selection In TEMPoral datasets")
elif isDominant:
frame = JFrame("Mcheza - Dominant Selection Workbench")
else:
frame = JFrame("LOSITAN - Selection Workbench")
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
doPrettyType(frame, manager)
frame.setVisible(1)
frame.setResizable(0)
return frame
示例10: install
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setVisible [as 别名]
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)
示例11: __init__
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setVisible [as 别名]
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)
示例12: __init__
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setVisible [as 别名]
class ShowImageViewer:
def __init__(self):
self.frame = JFrame("Display Image")
btn = JButton("Switch",actionPerformed=self.switchPic)
#self.frame.getContentPane().add(btn)
self.switchPic('/home/jack/Desktop/mgarvin.jpg')
self.frame.setSize(500,500)
self.frame.setVisible(True)
def callSwitchPic(self,event):
self.switchPic('/home/jack/Desktop/mteam.jpg')
def switchPic(self,image):
panel = ShowImage(image)
self.frame.getContentPane().add(panel)
示例13: geom_viewer
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setVisible [as 别名]
def geom_viewer(dsm2file = "dsm2.inp"):
"""
geom_viewer(dsm2file = "dsm2.inp")
starts off a dsm2 geometry viewer for dsm2 input data
Irregular xsections are plotted if available otherwise
regular xsections are plotted.
"""
dgv = DSM2GeomViewer(dsm2file)
mp = dgv.gui()
fr = JFrame()
fr.setTitle('Geom Viewer')
fr.getContentPane().add(mp)
fr.setLocation(300,100)
fr.pack()
sz = fr.getSize()
fr.setSize(250,sz.height)
fr.setVisible(1)
示例14: createAndShowGUI
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setVisible [as 别名]
def createAndShowGUI():
# Create the GUI and show it. As with all GUI code, this must run
# on the event-dispatching thread.
frame = JFrame("GUI Development ")
frame.setSize(500, 600)
frame.setLayout(BorderLayout())
splitPane = JSplitPane(JSplitPane.VERTICAL_SPLIT)
#Create and set up the content pane.
psimures= ResourcePanel()
psimures.setOpaque(True)
pconfig = ConfigurationPanel()
pconfig.setOpaque(True) #content panes must be opaque
# show the GUI
splitPane.add(psimures)
splitPane.add(pconfig)
frame.add(splitPane)
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
frame.setVisible(True)
示例15: createAndShowGUI
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setVisible [as 别名]
def createAndShowGUI():
# Create the GUI and show it. As with all GUI code, this must run
# on the event-dispatching thread.
frame = JFrame("MAE ")
frame.setSize(1024, 768)
panel= JPanel()
panel.setLayout(GridBagLayout())
#Create and set up the content pane.
psimures= SimoutPanel()
psimures.setOpaque(True)
c = GridBagConstraints()
c.fill = GridBagConstraints.HORIZONTAL
c.weightx = 1
c.gridx = 0
c.gridy = 0
panel.add(psimures, c);
pmeasure= MeasPanel()
pmeasure.setOpaque(True)
c = GridBagConstraints()
c.fill = GridBagConstraints.HORIZONTAL
c.weightx = 1
c.gridx = 0
c.gridy = 1
panel.add(pmeasure, c);
preport = ReportPanel()
preport.setOpaque(True)
c = GridBagConstraints()
c.fill = GridBagConstraints.VERTICAL
c.weighty = 1
c.gridx = 1
c.gridy = 0
c.gridheight= 2
panel.add(preport,c)
# show the GUI
frame.add(panel)
# frame.add(pmeasure)
# frame.add(preport)
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
frame.setVisible(True)