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


Python JFrame.validate方法代码示例

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


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

示例1: PythonWindow

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import validate [as 别名]

#.........这里部分代码省略.........
                        KeyEvent.VK_CLOSE_BRACKET)
        editmenu.add(item)
        
        item = new_item("Dedent Selection", "dedentselection",
                        KeyEvent.VK_OPEN_BRACKET)
        editmenu.add(item)
        
        shellmenu = JMenu("Interactive")
        menubar.add(shellmenu)
        
        item = new_item("Previous Input", "up", KeyEvent.VK_UP,
            mod=ActionEvent.ALT_MASK)
        shellmenu.add(item)
        
        item = new_item("Next Input", "down", KeyEvent.VK_DOWN,
                         mod=ActionEvent.ALT_MASK)
        shellmenu.add(item)


        self.frame.setJMenuBar(menubar)
    
    def toggle_visibility(self):
        self.frame.visible = not self.frame.visible
    def add_component(self, c):
        self.remove_component()
        self.frame.add(c, BorderLayout.PAGE_START)
        self.component = c
    def remove_component(self):
        if self.component is not None:
            self.frame.remove(self.component)
            self.component = None
    def add(self, text, type="input"):
        self.outputpane.addtext(text, type)
        self.frame.validate()
    def error(self, text):
        self.outputpane.addtext(text, "error", ensure_newline=True)
    def write(self, text):
        self.add(text, "output")

    # Code execution methods
    def runcode(self, source, interactive=True):
        if not source.strip():
            return True
        processed_source = source.replace("$", "geo.")
        code = self.interface.compileinteractive(processed_source)
        if code in ("continue", "error"):
            code = self.interface.compilemodule(processed_source)
            if code == "error":
                return
        if code == "error":
            return False
        source = source.strip()
        if interactive:
            self.history.append(source)
            self.current_text = ""
            self.outputpane.addtext(source +'\n', "input", ensure_newline=True)
        self.interface.run(code)
        return True
    def run(self):
        source = self.input.text
        if not source.strip():
            self.input.text = ""
            return
        processed_source = source.replace("$", "geo.")
        code = self.interface.compileinteractive(processed_source)
        if code in ("continue", "error"):
开发者ID:Serabe,项目名称:geogebra,代码行数:70,代码来源:gui.py

示例2: PythonWindow

# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import validate [as 别名]
class PythonWindow(KeyListener):
    def __init__(self):
        self.frame = JFrame("Python Window")
        #self.historyList = JList(DefaultListModel())
        #self.historyList.cellRenderer = MyListCellRenderer()
        scrollpane = JScrollPane()
        inputPanel = JPanel()
        inputPanel.layout = GridLayout(1, 1)
        self.input = JTextArea("")
        self.input.border = BorderFactory.createEmptyBorder(5, 5, 5, 5)
        self.input.tabSize = 4
        self.input.font = Font("Monospaced", Font.PLAIN, 12)
        self.input.addKeyListener(self)
        inputPanel.add(self.input)
        self.outputpane = OutputPane()
        scrollpane.viewport.view = self.outputpane.textpane  #self.historyList
        self.frame.add(scrollpane, BorderLayout.CENTER)
        self.frame.add(inputPanel, BorderLayout.PAGE_END)
        self.frame.size = 500, 600
        self.frame.visible = False
        self.component = None

    def toggle_visibility(self):
        self.frame.visible = not self.frame.visible

    def add_component(self, c):
        self.remove_component()
        self.frame.add(c, BorderLayout.PAGE_START)
        self.component = c

    def remove_component(self):
        if self.component is not None:
            self.frame.remove(self.component)
            self.component = None

    def add(self, text, type="input"):
        self.outputpane.addtext(text, type)
        #self.historyList.model.addElement({"text": text, "type": type})
        #self.historyList.validate()
        self.frame.validate()
        #last = self.historyList.model.getSize() - 1
        #self.historyList.ensureIndexIsVisible(last)
    def error(self, text):
        self.outputpane.addtext(text, "error", ensure_newline=True)

    def write(self, text):
        self.add(text, "output")

    def run(self, evt):
        source = self.input.text
        if not source.strip():
            self.input.text = ""
            return
        processed_source = source.replace("$", "geo.")
        code = interface.compileinteractive(processed_source)
        if code in ("continue", "error"):
            code = interface.compilemodule(processed_source)
            if code == "error":
                return
        source = source.strip() + '\n'
        self.outputpane.addtext(source, "input", ensure_newline=True)
        result = interface.run(code)
        if result == "OK":
            self.input.text = ""

    def keyPressed(self, evt):
        pass

    def keyReleased(self, evt):
        pass

    def keyTyped(self, evt):
        if evt.keyChar == '\n':
            # Only try to run compound statements when they end with
            # two \n
            source = self.input.text
            lines = source.split("\n")
            if lines[0].rstrip().endswith(":") and not source.endswith("\n\n"):
                for i, c in enumerate(lines[-2]):
                    if c not in ' \t': break
                else:
                    self.run(evt)
                    return
                prefix = lines[-2][:i]
                if lines[-2].endswith(":"):
                    prefix += '\t'
                self.input.text = source + prefix
            else:
                self.run(evt)
开发者ID:avilleret,项目名称:geogebra,代码行数:91,代码来源:pyggb.py


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