zoukankan      html  css  js  c++  java
  • wxpython demo


    #!/usr/bin/python
    # encoding: utf-8
    '''Spare.py is a starting point for a wxPython program.'''
    import wx
    class Frame(wx.Frame):
        '''Frame class that displays an image'''
        def __init__(self,image, parent=None, id=-1,
                     pos=wx.DefaultPosition,
                     title='Hello, wxPython!'):
            '''Create a Frame instance and display image.'''
            temp = image.ConvertToBitmap()
            size = temp.GetWidth(), temp.GetHeight()
            wx.Frame.__init__(self, parent, id, title, pos, size)
            self.bmp = wx.StaticBitmap(parent=self, bitmap=temp)
    class App(wx.App):
        def OnInit(self):
            image = wx.Image('test.jpg',wx.BITMAP_TYPE_JPEG)
            self.frame = Frame(image)
            self.frame.Show()
            self.SetTopWindow(self.frame)
            return True
    def main():
        app = App(redirect=True)
        print 'aaa'
        app.MainLoop()
    if __name__ == '__main__':
        main()


    #!/usr/bin/python
    # encoding: utf-8
    '''Spare.py is a starting point for a wxPython program.'''
    import wx
    class Frame(wx.Frame):
        pass
    class App(wx.App):
        def OnInit(self):
            self.frame = Frame(parent=None,title='Spare')
            self.frame.Show()
            self.SetTopWindow(self.frame)
            return True
    if __name__ == '__main__':
        app = App()
        app.MainLoop()


    # encoding: utf-8

    import wx
    class MyFrame(wx.Frame):
        def __init__(self):
            wx.Frame.__init__(self, None, -1, "My Frame", size=(300,300))
            panel = wx.Panel(self, -1)
            panel.Bind(wx.EVT_MOTION, self.OnMove)
            wx.StaticText(panel, -1, "Pos:", pos=(10, 12))
            self.posCtrl = wx.TextCtrl(panel,-1,"",pos=(40,10))
        def OnMove(self, event):
            pos = event.GetPosition()
            self.posCtrl.SetValue("%s, %s" % (pos.x, pos.y))

    if __name__ == '__main__':
    #     app = wx.App()
        app = wx.PySimpleApp()
        frame = MyFrame()
        frame.Show(True)
        app.MainLoop()

  • 相关阅读:
    转 meta标签之详解
    面向过程分析方法和面向对象分析方法区别到底在哪里
    几大开发模型区别与联系
    第6周作业
    第5次作业
    第四次作业
    4.回合制战斗游戏中需要哪些基本的元素或者属性来达到战斗乐趣?
    需求获取常见的方法是进行客户访谈,结合你的实践谈谈会遇到什么问题,你是怎么解决的?
    4.你认为一些军事方面的软件系统采用什么样的开发模型比较合适?
    作业三
  • 原文地址:https://www.cnblogs.com/zhang-pengcheng/p/4322613.html
Copyright © 2011-2022 走看看