wxPython窗體拆分布局基礎(chǔ)組件
本文實例為大家分享了wxPython窗體拆分布局的具體代碼,供大家參考,具體內(nèi)容如下
BoxSizer 布局管理
參數(shù)說明:
orient:wx.VERTICAL(垂直方向) 或 wx.HORIZONTAL(水平方向)
proportion:控件在方向上所占空間的相對于其他組件比例,
porportion=0,表示保持本身大小;
porportion=1,表示在水平方向上占三分之一的空間;
porportion=2,表示在水平方向上占三分之二的空間。
flag: wx.TOP | wx.BOTTOM | wx.LEFT | wx.RIGHT | wx.ALL |
wx.EXPAND(自動填充)
#-*- coding:utf-8 -*-
import wx
from wx._core import BoxSizer, GridSizer
from wx.lib.splitter import MultiSplitterWindow, MultiSplitterEvent
from wx.lib.agw.fourwaysplitter import FourWaySplitter
class ProxyFrame(wx.ScrolledWindow):
def __init__(self, parent):
wx.ScrolledWindow.__init__(self, parent)
self.createWidget()
def createWidget(self):
self.proxy_split_mult = wx.SplitterWindow(self, style=wx.SP_LIVE_UPDATE, size=(800, 450))
self.proxy_split_mult.SetMinimumPaneSize(10) #最小面板大小
self.proxy_split_top = wx.SplitterWindow(self.proxy_split_mult) #上結(jié)構(gòu)
self.proxy_split_bottom = wx.SplitterWindow(self.proxy_split_mult) #下結(jié)構(gòu)
########## 結(jié)構(gòu)上左右 ##########
self.proxy_scrol_leftTop = wx.ScrolledWindow(self.proxy_split_top)
self.proxy_scrol_leftTop.SetBackgroundColour(wx.WHITE)
self.proxy_scrol_leftTop.SetScrollbars(10, 10, 400, 300)
self.proxy_scrol_leftTop.SetAutoLayout(1)
self.proxy_scrol_rightTop = wx.ScrolledWindow(self.proxy_split_top)
self.proxy_scrol_rightTop.SetBackgroundColour(wx.BLACK)
self.proxy_split_top.SetMinimumPaneSize(10) #最小面板大小
self.proxy_split_top.SplitVertically(self.proxy_scrol_leftTop, self.proxy_scrol_rightTop) #分割面板
self.proxy_split_top.SetSashGravity(0.5)
########## 結(jié)構(gòu)上左右 end ##########
########## 結(jié)構(gòu)下左右 ##########
self.proxy_scrol_leftBottom = wx.ScrolledWindow(self.proxy_split_bottom)
self.proxy_scrol_leftBottom.SetBackgroundColour(wx.WHITE)
self.proxy_scrol_rightBottom = wx.ScrolledWindow(self.proxy_split_bottom)
self.proxy_scrol_rightBottom.SetBackgroundColour(wx.BLACK)
self.proxy_split_bottom.SetMinimumPaneSize(10) #最小面板大小
self.proxy_split_bottom.SplitVertically(self.proxy_scrol_leftBottom, self.proxy_scrol_rightBottom) #分割面板
self.proxy_split_bottom.SetSashGravity(0.5)
########## 結(jié)構(gòu)下左右 end ##########
self.proxy_split_mult.SplitHorizontally(self.proxy_split_top, self.proxy_split_bottom) #分割面板
self.proxy_split_mult.SetSashGravity(0.5)
self.SetScrollbars(10, 10, 400, 300)
sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add(self.proxy_split_mult, 1, flag=wx.EXPAND) #自動縮放
self.SetSizer(sizer)
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, "My Frame", size=(800, 450))
self.createWidget()
def createWidget(self):
########## 窗體底部狀態(tài)欄 ##########
self.statusbar = self.CreateStatusBar(2, wx.ST_SIZEGRIP)
self.statusbar.SetStatusText("", 0)
self.statusbar.SetStatusText("", 1)
########## HTTP代理書簽頁 ##########
self.createProxyWidget()
#HTTP代理書簽頁
def createProxyWidget(self):
self.proxy_nb = wx.Notebook(self, -1, name="proxy_nb")
self.proxyFrame = ProxyFrame(self.proxy_nb)
self.proxy_nb.AddPage(self.proxyFrame, u"HTTP代理")
def main():
#設(shè)置了主窗口的初始大小960x540 800x450 640x360
root = wx.App()
frame = MainFrame()
frame.Show(True)
root.MainLoop()
if __name__ == "__main__":
main()

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
- python-地圖可視化組件folium的操作
- Python QT組件庫qtwidgets的使用
- wxPython實現(xiàn)文本框基礎(chǔ)組件
- python tkinter組件使用詳解
- python tkinter組件擺放方式詳解
- 對Python中TKinter模塊中的Label組件實例詳解
- Python wxPython庫Core組件BoxSizer用法示例
- Python:Scrapy框架中Item Pipeline組件使用詳解
- Python調(diào)用C# Com dll組件實戰(zhàn)教程
- Python MySQL數(shù)據(jù)庫連接池組件pymysqlpool詳解
- 使用Python的Django框架中的壓縮組件Django Compressor
- 零基礎(chǔ)寫python爬蟲之使用urllib2組件抓取網(wǎng)頁內(nèi)容
- python drf各類組件的用法和作用
相關(guān)文章
Python打包代碼成exe可執(zhí)行文件的方法總結(jié)
將Python代碼打包成可執(zhí)行文件(.exe)是一種非常有效的解決方案,能夠使用戶無需安裝Python環(huán)境即可直接運行程序,本文整理了一些常見的方法,希望對大家有所幫助2024-10-10
python中matplotlib條件背景顏色的實現(xiàn)
這篇文章主要給大家介紹了關(guān)于python中matplotlib條件背景顏色的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家學習或者使用python具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧2019-09-09
使用selenium模擬登錄解決滑塊驗證問題的實現(xiàn)
這篇文章主要介紹了使用selenium模擬登錄解決滑塊驗證問題的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2019-05-05
詳解python uiautomator2 watcher的使用方法
這篇文章主要介紹了python uiautomator2 watcher的使用方法,該方是基于uiautomator2如下版本進行驗證,本文給大家介紹的非常詳細,需要的朋友可以參考下2019-09-09

