def start_lconsole(): UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()) app.appInit() world = World() world.enableImportHooks() console = Console.Console('Console') world.setRootSubject(Console.ConsoleSubject(console, world.worldSubject)) if len(sys.argv) > 1: if len(sys.argv) > 2: print 'Usage:' print '\t %s <python_script>' % (sys.argv[0], ) sys.exit(-1) filename = sys.argv[1] if filename.lower().endswith('.py'): m = importPy2File(filename) console.executeModule(m, True) else: print 'Python script filename must end with .py' sys.exit(-1) def _onClose(wm): app.appShutdown() wm = WindowManager(world) wm.onCloseLastWindow = _onClose wm.showRootWindow()
def draw(self): try: UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); except: pass self.images_dict = dict() self.canvas = Canvas(self.images_dict, None) self.canvas.addMouseListener(self) self.frame = JFrame("SimplePyzzle", visible = 1) self.frame.setMinimumSize(Dimension(300, 300)) self.frame.setLocationRelativeTo(None) self.generate_button = JButton("Generate Puzzle") self.bottom_panel = JPanel() self.combo_box_list = [9, 16, 25, 36, 49] self.combo_box = JComboBox(self.combo_box_list) self.frame.contentPane.add(self.canvas, BorderLayout.CENTER) self.frame.contentPane.add(self.bottom_panel, BorderLayout.SOUTH) self.bottom_panel.add(self.generate_button, BorderLayout.EAST) self.bottom_panel.add(self.combo_box, BorderLayout.WEST) self.generate_button.actionPerformed = self.generate_board self.frame.setSize(500, 500) self.frame.defaultCloseOperation = JFrame.EXIT_ON_CLOSE; self.frame.pack()
def main(): load('bookshelf.conf') if config('LOCALE') is not None and config('LOCALE') != '': Locale.setDefault(Locale(config('LOCALE'))) from window import BookshelfView from logic import Bookshelf UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()) view = BookshelfView(Bookshelf()) screenSize = Toolkit.getDefaultToolkit().getScreenSize(); view.setLocation(screenSize.width/5, screenSize.height/5) view.setVisible(1)
def __init__(self): UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); size = Dimension(800, 800) self.setPreferredSize(size) screenSize = Toolkit.getDefaultToolkit().getScreenSize(); self.setLocation(screenSize.getSize().width/2 - size.width/2, 100) self.setTitle("bashED Terminal HQ EXTREME"); self.setUndecorated(True) self.getRootPane().setOpaque(False) #self.getRootPane().setWindowDecorationStyle(JRootPane.FRAME); self.setBackground(Color(0,128,0, 198)) #j = JDesktopPane() #j.setOpaque(False) self.setLayout(None) self.setIconImage(ImageIcon('bin/gui/media/' + "icon.png").getImage()) mp = MainPanel() self.add(mp) mp.setBounds(0, 0, size.width, size.height) imageTest = ImageIcon('bin/gui/media/' + "image.png") imageTestLabel = JLabel(imageTest) self.add(imageTestLabel) imageTestLabel.setBounds(0, 0, size.width, size.height) #self.getContentPane().add(mp) #self.getContentPane().add(JLabel("Iglo")) bb = BorderFactory.createLineBorder(Color.BLACK, 5) bw1 = BorderFactory.createLineBorder(Color.WHITE, 1) bw2 = BorderFactory.createLineBorder(Color.WHITE, 1) mp.setBorder( BorderFactory.createCompoundBorder( bw1, BorderFactory.createCompoundBorder(bb, bw2) )) #make the window viewable self.defaultCloseOperation=JFrame.EXIT_ON_CLOSE self.pack() self.setVisible(True)
def __init__(self): UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()) size = Dimension(800, 800) self.setPreferredSize(size) screenSize = Toolkit.getDefaultToolkit().getScreenSize() self.setLocation(screenSize.getSize().width / 2 - size.width / 2, 100) self.setTitle("bashED Terminal HQ EXTREME") self.setUndecorated(True) self.getRootPane().setOpaque(False) #self.getRootPane().setWindowDecorationStyle(JRootPane.FRAME); self.setBackground(Color(0, 128, 0, 198)) #j = JDesktopPane() #j.setOpaque(False) self.setLayout(None) self.setIconImage(ImageIcon('bin/gui/media/' + "icon.png").getImage()) mp = MainPanel() self.add(mp) mp.setBounds(0, 0, size.width, size.height) imageTest = ImageIcon('bin/gui/media/' + "image.png") imageTestLabel = JLabel(imageTest) self.add(imageTestLabel) imageTestLabel.setBounds(0, 0, size.width, size.height) #self.getContentPane().add(mp) #self.getContentPane().add(JLabel("Iglo")) bb = BorderFactory.createLineBorder(Color.BLACK, 5) bw1 = BorderFactory.createLineBorder(Color.WHITE, 1) bw2 = BorderFactory.createLineBorder(Color.WHITE, 1) mp.setBorder( BorderFactory.createCompoundBorder( bw1, BorderFactory.createCompoundBorder(bb, bw2))) #make the window viewable self.defaultCloseOperation = JFrame.EXIT_ON_CLOSE self.pack() self.setVisible(True)
def setNativeUI(cls): """ generated source for method setNativeUI """ try: UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()) except Exception as e: System.err.println("Unable to set native look and feel.")
def start_larch(): global world UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() ) jarCustomLarchApp = [] jarCustomPythonApp = [ False ] # Register a JAR entry handler so that we can pick up custom apps def _handle_larch_app(name, reader): buf = reader() jarCustomLarchApp.append( buf ) def _handle_python_app(name, reader): jarCustomPythonApp[0] = True app_in_jar.registerJarEntryHandler( lambda name: name == 'app.larch', _handle_larch_app ) app_in_jar.registerJarEntryHandler( lambda name: name == 'app.py' or name == 'app$py.class', _handle_python_app ) # If Larch was started from a JAR, scan it if app_in_jar.startedFromJar(): app_in_jar.scanLarchJar() app.appInit() world = World() world.enableImportHooks() if len( sys.argv ) > 1: if sys.argv[1] == '-app': if len( sys.argv ) < 3: print 'Usage:' print '\t{0} -app <app_name>' sys.exit() # Custom app importName = sys.argv[2] appModule = __import__( importName ) components = importName.split( '.' ) for comp in components[1:]: appModule = getattr( appModule, comp ) appState = appModule.newAppState() world.setRootSubject( appModule.newAppStateSubject( world, appState ) ) else: # Load a document filename = sys.argv[1] document = Document.readFile( world, filename ) if document is None: print 'Could not load {0}'.format(filename) sys.exit() subject = document.newSubject( world.worldSubject, None, filename ) world.setRootSubject( subject ) else: if len( jarCustomLarchApp ) > 0: buf = jarCustomLarchApp[0] document = Document.readFromBytes( world, buf, 'app' ) subject = document.newSubject( world.worldSubject, None, 'app' ) world.setRootSubject( subject ) elif jarCustomPythonApp[0]: import app as appModule appState = appModule.newAppState() world.setRootSubject( appModule.newAppStateSubject( world, appState ) ) else: from LarchCore.MainApp import MainApp appState = MainApp.newAppState() world.setRootSubject( MainApp.newAppStateSubject( world, appState ) ) def _onClose(wm): app.appShutdown() wm = WindowManager( world ) wm.onCloseLastWindow = _onClose wm.showRootWindow()
def run(scene, w=512, h=512, aa=1, threads=1): """Create GUI and perform ray-tracing.""" # Make Swing not look like garbage (so much) UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()) # Setup frame frame = JFrame("RayTracer", defaultCloseOperation=JFrame.EXIT_ON_CLOSE, size=(w, h)) frame.setIconImage(ImageIcon("resources/icon.png").getImage()) canvas = RayTracePanel(w, h, aa, threads) frame.getContentPane().add(JScrollPane(canvas)) # Save FileChooser fcS = JFileChooser() fcS.addChoosableFileFilter(FileNameExtensionFilter("Windows Bitmap (*.bmp)", ["bmp"])) fcS.addChoosableFileFilter(FileNameExtensionFilter("JPEG / JFIF (*.jpg)", ["jpg"])) fcS.addChoosableFileFilter(FileNameExtensionFilter("Portable Network Graphics (*.png)", ["png"])) def saveFile(event): """Performed when the save button is pressed""" result = fcS.showSaveDialog(frame) if result == JFileChooser.APPROVE_OPTION: file = fcS.getSelectedFile() fname = file.getPath() ext = fcS.getFileFilter().getExtensions()[0] if not fname.endswith("." + ext): file = File(fname + "." + ext) canvas.saveToFile(file, ext) # Open FileChooser fcO = JFileChooser() fcO.addChoosableFileFilter(FileNameExtensionFilter("RayTrace Scene File (*.rts)", ["rts"])) def openFile(event): """Performed when the open button is pressed""" result = fcO.showOpenDialog(frame) if result == JFileChooser.APPROVE_OPTION: fname = fcO.getSelectedFile().getPath() if fname.endswith(".rts"): f = open(fname, "rb") newScene = SceneFactory().buildScene(f) f.close() Painter(canvas, newScene, openButton, saveButton, stopButton).start() def exit(event): """Performed when the exit button is pressed""" import sys sys.exit(0) def stop(event): """Peformed when the stop button is pressed""" canvas.stopRendering() # Setup Menu menuBar = JMenuBar() menu = JMenu("File") menuBar.add(menu) openButton = JMenuItem("Open...", actionPerformed=openFile) openButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)) menu.add(openButton) saveButton = JMenuItem("Save as...", actionPerformed=saveFile) saveButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)) menu.add(saveButton) menu.addSeparator() stopButton = JMenuItem("Stop Render", actionPerformed=stop) stopButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)) stopButton.setEnabled(False) menu.add(stopButton) menu.addSeparator() closeButton = JMenuItem("Close", actionPerformed=exit) closeButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK)) menu.add(closeButton) frame.setJMenuBar(menuBar) # Finish initializing GUI self.pack()
def open(): try: UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()) except: print 'Failed to enable native look and feel.' _open()
# And swing components from javax.swing import JFrame, JPanel, JApplet, UIManager from java.awt import FlowLayout, Dimension # custom views etc from DelvProcessing import * import inSite import org.rosuda.JRI.Rengine as Rengine from JRI_ggplot import JRI_ggplot # Following from http://www.eclipse.org/articles/Article-Swing-SWT-Integration/ # To reduce flicker on resize: System.setProperty("sun.awt.noerasebackground", "false") # To get Swing look and feel to match SWT: UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()) browser = Browser(shell, SWT.RESIZE) #browser.setText("hello world!") # TODO get the url to lineup a better way browser.setUrl('file:///Users/krismz/Software/delv/examples/java_cars/lineup.js/demo/index.html') bgd = GridData(SWT.FILL, SWT.FILL, True, True) #bgd.widthHint = 1500 ##bgd.heightHint = 1200 ##bgd.widthHint = 1200 #bgd.heightHint = 800 bgd.horizontalSpan = 3 browser.setLayoutData(bgd) browser2 = Browser(shell, SWT.RESIZE) browser2.setUrl('file:///Users/krismz/Software/delv/examples/java_cars/parallel_coords.html')
def run(scene, w=512, h=512, aa=1, threads=1): '''Create GUI and perform ray-tracing.''' #Make Swing not look like garbage (so much) UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()) #Setup frame frame = JFrame("RayTracer", defaultCloseOperation=JFrame.EXIT_ON_CLOSE, size=(w, h)) frame.setIconImage(ImageIcon('resources/icon.png').getImage()) canvas = RayTracePanel(w, h, aa, threads) frame.getContentPane().add(JScrollPane(canvas)) #Save FileChooser fcS = JFileChooser() fcS.addChoosableFileFilter( FileNameExtensionFilter('Windows Bitmap (*.bmp)', ['bmp'])) fcS.addChoosableFileFilter( FileNameExtensionFilter('JPEG / JFIF (*.jpg)', ['jpg'])) fcS.addChoosableFileFilter( FileNameExtensionFilter('Portable Network Graphics (*.png)', ['png'])) def saveFile(event): '''Performed when the save button is pressed''' result = fcS.showSaveDialog(frame) if result == JFileChooser.APPROVE_OPTION: file = fcS.getSelectedFile() fname = file.getPath() ext = fcS.getFileFilter().getExtensions()[0] if not fname.endswith('.' + ext): file = File(fname + '.' + ext) canvas.saveToFile(file, ext) #Open FileChooser fcO = JFileChooser() fcO.addChoosableFileFilter( FileNameExtensionFilter('RayTrace Scene File (*.rts)', ['rts'])) def openFile(event): '''Performed when the open button is pressed''' result = fcO.showOpenDialog(frame) if result == JFileChooser.APPROVE_OPTION: fname = fcO.getSelectedFile().getPath() if fname.endswith('.rts'): f = open(fname, 'rb') newScene = SceneFactory().buildScene(f) f.close() Painter(canvas, newScene, openButton, saveButton).start() def exit(event): '''Performed when the exit button is pressed''' import sys sys.exit(0) #Setup Menu menuBar = JMenuBar() menu = JMenu("File") menuBar.add(menu) openButton = JMenuItem("Open...", actionPerformed=openFile) openButton.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)) menu.add(openButton) saveButton = JMenuItem("Save as...", actionPerformed=saveFile) saveButton.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)) menu.add(saveButton) menu.addSeparator() closeButton = JMenuItem('Close', actionPerformed=exit) closeButton.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK)) menu.add(closeButton) frame.setJMenuBar(menuBar) #Finish initializing GUI frame.pack() #frame.setLocationRelativeTo(None) frame.setVisible(True) #Perform ray-tracing if scene is not None: Thread(Painter(canvas, scene, openButton, saveButton)).start()
def run(scene, w=512, h=512, aa=1, threads=1): '''Create GUI and perform ray-tracing.''' #Make Swing not look like garbage (so much) UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()) #Setup frame frame = JFrame( "RayTracer", defaultCloseOperation=JFrame.EXIT_ON_CLOSE, size=(w, h) ) frame.setIconImage(ImageIcon('resources/icon.png').getImage()) canvas = RayTracePanel(w, h, aa, threads) frame.getContentPane().add(JScrollPane(canvas)) #Save FileChooser fcS = JFileChooser() fcS.addChoosableFileFilter(FileNameExtensionFilter('Windows Bitmap (*.bmp)', ['bmp'])) fcS.addChoosableFileFilter(FileNameExtensionFilter('JPEG / JFIF (*.jpg)', ['jpg'])) fcS.addChoosableFileFilter(FileNameExtensionFilter('Portable Network Graphics (*.png)', ['png'])) def saveFile(event): '''Performed when the save button is pressed''' result = fcS.showSaveDialog(frame) if result == JFileChooser.APPROVE_OPTION: file = fcS.getSelectedFile() fname = file.getPath() ext = fcS.getFileFilter().getExtensions()[0] if not fname.endswith('.' + ext): file = File(fname + '.' + ext) canvas.saveToFile(file, ext) #Open FileChooser fcO = JFileChooser() fcO.addChoosableFileFilter(FileNameExtensionFilter('RayTrace Scene File (*.rts)', ['rts'])) def openFile(event): '''Performed when the open button is pressed''' result = fcO.showOpenDialog(frame) if result == JFileChooser.APPROVE_OPTION: fname = fcO.getSelectedFile().getPath() if fname.endswith('.rts'): f = open(fname, 'rb') newScene = SceneFactory().buildScene(f) f.close() Painter(canvas, newScene, openButton, saveButton).start() def exit(event): '''Performed when the exit button is pressed''' import sys sys.exit(0) #Setup Menu menuBar = JMenuBar() menu = JMenu("File") menuBar.add(menu) openButton = JMenuItem("Open...", actionPerformed=openFile) openButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)) menu.add(openButton) saveButton = JMenuItem("Save as...", actionPerformed=saveFile) saveButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)) menu.add(saveButton) menu.addSeparator() closeButton = JMenuItem('Close', actionPerformed=exit) closeButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK)) menu.add(closeButton) frame.setJMenuBar(menuBar) #Finish initializing GUI frame.pack() #frame.setLocationRelativeTo(None) frame.setVisible(True) #Perform ray-tracing if scene is not None: Thread(Painter(canvas, scene, openButton, saveButton)).start()