可視化Python設計工具

來源:互聯網
上載者:User

boa-constructor-0.4.4.win32.exe 是一款協助Python進行可視化設計的表單設計器。
目前正在Alpha階段,它簡化了基於wxWindow的Python的表單布局和設計。

如果您利用boa建立了一個基本的wx架構那麼,改動少量的代碼就可以進行可視化設計了。

[code]

import sys, os  
from   wxPython.wx import *

class main_window(wxFrame):
      def __init__(self, parent, id, title):
         wxFrame.__init__(self, parent, -1, title, size = (200, 100),          
         style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
         self.control = wxTextCtrl(self, -1, style=wxTE_MULTILINE)
         self.Show(true)

    
class App(wxApp):
      def OnInit(self):
            frame = main_window(None, -1, "wxPython: (A Demonstration)")
            self.SetTopWindow(frame)
           
            return true
     
    
app = App(0)
app.MainLoop()
[/code]
以上代碼是非boa的wx基本架構,您可以結合自動產生的來修改。

或者您簡化下面的代碼來得到您想要的最簡的架構。
[code]
#Boa:Frame:Frame1
#-*-coding:gb2312-*-
import sys, os  
from   wxPython.wx import *

import wx
from wx.lib.anchors import LayoutAnchors

def create(parent):
  
    return Frame1(parent)

[wxID_FRAME1, wxID_FRAME1BUTTON1, wxID_FRAME1BUTTON2, wxID_FRAME1PANEL1,
 wxID_FRAME1STATICTEXT1, wxID_FRAME1STATICTEXT2, wxID_FRAME1STATICTEXT3,
 wxID_FRAME1STATICTEXT4, wxID_FRAME1TEXTCTRL1, wxID_FRAME1TEXTCTRL2,
 wxID_FRAME1TEXTCTRL3, wxID_FRAME1TEXTCTRL4,
] = [wx.NewId() for _init_ctrls in range(12)]

class Frame1(wx.Frame):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
              pos=wx.Point(271, 171), size=wx.Size(400, 492),
              style=wx.DEFAULT_FRAME_STYLE, title=u'可視化 boa-construction Python工具')
        self.SetClientSize(wx.Size(392, 458))

        self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1', parent=self,
              pos=wx.Point(0, 0), size=wx.Size(392, 458),
              style=wx.TAB_TRAVERSAL)

        self.staticText1 = wx.StaticText(id=wxID_FRAME1STATICTEXT1,
              label='staticText1', name='staticText1', parent=self.panel1,
              pos=wx.Point(16, 8), size=wx.Size(62, 14), style=0)

        self.textCtrl1 = wx.TextCtrl(id=wxID_FRAME1TEXTCTRL1, name='textCtrl1',
              parent=self.panel1, pos=wx.Point(112, 8), size=wx.Size(100, 22),
              style=0, value='textCtrl1')

        self.staticText2 = wx.StaticText(id=wxID_FRAME1STATICTEXT2,
              label='staticText2', name='staticText2', parent=self.panel1,
              pos=wx.Point(16, 40), size=wx.Size(62, 14), style=0)

        self.textCtrl2 = wx.TextCtrl(id=wxID_FRAME1TEXTCTRL2, name='textCtrl2',
              parent=self.panel1, pos=wx.Point(112, 40), size=wx.Size(100, 22),
              style=0, value='textCtrl2')

        self.staticText3 = wx.StaticText(id=wxID_FRAME1STATICTEXT3,
              label='staticText3', name='staticText3', parent=self.panel1,
              pos=wx.Point(16, 72), size=wx.Size(62, 14), style=0)

        self.textCtrl3 = wx.TextCtrl(id=wxID_FRAME1TEXTCTRL3, name='textCtrl3',
              parent=self.panel1, pos=wx.Point(112, 80), size=wx.Size(100, 22),
              style=0, value='textCtrl3')

        self.staticText4 = wx.StaticText(id=wxID_FRAME1STATICTEXT4,
              label='staticText4', name='staticText4', parent=self.panel1,
              pos=wx.Point(16, 112), size=wx.Size(62, 14), style=0)

        self.textCtrl4 = wx.TextCtrl(id=wxID_FRAME1TEXTCTRL4, name='textCtrl4',
              parent=self.panel1, pos=wx.Point(112, 112), size=wx.Size(100, 22),
              style=0, value='textCtrl4')

        self.button1 = wx.Button(id=wxID_FRAME1BUTTON1, label='button1',
              name='button1', parent=self.panel1, pos=wx.Point(56, 408),
              size=wx.Size(75, 24), style=0)
        self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Button,
              id=wxID_FRAME1BUTTON1)

        self.button2 = wx.Button(id=wxID_FRAME1BUTTON2, label='button2',
              name='button2', parent=self.panel1, pos=wx.Point(224, 408),
              size=wx.Size(75, 24), style=0)

    def __init__(self, parent):
        self._init_ctrls(parent)
        self.Show(true)

    def OnButton1Button(self, event):
        event.Skip()

class App(wxApp):
      def OnInit(self):
            frame = Frame1(None)
            self.SetTopWindow(frame)
            return true
     
    
app = App(0)
app.MainLoop()

[/code]

閱讀本文需要有一種進階程式設計語言的使用經曆,通常是 Basic C/C++ Java Pascal Python Perl Tcl 中的一種。
一種視覺化檢視的使用 VC BCB VB Delphi 等。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.